How to enable a UUID128 service and its characteristcs at bluez/bluetoothctl? - bluetooth-lowenergy

I am playing around with a own device that runs bluetooth 5.0 + an own service = 3 characteristics.
NRFconnect give me a nice picture of the services.
Now I am running my Ubuntu and trying to do the same via cmdline. So I am using bluetoothctl. The service I like to use has the UUID128 49535343-fe7d-4ae5-8fa9-9fafd205e000.
When connecting to the device all other services are show except my own one.
[bluetooth]# connect EA:55:E3:4F:55:55
Attempting to connect to EA:55:E3:4F:55:55
[CHG] Device EA:55:E3:4F:55:55 Connected: yes
Connection successful
[NEW] Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0021
00001801-0000-1000-8000-00805f9b34fb
Generic Attribute Profile
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0021/char0022
00002a05-0000-1000-8000-00805f9b34fb
Service Changed
[NEW] Primary Service (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031
0000180a-0000-1000-8000-00805f9b34fb
Device Information
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char0032
00002a29-0000-1000-8000-00805f9b34fb
Manufacturer Name String
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char0034
00002a24-0000-1000-8000-00805f9b34fb
Model Number String
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char0036
00002a25-0000-1000-8000-00805f9b34fb
Serial Number String
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char0038
00002a27-0000-1000-8000-00805f9b34fb
Hardware Revision String
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char003a
00002a26-0000-1000-8000-00805f9b34fb
Firmware Revision String
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char003c
00002a28-0000-1000-8000-00805f9b34fb
Software Revision String
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char003e
00002a23-0000-1000-8000-00805f9b34fb
System ID
[NEW] Characteristic (Handle 0x0000)
/org/bluez/hci0/dev_EA_55_E3_4F_55_55/service0031/char0040
00002a2a-0000-1000-8000-00805f9b34fb
IEEE 11073-20601 Regulatory Cert. Data List
[CHG] Device EA:55:E3:4F:55:55 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device EA:55:E3:4F:55:55 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device EA:55:E3:4F:55:55 UUIDs: 0000180a-0000-1000-8000-00805f9b34fb
[CHG] Device EA:55:E3:4F:55:55 UUIDs: 49535343-fe7d-4ae5-8fa9-9fafd205e000
[CHG] Device EA:55:E3:4F:55:55 ServicesResolved: yes
It looks to me that bluez discovers the service but does not create the characteristic/service nodes. Any ideas how I can make it work?

Related

IRK distribution when devices connected with public address

I have a question, for BLE experts, regarding the IRK exchanged when bonding occurs between two BLE devices with public address. I don't remember where I saw the statement that if during exchange keys a device "A" got IRK from a peer device "B" that has public address, the device "A" keep the received IRK as zeros.
Could somebody confirm or deny this statement?
Thank you in advance
Searching in the spec5.3 I found nothing about keeping the IRK that received from device with public address.
Every device must have either a Public Address or a Static Random Address that is used as the Identity Address.
When a device advertises, connects or sends a scan request, it can either choose to use this Identity address as its own address or use a Resolvable Private Address derived from its own IRK (if the device has an IRK). If the device does not have an IRK, it must use its Identity Address (or possibly a non-resolvable private address).
Whenever the IdKey bit is set in the Pairing Request and Pairing Response messages for the central or the peripheral, respectively, the IRK and Identity Address shall be distributed. If a device does not have an IRK, it sets the IRK field to 16 zero bytes in the SMP Identity Information packet during the key distribution phase during the pairing, per Bluetooth Core specification v5.3, Vol 3, Part H (SMP), section 3.6.4:
Note: An all zero Identity Resolving Key data field indicates that a device does not have a valid resolvable private address.
I think you have misunderstood something, because there is nothing that says that a device receiving a valid IRK or no IRK at all shall "set it to zeros" if the same remote device happens to have a Public Address (either as the address used during the connection or as its Identity Address). In fact, an all-zero IRK is not even valid, since such a one could not be sent over the SMP protocol (since an all-zero IRK would mean a non-existing IRK).
Note that it's perfectly fine for a device that "has a public address" to also have an IRK. It might for one connection use the public address and for another connection use a Resolvable Private Address derived from its IRK.
It is however common that devices have a public address as Identity Address and no IRK. In that case the bonding storage representing this device will store the public address and no IRK, (since it receives an all-zero IRK during key distribution).

How to enable notification and indications on Arduino nano 33 IOT BLE descriptor?

I am making BLE echo system between Arduino and Android.
I have finished to make read and write function. But I want Android can automatically detect value when BluetoothGattCharacteristic value change. So I made set notification on Android.
When I tried to check the fucntion is working properly or not, It was not working properly. And I use nRFConnect App to check what is the problem. the problem is the status of descriptor on Arduino is Notification and indications disabled. And I googled how to enable notification and indication on Arduino. But on the Arduino's document, I cannot find the function which can make enable descriptor's notification and indication. this is the document link. So is it possible to enable notification and indication on Arduino BLE??
Code of Arduino nano 33 IOT.
#include <ArduinoBLE.h>
BLEService echoService("00000000-0000-1000-8000-00805f9b34fb");
BLEStringCharacteristic charac ("741c12b9-e13c-4992-8a5e-fce46dec0bff", BLERead | BLEWrite | BLENotify,40);
BLEDescriptor Descriptor("beca6057-955c-4f8a-e1e3-56a1633f04b1","Descriptor");
String var = "";
void setup(){
Serial.begin(9600);
while(!Serial);
if(!BLE.begin()){
Serial.println("starting BLE failed.");
while(1);
}
BLE.setLocalName("Arduino BLE Echo");
BLE.setAdvertisedService(echoService);
charac.addDescriptor(Descriptor);
echoService.addCharacteristic(charac);
BLE.addService(echoService);
BLE.advertise();
Serial.println("Bluetooth device active, waiting for connections...");
Serial.println(" ");
}
void loop(){
BLEDevice central = BLE.central();
if(central){
Serial.println("* Connected to central device!");
Serial.print("Connected to central : ");
Serial.println(central.address());
Serial.println(" ");
while(central.connected()){
if(charac.written()){
var = charac.value();
Serial.println(String(var));
delay(500);
charac.writeValue(var);
Serial.println("write stringCharacteristic");
}
}
Serial.print("Disconnected from central: ");
Serial.println(central.address());
}
}
picture of nRFConnection APP.
You need to enable the notifications from the Android side in order to receive the BLE notifications. This is because according to the BLE specification, BLE notifications are disabled by default. If you want BLE notifications to remain enabled after the first time you enable them, you can bond with the Arduino device. This way, the status of the notification will persist across power cycles and disconnection/reconnection, and as soon as you reconnect to the Arduino device, notifications will be enabled by default (but again, you still have to enable them the first time).
This can be seen in the paragraph below (Bluetooth Specification v5.3, Vol 3, Part G, Section 3.3.3.3 - Clinet Characteristic Configuration - Page 1489):-
"The Client Characteristic Configuration declaration is an optional
characteristic descriptor that defines how the characteristic may be
configured by a specific client. The Client Characteristic
Configuration descriptor value shall be persistent across connections
for bonded devices. The Client Characteristic Configuration descriptor
value shall be set to the default value at each connection with
non-bonded devices.The characteristic descriptor value is a bit
field. When a bit is set, that action shall be enabled, otherwise it
will not be used. The Client Characteristic Configuration descriptor
may occur in any position within the characteristic definition after
the Characteristic Value. Only one Client Characteristic Configuration
declaration shall exist in a characteristic definition.
The default value for the Client Characteristic Configuration descriptor value shall be 0x0000."
Note that the Client Characteristic Descriptor (CCCD) is the attribute in the characteristic that handles notification/indications. You can read more about this here:-
Bluetooth Low Energy: A Primer
Bluetooth GATT
Bluetooth Low Energy Characteristics Tutorial

How in a bluetooth connection can the Peripheral get the Central device name

Is there any way for a Peripheral to get a Central device's name when establishing a bluetooth connection (BLE)? I'm unsure if Bleno has the tools necessary to get this.
Just read the Device Name in the remote GATT server. The peripheral must support GATT client in order to be able to read the device name.

Get MAC address in scan response packet for BLE Device

Refer to question: Get MAC address of bluetooth low energy peripheral
We have board where we have kept MAC id in encrypted form in advertisement packet and reading those MAC-id in our iOS App. Since Apple actually suppress MAC id information for BLE device Will it be problem (App rejection) if manufacturer puts this in packet and app reads it?

Unable to read TX characteristic value of Nordic UART service, on Linkitone board as Central device

I am amateur for GATT and ble.
I am using Linkit one board as central device and Nrf51 board as peripheral device. Central device successfully connecting with peripheral device, able to seach all Services UUID, Characteristic UUID, but it fails to read the characteristic value. Value which display on Linkit side it is not same as mentioned in nordic side.
I am able to get the characteristic value in nordic app and as well as nordic board as an peripheral device.
Linkitone as central device fails to read TX characteristic value of nordic uart service from any peripheral device. Even when I tried Linkitone as peripheral device and try to read the Nordic uart service value by nordic app, it fails. App get hanged every time.
Below I mentioned the value which gave to tx characteristic the value which is getting on central side. So is there any problem with Linkitone board with ble UART service or there is any different reason for this?

Resources