- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Cannot explain why my android test phones stay connected, but the apples ones timeout, with this message? Takes approximately 30 seconds, but does it consistently. Connect, and in ~30 seconds it disconnects, no explanation. Timeout EVT never fires.
BLE Stack Here:
/* Call back that gets called at any time, and point the BLE block to that call back*/
void Custom_Event_Handler(uint32 event, void * eventparam) /* event is the read or write, eventparam point to event data */
{
CYBLE_GATTS_WRITE_REQ_PARAM_T *write_request_param; /* this is local variable structure where all the data from the write request event we be stored, this cast makes them the same structure */
switch(event)
{
case CYBLE_EVT_STACK_ON:
/* Start Advertisement and enter Discoverable mode*/
LedColor(CYAN);
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
break;
case CYBLE_EVT_GATTS_WRITE_REQ: /* this is the event where a value is written to the gatt from the phone */
write_request_param = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventparam; /* this is where the entire data structure of the BLE packet is stored, value, size length, descriptor, limits, etc */
if(CYBLE_PWM1_PWM1_VALUE_CHAR_HANDLE == write_request_param->handleValPair.attrHandle) /* the recieved event is compared to the assigned event value in the definition */
{
BLE_PWM_1 = write_request_param->handleValPair.value.val[0]; /* the PWM value is loaded with the actual value*/
/* Update control handle with new values */
PWM_1.attrHandle = CYBLE_PWM1_PWM1_VALUE_CHAR_HANDLE;
PWM_1.value.val = &BLE_PWM_1;
PWM_1.value.len = PWM_1_CHAR_DATA_LEN;
if(PWM_1_ReadCompare() != BLE_PWM_1)
{ delta_PWM_1 = 1;
PWM_1_WriteCompare(BLE_PWM_1);
}
/* Send updated control handle as attribute for read by central device, so that
* Client reads the new data */
CyBle_GattsWriteAttributeValue(&PWM_1,FALSE,&connHandle,FALSE);
}
if(CYBLE_PWM2_PWM2_VALUE_CHAR_HANDLE == write_request_param->handleValPair.attrHandle) /* the recieved event is compared to the assigned event value in the definition */
{
BLE_PWM_2 = write_request_param->handleValPair.value.val[0]; /* the PWM value is loaded with the actual value*/
/* Update control handle with new values */
PWM_2.attrHandle = CYBLE_PWM2_PWM2_VALUE_CHAR_HANDLE;
PWM_2.value.val = &BLE_PWM_2;
PWM_2.value.len = PWM_2_CHAR_DATA_LEN;
if(PWM_2_ReadCompare() != BLE_PWM_2)
{
delta_PWM_2 = 1;
PWM_2_WriteCompare(BLE_PWM_2);
}
/* Send updated handle as attribute for read by central device, so that
* Client reads the new data */
CyBle_GattsWriteAttributeValue(&PWM_2,FALSE,&connHandle,FALSE);
}
if(CYBLE_SWITCH1_SWITCH1_VALUE_CHAR_HANDLE == write_request_param->handleValPair.attrHandle) /* the recieved event is compared to the assigned event value in the definition */
{
BLE_Switch1_Binary = write_request_param->handleValPair.value.val[0]; /* the PWM value is loaded with the actual value*/
/* Update control handle with new values */
SW_1.attrHandle = CYBLE_SWITCH1_SWITCH1_VALUE_CHAR_HANDLE;
SW_1.value.val = &BLE_Switch1_Binary;
SW_1.value.len = SW_1_CHAR_DATA_LEN;
curr_BLE_switch1_status = BLE_Switch1_Binary;
delta_BLE_switch1 = curr_BLE_switch1_status ^ prev_BLE_switch1_status;
prev_BLE_switch1_status = curr_BLE_switch1_status;
/* Send updated control handle as attribute for read by central device, so that
* Client reads the new data */
CyBle_GattsWriteAttributeValue(&SW_1,FALSE,&connHandle,FALSE);
}
if(CYBLE_SWITCH2_SWITCH2_VALUE_CHAR_HANDLE == write_request_param->handleValPair.attrHandle) /* the recieved event is compared to the assigned event value in the definition */
{
BLE_Switch2_Binary = write_request_param->handleValPair.value.val[0]; /* the PWM value is loaded with the actual value*/
/* Update control handle with new values */
SW_2.attrHandle = CYBLE_SWITCH2_SWITCH2_VALUE_CHAR_HANDLE;
SW_2.value.val = &BLE_Switch2_Binary;
SW_2.value.len = SW_2_CHAR_DATA_LEN;
curr_BLE_switch2_status = BLE_Switch2_Binary;
delta_BLE_switch2 = curr_BLE_switch2_status ^ prev_BLE_switch2_status;
prev_BLE_switch2_status = curr_BLE_switch2_status;
/* Send updated control handle as attribute for read by central device, so that
* Client reads the new data */
CyBle_GattsWriteAttributeValue(&SW_2,FALSE,&connHandle,FALSE);
}
// Pairing
if(CYBLE_PAIRING_PAIRING_CONTROL_CHAR_HANDLE == write_request_param->handleValPair.attrHandle) /* the recieved event is compared to the assigned event value in the definition */
{
Pairing_control = write_request_param->handleValPair.value.val[0]; /* the PWM value is loaded with the actual value*/
/* Update control handle with new values */
PAIRING.attrHandle = CYBLE_PAIRING_PAIRING_CONTROL_CHAR_HANDLE;
PAIRING.value.val = &Pairing_control;
PAIRING.value.len = PAIRING_CHAR_DATA_LEN;
pairingUpdate = 1;
/* Client reads the new data */
CyBle_GattsWriteAttributeValue(&PAIRING,FALSE,&connHandle,FALSE);
}
//STATUS
if(CYBLE_STATUS_STATUS_VALUE_CHAR_HANDLE == write_request_param->handleValPair.attrHandle) /* the recieved event is compared to the assigned event value in the definition */
{
Status = write_request_param->handleValPair.value.val[0]; /* the PWM value is loaded with the actual value*/
/* Update control handle with new values */
STATUS.attrHandle = CYBLE_STATUS_STATUS_VALUE_CHAR_HANDLE;
STATUS.value.val = &Status;
STATUS.value.len = STATUS_CHAR_DATA_LEN;
CyBle_GattsWriteAttributeValue(&STATUS,FALSE,&connHandle,FALSE);
}
/* Send the response to the write request received. */
CyBle_GattsWriteRsp(((CYBLE_GATTS_WRITE_REQ_PARAM_T *)eventparam)->connHandle);
break;
case CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ:
break;
case CYBLE_EVT_GAP_DEVICE_CONNECTED:
/* This flag is used in application to check connection status */
/* Update attribute handle on GATT Connection*/
LedColor(BLUE);
deviceConnected = TRUE;
break;
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
/* Start Advertisement and enter Discoverable mode*/
deviceConnected = FALSE;
LedColor(GREEN);
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
break;
case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
if((deviceConnected == FALSE) && (CyBle_GetState() != CYBLE_STATE_ADVERTISING))
{
CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
LedColor(YELLOW);
}
if((deviceConnected == TRUE) && (CyBle_GetState() != CYBLE_STATE_ADVERTISING))
{
CyBle_GappStopAdvertisement();
LedColor(MAGENTA);
}
break;
case CYBLE_EVT_GATT_CONNECT_IND:
CyBle_GappStopAdvertisement();
break;
case CYBLE_EVT_GATT_DISCONNECT_IND:
break;
case CYBLE_EVT_TIMEOUT:
LedColor(RED);
break;
default: /*this is where you go for any event not listed in the event handler, you just leave */
break;
}
}
Error on Apple
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi herb_2497906.
You may also want to check if your PSoC4 BLE component follows the Advertising and Connection parameters guidelines from Apple to have a stable connection with an Apple product. Here's the link: https://developer.apple.com/library/content/qa/qa1931/_index.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello Herb,
I checked with Apple iPhone 7 there it is working fine. I didn't get any error.
Please tell me the Bluetooth specifications of your Apple.
Thanks,
P Yugandhar.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi herb_2497906.
You may also want to check if your PSoC4 BLE component follows the Advertising and Connection parameters guidelines from Apple to have a stable connection with an Apple product. Here's the link: https://developer.apple.com/library/content/qa/qa1931/_index.html