Reputation: 965
I have made a simple arduino code, where there are 6 characteristics, I have made a flutter apk where I observe all the characteristics which I defined in the arduino.
In setup code of arudino ->
// Create the BLE Service
BLEService* pService = pServer->createService(SERVICE_UUID);
// Create a BLE Characteristic
pCharacteristic1 = pService->createCharacteristic(
CHARACTERISTIC_UUID1,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE);
// Create a BLE Descriptor
pCharacteristic1->addDescriptor(new BLE2902());
// Create a BLE Characteristic
pCharacteristic2 = pService->createCharacteristic(
CHARACTERISTIC_UUID2,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE);
// Create a BLE Descriptor
pCharacteristic2->addDescriptor(new BLE2902());
// Create a BLE Characteristic
pCharacteristic3 = pService->createCharacteristic(
CHARACTERISTIC_UUID3,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE);
// Create a BLE Descriptor
pCharacteristic3->addDescriptor(new BLE2902());
// Create a BLE Characteristic
pCharacteristic4 = pService->createCharacteristic(
CHARACTERISTIC_UUID4,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE);
// Create a BLE Descriptor
pCharacteristic4->addDescriptor(new BLE2902());
// Create a BLE Characteristic
pCharacteristic5 = pService->createCharacteristic(
CHARACTERISTIC_UUID5,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE);
// Create a BLE Descriptor
pCharacteristic5->addDescriptor(new BLE2902());
// Create a BLE Characteristic
pCharacteristic6 = pService->createCharacteristic(
CHARACTERISTIC_UUID6,
BLECharacteristic::PROPERTY_READ | BLECharacteristic::PROPERTY_WRITE | BLECharacteristic::PROPERTY_NOTIFY | BLECharacteristic::PROPERTY_INDICATE);
// Create a BLE Descriptor
pCharacteristic6->addDescriptor(new BLE2902());
And in loop of arudino->
// notify changed value
if (deviceConnected) {
pCharacteristic1->setValue((uint8_t*)&value, 4);
pCharacteristic1->notify();
pCharacteristic2->setValue((uint8_t*)&value, 4);
pCharacteristic2->notify();
pCharacteristic3->setValue((uint8_t*)&value, 4);
pCharacteristic3->notify();
pCharacteristic4->setValue((uint8_t*)&value, 4);
pCharacteristic4->notify();
pCharacteristic5->setValue((uint8_t*)&value, 4);
pCharacteristic5->notify();
pCharacteristic6->setValue((uint8_t*)&value, 4);
pCharacteristic6->notify();
value++;
digitalWrite(2, HIGH);
delay(1000); // bluetooth stack will go into congestion, if too many packets are sent, in 6 hours test i was able to go as low as 3ms
} else {
digitalWrite(2, HIGH); // Turn the LED on (HIGH is the voltage level)
delay(2000); // Wait for a second
digitalWrite(2, LOW); // Turn the LED off by making the voltage LOW
delay(1000);
}
Now in android logs i can find only 4 descriptor values, the characteristics 5 have empty descriptor and characteristics 6 was never found in the characteristics list
This is the log in android studio->
BluetoothCharacteristic{uuid: beb54831-36e1-4688-b7f5-ea07361b26a8, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, secondaryServiceUuid: null, properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: true, notify: true, indicate: true, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, descriptors: [BluetoothDescriptor{uuid: 00002902-0000-1000-8000-00805f9b34fb, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, characteristicUuid: beb54831-36e1-4688-b7f5-ea07361b26a8, value: []}], value: []}
BluetoothCharacteristic{uuid: beb54832-36e1-4688-b7f5-ea07361b26a8, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, secondaryServiceUuid: null, properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: true, notify: true, indicate: true, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, descriptors: [BluetoothDescriptor{uuid: 00002902-0000-1000-8000-00805f9b34fb, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, characteristicUuid: beb54832-36e1-4688-b7f5-ea07361b26a8, value: []}], value: []}
BluetoothCharacteristic{uuid: beb54833-36e1-4688-b7f5-ea07361b26a8, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, secondaryServiceUuid: null, properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: true, notify: true, indicate: true, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, descriptors: [BluetoothDescriptor{uuid: 00002902-0000-1000-8000-00805f9b34fb, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, characteristicUuid: beb54833-36e1-4688-b7f5-ea07361b26a8, value: []}], value: []}
BluetoothCharacteristic{uuid: beb54834-36e1-4688-b7f5-ea07361b26a8, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, secondaryServiceUuid: null, properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: true, notify: true, indicate: true, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, descriptors: [BluetoothDescriptor{uuid: 00002902-0000-1000-8000-00805f9b34fb, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, characteristicUuid: beb54834-36e1-4688-b7f5-ea07361b26a8, value: []}], value: []}
But for beb54835, there is no descriptor and beb54836 was not found in the characteristics.
BluetoothCharacteristic{uuid: beb54835-36e1-4688-b7f5-ea07361b26a8, deviceId: C0:49:EF:CE:E7:E2, serviceUuid: 4fafc201-1fb5-459e-8fcc-c5c9c331914b, secondaryServiceUuid: null, properties: CharacteristicProperties{broadcast: false, read: true, writeWithoutResponse: false, write: true, notify: true, indicate: true, authenticatedSignedWrites: false, extendedProperties: false, notifyEncryptionRequired: false, indicateEncryptionRequired: false}, descriptors: [], value: []}
Upvotes: 0
Views: 140
Reputation: 965
Found that editing the numHandles solved the issue, by default only 15 numHandles was allowed
pService = pServer->createService(BLEUUID(SERVICE_UUID), 100); // 100 handles
Upvotes: 0