Unauthenticated pairing issue

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

cross mob
shdhc_2578096
Level 2
Level 2
First like given

Hi,

I am setting BLE device as a GAP peripheral and trying to pair with Cysmart app.

Pairing is not working.

security setting are : mode 1 | unauthenticated pairing with encryption.

I/O Capabilities  - none

bonding requirement -Bonding

Encryption key size - 7 bytes.

call back generating following event -

case CYBLE_EVT_STACK_ON: CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:

following event are generating when start pairing process from cysmart app :

case CYBLE_EVT_GATT_CONNECT_IND:

case CYBLE_EVT_GAP_DEVICE_CONNECTED:

case CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO:

case CYBLE_EVT_GAP_AUTH_REQ: res = CyBle_GappAuthReqReply(cyBle_connHandle.bdHandle, &cyBle_authInfo);   - error - CYBLE_ERROR_INVALID_OPERATION

case CYBLE_EVT_GAP_AUTH_FAILED:  error - CYBLE_GAP_AUTH_ERROR_LINK_DISCONNECTED ;

case CYBLE_EVT_GATT_DISCONNECT_IND;

why CyBle_GappAuthReqReply() is invalid operation?

0 Likes
1 Solution

Hi Ganesh,

I added code to store bonding data.

The Configuration In my project are:

security setting are : mode 1 | unauthenticated pairing with encryption.

I/O Capabilities  - none

bonding requirement -Bonding

Encryption key size - 16 bytes.

based on those configuration: I am getting following event.

event 0x41

event 0x27 Gap_Device Connected

event 0x33 CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO

event 0x21 CYBLE_EVT_GAP_AUTH_REQ

event 0x42 CYBLE_EVT_GATT_DISCONNECT

event 0x25 CYBLE_EVT_GAP_AUTH_FAILED, reason: LINK_DISCONNECTED

event 0x28

The event you are seeing and attached in last comments are not for my projects configuration.I think your configurations are different.

How are you getting 0x2a , 0x43, 0x57 events?

View solution in original post

0 Likes
10 Replies
VenkataD_41
Moderator
Moderator
Moderator
750 replies posted 500 replies posted 250 solutions authored

Hi,

Can you please attach your project here? We will check it at our side and will respond to you.

Thanks

Ganesh

0 Likes

Hi,

I am bit struggling here about how to attach my project.

I am not able to see option for attachment.

could you please tell me How I can attach the project?

0 Likes

Hi,

Once you log in, please click on the "Use advanced editor" at right side top corner of the post to get the options to attach at the right side bottom of the post.

Thanks

Ganesh

0 Likes
lock attach
Attachments are accessible only for community members.

Hi,

Find Attached my project.

I have only kept Bluetooth connectivity part in my project at this moment.

This is the event I am getting during the pairing process on UART communication.

event 0x41

event 0x27 Gap_Device Connected

event 0x33 CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO

event 0x21 CYBLE_EVT_GAP_AUTH_REQ error CODE :2

event 0x42 CYBLE_EVT_GATT_DISCONNECT

event 0x25 CYBLE_EVT_GAP_AUTH_FAILED, reason: LINK_DISCONNECTED

event 0x28

event 0x28

event 0x26

0 Likes

Hi,

Did you get a chance to look into project?

are you still working on this issue?

Thanks,

Shilpa

0 Likes

Hi Shilpa,

The reason for getting 0x02 for the API CyBle_GappAuthReqReply( ) is beause of calling the API more than once.

Whenever the event CYBLE_EVT_GAP_AUTH_REQ comes the BLE_1_eventhandler.c implements the CyBle_GappAuthReqReply( ) API call. The user do not have to call his API again in the application layer.

You can check this in BLE_1_eventhandler.c under that CYBLE_EVT_GAP_AUTH_REQ event in he generated source files.

Thanks

Ganesh

0 Likes

Hi Ganesh,

As per suggestion, I removed CyBle_GappAuthReqReply() function from call back.

Then I don't get error code 2.

But somehow I am getting following event.

event 0x41

event 0x27 Gap_Device Connected

event 0x33 CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO

event 0x21 CYBLE_EVT_GAP_AUTH_REQ

event 0x42 CYBLE_EVT_GATT_DISCONNECT

event 0x25 CYBLE_EVT_GAP_AUTH_FAILED, reason: LINK_DISCONNECTED

event 0x28

event 0x28

event 0x26

How do I know what is the reason of GATT_DISCONNECT?

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Shilpa,

In your project, you have selected the security option as "Bonding" but you have not stored the bonding information to the flash. Therefore after every reset of the device the bonding information has lost and you are getting the event CYBLE_EVT_GAP_AUTH_FAILED and therefore the central is sending the Authentication request again.

A my side I am not getting the CYBLE_EVT_GATT_DISCONNECT event unless I disconnect manually.  Please find the attached image.

Please check the Day15_Bonding code example to implement the bonding in your code example.

PSoC-4-BLE/100_Projects_in_100_Days at master · cypresssemiconductorco/PSoC-4-BLE · GitHub

Please check the reason for Authentication failure using the event Param of the event CYBLE_EVT_GAP_AUTH_FAILED.

Thanks

Ganesh

Hi Ganesh,

I added code to store bonding data.

The Configuration In my project are:

security setting are : mode 1 | unauthenticated pairing with encryption.

I/O Capabilities  - none

bonding requirement -Bonding

Encryption key size - 16 bytes.

based on those configuration: I am getting following event.

event 0x41

event 0x27 Gap_Device Connected

event 0x33 CYBLE_EVT_GAP_SMP_NEGOTIATED_AUTH_INFO

event 0x21 CYBLE_EVT_GAP_AUTH_REQ

event 0x42 CYBLE_EVT_GATT_DISCONNECT

event 0x25 CYBLE_EVT_GAP_AUTH_FAILED, reason: LINK_DISCONNECTED

event 0x28

The event you are seeing and attached in last comments are not for my projects configuration.I think your configurations are different.

How are you getting 0x2a , 0x43, 0x57 events?

0 Likes

Hi,

I found the problem.Now Bluetooth is started pairing.

Thank you for help.

0 Likes