This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Hide Characteristics values before Bound

Hello,

I am going my project with NRG51822 in SDK 11. I build a android app that can connect to my device and access vendor specific service.

My device dedicates one button for BLE connection, and it will trigger limited advertising on button pressed. Android could connect to device in 30 secs after BLE button pressed, and it will perform bond procedure after "Just Works" pairing.

I want characteristics that in vendor specific service can not be accessible before bound, what should I do? Does any example in SDK 11 has the similar procedure that I could refer to?

Regards,

code_hard

  • Interesting question.

    AFIK. Characteristic(s) details are transferred after the connection has been made.

    The advertising packet just contains the service UUID number, and nothing about the characteristics.

  • So the Android device will do service discovery and then bond if it receives an att error: insufficient authentication (unless the slave sends and SMP request prior to that). I suggest you add the vendor specific service after bonding and send a service changed indication to android to trigger a new service discovery (works as long as the android phone supports service changed indications). Note it's possible to add services, but not remove them. That is you wil have to reinitialize the SD to remove services, but this should only take about 1 ms.

  • Dear run_ar,

    Thank you for reply, allow me to repeat your suggestion on list.

    1. Android pair device with "Just Works". Android perform service discover procedure and can not discover vendor service at that time.
    2. Android perform bond procedure successful, then device add vendor service and send SCCD indication to android.
    3. Android perform service discover procedure again and get updated service list. Now Android could manipulate vendor service.
    4. On Disconnected event occured, device reinitialize SoftDevice module and return to un-updated service and wait for next pair.

    I don't want to misunderstand what you mean.

    Regards,

    code_hard

  • Do you want to hide a service or a Characteristic?

    They are not the same.

    Unless you are doing some sort of authenticated pairing, I'm not sure how this provides any more security.

    You initially said that your device will not advertise until the button is pressed, and hence nothing will be able to connect to the device prior to the button press as the Central device (e.g. Android phone), won't know what to connect to as it will not have the mac address of the Peripheral device.

    When you press the button, you have to hope that your Android application detects the advertising before any other device which may be listening, otherwise the other device will connect first and go through the same process as your Android app and prevent your Android app from connecting.

    Because of the way BLE frequency hops, the Android app is not guaranteed to receive the first transmitted advertisement.

  • @code_hard
    Yes, that sounds about right. But not sure about 4. I guess you might also want to be able to reconnect to the previously known device. And as Roger Clark says you won't know exactly which device is connecting to you when using just works, so you might want to consider using authentication (just works is unauthenticated).

Related