generic_xbow.h
1 /********************************************************************
2  *
3  * This library is free software; you can redistribute it and/or
4  * modify it under the terms of the GNU Lesser General Public
5  * License as published by the Free Software Foundation; either
6  * version 2.1 of the License, or (at your option) any later version.
7  *
8  * This library is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public
14  * License along with this library; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16  *
17  ********************************************************************/
18 /*********************************************************************
19  * TinyOS data structures.
20  * Portions borrowed from the TinyOS project (http://www.tinyos.net),
21  * distributed according to the Intel Open Source License.
22  *********************************************************************/
23 /***************************************************************************
24  * Desc: Driver for generic Crossbow WSN nodes
25  * Author: Adrian Jimenez Gonzalez, Jose Manuel Sanchez Matamoros
26  * Date: 15 Aug 2011
27  **************************************************************************/
28 
29 #ifndef _GENERIC_XBOW_TYPES_H
30 #define _GENERIC_XBOW_TYPES_H
31 
32 #define DEFAULT_GENERICXBOW_PORT "/dev/ttyUSB0"
33 #define DEFAULT_GENERICXBOW_PLATFORM "telosb"
34 #define DEFAULT_GENERICXBOW_OS "tos2x"
35 
36 #ifndef UNIQUE_TIMER
37 #define UNIQUE_TIMER unique("Timer")
38 #endif
39 
40 #define FIXED_UPDATE_INTERVAL 20
41 
42 #define STATIC_DELAY 40
43 
44 #define MAX_PAYLOAD 42
45 #define MAX_TOS_PAYLOAD 35
46 #define MAX_TRANSP_SIZE 100
47 
48 #define WSN_PLAYER_HEADER_COUNT 4
49 
50 #include <cstdio>
51 #include <iostream>
52 #include "mote/MoteIF.h"
53 
54 using namespace mote;
55 using namespace std;
56 
57 enum { MICA2DOT, MICA2, MICAZ, IRIS, TELOS, TELOSB, TMOTE, EYES, INTELMOTE2 };
58 
59 // AM for different message interface
60 enum{
61  AM_MOTE_MESSAGE = 10, // Node to pc messages
62  AM_BASE_MESSAGE = 11, // Node to base messages
63  AM_PLAYER_TO_WSN = 11, // PC to Node messages
64 };
65 
66 // appID for different message origins
67 enum{
68  ID_MOBILE_DATA = 1, // Mobile node message appId
69  ID_HEALTH = 2, // Health message appId
70  ID_FIXED_DATA = 3, // Fixed node message appId
71 };
72 
74 
75 // XMesh header.
76 typedef struct {
77  uint16_t orig;
78  uint16_t source;
79  uint16_t seq;
80  uint8_t appId;
81 } __attribute__ ((packed)) XMeshHeader;
82 
84 
85 // Health message
86 typedef struct {
87  XMeshHeader header;
88  uint16_t id;
89  uint16_t parent_id;
90 } __attribute__((packed)) HealthMsg;
91 
92 // Beacon message
93 typedef struct {
94  uint8_t type;
95  uint8_t node_id;
96  uint8_t sender_id; // RSSI sender
97  uint16_t rssi;
98  uint16_t stamp;
99  uint32_t timelow;
100  uint32_t timehigh;
101  float x;
102  float y;
103  float z;
104 } __attribute__((packed)) RSSIBeaconMsg;
105 
106 typedef struct {
107  uint8_t type;
108  uint16_t id;
109  uint16_t parent_id;
110  float x;
111  float y;
112  float z;
113  uint8_t status;
114 
115 } __attribute__((packed)) PositionMsg;
116 
117 
118 // Individual sensor description
119 typedef struct {
120  uint8_t type;
121  int16_t value;
122 } __attribute__((packed)) sensor_t;
123 
124 // Sensor or Alarm message
125 typedef struct {
126  uint8_t type;
127  uint16_t id;
128  uint16_t parent_id;
129  uint8_t sensor_count;
130  sensor_t *sensor;
131 } __attribute__((packed)) SensorMsg;
132 
133 // User defined data message
134 typedef struct {
135  uint8_t type;
136  uint16_t id;
137  uint16_t parent_id;
138  uint8_t data_size;
139  uint8_t *data;
140 } __attribute__((packed)) UserDataMsg;
141 
142 // Request Message
143 typedef struct {
144  uint8_t type;
145  uint16_t id;
146  uint16_t parent_id;
147  uint8_t request;
148  uint8_t parameters_size;
149  uint8_t *parameters;
150 } __attribute__((packed)) RequestMsg;
151 
152 // Command Message
153 typedef struct {
154  uint8_t type;
155  uint16_t id;
156  uint16_t parent_id;
157  uint8_t command;
158  uint8_t parameters_size;
159  uint8_t *parameters;
160 } __attribute__((packed)) CommandMsg;
161 
162 #endif
Definition: playerclient.h:313
Messages between wsn and a robot.
Definition: er.h:86
Definition: generic_xbow_structdef.cc:34