@@ -107,8 +107,11 @@ void ESBNetwork<radio_t>::begin(uint8_t _channel, uint16_t _node_address)
107
107
108
108
// Open up all listening pipes
109
109
uint8_t i = NUM_PIPES;
110
- while (i--)
111
- radio.openReadingPipe (i, pipe_address (_node_address, i));
110
+ uint8_t address[5 ];
111
+ while (i--) {
112
+ pipe_address (_node_address, i, address);
113
+ radio.openReadingPipe (i, address);
114
+ }
112
115
113
116
radio.startListening ();
114
117
}
@@ -143,11 +146,9 @@ uint8_t ESBNetwork<radio_t>::update(void)
143
146
#else
144
147
frame_size = MAX_FRAME_SIZE;
145
148
#endif
146
-
147
149
if (!frame_size) {
148
150
return NETWORK_CORRUPTION;
149
151
}
150
-
151
152
// Fetch the payload, and see if this was the last one.
152
153
radio.read (frame_buffer, frame_size);
153
154
@@ -293,7 +294,7 @@ uint8_t ESBNetwork<radio_t>::enqueue(RF24NetworkHeader* header)
293
294
294
295
result = f->header .type == EXTERNAL_DATA_TYPE ? 2 : 1 ;
295
296
296
- if (f->header .id > 0 && f->message_size > 0 ) {
297
+ if (f->header .id > 0 && f->message_size > 0 && f-> message_size <= MAX_PAYLOAD_SIZE ) {
297
298
// Load external payloads into a separate queue on linux
298
299
if (result == 2 ) {
299
300
external_queue.push (frameFragmentsCache[frame.header .from_node ]);
@@ -749,7 +750,6 @@ bool ESBNetwork<radio_t>::main_write(RF24NetworkHeader& header, const void* mess
749
750
750
751
if (header.to_node != NETWORK_MULTICAST_ADDRESS) {
751
752
networkFlags |= FLAG_FAST_FRAG;
752
- radio.stopListening ();
753
753
}
754
754
755
755
uint8_t retriesPerFrag = 0 ;
@@ -1014,15 +1014,11 @@ bool ESBNetwork<radio_t>::write_to_pipe(uint16_t node, uint8_t pipe, bool multic
1014
1014
{
1015
1015
bool ok = false ;
1016
1016
1017
- // Open the correct pipe for writing.
1018
- // First, stop listening so we can talk
1019
- if (!(networkFlags & FLAG_FAST_FRAG)) {
1020
- radio.stopListening ();
1021
- }
1022
-
1023
1017
if (!(networkFlags & FLAG_FAST_FRAG) || (frame_buffer[6 ] == NETWORK_FIRST_FRAGMENT && networkFlags & FLAG_FAST_FRAG)) {
1018
+ uint8_t address[5 ];
1019
+ pipe_address (node, pipe, address);
1020
+ radio.stopListening (address);
1024
1021
radio.setAutoAck (0 , !multicast);
1025
- radio.openWritingPipe (pipe_address (node, pipe));
1026
1022
}
1027
1023
1028
1024
ok = radio.writeFast (frame_buffer, frame_size, 0 );
@@ -1192,7 +1188,9 @@ void ESBNetwork<radio_t>::multicastLevel(uint8_t level)
1192
1188
{
1193
1189
_multicast_level = level;
1194
1190
radio.stopListening ();
1195
- radio.openReadingPipe (0 , pipe_address (levelToAddress (level), 0 ));
1191
+ uint8_t address[5 ];
1192
+ pipe_address (levelToAddress (level), 0 , address);
1193
+ radio.openReadingPipe (0 , address);
1196
1194
radio.startListening ();
1197
1195
}
1198
1196
@@ -1215,7 +1213,7 @@ uint16_t ESBNetwork<radio_t>::levelToAddress(uint8_t level)
1215
1213
/* *****************************************************************/
1216
1214
1217
1215
template <class radio_t >
1218
- uint64_t ESBNetwork<radio_t >::pipe_address (uint16_t node, uint8_t pipe)
1216
+ void ESBNetwork<radio_t >::pipe_address (uint16_t node, uint8_t pipe, uint8_t * address )
1219
1217
{
1220
1218
1221
1219
static uint8_t address_translation[] = { 0xc3 ,
@@ -1234,8 +1232,7 @@ uint64_t ESBNetwork<radio_t>::pipe_address(uint16_t node, uint8_t pipe)
1234
1232
#endif
1235
1233
#endif
1236
1234
};
1237
- uint64_t result = 0xCCCCCCCCCCLL ;
1238
- uint8_t * out = reinterpret_cast <uint8_t *>(&result);
1235
+ memset (address, 0xCC , 5 );
1239
1236
1240
1237
// Translate the address to use our optimally chosen radio address bytes
1241
1238
uint8_t count = 1 ;
@@ -1245,7 +1242,7 @@ uint64_t ESBNetwork<radio_t>::pipe_address(uint16_t node, uint8_t pipe)
1245
1242
#if defined(RF24NetworkMulticast)
1246
1243
if (pipe != 0 || !node)
1247
1244
#endif
1248
- out [count] = address_translation[(dec % 8 )]; // Convert our decimal values to octal, translate them to address bytes, and set our address
1245
+ address [count] = address_translation[(dec % 8 )]; // Convert our decimal values to octal, translate them to address bytes, and set our address
1249
1246
1250
1247
dec /= 8 ;
1251
1248
count++;
@@ -1254,14 +1251,12 @@ uint64_t ESBNetwork<radio_t>::pipe_address(uint16_t node, uint8_t pipe)
1254
1251
#if defined(RF24NetworkMulticast)
1255
1252
if (pipe != 0 || !node)
1256
1253
#endif
1257
- out [0 ] = address_translation[pipe];
1254
+ address [0 ] = address_translation[pipe];
1258
1255
#if defined(RF24NetworkMulticast)
1259
1256
else
1260
- out [1 ] = address_translation[count - 1 ];
1257
+ address [1 ] = address_translation[count - 1 ];
1261
1258
#endif
1262
- IF_RF24NETWORK_DEBUG (uint32_t * top = reinterpret_cast <uint32_t *>(out + 1 ); printf_P (PSTR (" NET Pipe %i on node 0%o has address %x%x\n\r " ), pipe, node, *top, *out));
1263
-
1264
- return result;
1259
+ IF_RF24NETWORK_DEBUG (uint32_t * top = reinterpret_cast <uint32_t *>(address + 1 ); printf_P (PSTR (" NET Pipe %i on node 0%o has address %x%x\n\r " ), pipe, node, *top, *address));
1265
1260
}
1266
1261
1267
1262
/* *********************** Sleep Mode ******************************************/
0 commit comments