I am using SDK15.2 and I am using ble_app_hrs example to build a device that has multiple sensors and a display.
I am constantly reading sensors data using blocking TWI and everything works great, but before the system goes to sleep I need to send a TWI commands that will turn off the sensors and the display, this is where I get the NRF_ERROR_BUSY at the nrf_drv_twi_tx call...
If I remove the "APP_ERROR_CHECK(err_code);" lines from my custom sensors and display libraries I dont get the error but the sensors and the display dont receive the command to turn off...
I tired doing a while loop until err_code becomes NRF_SUCCESS and also I tried doing the "do while(0)" loop as provided in the twi_master_with_twis_slave example but it didnt fix my problem.
I think the problem is that the constant reading keeps the TWI busy non stop and once the APP_ADV_DURATION times out and prepares the system to go to sleep (where i also try to send my TWI commands for turning off the sensors and display) is where I get the conflict...
Any suggestion how should i fix this properly?
Thanks in advance.