PSOC 4 BLE Pairing scenario

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

cross mob
manusharian
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello,

   

 

   

Can some one explain to me how exactly can I create the following behavior?

   

I want that any client that wants to connect to a peripheral, server device to be asked a password provided in advance and only when the correct password is given to connect, see the profile,etc.  Next I want that the client to be able to make a pair action to the device  and every time the device is near to connect automatically to it. I know that some parts of this behavior should be accomplish by the client like the automatically connection to the device but I am aware that something should also be done in peripheral which is a PSOC 4.

   

I already go through the examples like privicy(017), oob pairing(032) and bonding (015) but somehow I cannot fully understand them to implement my scenario. Also it would be great if you can also explain the state(event) in which a particular action should take place. For example I used  CyBle_GapFixAuthPassKey (1, 123456); in CYBLE_EVT_STACK_ON and I was able to pair in CYSmart with this code but I am not sure this is all. My Ble is set as Mode 1 security Authenticated pairing with encryption and I/O capabilities KeyBoard and Display(even if my device doesn't have such, I personally am not sure why are those used) and Bonding.

   

Thank you!

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

   

Can you confirm if you need a Fixed Passkey so that server can be connected with a predefined key. If yes, I am attaching a simple example for this.

   

Thanks,

   

Hima

View solution in original post

0 Likes
5 Replies
lock attach
Attachments are accessible only for community members.
himam_31
Employee
Employee
50 likes received 25 likes received 10 likes received

Hello,

   

Can you confirm if you need a Fixed Passkey so that server can be connected with a predefined key. If yes, I am attaching a simple example for this.

   

Thanks,

   

Hima

0 Likes
manusharian
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hello Hima,

   

Yes we want the password to be a fixed one and if possible should prevent the connection until a pairing is done. Once the pairing is initiated we would like the user to introduce the pass or maybe the device will have a NFC tag and the phone should take it from the NFC. Afterwards, we want that the user to be able to change this password if wanted in case it will unpair the device. I think this is all  because after this pairing the phone can automatically connect if it finds the device near. 

0 Likes

Update: I have used the example provided but still have some questions. If for example I hit connect the request was received and the CySmart ask to hit pair or not. If I hit not then the connection is still established so how can I achieve this?

0 Likes
Anonymous
Not applicable

Under CYBLE_EVT_GAP_AUTH_FAILED in the StackEventHandler(), you can add this line:

   

CyBle_GapDisconnect(cyBle_connHandle.bdHandle);

   

This will cause the peripheral to disconnect if the authentication fails. If you select press 'No' when pairing is requested, the GAP_AUTH_FAILED event will be raised at the peripheral after timeout(30 seconds). So, after you make the above changes, you will see that the device will get disconnected after 30 seconds if you select 'no' during the pairing request.

Hello yssu,

   

Thanks for the clarifications! I observed that behavior but did not know why. In the future I will think to a better privacy.

0 Likes