NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

Issue with Client-Server Connection and Pairing Using NimBLE Library

Open nitin-jethava opened this issue 11 months ago • 3 comments

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_addr and desc->peer_id_addr as the client address in client->connect(remote_address);.

Current Issues:

  1. No pairing prompt appears when I connect the server using a mobile phone.
  2. 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.

nitin-jethava avatar Dec 04 '24 06:12 nitin-jethava