h2zero / NimBLE-Arduino

A fork of the NimBLE library structured for compilation with Arduino, for use with ESP32, nRF5x.
https://h2zero.github.io/NimBLE-Arduino/
Apache License 2.0
700 stars 145 forks source link

How to require a passkey for Notify? #630

Closed trullock closed 8 months ago

trullock commented 8 months ago

I have a server which sends out notifications.

I want only trusted clients to be able to connect (mac unknown) so wish to protect the connection with a passkey/pin.

I can't get nrfConnect to ask for a passkey without adding READ_ENC to my characteristic.

Does adding READ_ENC imply that clients can Read?

Am I misunderstanding the API, is this a missing feature, or am I not understanding the BT standard. Must you be able to read in order to notify?

Thanks

h2zero commented 8 months ago

To require all connections to be secure you can call NimBLEDevice::startSecurity in the onConnect callback. Something like this : https://github.com/h2zero/NimBLE-Arduino/issues/92#issuecomment-720788573

trullock commented 8 months ago

Great, thanks for your help