Go Down

Topic: Nano 33 ble nRF52840 - BLE long range/pairing ? Mbed BLE API ? Adafruit Lib? (Read 4968 times) previous topic - next topic

Klaus_K

I have an iPhone XR that includes Bluetooth 5.0, is long range an optional feature of version 5.0 ?
Yes, the Bluetooth LE Coded PHY (125kBit (~4x range), 500kBit (~2x range)) and LE2M 2MBit (higher data rate but shorter range) are all optional features in Bluetooth 5.0.

I found some post where people believe iPhone XR could support LR. But that could just be a guess based on the fact that it supports BLE5. Additionally, the hardware might be able, but iOS might not support it on this phone.

Even if you have an iPhone 11 and iOS supports LR you might still not be able to use it unless you have an app that actively uses this feature. My guess is right now, there are no consumer end products on the market that use this feature. If I were Apple, I would enable the feature in the OS for apps that want to use it but otherwise the LR mode would stay switched off.

So, I recommend you look for indications that an app might support this feature and see if you can use that to test it. You can also look if you can find some app development information about this feature.

pailhoux

Very good job Colas71 and thanks your for your contribution.

I am not yet very comfortable with this Mbed BLE_API and the BLE. How can I add and assign a custum service with custom UUIDs and these characteristics.

Before your code I used ArduinoBLE.h

// BLE Battery Service
BLEService batteryService("180F");

// BLE Battery Level Characteristic
BLEUnsignedCharCharacteristic BatterieChar("2a19", BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedCharCharacteristic MouvementChar("2a20",BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedCharCharacteristic DetectionChar("2a21",BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes
BLEUnsignedCharCharacteristic AlarmeChar("2a22",BLERead | BLENotify); // remote clients will be able to get notifications if this characteristic changes


BLE.setAdvertisedService(batteryService); // add the service UUID
 batteryService.addCharacteristic(BatterieChar); // add the battery level characteristic
 batteryService.addCharacteristic(MouvementChar);
 batteryService.addCharacteristic(DetectionChar);
 batteryService.addCharacteristic(AlarmeChar);
 BLE.addService(batteryService); // Add the battery service
 BatterieChar.writeValue(0); // set initial value for this characteristic

Thanks for your replies

Klaus_K

I am not yet very comfortable with this Mbed BLE_API and the BLE. How can I add and assign a custum service with custom UUIDs and these characteristics.
When you create your own services and characteristics you should use random 128-bit UUIDs. You can write a small script to generate them yourself or use a web tool (Google UUID generator).

16-bit UUIDs are assigned by the Bluetooth SIG and you should only use them when you implement a defined service or characteristic. You can look them up on the Bluetooth SIG web page.

https://www.bluetooth.com/specifications/gatt/services/

https://www.bluetooth.com/specifications/gatt/characteristics/

pailhoux

Ok thanks.

But my question is : how I have to do for add one custum service called MYSERVICE for exemple and one or more int custum Characteric to this servie called for exemple MYCHARACTERIC1.
Using the Colas71 code.

Probably using methods of _adv_data_builder member of AdvertisingDataBuilder class but I don't find any exemple on the web and I unsucced by myself. :smiley-confuse:


cosine32

Thank you so much for this Colas71. I was working towards this on my own, but finding the mbed documentation and examples severely lacking. You have probably saved me a weeks work, although I do still need to understand it all.

Has anyone investigated the range using code based on this example, with a couple of BLE 33s?

gerrikoio

I found my solution here :

https://os.mbed.com/teams/Bluetooth-Low-Energy/code/BLE_GATT_Example/file/f6814152873c/CustomService.h/

In addition there is a video. ;)
The link here was created in 2015 and was for an earlier version of MBED. So I believe quite a bit has changed since.

I believe Arduino is currently using a hybrid MBED based primarily on version 5.14.

https://os.mbed.com/docs/mbed-os/v5.14/apis/bluetooth.html

In my opinion, the best MBED BLE implementation of a custom peripheral service can be found here (GattServer) as this uses 128-bit UUID's.

https://os.mbed.com/docs/mbed-os/v5.14/apis/gattserver.html

The major downside here is that this example appears to over complicate matters as I can find no real benefit from using #include "platform/Callback.h" for example (and this caused an error when trying to compile). Similarly not sure why #include "platform/NonCopyable.h" is also used. Beside that it demonstrates the use of creating and attaching your READ, WRITE, WRITEWITHOUTREPONSE, INDICATE and NOTIFY attributes for your characteristics etc.

Go Up