This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Print something after TIMEOUT EVENT when advertisement stops.

Hi friends..! I am trying to print data on UART but only just after when TIMEOUT (180 sec) occurs in the project BLE.zip. Is there something BLE stack event has to be used? if yes than how? Thanks in advance for every Helper..! :).

  • SDK 11.0.0 . I want to readvertise as soon as mpu shakes observations and issues occuring are :-

    1)If I shake mpu & give command of readvertise before timeout than FATAL ERROR(all 4leds On && advertisement stop) occurs.

    2)If I shake mpu and give command of readvertise after timeout than nothing occurs.

    Is it possible to make some function like process events in main loop which always keep checking if some event has occured or not.

  • Hello Rajat

    To print a message on timeout you could either add a new handler in ble_evt_dispatch, or add a new case to an existing handler, such as on_ble_evt. In the switch you could add a case for BLE_GAP_EVT_TIMEOUT in which you print a message. Do note however that if you just add a log message the chip might go into system OFF mode before the message is printed, if you have configured the device to do so, so you would need to wait until the message has been transmitted.

    The fatal error you receive will occur when you try to activate advertisting when it is already doing so. I recommend you create an advertising flag that you poll to see if the device is advertising before you try to enable it.

    If the chip has gone into system OFF mode, you will need to wake it. You can look at the power section of the product specification of the chip you are using for more information.

    Best regards

    Jørn Frøysa

  • Hello Jorn

    Thanks for commenting.

    I add a new case to an existing handler, i.e in on_ble_evt. In the switch, I added a case as BLE_GAP_EVT_TIMEOUT but problem was as device was getting into timeout it was entering sleep mode and stops executing the for Loop. so I disable the sleep mode on entering into idle mode by commenting cases of on_adv_evt(ble_adv_evt_t ble_adv_evt) function and then doing some changes the application worked. So key was to disable the sleep mode even after timeout. But how can I keep executing the main loop while in sleep mode?

    Best regards

  • You cannot execute the main loop while in sleep. While in sleep the CPU core will power down and stop executing instructions. You can however set up so that a signal from the MPU awakens the chip. So for instance if the MPU registers movement it generates a signal connected to the chips GPIO which awakens the chip. This is described in the POWER section of the product specification.

Related