Some questions about RFM69 library :
First, I use the v1.3.0 (last one from arduino library manager), and RF69_BROADCAST_ADDR is 255, not 0 like argued in the blog (https://lowpowerlab.com/2019/05/02/rfm69-10bit-node-addresses/)
Secondly, When we send a broadcast, all nodes will receive the message, but we don't want to send an ACK from every node, that's what do the code below :
// check whether an ACK was requested in the last received packet (non-broadcasted packet)
bool RFM69::ACKRequested() {
return ACK_REQUESTED && (TARGETID != RF69_BROADCAST_ADDR);
}
But if the radio on a node is in promiscuous mode, it will receive the message even if the target node is another one and the target node is not the broadcast address, but we don't want this "spy" send an ACK answer because it could make collision with the ACK of the target node, even if his ACK will be ignored. To my mind we should check if the TARGETID corresponds to our NODEID, and since our NODEID couldn't be RF69_BROADCAST_ADDR the code below would deal with these case :
// check whether an ACK was requested in the last received packet (non-broadcasted packet)
bool RFM69::ACKRequested() {
return ACK_REQUESTED && (TARGETID == _address);
}
Am I correct ?
To my mind, a spy shouldn't reply to an ACK requested to another one. This could be written in the sketch of the spy, but it should be written for each sketch, and some times a spy can de the target of an ACK so we have to check if we are the target or just spying...
If we check in ACKRequested function if we are the target, it will avoid sending an ACK from a broadcast message since our address should not be equal to the broadcast address and also avoid to send an ACK if the message is sent to someone else without adding some code on each sketch for a spy...
// check whether an ACK was requested in the last received packet (non-broadcasted packet)
bool RFM69::ACKRequested() {
return ACK_REQUESTED && (TARGETID == _address);
}
How about this:
bool RFM69::ACKRequested() {
return ACK_REQUESTED && (TARGETID != RF69_BROADCAST_ADDR) && (TARGETID == _address);
}