13
13
pb_byte_t pb_buf[PB_BUFSIZE+4 ];
14
14
size_t pb_size = 0 ; // Number of bytes currently in the buffer
15
15
16
+ // Nonce to request only my nodeinfo and skip other nodes in the db
17
+ #define SPECIAL_NONCE 69420
18
+
16
19
// Wait this many msec if there's nothing new on the channel
17
20
#define NO_NEWS_PAUSE 25
18
21
@@ -220,7 +223,7 @@ bool handle_mesh_packet(meshtastic_MeshPacket *meshPacket) {
220
223
return true ;
221
224
}
222
225
223
- // Parse a packet that came in, and handle it. Return true iff we were able to parse it.
226
+ // Parse a packet that came in, and handle it. Return true if we were able to parse it.
224
227
bool handle_packet (uint32_t now, size_t payload_len) {
225
228
meshtastic_FromRadio fromRadio = meshtastic_FromRadio_init_zero;
226
229
@@ -231,6 +234,11 @@ bool handle_packet(uint32_t now, size_t payload_len) {
231
234
memmove (pb_buf, pb_buf+4 +payload_len, PB_BUFSIZE-4 -payload_len);
232
235
pb_size -= 4 + payload_len;
233
236
237
+ // Be prepared to request a node report to re-establish flow after an MT reboot
238
+ meshtastic_ToRadio toRadio = meshtastic_ToRadio_init_default;
239
+ toRadio.which_payload_variant = meshtastic_ToRadio_want_config_id_tag;
240
+ toRadio.want_config_id = SPECIAL_NONCE;
241
+
234
242
if (!status) {
235
243
d (" Decoding failed" );
236
244
return false ;
@@ -245,6 +253,8 @@ bool handle_packet(uint32_t now, size_t payload_len) {
245
253
return handle_config_complete_id (now, fromRadio.config_complete_id );
246
254
case meshtastic_FromRadio_packet_tag:
247
255
return handle_mesh_packet (&fromRadio.packet );
256
+ case meshtastic_FromRadio_rebooted_tag:
257
+ _mt_send_toRadio (toRadio);
248
258
default :
249
259
if (mt_debugging) {
250
260
// Rate limit
@@ -273,6 +283,8 @@ void mt_protocol_check_packet(uint32_t now) {
273
283
274
284
if (pb_buf[0 ] != MT_MAGIC_0 || pb_buf[1 ] != MT_MAGIC_1) {
275
285
d (" Got bad magic" );
286
+ memset (pb_buf, 0 , PB_BUFSIZE);
287
+ pb_size = 0 ;
276
288
return ;
277
289
}
278
290
0 commit comments