NimBLE-Arduino
NimBLE-Arduino copied to clipboard
Issue with Client-Server Connection and Pairing Using NimBLE Library
I'm transitioning my BLE implementation from the BLEDevice library to the NimBLE library to optimize flash and RAM usage. Here's the issue I'm facing:
Previous Library (BLEDevice):
- Implemented both server and client functionality.
- Used
client->connect(remote_address);to connect to a remote device based on its Bluetooth address (remote_address). - Configured pairing and bonding as follows:
BLEDevice::setEncryptionLevel(ESP_BLE_SEC_ENCRYPT); BLEDevice::setSecurityCallbacks(new _Pairing()); pSecurity = new BLESecurity(); pSecurity->setAuthenticationMode(ESP_LE_AUTH_REQ_SC_BOND); pSecurity->setCapability(ESP_IO_CAP_IO); pSecurity->setRespEncryptionKey(ESP_BLE_ENC_KEY_MASK | ESP_BLE_ID_KEY_MASK); - Pairing and bonding worked, and the client could securely connect to the server.
NimBLE Implementation:
- Created both server and client functionality with similar logic.
- For the remote device address, I tried both
desc->peer_ota_addranddesc->peer_id_addras the client address inclient->connect(remote_address);.
Current Issues:
- No pairing prompt appears when I connect the server using a mobile phone.
- The client fails to connect to the server using the provided remote device addresses.
Looking for guidance on how to resolve these issues in NimBLE, especially for establishing pairing and secure client-server connections.