how to make BLE devices to ask for authentication before connecting to IOS apps or android apps

I am using RTBTM01 BLE module, 

am not able avoid connecting ios app without pairing. my ble device automatically connects to both ios/android apps.

*) How to connect my BLE peripheral with ios app with pairing request only.

in our case it automatically connects with BLE peripheral without pairing.
our BLE's firmware already contains some default services, if i want to make encrypt
those serivices or characteristic in that services what are all the changes need to to be
done in app written on top of BLE stack.
i am using the example app given for Renesas SK board(project:an-r12an0056eu0100-synergy-ble-rl78-g1d)

*)How to set permission to those characteristics to avoid connecting and advertising without pairing.

 i have referred some links also,

*) some of them are saying to return error codes

if peripheral devices need pairing, peripheral should respond "Insufficient Authorization" or
"Insufficient Authentication" error code
if this is need to be done, how to do or which function should i use for returning above error?
*) otherwise please suggest me if there is any other way to avoid BLE connection without authentication?

 Thank You

  • Hi bharath,

    As far as I see, function scps_send_response in file rBLE/src/host/sample_profile/scp/scps.c is resposible for returning ATT error codes. In file rBLE/src/include/rble_api.h there are RBLE_ATT_ERR_INSUFF_AUTHEN and RBLE_ATT_ERR_INSUFF_AUTHOR definied.

    On there are many resources available regarding Bluetooth using RL78/G1D-based devices:

    Sample programs:
    and in general:

  • In reply to adboc:

    Hi adboc,
    Thank you for the suggestion, even me also sending RBLE_ATT_ERR_INSUFF_AUTHEN at same place you mentioned.
    i will follow the links and update you.

    Thank you.

    Bharath GK
  • In reply to adboc:

    Hi adboc,
    it works.
    after sending error codeRBLE_ATT_ERR_INSUFF_AUTHEN from scps_send_response() from BLE deivce ios app asks for pairing code.

    Thanks a lot....
  • In reply to adboc:

    Hi adboc,
    thank you for your suggestion.
    i have one more question related to bonding /pairing..
    i.e is it possible to not allow to connect phone apps/central devices without bonding/pairing request before the connection establisment?

    one level of security is maintaine at gatt level if somebody try to read/write attribute characteristics it prompts for pairing.

    so is it possible to not allow to connect to a phone or any aother central devices without pairing/bonding?

    any comments on this will be helpful for me.
    thank you.

    Bharath GK