3 Replies Latest reply on Apr 18, 2018 9:37 AM by e.pratt_1639216

    How to know if the connection is paired.

    asier_1604701

      Hi,

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

      Thanks,

      Asier.

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

          Hello,

          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.
            asier_1604701

            Hello,

            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 ?

            Regards,

            Asier.

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

              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:

              CYBLE_EVT_GAP_AUTH_FAILED

              CYBLE_EVT_GAP_AUTH_COMPLETE

              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.