Open FynnHR opened 6 years ago
Are you sure you have service and characteristic with the same UUID:
// The remote service we wish to connect to.
static BLEUUID serviceUUID("6e400001-c352-11e5-953d-0002a5d5c51b");
// The characteristic of the remote service we are interested in.
static BLEUUID charUUID("6e400001-c352-11e5-953d-0002a5d5c51b");
@Caramba11 How did you get the debug system messages above?
I think my problem is similar to yours but my system messages look slightly different
Forming a connection to f5:e1:02:80:05:f4
I suspect that the authentication did not go through correctly, as by changing the passkey in the code below doesn't change the output of the system messages, ie it still manages to connect to the server even when the passkey is wrong.
uint32_t onPassKeyRequest(){ return 123123; }
Sorry for the late reply first. @chegewara The issue was caused by the identical UUIDs (argh). But now the same code (just put the right UUIDs in) is not connecting to the device anymore, I will attache the new debung output.
@skyng22003 I got these messages by switching the debug level to Verbose.
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:1
load:0x3fff0018,len:4
load:0x3fff001c,len:952
load:0x40078000,len:6084
load:0x40080000,len:7936
entry 0x40080310
Starting Arduino BLE Client application...
[D][BLEScan.cpp:196] start(): >> start(duration=30)
[D][BLEScan.cpp:221] start(): << start()
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT
[D][BLEUtils.cpp:1229] dumpGapEvent(): [status: 0]
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_START_COMPLETE_EVT
[D][BLEUtils.cpp:1305] dumpGapEvent(): [status: 0]
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 00:18:da:0a:5c:74, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_PUBLIC, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -71, ble_adv: ??, flag: 6 ([LE General Discoverable Mode] [BR/EDR Not Supported] ), num_resps: 1, adv_data_len: 31, scan_rsp_len: 0
[D][BLEAdvertisedDevice.cpp:422] setRSSI(): - setRSSI(): rssi: -71
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 06
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x07 (ESP_BLE_AD_TYPE_128SRV_CMPL), length: 16, data: 1bc5d5a502003d95e51152c30100406e
[D][BLEAdvertisedDevice.cpp:451] setServiceUUID(): - addServiceUUID(): serviceUUID: 6e400001-c352-11e5-953d-0002a5d5c51b
[D][BLEAdvertisedDevice.cpp:251] parseAdvertisement(): Type: 0x09 (ESP_BLE_AD_TYPE_NAME_CMPL), length: 8, data: 412d304135433734
[D][BLEAdvertisedDevice.cpp:411] setName(): - setName(): name: A-0A5C74
BLE Advertised Device found: Name: A-0A5C74, Address: 00:18:da:0a:5c:74, serviceUUID: 6e400001-c352-11e5-953d-0002a5d5c51b
Found our device! address: [D][BLEScan.cpp:244] stop(): >> stop()
[D][BLEScan.cpp:257] stop(): << stop()
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 00:18:da:0a:5c:74, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_PUBLIC, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -70, ble_adv: ??, flag: 6 ([LE General Discoverable Mode] [BR/EDR Not Supported] ), num_resps: 1, adv_data_len: 31, scan_rsp_len: 0
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 00:18:da:0a:5c:74, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_PUBLIC, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -68, ble_adv: ??, flag: 6 ([LE General Discoverable Mode] [BR/EDR Not Supported] ), num_resps: 1, adv_data_len: 31, scan_rsp_len: 0
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 00:18:da:0a:5c:74, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_PUBLIC, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -68, ble_adv: ??, flag: 6 ([LE General Discoverable Mode] [BR/EDR Not Supported] ), num_resps: 1, adv_data_len: 31, scan_rsp_len: 0
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_RESULT_EVT
[D][BLEUtils.cpp:1265] dumpGapEvent(): search_evt: ESP_GAP_SEARCH_INQ_RES_EVT, bda: 00:18:da:0a:5c:74, dev_type: ESP_BT_DEVICE_TYPE_BLE, ble_addr_type: BLE_ADDR_TYPE_PUBLIC, ble_evt_type: ESP_BLE_EVT_CONN_ADV, rssi: -65, ble_adv: ??, flag: 6 ([LE General Discoverable Mode] [BR/EDR Not Supported] ), num_resps: 1, adv_data_len: 31, scan_rsp_len: 0
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_SCAN_STOP_COMPLETE_EVT
[D][BLEUtils.cpp:1317] dumpGapEvent(): [status: 0]
Forming a connection to 00:18:da:0a:5c:74
[D][BLEDevice.cpp:54] createClient(): >> createClient
[D][BLEDevice.cpp:60] createClient(): << createClient
- Created client
[D][BLEClient.cpp:91] connect(): >> connect(00:18:da:0a:5c:74)
[D][BLEClient.cpp:74] clearServices(): >> clearServices
[D][BLEClient.cpp:81] clearServices(): << clearServices
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_REG_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_REG_EVT
[D][BLEUtils.cpp:1550] dumpGattClientEvent(): [status: ESP_GATT_OK, app_id: 0x0]
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_CONNECT_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_CONNECT_EVT
[D][BLEUtils.cpp:1407] dumpGattClientEvent(): [conn_id: 0, remote_bda: 00:18:da:0a:5c:74]
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_OPEN_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_OPEN_EVT
[D][BLEUtils.cpp:1503] dumpGattClientEvent(): [status: ESP_GATT_OK, conn_id: 0, remote_bda: 00:18:da:0a:5c:74, mtu: 23]
[D][BLEClient.cpp:123] connect(): << connect(), rc=1
- Connected to server
[D][BLEClient.cpp:322] getService(): >> getService: uuid: 6e400001-c352-11e5-953d-0002a5d5c51b
[D][BLEClient.cpp:358] getServices(): >> getServices
[D][BLEClient.cpp:74] clearServices(): >> clearServices
[D][BLEClient.cpp:81] clearServices(): << clearServices
[D][BLEUtils.cpp:1091] dumpGapEvent(): Received a GAP event: ESP_GAP_BLE_AUTH_CMPL_EVT
[D][BLEUtils.cpp:1160] dumpGapEvent(): [bd_addr: 00:18:da:0a:5c:74, key_present: 0, key: ***, key_type: 0, success: 1, fail_reason: 0, addr_type: ***, dev_type: ESP_BT_DEVICE_TYPE_BLE]
[I][BLEDevice.cpp:250] gapEventHandler(): ESP_GAP_BLE_AUTH_CMPL_EVT
[I][sketch_aug10a.ino:33] onAuthenticationComplete(): remote BD_ADDR:
[I][sketch_aug10a.ino:35] onAuthenticationComplete(): address type = 0
[I][sketch_aug10a.ino:37] onAuthenticationComplete(): pair status = success
[D][BLEClient.cpp:402] handleGAPEvent(): BLEClient ... handling GAP event!
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_SEARCH_RES_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_SEARCH_RES_EVT
[D][BLEUtils.cpp:1602] dumpGattClientEvent(): [conn_id: 0, start_handle: 1 0x01, end_handle: 9 0x09, srvc_id: uuid: 00001800-0000-1000-8000-00805f9b34fb, inst_id: 1
[D][BLERemoteService.cpp:29] BLERemoteService(): >> BLERemoteService()
[D][BLERemoteService.cpp:37] BLERemoteService(): << BLERemoteService()
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_SEARCH_RES_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_SEARCH_RES_EVT
[D][BLEUtils.cpp:1602] dumpGattClientEvent(): [conn_id: 0, start_handle: 10 0x0a, end_handle: 10 0x0a, srvc_id: uuid: 00001801-0000-1000-8000-00805f9b34fb, inst_id: 10
[D][BLERemoteService.cpp:29] BLERemoteService(): >> BLERemoteService()
[D][BLERemoteService.cpp:37] BLERemoteService(): << BLERemoteService()
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_SEARCH_RES_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_SEARCH_RES_EVT
[D][BLEUtils.cpp:1602] dumpGattClientEvent(): [conn_id: 0, start_handle: 11 0x0b, end_handle: 65535 0xffff, srvc_id: uuid: 6e400001-c352-11e5-953d-0002a5d5c51b, inst_id: 11
[D][BLERemoteService.cpp:29] BLERemoteService(): >> BLERemoteService()
[D][BLERemoteService.cpp:37] BLERemoteService(): << BLERemoteService()
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_SEARCH_CMPL_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_SEARCH_CMPL_EVT
[D][BLEUtils.cpp:1581] dumpGattClientEvent(): [status: ESP_GATT_OK, conn_id: 0]
[D][BLEClient.cpp:374] getServices(): << getServices
[D][BLEClient.cpp:335] getService(): << getService: found the service with uuid: 6e400001-c352-11e5-953d-0002a5d5c51b
- Found our service
[D][BLERemoteService.cpp:167] retrieveCharacteristics(): >> getCharacteristics() for service: 6e400001-c352-11e5-953d-0002a5d5c51b
[D][BLERemoteService.cpp:198] retrieveCharacteristics(): Found a characteristic: Handle: 13, UUID: 6e400002-c352-11e5-953d-0002a5d5c51b
[D][BLERemoteCharacteristic.cpp:41] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 13 0x13, uuid: 6e400002-c352-11e5-953d-0002a5d5c51b
[D][BLERemoteCharacteristic.cpp:284] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: 6e400002-c352-11e5-953d-0002a5d5c51b
[E][BLERemoteCharacteristic.cpp:308] retrieveDescriptors(): esp_ble_gattc_get_all_descr: ESP_GATT_NOT_FOUND
[D][BLERemoteCharacteristic.cpp:330] retrieveDescriptors(): << retrieveDescriptors(): Found 0 descriptors.
[D][BLERemoteCharacteristic.cpp:49] BLERemoteCharacteristic(): << BLERemoteCharacteristic
[D][BLERemoteService.cpp:198] retrieveCharacteristics(): Found a characteristic: Handle: 15, UUID: 6e400003-c352-11e5-953d-0002a5d5c51b
[D][BLERemoteCharacteristic.cpp:41] BLERemoteCharacteristic(): >> BLERemoteCharacteristic: handle: 15 0x15, uuid: 6e400003-c352-11e5-953d-0002a5d5c51b
[D][BLERemoteCharacteristic.cpp:284] retrieveDescriptors(): >> retrieveDescriptors() for characteristic: 6e400003-c352-11e5-953d-0002a5d5c51b
[E][BLERemoteCharacteristic.cpp:315] retrieveDescriptors():
[D][BLERemoteCharacteristic.cpp:316] retrieveDescriptors(): Found a descriptor: Handle: 16, UUID: 00002902-0000-1000-8000-00805f9b34fb
[D][BLERemoteCharacteristic.cpp:330] retrieveDescriptors(): << retrieveDescriptors(): Found 1 descriptors.
[D][BLERemoteCharacteristic.cpp:49] BLERemoteCharacteristic(): << BLERemoteCharacteristic
[D][BLERemoteService.cpp:214] retrieveCharacteristics(): << getCharacteristics()
- Found our characteristic
[D][BLERemoteCharacteristic.cpp:434] readValue(): >> readValue(): uuid: 6e400002-c352-11e5-953d-0002a5d5c51b, handle: 13 0x0d
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_READ_CHAR_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_READ_CHAR_EVT
[D][BLEUtils.cpp:1527] dumpGattClientEvent(): [status: ESP_GATT_INSUF_AUTHENTICATION, conn_id: 0, handle: 13 0x0d, value_len: 0]
[D][BLERemoteCharacteristic.cpp:462] readValue(): << readValue(): length: 0
The characteristic value was:
[D][BLERemoteCharacteristic.cpp:479] registerForNotify(): >> registerForNotify(): Characteristic: uuid: 6e400002-c352-11e5-953d-0002a5d5c51b, handle: 13 0xd, props: broadcast: 0, read: 0, write_nr: 1, write: 1, notify: 0, indicate: 0, auth: 0
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_REG_FOR_NOTIFY_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_REG_FOR_NOTIFY_EVT
[D][BLEUtils.cpp:1566] dumpGattClientEvent(): [status: ESP_GATT_OK, handle: 13 0x0d]
[D][BLERemoteCharacteristic.cpp:510] registerForNotify(): << registerForNotify()
We are now connected to the BLE Server.
Setting new characteristic value to "Time since boot: 2"
[D][BLERemoteCharacteristic.cpp:551] writeValue(): >> writeValue(), length: 18
[D][BLEDevice.cpp:143] gattClientEventHandler(): gattClientEventHandler [esp_gatt_if: 4] ... ESP_GATTC_WRITE_CHAR_EVT
[D][BLEUtils.cpp:1377] dumpGattClientEvent(): GATT Event: ESP_GATTC_WRITE_CHAR_EVT
[D][BLEUtils.cpp:1623] dumpGattClientEvent(): [status: ESP_GATT_INSUF_AUTHENTICATION, conn_id: 0, handle: 13 0x0d, offset: 0]
[D][BLERemoteCharacteristic.cpp:579] writeValue(): << writeValue
Setting new characteristic value to "Time since boot: 3"
[D][BLERemoteCharacteristic.cpp:551] writeValue(): >> writeValue(), length: 18
Thanks for your help
Hardware:
Board: ESP32 Dev Module Core Installation/update date: 2018-08-01 IDE name: Arduino IDE Flash Frequency: 40Mhz Upload Speed: 115200
Description:
Im using the "BLE_client_numeric_confirmation.ino" to connect to a BLE device using a six digit pin. The connection can be established, but as soon as the code runs
pRemoteCharacteristic = pRemoteService->getCharacteristic(charUUID);
the ESP32 reboots.Sketch:
Debug Messages: