Cysmart API, looking to bond to a device using a passkey.

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
TiKr_3309711
Level 1
Level 1

I can connect to the device and start the .pair process. I'm just having trouble getting to a point to input the passkey. Any examples would be great. Thank you

0 Likes
1 Solution

Hello Tim,

        The description of BLE_ERROR_GAP_AUTH_PASSKEY_ENTRY_FAILED is "User input of passkey failed, for example, the user cancelled the operation"

This error code may occur when the peer device sends a security request to Mobile App for initiating the pairing procedure and if the peer device sends a security request ( Basically, calling CyBle_AuthReq() API ), first we need to accept the security request and then only pairing procedure will start.

In this case first you might need to update the enum CyPairingResponseCode  to ACCEPT to start the pairing procedure. Please try it.

-Gyan

View solution in original post

0 Likes
12 Replies
SayaniS_66
Moderator
Moderator
Moderator
10 likes received First like received

Hello,

Please go through the example linked below which implements bonding using passkey entry.

https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day015_Bon...

Thanks,

Sayani.

0 Likes

Not exactly what I'm looking for, I'm trying to bond to a device using the Cysmart Dongle API in C# to enter a passkey and bond to the device. I've gone through the reference guide and able to connect to the device, but I'm struggling to progress from there to enter the passkey to bond to the device. Any examples of that on the Cysmart API side would be greatly appreciated. Thanks

0 Likes

Hi,

Are u using the CyPairSettings() API and setting the parameters to their appropriate values. Depending on the IO capabilities and the MITM, the bonding process will be done. Please check these parameters in your code.

Thanks,

Sayani.

0 Likes

Yes I am using CyPairSettings, I am trying to get the Passkey function to work, since the device requires a passkey to bond to the device. Looking for possibly some example code on that process since the API reference guide isn't very clear on how that function is supposed to work.

0 Likes

Hello,

    For the passkey pairing procedure , you need to set the security level as AUTHENTICATED_PAIRING_WITH_ENCRYPTION. If you want the devices to be bond you also need to 'set' the bonding flag.

With above said , the API will look like below.

CyPairSettings(CySecurityLevel.AUTHENTICATED_PAIRING_WITH_ENCRYPTION, true, 16, CyPairingProperties.None);

Also, you need appropriate IO capabilities to be be set to perform the passkey pairing procedure. If the peer device has display capability (to display the passkey) , you should have keyboard  capability to enter the passkey.

You can set/get your device IO capability by using the c# API  SetDeviceIoCapabilities (CyBleDeviceIoCapabilities ioCapability) /GetDeviceIoCapabilities (CyBleDeviceIoCapabilities ioCapability) respectively. ( Handle the callback function)

The bonding flag should be 'set' in both of the BLE devices ( central and peripheral ) to store the bonding data.

We do not have any sample examples to demonstrate all of the concepts but a simple example project with few features can be found from below link.

                                 CySmart API C# example

-Gyan

0 Likes

That's been helpful, as I've made some progress now I'm getting from the "OnPairingCompleted" BLE_ERROR_GAP_AUTH_INSUFFICIENT_ENCRYPTION_KEY_SIZE. Any idea's on what I could be doing wrong here? Thanks

0 Likes

So it looks like I've made quite a bit of progress into bonding, the question I have now is I'm getting a response.Response = REJECT for my passkey. I am currently doing this.

public override void OnPasskeyEntryRequest(CyPasskeyEntryResponse response)

{

     response.Passkey = 000000;

          base.OnPasskeyEntryRequest(response);

}

Is there something else I am missing or doing incorrectly?

gyan

0 Likes

Hello Tim Krous,

   Can you get the error code for passkey REJECT ? All the error code definitions are given in the CySmart API reference guide (http://www.cypress.com/file/232791/download ) ?

Also , which peer peripheral device are you using to connect with your App ? Could you share the peripheral project to confirm if the security settings are configured well in your project?

-Gyan

0 Likes

I am getting an error for the passkey reject, the Cystatus comes back as BLE_OK. I have verified that it works in the Cysmart Windows Application and successfully bonds after it prompts for the passcode. Is there another call or callback I need to handle after the ONPasskeyEntryRequest?

gyan

0 Likes

So I solved one issue that I was having, it looks like you have to call the SendPassKey inside that OnpasskeyEntryResponse in which i posted above. No i'm getting the CyStatus error BLE_ERROR_GAP_AUTH_PASSKEY_ENTRY_FAILED.

Any idea's on my next step? Is there another callback that I need to handle or something else i need to send out? Thanks

gyan

0 Likes

Hello Tim,

        The description of BLE_ERROR_GAP_AUTH_PASSKEY_ENTRY_FAILED is "User input of passkey failed, for example, the user cancelled the operation"

This error code may occur when the peer device sends a security request to Mobile App for initiating the pairing procedure and if the peer device sends a security request ( Basically, calling CyBle_AuthReq() API ), first we need to accept the security request and then only pairing procedure will start.

In this case first you might need to update the enum CyPairingResponseCode  to ACCEPT to start the pairing procedure. Please try it.

-Gyan

0 Likes

setting the passkey.passkey and passkey.Cypariing Response code = Accept worked and allowed me to bond to the device. Thank you.

gyan

0 Likes