Hello,
My board reads data from acceleration sensor and sends it to ESB message.
When acceleration is under threshold, nRF52832 went sleep mode.
Before entering sleep mode, I want to send a ESB message which notify nRF52832 is in sleep mode.
But It doesn't work as I expected. Time to time, sleep message is sent. But most of time sleep message isn't sent.
I tried "nrf_esb_flush_tx" and "nrf_esb_is_idle". But It still not work.
How could I sure that sleep message is sent before entering sleep mode?
Before sleep_mode_enter, sleep message is sent(battery 0 percent).
static void stopSensor(void *p_data, uint16_t p_size)
{
uint8_t batteryPercent;
bool esbState;
tx_payload.length = NRF_ESB_PAYLOAD_LENGTH;
tx_payload.noack = false;
/* device id */
tx_payload.pipe = NRF_ESB_PIPE_ID;
memcpy(tx_payload.data,&seqData,sizeof(uint32_t));
batteryPercent = 0;
memcpy(tx_payload.data+sizeof(uint32_t)+TOTAL_DATA_BYTE_IN_FRAME, &batteryPercent, sizeof(uint8_t));
nrf_esb_flush_tx();
if (nrf_esb_write_payload(&tx_payload) == NRF_SUCCESS)
{
seqData++;
}
else
{
NRF_LOG_INFO("Sending packet failed\n\r");
}
do{
esbState = nrf_esb_is_idle();
}while(!esbState);
nrf_gpio_pin_write(PIN_LED3_ON,0);
/* Disable sensor. */
lis3mdl_operating_mode_set(&lis_ctx, LIS3MDL_POWER_DOWN);
sleep_mode_enter();
}
bat:0 isn't received well.