GAP role “Peripheral and Central” NOT Connecting

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

cross mob
Anonymous
Not applicable

Hello Cypress PRoC BLE World:

   

 

   

I have a Cypress PRoC BLE configured with a GAP role of: “Peripheral and Central”.

   

The device starts scanning when calling CyBle_GapcStartScan() and stops scanning when calling CyBle_GapcStopScan() just fine.

   

However, it will not connect when calling CyBle_GapcConnectDevice(), which apparently uses the “Component Customizer GUI” settings.

   

It will also not connect when calling CyBle_GapcInitConnection(), which apparently uses the given settings instead of the “Component Customizer GUI” settings, before calling CyBle_GapcConnectDevice().

   

 

   

CyBle_GapcConnectDevice() and CyBle_GapcInitConnection() are both returning CYBLE_ERROR_INVALID_PARAMETER.

   

CyBle_GapcConnectDevice() resides in BLE.c and is declared in BLE.h.

   

However, CyBle_GapcInitConnection(), which is called by CyBle_GapcConnectDevice(), is not declared in BLE_StackGap.h, due to “#ifdef GAP_CENTRAL” not being defined, and that is evidently the problem.

   

 

   

QUESTION:

   

Why is “GAP_CENTRAL” not defined (to employ CyBle_GapcInitConnection()) but CYBLE_GAP_ROLE_CENTRAL is defined (to employ CyBle_GapcConnectDevice(), which calls CyBle_GapcInitConnection()) for a GAP role of: “Peripheral and Central”?

   

 

   

Thank you,

   

Tim

0 Likes
11 Replies
Anonymous
Not applicable

Tim,

   

 

   

Can you post your project for reference?

0 Likes
Anonymous
Not applicable

Hello Roit:

   

How do I post a project?

   

Thank you,

   

Tim

0 Likes
Anonymous
Not applicable

Tim,

   

I meant attach the project here. Sorry if it was misleading.

   

While replying to this post, you should be seeing an option to 'Add Attachments' below the box where you add text. You can attach the project as a ZIP file.

0 Likes
Anonymous
Not applicable

Hello Roit:

   

Which files should I include in the zip file?

   

Thanks,

   

Tim

0 Likes
Anonymous
Not applicable

Roit:

   

 

   

I created a smaller project for easier review and it DOES connect but the header files are the same, in regard to the defines, in both projects.

   

I will investigate to determine why the line of code in BLE.c below in CyBle_GapcConnectDevice():

   

   apiResult = CyBle_GapcInitConnection(&cyBle_connectionParameters);

   

returns CYBLE_ERROR_OK in the smaller project but returns CYBLE_ERROR_INVALID_PARAMETER in the larger project even though the function CyBle_GapcInitConnection() in CyBle_GapcConnectDevice() is not declared in BLE_StackGap.h (because it is #ifdefed out) for both projects.

   

 

   

Thanks again,

   

Tim

0 Likes
Anonymous
Not applicable

Tim,

   

 

   

I feel that there should be no implicit changes to the BLE component generated files if the BLE component settings of the two projects (smaller and larger) are similar.

   

If the CyBle_GapcInitConnection() is returning a CYBLE_ERROR_INVALID_PARAMETER, then please check the parameters that are being set for this API. It is possible that the device address values are invalid.

   

Can you also check the value of CyBle_GetState() in those two projects?

0 Likes
Anonymous
Not applicable

Hello Roit:

   

The code that passes the parameters to CyBle_GapcConnectDevice() is identical in the two projects.
The code below is implemented in both projects to print the value returned by CyBle_GetState() before and after the value for CyBle_GapcConnectDevice(Macs):

   

   sprintf(string, "State=%d\r\n", CyBle_GetState());
   UART_UartPutString(string);
   i = CyBle_GapcConnectDevice(Macs);
   sprintf(string, "Connect=%d\r\n", i);
   UART_UartPutString(string);
   if (i == CYBLE_ERROR_OK)
   {
      UART_UartPutString("AOK\r\n");
   }
   else
   {
      UART_UartPutString("ERR\r\n");
   }
   sprintf(string, "State=%d\r\n", CyBle_GetState());
   UART_UartPutString(string);

   

The printed results follow for the smaller project that DOES connect:
State=6
Connect=0
AOK
State=5

   

The printed results follow for the larger project that DOES NOT connect:
State=6
Connect=1
ERR
State=6

   

Thank you,
Tim

0 Likes
Anonymous
Not applicable

Tim,

   

 

   

I guess the second project is already in some state or BLE setting that does not allow the GapcConnectDevice to pass through.

   

I would suggest creating a technical case at http://www.cypress.com/support and posting both your projects for reference.

0 Likes
Anonymous
Not applicable

Hello Roit:

   

I discovered that the issue is that the Configure BLE, GAP Settings, Slave latency, Connection supervision timeout (ms) must be checked and set to 10000 ms.

   

What is the Slave latency, Connection supervision timeout and if it is required why is there an option to not use it which prevents a connection?

   

Thanks much,

   

Tim

0 Likes
Anonymous
Not applicable

Tim,

   

Slave latency and Connection timeout are BLE connection parameters (along with connection interval) that are negotiated between a Central and Peripheral device every time a connection is made.

   

Connection interval: It is the interval at which both Central and Peripheral device will communicate with each other, irrespective of whether there is actual data or not.

   

Connection Supervision Timeout: It is the period for which if there are no consecutive connection events, the connection is considered lost.

   

Slave Latency: It is the number of intervals that a Peripheral can ignore the connection event before it must communicate with the Central device. It is a method to provide the flexibility of to peripheral device to conserve more power.

   

These are the values that are always communicated at a connection, so they are always required. What can be changed are their values. If one of the devices does not accept the values set by other, then the connection can fail.

   

 

   

Do note that BLE spec mandates a minimum and maximum values for each parameter, for example, minimum Connection interval that can be set is 7.5 ms. Similarly for Slave Latency and Connection timeout.

   

If you are setting values in BLE component that violates any of the spec, then the component will issue a warning and help you to fix it.

0 Likes
Anonymous
Not applicable

Hello Roit:

   

Thank you for the explanations and definitions.

   

Tim

0 Likes