Ble connection only on certain events

mikachesnutt gravatar image

asked 2017-08-11 17:56:16 +0100

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.

edit retag flag offensive close delete report spam


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

DMS ( 2017-08-14 06:33:42 +0100 )editconvert to answer

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.

run_ar ( 2017-08-14 11:33:31 +0100 )editconvert to answer

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?

developer  ( 2017-08-14 16:37:46 +0100 )editconvert to answer

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?

run_ar ( 2017-08-15 08:50:26 +0100 )editconvert to answer

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.

run_ar ( 2017-08-15 08:53:01 +0100 )editconvert to answer

thank you run_ar for the help! I expect the peripheral to send data anywhere from seconds between packets and as long as once in two hours.

developer  ( 2017-08-15 17:00:22 +0100 )editconvert to answer

Without knowing the exact usecase, I think I would have a commissioning process to begin with to bond the devices for security. Then disconnect. After that it sounds as if you could use the scheme of scanning every 30 seconds, and connect if you receive an advertisement.

run_ar ( 2017-08-21 09:48:47 +0100 )editconvert to answer