English
Language : 

AN91267 Datasheet, PDF (28/62 Pages) Ramtron International Corporation – Getting Started with PSoC
Getting Started with PSoC® 4 BLE
Figure 39. BLE Stack Event Handler Flow Chart
Stack
Event
Stack ON or device
disconnected?
Yes
Start Advertising
No
Device
connected?
Yes
No
Advertising
timeout?
Yes
No
Return from stack event
handler
Update device state to
connected
Enter device stop mode
(wake up from stop
mode is through device
reset)
Code 2. BLE Stack Event Handler Firmware
void StackEventHandler(uint32 event, void *eventParam)
{
switch(event)
{
/* Mandatory events to be handled by Find Me Target design */
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(CYBLE_ADVERTISING_FAST);
Advertising_LED_Write(LED_ON);
alertLevel = NO_ALERT;
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_GAPP_ADVERTISEMENT_START_STOP:
if(CyBle_GetState() == CYBLE_STATE_DISCONNECTED)
{
www.cypress.com
Document No. 001-91267 Rev. *D
28