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

Re-connect to central device(phone)

Hi,

My device sends the advertising packet when some button pressed.

Then phone app will connect to my device and do some process between my device and disconnect.

Then my device goes to sleep.

My device will wake-up every single 1 hour.

I want to re-connect to phone without advertising when periodic wake-up.

If no phone is near, go to sleep.

How can I do this?

My firmware is modified from ble_sdk_uart_over_ble_main.c

BR

Paul

Parents
  • Hi Paul,

    It is not possible for a phone to connect if the peripheral is not advertising. A BLE connection can only be established when the peripheral is advertising. The phone will send a connect request packet right after receiving a advertising packet, and in that time window the advertising peripheral is listening for connection requests. If it is received, the connection is established.

    What is it you want to achieve? If you only want a specific phone to connect at regular wakeup, then you can handle this using whitelisting when you advertise every hour. Similarly, if you want any phone to connect when you press a button, you can advertise without whitelisting in this case.

    Based on my understanding of your requirement (including some guesses) you could do the following:

    1. If you want to add a new phone, press a button. When this happens, start advertising without whietlisting. If a connection is established, initiate bonding so that you have the IRK which is needed to to subsequent whitelisting.
    2. Us an app_timer to wake up every hour and start advertising with whitelisting (this allows you to filter in up to 8 phones  you are bonded with). Timeout after a few seconds/minutes in case of no connection and try again in an hour(?)
    3. If a connection is established, do whatever you should do, then disconnect. The app timer will make sure the device wakes up and starts to advertise again in one hour.

    The SDK has some examples of whitelisting, for instance the Current Time Application.

Reply Children
No Data
Related