1 #ifndef _PUD_WIREFORMAT_H_
2 #define _PUD_WIREFORMAT_H_
15 /** The version of the wire format */
16 #define PUD_WIRE_FORMAT_VERSION 0
20 * We use the smask of nmeaINFO and the flags below on top of that
23 /** Flags that the GPS information contains the nodeId */
24 #define PUD_FLAGS_ID 0x80
30 /** The number of bits for the time field */
31 #define PUD_TIME_BITS 17
37 /** The number of bits for the latitude field */
38 #define PUD_LATITUDE_BITS 28
40 /** The maximum size of the string representation of the latitude
41 * sign [0,90] [0,59] dot [0,59] [0,999] */
42 #define PUD_TX_LATITUDE_DIGITS (1 + 2 + 2 + 1 + 2 + 3)
44 /** The number of decimals of the latitude in the transmit sentence */
45 #define PUD_TX_LATITUDE_DECIMALS "5"
51 /** The number of bits for the longitude field */
52 #define PUD_LONGITUDE_BITS 27
54 /** The maximum size of the string representation of the longitude
55 * sign [0,180] [0,59] dot [0,59] [0,999] */
56 #define PUD_TX_LONGITUDE_DIGITS (1 + 3 + 2 + 1 + 2 + 3)
58 /** The number of decimals of the longitude in the transmit sentence */
59 #define PUD_TX_LONGITUDE_DECIMALS "5"
65 /** The number of bits for the altitude field */
66 #define PUD_ALTITUDE_BITS 16
68 /** The minimum altitude */
69 #define PUD_ALTITUDE_MIN (-400)
71 /** The maximum altitude */
72 #define PUD_ALTITUDE_MAX (((1 << PUD_ALTITUDE_BITS) - 1) + PUD_ALTITUDE_MIN)
74 /** The maximum size of the string representation of the altitude */
75 #define PUD_TX_ALTITUDE_DIGITS 6
81 /** The number of bits for the speed field */
82 #define PUD_SPEED_BITS 12
84 /** The maximum speed value */
85 #define PUD_SPEED_MAX ((1 << PUD_SPEED_BITS) - 1)
87 /** The maximum size of the string representation of the speed */
88 #define PUD_TX_SPEED_DIGITS 4
94 /** The number of bits for the track angle field */
95 #define PUD_TRACK_BITS 9
97 /** The maximum size of the string representation of the track angle */
98 #define PUD_TX_TRACK_DIGITS 3
104 /** The number of bits for the HDOP field */
105 #define PUD_HDOP_BITS 11
107 /** The HDOP resolution (in m) */
108 #define PUD_HDOP_RESOLUTION (0.1)
110 /** The maximum HDOP value (in m) */
111 #define PUD_HDOP_MAX (((1 << PUD_HDOP_BITS) - 1) * PUD_HDOP_RESOLUTION)
113 /** The maximum size of the string representation of the HDOP */
114 #define PUD_TX_HDOP_DIGITS 5
116 /** The number of decimals of the HDOP in the transmit sentence */
117 #define PUD_TX_HDOP_DECIMALS "3"
123 /** The maximum size of the string representation of the nodeIdType */
124 #define PUD_TX_NODEIDTYPE_DIGITS 3
130 /** The maximum size of the string representation of the nodeId */
131 #define PUD_TX_NODEID_BUFFERSIZE 1023
134 * Wire Format Structures
137 /** Sub-format GPS information, 120 bits = 15 bytes */
139 uint32_t time :PUD_TIME_BITS; /**< the number of seconds since midnight, ALWAYS present */
140 uint32_t lat :PUD_LATITUDE_BITS; /**< latitude */
141 uint32_t lon :PUD_LONGITUDE_BITS; /**< longitude */
142 uint32_t alt :PUD_ALTITUDE_BITS; /**< altitude */
143 uint32_t speed :PUD_SPEED_BITS; /**< speed */
144 uint32_t track :PUD_TRACK_BITS; /**< track angle */
145 uint32_t hdop :PUD_HDOP_BITS; /**< HDOP */
146 }__attribute__((__packed__)) GpsInfo;
148 /** Sub-format Node information, 8 + variable bits = 1 + variable bytes */
150 uint8_t nodeIdType; /**< the nodeIdType */
151 unsigned char nodeId; /**< placeholder for variable length nodeId string */
152 }__attribute__((__packed__)) NodeInfo;
154 /** Complete format, 8+8+8+120+(8+variable) bits = 18+(1+variable) bytes*/
156 uint8_t version; /**< the version of the sentence */
157 uint8_t validityTime; /**< the validity time of the sentence */
158 uint8_t smask; /**< mask signaling the contents of the sentence */
159 GpsInfo gpsInfo; /**< the GPS information (MANDATORY) */
160 NodeInfo nodeInfo; /**< placeholder for node information (OPTIONAL) */
161 }__attribute__((__packed__)) PudOlsrWireFormat;
163 /** The size of the wire format, minus the size of the node information */
164 #define PUD_OLSRWIREFORMATSIZE (sizeof(PudOlsrWireFormat) - sizeof(NodeInfo))
166 #endif /* _PUD_WIREFORMAT_H_ */