3 Replies Latest reply on Apr 18, 2018 9:37 AM by epr_1639216

    How to know if the connection is paired.


      I would like to know if is there any function to ask if a connection is paired (encrypted) or not ?



        • 1. Re: How to know if the connection is paired.


          If you attempt to read/write an attribute that requires encryption/authentication, then it will throw an error for insufficient encryption/authentication if it is not encrypted/authenticated.

          See here: http://origin-www.cypress.com/forum/psoc-4-ble/ble-pairing-issue

          Otherwise, you should be able to do the CyBle_GapAuthReq() function call in CYBLE_EVT_GAP_DEVICE_CONNECTED callback event to immediately encrypt upon device connection.

          1 of 1 people found this helpful
          • 2. Re: How to know if the connection is paired.


            Yes, is wich I do, read/write an attribute that requires encryption, but I wonder myself if there ir a function that returns connection state (true/false encrytion).

            I also know that exist CYBLE_EVT_GAP_ENCRYPT_CHANGE event. But I suppous that it is produced when encryption state changes, is not it ?



            • 3. Re: How to know if the connection is paired.

              There are more events that occur involving encryption:

              When you run the CyBle_GapAuthReq() function (as a client) then you will get either a success or failure event:



              and you will get the CYBLE_EVT_GAP_AUTH_REQ event if the remote side of the connection requests authentication/encryption.

              The event: CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO might have the "encryption enabled/disabled" flag you are looking for, but from what I can see, you will probably need to track the state of the encryption based upon the events that occur.

              By default the device will not be encrypted when it connects, so if you have a state variable with default false when you connect to a device, and then change it based on the CYBLE_EVT_GAP_ENCRYPT_CHANGE event arguments, then you can accurately follow the encryption of the connection to ensure no "plain data" communication occurs.