Unable To WriteValue Or ReadValue On BLE Characteristics #4509
Maybe your like
- Notifications You must be signed in to change notification settings
- Fork 7.8k
- Star 15.9k
- Code
- Issues 113
- Pull requests 18
- Discussions
- Actions
- Projects 2
- Wiki
- Security
Uh oh!
There was an error while loading. Please reload this page.
- Insights
Description
Hardware:
Board: ESP32 DevKit V1 Core Installation version: 1.0.4 IDE name: Arduino IDE Flash Frequency: 80Mhz PSRAM enabled: no Upload Speed: 921600 Computer OS: Windows 10
Description:
I tried to use the BLEClient to communicate with my camera. The camera requires pairing before doing anything, so I tried to use nRFConnect app on my Android phone. When not paired, you can discover all the services and characteristics, but if you try to access (read/write) any characteristic, the pairing prompt will appear on the camera screen and you would need to accept it to successfully read/write the value. I can discover the services and characteristics using BLEClient, but absolutely nothing happens when I tried to read or write the characteristics. There is no pairing prompt on camera screen, reading always return empty string and writting just nothing at all.
Sketch: (removed the searching and doing other actions part)
... /* BLE device found handler */ class BleAdvertisedDeviceHandler: public BLEAdvertisedDeviceCallbacks { void onResult(BLEAdvertisedDevice advertisedDevice) { Serial.print("BLE Advertised Device found: "); Serial.println(advertisedDevice.toString().c_str()); if(advertisedDevice.getAddress().equals(cameraMacAddress)) { bleScanner->stop(); cameraDevice = new BLEAdvertisedDevice(advertisedDevice); connectState = FOUND_BLE_DEVICE; } } }; bool Connect() { cameraConnection = BLEDevice::createClient(); cameraConnection->setClientCallbacks(new BleConnectionHandler()); cameraConnection->connect(cameraDevice); Serial.println("Connected"); // Get location service BLERemoteService* locationService = cameraConnection->getService(locationServiceUuid); if (locationService == nullptr) { Serial.println("ERROR: No specified service"); cameraConnection->disconnect(); return false; } Serial.println("Location service found"); // Get location read parameter characteristic locationCharaRead = locationService->getCharacteristic(locationCharaReadUuid); if (locationCharaRead == nullptr) { Serial.println("ERROR: No specified characteristic"); cameraConnection->disconnect(); return false; } Serial.println("Location read parameter characteristic found"); Serial.print("Handle=0x"); Serial.print(locationCharaRead->getHandle(), HEX); Serial.print(" CanRead="); Serial.print(locationCharaRead->canRead()); Serial.print(" CanWrite="); Serial.println(locationCharaRead->canWrite()); // Get location write coordinate characteristic locationCharaWrite = locationService->getCharacteristic(locationCharaWriteUuid); if (locationCharaWrite == nullptr) { Serial.println("ERROR: No specified characteristic"); cameraConnection->disconnect(); return false; } Serial.println("Location write coordinate characteristic found"); Serial.print("Handle=0x"); Serial.print(locationCharaWrite->getHandle(), HEX); Serial.print(" CanRead="); Serial.print(locationCharaWrite->canRead()); Serial.print(" CanWrite="); Serial.println(locationCharaWrite->canWrite()); // Try to read the characteristic Serial.print(locationCharaRead->readValue().c_str()); return true; } ...Debug Messages:
[V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 18 [V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown [V][BLERemoteService.cpp:162] retrieveCharacteristics(): >> getCharacteristics() for service: 8000dd00-dd00-ffff-ffff-ffffffffffff [V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 18 [D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 42, UUID: 0000dd01-0000-1000-8000-00805f9b34fb [D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown [V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 42 0x42, uuid: 0000dd01-0000-1000-8000-00805f9b34fb [V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: 0000dd01-0000-1000-8000-00805f9b34fb [D][BLERemoteCharacteristic.cpp:280] retrieveDescriptors(): Found a descriptor: Handle: 43, UUID: 00002902-0000-1000-8000-00805f9b34fb [V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 1 descriptors. [V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic [D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 45, UUID: 0000dd11-0000-1000-8000-00805f9b34fb [V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 45 0x45, uuid: 0000dd11-0000-1000-8000-00805f9b34fb [V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: 0000dd11-0000-1000-8000-00805f9b34fb [E][BLERemoteCharacteristic.cpp:274] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown [V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 0 descriptors. [V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic [D][BLERemoteService.cpp:193] retrieveCharacteristics(): Found a characteristic: Handle: 47, UUID: 0000dd21-0000-1000-8000-00805f9b34fb [V][BLERemoteCharacteristic.cpp:36] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 47 0x47, uuid: 0000dd21-0000-1000-8000-00805f9b34fb [V][BLERemoteCharacteristic.cpp:250] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: 0000dd21-0000-1000-8000-00805f9b34fb [E][BLERemoteCharacteristic.cpp:274] retrieveDescriptors(): esp_ble_gattc_get_all_descr: Unknown [V][BLERemoteCharacteristic.cpp:294] retrieveDescriptors(): << retrieveDescriptors(): Found 0 descriptors. [V][BLERemoteCharacteristic.cpp:45] BLERemoteCharacteristic(): << BLERemoteCharacteristic [V][BLERemoteService.cpp:209] retrieveCharacteristics(): << getCharacteristics() Location read parameter characteristic found Handle=0x2F CanRead=1 CanWrite=0 Location write coordinate characteristic found Handle=0x2D CanRead=0 CanWrite=1 [V][BLERemoteCharacteristic.cpp:398] readValue(): >> readValue(): uuid: 0000dd21-0000-1000-8000-00805f9b34fb, handle: 47 0x2f [D][FreeRTOS.cpp:189] take(): Semaphore taking: name: ReadCharEvt (0x3ffdfab0), owner: <N/A> for readValue [D][FreeRTOS.cpp:198] take(): Semaphore taken: name: ReadCharEvt (0x3ffdfab0), owner: readValue [V][FreeRTOS.cpp:63] wait(): >> wait: Semaphore waiting: name: ReadCharEvt (0x3ffdfab0), owner: readValue for readValue [V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 3 [D][BLEDevice.cpp:148] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown [V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 3 [V][BLEUtils.cpp:1283] dumpGattClientEvent(): GATT Event: Unknown [V][BLEUtils.cpp:951] gattClientEventTypeToString(): Unknown GATT Client event type: 3 [D][BLEClient.cpp:158] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... Unknown [V][FreeRTOS.cpp:143] give(): Semaphore giving: name: ReadCharEvt (0x3ffdfab0), owner: readValue [V][FreeRTOS.cpp:77] wait(): << wait: Semaphore released: name: ReadCharEvt (0x3ffdfab0), owner: <N/A> [V][BLERemoteCharacteristic.cpp:426] readValue(): << readValue(): length: 0Metadata
Metadata
Assignees
No one assignedLabels
No labelsNo labelsType
No typeProjects
No projectsMilestone
No milestoneRelationships
None yetDevelopment
No branches or pull requestsIssue actions
You can’t perform that action at this time.Tag » Arduino Ble Readvalue
-
ArduinoBLE - adValue() - Arduino Reference
-
Understanding BLE lue() - Arduino Forum
-
ArduinoBLE - Arduino Reference
-
Get Continuously The Value Of A BLE Service, Communication ...
-
BLE Central Print Out Values Of Int Characteristic - Arduino Forum
-
dValue! - MKRWIFI1010 - Arduino Forum
-
ARduinoBLE Write INT? - Programming Questions - Arduino Forum
-
BLE 33 Peripheral Not Updating - Nano 33 BLE Sense - Arduino Forum
-
Converting Uint8_t Using Arduino 33 BLE And NRF
-
BLERemoteCharacteristic::readValue() Does Not Return The Correct ...
-
Read From One Characteristic · P5.ble.js - ITP
-
Esp-nimble-cpp: NimBLERemoteDescriptor Class Reference
-
BLE Characteristic ReadValue Cannot Reliably Read Data - ESP32 Forum
-
Python - Blupy Read Value From Chacteristics As Integer And Not As Ascii