12
12
#define TO_BROADCAST (x ) (0xBB00000000LL + x)
13
13
#define TO_ADDRESS (x ) (0xAA00000000LL + x)
14
14
15
- #define PEER_DISCOVERY_TIME 3000
15
+ #define PEER_DISCOVERY_TIME 4000
16
16
#define PEER_CHECK_TIME 4000
17
- #define PEER_TIMEOUT 2
17
+ #define PEER_TIMEOUT 3
18
18
19
19
MeshBase::MeshBase (uint8_t ce,uint8_t cs)
20
20
: radio(ce, cs)
@@ -89,16 +89,6 @@ void MeshBase::Message::AddPart(const void* payload, uint8_t len, uint8_t part_n
89
89
{
90
90
uint8_t start_pos = part_num * MAX_PAYLOAD_SIZE;
91
91
uint8_t end_pos = len + (part_num * MAX_PAYLOAD_SIZE);
92
- Serial.print (" R AddPart() : Adding part. start_pos=" );
93
- Serial.print (start_pos);
94
- Serial.print (" end_pos=" );
95
- Serial.print (end_pos);
96
- Serial.print (" len=" );
97
- Serial.print (len);
98
- Serial.print (" part_num=" );
99
- Serial.print (part_num);
100
- Serial.print (" more_parts=" );
101
- Serial.println (more_parts);
102
92
if (data ==NULL )
103
93
data =malloc (end_pos);
104
94
if (end_pos > data_used)
@@ -119,17 +109,16 @@ bool MeshBase::Message::IsDone() const
119
109
// in the stream, and split_part to total number of blocks in the stream.
120
110
// So if split_more is false, and we have the right number of blocks_recieved
121
111
// we are good to go.
122
- Serial.print (" R IsDone() : split_more=" );
123
- Serial.print (header.split_more );
124
- Serial.print (" split_part=" );
125
- Serial.print (header.split_part );
126
- Serial.print (" blocks_recieved=" );
127
- Serial.print (blocks_recieved);
128
- if (!header.split_more && blocks_recieved > header.split_part )
129
- {
130
- Serial.println (" - True **" );
112
+ if (!header.split_more && blocks_recieved > header.split_part ) {
113
+ if (blocks_recieved >1 ) {
114
+ Serial.print (" R IsDone() : id=" );
115
+ Serial.print (header.msg_id );
116
+ Serial.println (" - True **" );
117
+ }
131
118
return true ;
132
119
}
120
+ Serial.print (" R IsDone() : id=" );
121
+ Serial.print (header.msg_id );
133
122
Serial.println (" - False" );
134
123
return false ;
135
124
}
@@ -237,16 +226,21 @@ void MeshBase::SendMessage(uint32_t to, uint8_t type, const void* data, uint8_t
237
226
result = radio.write (buff, wire_size);
238
227
}else {
239
228
result = radio.write (buff, wire_size);
240
- }
241
- radio.startListening ();
242
- if (!is_broadcast)
243
- {
229
+ if (result ==false ) {
230
+ // Issue transmitting packet, retry?
231
+ radio.startListening ();
232
+ delay (100 );
233
+ radio.stopListening ();
234
+ result = radio.write (buff, wire_size);
235
+ }
244
236
Serial.print (" T Sending pkt split_part=" );
245
237
Serial.print (msg->split_part );
238
+ Serial.print (" id=" );
239
+ Serial.print (msg->msg_id );
246
240
Serial.print (" result=" );
247
241
Serial.println (result);
248
242
}
249
- delay ( 100 );
243
+ radio. startListening ( );
250
244
}
251
245
}
252
246