User Manual

Getting Started With EZ-
www.cypress.com Document No.: 001-96841 Rev. ** 38
Figure 49. Bluetooth Low Energy Stack Event Handler Firmware
#define LED_ON (0u)
#define LED_OFF (1u)
extern CYBLE_GAPP_DISC_PARAM_T cyBle_discoveryParam;
extern CYBLE_GAPP_DISC_MODE_INFO_T
cyBle_discoveryModeInfo;
void StackEventHandler(uint32 event, void* eventParam)
{
switch(event)
{
case CYBLE_EVT_STACK_ON:
case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
/* Start BLE advertisement for 30 seconds and update link
* status on LEDs */
CyBle_GappStartAdvertisement();
Advertising_LED_Write(LED_ON);
Disconnect_LED_Write(LED_ON);
Alert_LED_Write(LED_OFF)
break;
case CYBLE_EVT_GAP_DEVICE_CONNECTED:
/* BLE link is established */
Advertising_LED_Write(LED_OFF);
Disconnect_LED_Write(LED_OFF);
break;
case CYBLE_EVT_TIMEOUT:
if(*(uint8 *) eventParam == CYBLE_GAP_ADV_MODE_TO)
{
/* Advertisement event timed out, go to low power
* mode (Hibernate mode) and wait for an external
* user event to wake up the device again */
Advertising_LED_Write(LED_OFF);
Disconnect_LED_Write(LED_OFF);
Alert_LED_Write(LED_OFF);
Wakeup_SW_ClearInterrupt();
Wakeup_Interrupt_ClearPending();
Wakeup_Interrupt_Start();
CySysPmHibernate();
}
break;
default:
break;
}
}