@@ -27,7 +27,7 @@ void MeshBase::Begin()
2727{
2828 radio.begin ();
2929 radio.enableDynamicPayloads ();
30- radio.setRetries (2 , 1 );
30+ radio.setRetries (4 , 2 );
3131 radio.openReadingPipe (1 , TO_BROADCAST (PEER_DISCOVERY));
3232 radio.setAutoAck (0 , true );
3333 radio.setAutoAck (1 , false );
@@ -145,6 +145,9 @@ void MeshBase::HandlePacket(const byte* data, uint8_t len)
145145 const MeshBase::MessageHeader* header = (struct MeshBase ::MessageHeader*)data;
146146 uint8_t payload_length = len - sizeof (MessageHeader);
147147 const byte* payload = data + sizeof (MessageHeader);
148+ if (header->protocol_version != 1 )
149+ return ;
150+
148151 Message* s = assembly_list.Find <const MessageHeader*>(header, &FindStream);
149152 if (s == NULL ) {
150153 s = new Message (*header);
@@ -221,20 +224,29 @@ void MeshBase::SendMessage(uint32_t to, uint8_t type, const void* data, uint8_t
221224 msg->split_part = num;
222225 msg->split_more = remaining_length > MAX_PAYLOAD_SIZE;
223226 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);
224228
225229 radio.stopListening ();
230+ bool result = true ;
226231 if (is_broadcast)
227232 radio.openWritingPipe (TO_BROADCAST (to));
228233 else
229234 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+ }
231241 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 );
238250 }
239251}
240252
0 commit comments