BLEDocs
BLEDocs copied to clipboard
Checking creditsAvailable for setLocalData() before sendData()
Hi guys, thanks for the great documentation!!
I was going through your lighting_with_state.ino sketch and saw that you check for data credits before you call setLocalData. I'm a little confused since per the Nordic docs (page 77 of the nRF8001 product spec), setLocalData doesn't use up any data credits but calling sendData does.
What was the reason you check for available credits before you set the local value?
For reference (lighting_with_state.ino, lines 164 - 176):
// STATE
if (nrf->isPipeOpen(BUTTON_STATE_PIPE) && nrf->creditsAvailable()) {
Serial.println("Setting 1");
foo = 1;
nrf->setLocalData(BUTTON_STATE_PIPE, 1, &foo);
}
// TX
if ( nrf->isPipeOpen(BUTTON_TX_PIPE) ) {
Serial.println("Sending 1");
foo = 1;
nrf->sendData(BUTTON_TX_PIPE, 1, &foo);
}
Thanks!!
- Jonathan