Bluetooth Low Energy on different platforms - bluetooth-lowenergy

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.

Related

Need help for a deeper understanding of BLE

I have to write a BLE application on an embedded device and there are some features where I'm not sure if BLE supports that or whether I've to create some wrapper around everything or if it's maybe not possible at all. The gerenal descriptions of Bluetooth and BLE I found around the internet usually only cover the overall functionality but don't go in too much detail. If this post gets too complex I'll split it up into different smaller ones.
I use the STM32 BlueNRG-MS chip
1. Discoverability (resolved)
The user has to be able to disable the BLE function in case there are several devices in reach. I see that there are functions aci_gap_set_discoverable() or aci_gap_set_non_discoverable() but altough I set it to not discoverable I can still see it in the LightBlue App on my mobile. How would I correctly disable the BLE functionality of a device to make sure no one can see it or connect to it?
Update: Okay that has been a mistake from my end, if I call the aci_gap_set_non_discoverable() function it is actually undiscoverable. So that's fine.
2. Only accept connections of paired devices
I'd like to achieve a behavior such that, if you have an unpaired phone you have to set the BLE device into a pairing mode in order to connect. If the phone has already been paired, the BLE device shall accept the connection request regardless of whether it's currently in pairing mode or not. Is this what the whitelist should be there for or do I have to do this manually by saving the address of the device after successful pairing? If whitelist is the right approach, I read that newer phones cause issues with whitelisting because they change their address on a regular basis, how can I handle this? That's actually where I thought I'm gonna work with the "discoverability".
3. Automatically reconnect
I'm not sure if this topic has to be handled on the BLE device or on the mobile phone. E.g. my phone is paired with my car's radio, so whenever the phone is in the car it automatically connects - how is this done? It's still the phone that acts as central device I assume?

BLE CC2541 disconnect with the app after some time

I am working on CC2541 BLE controller. I am using SimpleBLEPeripheral from TI BLE stack which is available on TI's website. I have interfaced the controller with a sensor whose state changes at an interval of 3 seconds. This means that event is generated at every 3 seconds. I am using custom profile's UUID whose length is 128 bits. I have also developed an app to get the sensor's data on my app. All is working good but device is getting disconnected with the app after establishing a connection.
I also tried changing the Connection Parameter in firmware but the issue is not resolved yet.
What should I try to make this connection flawless? I want that device should not get disconnected when it is in range and also if the device is out of range for sometime, it should auto reconnect with the app when it comes in the range of the mobile phone.

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

Application is not able to capture each and every scan responses from the ble device

I am developing a BLE android application where I have used RxAndroidBLe for BLE communication.
Everything working fine except one issue that the application is not receiving every scan response broadcasted by the BLE device (I am not sure whether it is an issue or not). The BLE device is set to broadcast it in every 1 second. It broadcasts the scan response on all the three channels 37,38,39 in round robin fashion. The application is intend to scan continuously until the application gets closed. But I observed that the application is not receiving all the scan response. Means it is not receiving scan response from the devices in every 1 second. Sometimes there is a gap of 2,3 seconds or more. I want to know is there any solution to overcome this issue or this is a valid behavior?
Any suggestion would be appreciated. Thanks in advance.
Due to nature of BLE scanning it is not certain that you will receive each scan response broadcast. At basic, it depend mostly on scan interval and scan window parameters (host side) and the interval you are broadcasting responses.
You can try low latency scan mode to improve your results.

Is it possible to set several advertisements for the same Bluetooth LE device?

To test bluetooth scalability, I want the same device (a Raspberry Pi or a laptop) to emit several BLE advertisements. So far, I have tried using bleno (NodeJS), hcitool and CoreBluetooth for OSX, but I can not setup more than one.
Is this a hardware/system/bluetooth limitation? Has somebody managed to do this?
Different bluetooth devices have different maximum advertising rates. These typically range from 10Hz to 40Hz. Some bluetooth devices have the ability to spoof their MAC address so different advertisements appear to come from different physical devices. This is often important for scalability testing, because some receivers keep track of unique devices by MAC address.
As #Emil says in his answer, it is possible to "interleave" advertisements such that you change the advertisement (and ideally the MAC address) every few hundred milliseconds so it appears by receiving devices that there are multiple advertisers around. I have done this with both Raspberry Pi and iOS transmitters, but in neither case could I alter the MAC address.
It is important to understand, though, that the actual number of packets received when you do this does not change. So while you may be testing scalability of unique advertisements detected, you will not be doing the same thing as testing with multiple physical advertisers.
That's not possible by the Bluetooth specification. However you can start off with one data then set a timer in your app that stops advertising. Then you start off again with the next data. And so on.

Resources