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

Ble connection only on certain events

I want to connect a central and peripheral and only have ble on when the peripheral senses a certain event that exceeds a threshold. Do the devices need to connect on startup to recognize eachother? How is the best way to turn the connection on/off? I am using the heart rate collector as a base.

  • try to use multiactivity example in SDK 11+(advertising),

  • You can start to advertise when it suites your application. This also depends on the central application that needs to scan for advertisements to be able to initate the connection. If the central can scan all the time, it's ok to do so, and start advertising when ble should be turned on. But if power is limited on the central or if you have multiple advertisers you might want to use another scheme. Guess I'm trying to say that it depends on your application, so if you elaborate a little on the use case it will be easier to give recommendations. Thanks.

  • I have a central board that is functioning similar to the heart rate collector and I want it to scan every 30 seconds to check for updates to the data on the peripheral device. The peripheral device only sends updates when it has data that passes a certain threshold. So when it senses that data it will turn BLE on and send the packet over. Do the two devices need to have ble on at the beginning to establish connection and enable notifications?

  • How often do you expect the peripheral to send data, that is, how often will it pass the threshold? If you establish a connection at the beginning and use a slow connection interval you can use our online power profiler to check the average current consumption of the ble chip. However, if you choose to disconnect between transmits you will have to spend time reconnecting, and; if you don't use bonding you will have to enable notifications every time you connect. If you use bonding you will have to wait until encryption is started before you can start sending notifications. if you scan every 30 second, you will have to advertise for some time for the scanner to pick up the advertisement packet, but I assume that doesn't matter in your application?

  • Not sure what you mean by having the ble on at the beginning. Assuming you use bonding, you would probably want to have some sort of commissioning procedure at the beginning to enable bonding. If you don't care what device connects to your peripheral, you don't need to do so.

Related