@@ -132,16 +132,17 @@ send_error(double timestamp, struct sockaddr_in *reader_addr, char *error_msg, u
132
132
133
133
134
134
void
135
- send_packet (double timestamp , struct sockaddr_in * reader_addr , const uint8_t * signature , const TBeaconNgTracker * track )
135
+ send_packet (double timestamp , struct sockaddr_in * reader_addr , uint16_t reader_id , const uint8_t * signature , const TBeaconNgTracker * track )
136
136
{
137
137
int i = 0 , j ;
138
138
uint32_t t ;
139
139
const TBeaconNgSighting * slot ;
140
140
141
141
i += sprintf (buf + i , "{" );
142
142
143
- i += sprintf (buf + i , "\"reader\": {\"ip\":\"%s\",\"t\":%d}," ,
143
+ i += sprintf (buf + i , "\"reader\": {\"ip\":\"%s\",\"id\":%d,\" t\":%d}," ,
144
144
inet_ntoa (reader_addr -> sin_addr ),
145
+ reader_id ,
145
146
(uint32_t ) timestamp );
146
147
147
148
i += sprintf (buf + i , "\"packet\": {\"id\":\"%08X\",\"t\":%d," ,
@@ -206,9 +207,9 @@ send_packet(double timestamp, struct sockaddr_in *reader_addr, const uint8_t *si
206
207
static int
207
208
parse_packet (double timestamp , struct sockaddr_in * reader_addr , const void * data , int len )
208
209
{
209
- uint32_t t ;
210
210
const TBeaconLogSighting * pkt ;
211
211
TBeaconNgTracker track ;
212
+ uint32_t t ;
212
213
213
214
if (len < (int )sizeof (TBeaconLogSighting ))
214
215
return len ;
@@ -253,8 +254,8 @@ parse_packet (double timestamp, struct sockaddr_in *reader_addr, const void *dat
253
254
return len ;
254
255
}
255
256
256
- /* show & process latest packet */
257
- send_packet (timestamp , reader_addr , ((uint8_t * ) & pkt -> log ) + sizeof (track ) - CONFIG_SIGNATURE_SIZE , & track );
257
+ /* send packet */
258
+ send_packet (timestamp , reader_addr , ntohs ( pkt -> hdr . reader_id ), ((uint8_t * ) & pkt -> log ) + sizeof (track ) - CONFIG_SIGNATURE_SIZE , & track );
258
259
259
260
return sizeof (TBeaconLogSighting );
260
261
}
@@ -338,9 +339,9 @@ main (int argc, char **argv)
338
339
ret = listen_packets ();
339
340
340
341
mosquitto_disconnect (mosq );
341
- mosquitto_loop_stop (mosq , false);
342
- mosquitto_destroy (mosq );
343
- mosquitto_lib_cleanup ();
342
+ mosquitto_loop_stop (mosq , false);
343
+ mosquitto_destroy (mosq );
344
+ mosquitto_lib_cleanup ();
344
345
345
346
return ret ;
346
347
}
0 commit comments