I am sending data from Arduino Nano 33 BLE Sense to Raspberry Pi 4 over BLE.
I am using ArduinoBLE.h library.
The data I send is acceleration data. I defined my characteristic as follow:
BLEShortCharacteristic accelerometerCharacteristic_X( BLE_UUID_ACCELEROMETER_X, BLERead | BLENotify );
This is what I read from my Pi:
{"uuid":"2101","name":null,"type":null,"properties":["read","notify"]}
I realised when defining a characteristic there is no place to define the name and if you define the data type (short in this case) before hand, you can only provide properties and UUID:
BLECharacteristic::BLECharacteristic(const char* uuid, uint8_t properties, int valueSize, bool fixedLength) :
BLECharacteristic(new BLELocalCharacteristic(uuid, properties, valueSize, fixedLength))
{
}
BLECharacteristic::BLECharacteristic(const char* uuid, uint8_t properties, const char* value) :
BLECharacteristic(new BLELocalCharacteristic(uuid, properties, value))
{
}
I have thought the const char* value
indicates a characteristic name, but it is not, it is just an another way to define size, I did not even understand why that exists:
BLELocalCharacteristic::BLELocalCharacteristic(const char* uuid, uint8_t properties, const char* value) :
BLELocalCharacteristic(uuid, properties, strlen(value))
{
writeValue(value);
}
Then, I came across with this thread.
I bet if you create a descriptor with ID
0x2901
(attached to your characteristic) and set its value to "My Chracteristic", thenCharacteristc.Name
will be "My Chracteristic" in your C# code.
So, I have created a descriptor and added to my characteristic:
BLEDescriptor accelerationXDescriptor("2901", "AccelerationX");
accelerometerCharacteristic_X.addDescriptor(accelerationXDescriptor);
But, I did not see any changes. So my question is how can I define the characteristic name?
Also what is the best way to send acceleration data? I need to send all X, Y, Z, but I will the processing them separately, so I created a characteristic for each, but I am not sure, it that is the best method.
I am reading the data at Pi using node.js.