Browse Source

Limit the max number of nodes supported in RFM69 module

ota
Xose Pérez 6 years ago
parent
commit
915082162d
2 changed files with 10 additions and 3 deletions
  1. +4
    -0
      code/espurna/config/general.h
  2. +6
    -3
      code/espurna/rfm69.ino

+ 4
- 0
code/espurna/config/general.h View File

@ -1352,6 +1352,10 @@
#define RFM69_MAX_TOPICS 50
#endif
#ifndef RFM69_MAX_NODES
#define RFM69_MAX_NODES 255
#endif
#ifndef RFM69_DEFAULT_TOPIC
#define RFM69_DEFAULT_TOPIC "/rfm69gw/{node}/{key}"
#endif


+ 6
- 3
code/espurna/rfm69.ino View File

@ -25,7 +25,7 @@ struct _node_t {
unsigned char lastPacketID = 0;
};
_node_t _rfm69_node_info[255];
_node_t _rfm69_node_info[RFM69_MAX_NODES];
unsigned char _rfm69_node_count;
unsigned long _rfm69_packet_count;
@ -115,6 +115,9 @@ void _rfm69Debug(const char * level, packet_t * data) {
void _rfm69Process(packet_t * data) {
// Is node beyond RFM69_MAX_NODES?
if (data->senderID >= RFM69_MAX_NODES) return;
// Count seen nodes and packets
if (_rfm69_node_info[data->senderID].count == 0) ++_rfm69_node_count;
++_rfm69_packet_count;
@ -235,10 +238,10 @@ void _rfm69Loop() {
}
void _rfm69Clear() {
for(unsigned int i=0; i<(sizeof(_rfm69_node_info) / sizeof(_node_t)); i++) {
for(unsigned int i=0; i<RFM69_MAX_NODES; i++) {
_rfm69_node_info[i].duplicates = 0;
_rfm69_node_info[i].missing = 0;
_rfm69_node_info [i].count = 0;
_rfm69_node_info[i].count = 0;
}
_rfm69_node_count = 0;
_rfm69_packet_count = 0;


Loading…
Cancel
Save