@@ -27,7 +27,7 @@ void MeshBase::Begin()
27
27
{
28
28
radio.begin ();
29
29
radio.enableDynamicPayloads ();
30
- radio.setRetries (2 , 1 );
30
+ radio.setRetries (4 , 2 );
31
31
radio.openReadingPipe (1 , TO_BROADCAST (PEER_DISCOVERY));
32
32
radio.setAutoAck (0 , true );
33
33
radio.setAutoAck (1 , false );
@@ -145,6 +145,9 @@ void MeshBase::HandlePacket(const byte* data, uint8_t len)
145
145
const MeshBase::MessageHeader* header = (struct MeshBase ::MessageHeader*)data;
146
146
uint8_t payload_length = len - sizeof (MessageHeader);
147
147
const byte* payload = data + sizeof (MessageHeader);
148
+ if (header->protocol_version != 1 )
149
+ return ;
150
+
148
151
Message* s = assembly_list.Find <const MessageHeader*>(header, &FindStream);
149
152
if (s == NULL ) {
150
153
s = new Message (*header);
@@ -221,20 +224,29 @@ void MeshBase::SendMessage(uint32_t to, uint8_t type, const void* data, uint8_t
221
224
msg->split_part = num;
222
225
msg->split_more = remaining_length > MAX_PAYLOAD_SIZE;
223
226
memcpy (buff + sizeof (MessageHeader), (const byte*)data + (num * MAX_PAYLOAD_SIZE), min (remaining_length, MAX_PAYLOAD_SIZE));
227
+ uint8_t wire_size = min (remaining_length + sizeof (MessageHeader), MAX_PACKET_SIZE);
224
228
225
229
radio.stopListening ();
230
+ bool result = true ;
226
231
if (is_broadcast)
227
232
radio.openWritingPipe (TO_BROADCAST (to));
228
233
else
229
234
radio.openWritingPipe (TO_ADDRESS (to));
230
- radio.write (buff, min (remaining_length + sizeof (MessageHeader), MAX_PACKET_SIZE));
235
+ if (is_broadcast) {
236
+ // radio.startWrite(buff, wire_size);
237
+ result = radio.write (buff, wire_size);
238
+ } else {
239
+ result = radio.write (buff, wire_size);
240
+ }
231
241
radio.startListening ();
232
- Serial.print (" T Sending pkt split_part=" );
233
- Serial.print (msg->split_part );
234
- Serial.print (" split_more=" );
235
- Serial.print (msg->split_more );
236
- Serial.print (" length=" );
237
- Serial.println (min (remaining_length, MAX_PAYLOAD_SIZE));
242
+ if (!is_broadcast)
243
+ {
244
+ Serial.print (" T Sending pkt split_part=" );
245
+ Serial.print (msg->split_part );
246
+ Serial.print (" result=" );
247
+ Serial.println (result);
248
+ }
249
+ delay (100 );
238
250
}
239
251
}
240
252
0 commit comments