Android BLE scan interval for Nearby Notifications? - android-notifications

What is the scan interval that is currently being used by Android for the Nearby Notifications feature (app-less)?
On a parallel note, does the stability value for the beacon have anything to do with this interval? How/If is the Nearby Notification affected when the stability value is changed between stable, portable, mobile & roving?

Nearby Notifications scanning is also the same as Nearby Messages background scanning. It does so at every screen on.
The stability of the beacon does not affect Nearby Notification.

According to this Google I/O talk : https://www.youtube.com/watch?v=Acdu2ZdBaZE&list=PLOU2XLYxmsILe6_eGvDN3GyiodoV3qNSC&index=28
If Location History is enabled on the device, BLE scan will also be done in the background. Although I cannot find the exact interval in the documentation.

Related

How to run watchOS app connected to BLE peripheral in the background?

I'm creating a watchOS application. The app should connect to a BLE tag, which sends distance values to the apple watch. If the distance falls below a given value, the application should give some feedback to the user about this.
Reading about core bluetooth and background tasks, it doesn't seems like it's possible. If I'm correct, when the application is suspended, it will no longer receive data from the BLE peripheral. How should I approach this task? Is it possible to run an application like this for 8 hours in the background? I can't find any more information about this, and it seems like it's impossible.
There are restrictions to WatchOS apps using Bluetooth in the background, the main being:-
The minimum connection interval is 30ms instead of 15ms (for iOS
devices).
The Apple watch can only operate as a central device.
The Apple watch can only be connected to two peripherals at one time.
The peripheral gets disconnected when the app goes into the background.
More details about this can be found in the following links:-
https://www.raywenderlich.com/336-core-bluetooth-in-watchos-tutorial
https://developer.apple.com/videos/play/wwdc2017/712/
The only exception to this is if you use the HKWorkoutSession. More information about this can be found here.
I hope this helps.

How do I program this BLE location tag?

I bought one of these:
https://www.aliexpress.com/item/Smart-finder-Key-finder-Wireless-Bluetooth-Tracker-Anti-lost-alarm-Smart-Tag-Child-Bag-Pet-GPS/32806261079.html
As far as I can tell it is a BLE (Bluetooth Low Energy) location tag.
I downloaded the app for it onto my iphone, and the app instantly recognised it and connected to it. The iPhone app seems to know how far away the tag is - it has a little map of the local area and says how many feet away. I was able to set the device name via the app, but I'm not sure if that set it locally or on the tag itself. The iPhone app also has a "find" button - when you press it, the tag beeps.
So I want to know how I can program this thing myself. I want to be able to identify it when it is nearby, connect to it and make it beep. I've searched for quite a while but not come up with much.
I'm assuming (wrongly/rightly?) that there is some general standard or approach for talking to these BLE location devices and carrying out the basic functions with them - but what is that standard - where is the documentation?
Does anyone have any idea how to program these BLE location tag devices?
BLE devices typically communicate using GATT, either using standard GATT services, or custom ones. The command to make it beep is probably implemented using a custom GATT service.
For finding out the distance to the beacon, typically the RSSI is used. This is a measure of the received power. It needs to be compared to the output power at the emitter. Usually beacons will put their output power in advertisement data, so it can be used without connecting to them. Here since the app is also able to send commands to the beacon, chances are it keeps a connection to it and has a custom GATT protocol to retrieve the output power.
Here is what I would suggest:
Read up on BLE, especially advertising and GATT. For instance read this for advertising and this for GATT. The full BLE spec is available here but should be used for reference and not introduction
Sniff the communication between your device and your phone. You can see this other answer of mine to get started
Replicate the communication protocol in you own app. For that you'll need to use your target platform's BLE libraries. For instance for iOS it is CoreBluetooth

BLE with iOS Advertising Interval

I have established a connection between an nRF52 which has the advertising interval set at 20ms and iOS software, but the packages are only received every second roughly. Has anyone had this issue before/knows any tricks to speed up the frequency? Many thanks.
Its depending on nRF52 or other peripheral advertising interval in firmware. Also depends on data/packets transfer speed/distance.
If there is write characteristic available on peripheral for set time, then send/write values and speed up for this. Some device has this property for advertising interval time set but iOS/Android app.

Bluetooth Low Energy on different platforms

I'm trying to establish a bluetooth low energy link between a custom pcb and a mobile device. The application requires a tablet device and a BLE link that operates as fast as possible.
Since the BLE Speed is main defined by the allowed number of packages per connection interval and the minimal connection interval I'm trying to find a tablet with those capabilitys.
I have been searching a lot and just found the following information:
IOS device are stuck with a minimal connection interval of 30ms
Android devices are technically able to deliver 6 packets each 7.5ms, but usually it wont settle for anything below 20ms.
I find it very hard to get solid information on that topic. I found nothing about Windows Tablets and Tizen Tablets.
Does anyone have information about that topic?
You see, the standard Android bluetooth code is (with sometimes small adjustments by each manufacturers) the same on every device and the bluetooth controllers available on the market tend to only send 3-6 packets each connection event if the min/max connection event length is set to 0, which it is by default in Android's code.
Is it possible for you to work with AOSP, i.e. modify the Android source code? If so you could change the HCI call where a connection is created or connection parameters are updated. Change the min/max connection event length (Minimum_CE_Length and Maximum_CE_Length) to some large value and you will then be able to write many many packets in one connection event regardless of connection interval.
The relevant places in the code are https://android.googlesource.com/platform/system/bt/+/d35bb40dd563e7f37df0a2fa9c0f61d0958b9601/stack/l2cap/l2c_ble.c#945 and https://android.googlesource.com/platform/system/bt/+/488005b16bd2552ce7e5f9c1e1b3d4072397fc26/stack/btm/btm_ble_bgconn.cc#394.

Is it possible to monitor multiple bands from a single app?

Is it possible to have one app on the android or ios phone monitor 2 or more bands, Place tiles and respond to button/ accelerometer events? I did not see that in the docs.
Thanks
Yes, this is possible. It is a more advanced configuration so you must pair the Band's in the phone's BlueTooth Settings. Then when you query the SDK APIs for devices you iterate over the devices and create one connection per device. This should allow you to then communicate with each device from within one app.

Resources