OK,
Thanks for the explanations, not so simple to code in C when you come from the Java world, quite a lot of differences between these two languages.
I changed (again) my coding on Tx side to prevent memory from playing tricks :
const uint8_t thisMasterAddress[] = "SRV00";
const uint8_t buttonAddress[][6] = { "BTN01","BTN02","BTN03","BTN04","BTN05","BTN06","BTN07","BTN08","BTN09","BTN10" };
void sendToBtn(int id, int c) {
Data_Sent.msg = c;
Data_Sent.rnd++;
bool rslt;
radio.stopListening();
radio.flush_tx();
radio.openWritingPipe(buttonAddress[id-1]);
rslt = radio.write(&Data_Sent, sizeof(Data_Sent));
if (rslt) {
btnConnected[id] = true;
if (radio.isAckPayloadAvailable()) {
radio.read(&ackData, sizeof(ackData));
newData = true;
}
else {
Serial.println(" Acknowledge but no data ");
}
}
else {
btnConnected[id] = false;
Serial.println(" Tx failed");
}
radio.startListening();
}
I've also remarked that these two functions have been depracated :
void openReadingPipe (uint8_t number, uint64_t address)
void openWritingPipe (uint64_t address)
Replaced by :
void openWritingPipe (const uint8_t *address)
void openReadingPipe (uint8_t number, const uint8_t *address)
On Rx side, is it now OK like that now ?
//Read the button number from the DIP switch
void getButtonNr() {
for (int i = 0; i < sizeof(DIPSwitchPins); ++i) {
pinMode(DIPSwitchPins[i], INPUT_PULLUP);
uint8_t curState = digitalRead(DIPSwitchPins[i]) ? 0 : 1;
buttonNumber += (curState << i);
}
byte str[5];
sprintf(str, "%d", buttonNumber);
if (buttonNumber > 9) {
thisButtonAddress[3] = str[0];
thisButtonAddress[4] = str[1];
}
else {
thisButtonAddress[4] = str[0];
}
}
Regards