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

how to auto connect and disconnect when we need send the data

hi....

i am using nrf52382 and segger 15.2 version , i want my peripheral to send the data only if it reaches the certain limit (threshold value) on that case it should start auto connecting with central , it should start advertise and pair, after sending the data , then disconnect and  want to enter the sleep mode. 

how to do this ? please guide me 

  • Hi,

    The peripheral can start the advertising once a certain criteria has been met. But the establishment of connection by sending a connection request has to be done by the central. This means that the central has to be scanning once the peripheral starts the advertising. You can use scanning with whitelist to avoid the central to connect to other devices. You could try the following approach:

    1. Start scanning. 
    2. Start advertising once your criteria for advertising has been met,
    3. Central connects once advertising packet has been received from peripheral in the whitelist.
    4. Data exchange
    5. Termination of link and go to sleep

    I would recommend reading our tutorials on BLE to get a better understanding of which callback functions you should use.

    Best regards

    Jared 

Related