No event generat after calling CyBle_GapcConnectDevice

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

cross mob
Anonymous
Not applicable

Hi.

I encountered the problem describe like the title. I use the PSoC example name "Central and Peripheral" and call the function "CyBle_GapcConnectDevice" which return "CYBLE_ERROR_OK". But both "CYBLE_EVT_GATT_CONNECT_IND" and "CYBLE_EVT_GAP_DEVICE_CONNECTED" never show up but "CYBLE_EVT_TIMEOUT" does after 30 seconds.

I have already make sure that the device able to be connected use the Cypress dongle and the program "CySmart".

What may be the possible faults ?  THANKS

0 Likes
3 Replies
GyanC_36
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

Hello,

   Are you suing the default project available in Github? (PSoC-4-BLE/100_Projects_in_100_Days/Day012_Central_Peripheral at master · cypresssemiconductorco/PSo... ) or have done any modifications ?

I tested the default project and it works fine. Please make sure that before sending the connection request (pressing 'c') , you select your peripheral device (pressing 'z').

If you have done any modifications in your project, please share the project.

-Gyan

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

Hello Gyan Chand

Thanks for your reply. I had tried the original example from the github but got the following log.

------------------------------------------------------------------------------------------------------------------------------------

BLE STACK ON:

s

CyBle_GapcStartScan API Success

Started to Scan

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Non connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 28be8d63e2f0

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 761335257f31

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:SCAN_RSP

    peerAddrType: RANDOM

    peerBdAddr: 761335257f31

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Non connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 2f1a0d5edb0d

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Non connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: da3497b790ac

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:SCAN_RSP

    peerAddrType: RANDOM

    peerBdAddr: da3497b790ac

Stopped Scanning

z

Device 0: 28be8d63e2f0

Device 1: 761335257f31

Device 2: 2f1a0d5edb0d

Device 3: da3497b790ac

Device 4: 448878952d63

Device 5: 0571ce529896

Device 6: 67fc8f06992d

Device 7: 413f235bbfc3

Select Device: Wrong digit

send 'c' to connect to the selected device

z3

Device 0: 28be8d63e2f0

Device 1: 761335257f31

Device 2: 2f1a0d5edb0d

Device 3: da3497b790ac                    <===   This is the target I want to connect.(a Bluetooth mouse, and it is in pairing mode)

Device 4: 448878952d63

Device 5: 0571ce529896

Device 6: 67fc8f06992d

Device 7: 413f235bbfc3

Select Device:3

send 'c' to connect to the selected device

c

Device disconnected

---------------------------------------------------------------------------------------------------------------------------------------

Then I modified the "main.c" and try to get the  "CYBLE_EVT_GAP_DEVICE_CONNECTED" event.

I found that original "main.c" only call function "CyBle_GapcConnectDevice" in case "CYBLE_EVT_GAPC_SCAN_START_STOP".

But before get "CYBLE_EVT_GAPC_SCAN_START_STOP" event, my central should never know which peripheral device to connect.

Then I use the function "CyBle_GapcConnectDevice" in main.c  while loop "case c".

And I got this log

-------------------------------------------------------------------------------------------------------------------------------------------------

main

CyBle_EventHandler eventCode: 0x1

BLE STACK ON:

s

CyBle_GapcStartScan API Success

CyBle_EventHandler eventCode: 0x2b

CYBLE_EVT_GAPC_SCAN_START_STOP (scanning started or stopped)

Started to Scan

ConnectCommand != 1CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Non connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 206d03af47c0

CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Non connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 0d76bf7e1125

CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 73047a5a6c6b

CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:SCAN_RSP

    peerAddrType: RANDOM

    peerBdAddr: 73047a5a6c6b

CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Non connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: 022fa68b4c35

CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:Connectable undirected advertising

    peerAddrType: RANDOM

    peerBdAddr: da3497b790ac

CyBle_EventHandler eventCode: 0x20

CYBLE_EVT_GAPC_SCAN_PROGRESS_RESULT:

eventType:SCAN_RSP

    peerAddrType: RANDOM

    peerBdAddr: da3497b790ac

CyBle_EventHandler eventCode: 0x2

out of StackEventHandler case range: 2

CyBle_EventHandler eventCode: 0x2b

CYBLE_EVT_GAPC_SCAN_START_STOP (scanning started or stopped)

Stopped Scanning

z4

case 'z':

Device 0: 206d03af47c0

Device 1: 0d76bf7e1125

Device 2: 73047a5a6c6b

Device 3: 022fa68b4c35

Device 4: da3497b790ac

Device 5: 0ae197d43d31

Device 6: 784d3db31727

Device 7: 1a8ac06c2cd5

Select Device:Right digit: 4

send 'c' to connect to the selected device

c

case 'c'

ConnectCommand = 1

CyBle_GapcConnectDevice 4: da3497b790ac

Connected as Master in while loop

CyBle_EventHandler eventCode: 0x2        <===== Time out event

CyBle_EventHandler eventCode: 0x28      <===== Disconnected event

----------------------------------------------------------------------------------------------------------------------------------------------

What may be the possible faults ?  THANKS

0 Likes

The code looks fine. Did you try with a different BLE device ?

What is the BLE version of your Mouse ?

-Gyan

0 Likes