- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I was wandering if it's at all possible to have a peripheral automatically reconnect to a phone after it wakes up, similar to say how classic Bluetooth headphones work, usually reconnecting to the phone with no input required on the users part?
- Labels:
-
MasterSlave
-
Scanning-Advertising
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
Yes there is. From the mobile side(at least on Android), there is API:
public BluetoothGatt connectGatt (Context context, boolean autoConnect, BluetoothGattCallback callback);
The second parameter is for autoConnect. So when the peripheral advertises again and if the app is still running, then they will reconnect.
I'm pretty sure you can do this on iOS also.
On the firmware application side, you have to either start advertising undirected or directed upon wake up . If you want to broadcast directed advertisements, you must have saved the information of the previously connected device in NVRAM before.
Remember, the client(the mobile) is the one that initiates the connection. So your peripheral needs to be advertising.
Does this help? Please let us know.
Thank you.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It works for iOS also, although I don't know the details. One thing to watch out for is the iOS app might stop scanning if it goes into some background mode.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I don't develop iOS apps, so I can't say for sure, but you can probably have a background service that is running. An analogy would be Android Service running in the background. That way your mobile can still scan if you wanted to. Although you probably don't want this behavior as it would drain your battery a lot.
James
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I know it can be done in iOS because our iOS guys got it to work, but it can be tricky and sometimes iOS behavior is not always what you think it will be. Bottom line, If you need the app to be connectable from background, be sure to test scenarios where you are browsing internet, listening to music, long periods of inactivity, etc. to make sure it works the way you want it to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I have an application that goes to sleep and after it wakes up I'd like it to alert an app that runs in the background as a service on Android. our android guy can listen to a connection being made with the phone, I would like to initiate this connection and if I'm not mistaken I would need to switch to a master role and try and connect to the device? if this is the case can someone point me in the right direction with regards to switching between roles
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Sean,
1. What you can do is force advertising and the client has to connect to you.
2. There is no role switch in BLE.
3. The Android App has to be scanning and scanning constantly.
4. So when your peripheral is advertising, the background app has to initiate the connection request
Hope this helps.
JT