nkolban / esp32-snippets

Sample ESP32 snippets and code fragments
https://leanpub.com/kolban-ESP32
Apache License 2.0
2.37k stars 710 forks source link

Unable to writeValue or readValue on BLE characteristics #1024

Closed whc2001 closed 4 years ago

whc2001 commented 4 years ago

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. I wonder what's wrong here. Here is the verbose log for characteristics discovering and value reading:

[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: 0
whc2001 commented 4 years ago

Moved to espressif/arduino-esp32.