Rohit, thanx a lot for this example! I try to implement this in my solution this way:
I add securityManager setup for BLE and security callbacks:
ble.securityManager().init(enableBonding, requireMITM, SecurityManager::IO_CAPS_DISPLAY_ONLY);
ble.securityManager().onPasskeyDisplay(passkeyDisplayCallback);
ble.securityManager().onSecuritySetupCompleted(securitySetupCompletedCallback);
Then i add security for my Characteristics:
some1Characteristic.requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM);
some2Characteristic.requireSecurity(SecurityManager::SECURITY_MODE_ENCRYPTION_WITH_MITM);
Everything works fine, while i try to write any to my some1Characteristic a have to pass security check once, and i got the passkey on onPasskeyDisplay Callback:
void passkeyDisplayCallback(Gap::Handle_t handle, const SecurityManager::Passkey_t passkey)
{
serial.printf("Input passKey: ");
for (unsigned i = 0; i < Gap::ADDR_LEN; i++) {
serial.printf("%c ", passkey[i]);
}
serial.printf("\r\n");
}
This process for devices with display, but when i try to put my own passkey - i have a problems:
uint8_t pass[6] = {0x01, 0x01, 0x01, 0x01, 0x01, 0x01};
ble.securityManager().init(enableBonding, requireMITM, SecurityManager::IO_CAPS_DISPLAY_ONLY, pass);
So, how i can implement my own pass?
A already ask a question about it here(https://developer.mbed.org/questions/54121/How-to-secure-ReadWriteGattCharacteristi/) , but nobody have any ideas on this.
May somebody have any experience deeper than demo examples?