data_gathering/beacon_node/ble_findme.c
static void stack_event_handler(uint32_t event, void* eventParam)
{
    switch(event)
    {
        /**********************************************************************
         * General events
         *********************************************************************/

        /* This event is received when the BLE stack is started */
        case CY_BLE_EVT_STACK_ON:
        {
            printf("[INFO] : BLE stack started \r\n");
            ble_start_advertisement();
            break;
        }

        /* This event is received when there is a timeout */
        case CY_BLE_EVT_TIMEOUT:
        {
            /* Reason for Timeout */
            cy_en_ble_to_reason_code_t reason_code =
                ((cy_stc_ble_timeout_param_t*)eventParam)->reasonCode;

            switch(reason_code)
            {
                case CY_BLE_GAP_ADV_TO:
                {
                    printf("[INFO] : Advertisement timeout event \r\n");
                    break;
                }
                case CY_BLE_GATT_RSP_TO:
                {
                    printf("[INFO] : GATT response timeout\r\n");
                    break;
                }
                default:
                {
                    printf("[INFO] : BLE timeout event\r\n");
                    break;
                }
            }

            break;
        }

        /* This event indicates completion of Set LE event mask */
        case CY_BLE_EVT_LE_SET_EVENT_MASK_COMPLETE:
        {
            printf("[INFO] : Set LE mask event mask command completed\r\n");
            break;
        }

        /* This event indicates set device address command completed */
        case CY_BLE_EVT_SET_DEVICE_ADDR_COMPLETE:
        {
            printf("[INFO] : Set device address command has completed \r\n");
            break;
        }

        /* This event indicates set Tx Power command completed */
        case CY_BLE_EVT_SET_TX_PWR_COMPLETE:
        {
            printf("[INFO] : Set Tx power command completed\r\n");
            break;
        }

        /* This event indicates BLE Stack Shutdown is completed */
        case CY_BLE_EVT_STACK_SHUTDOWN_COMPLETE:
        {
            printf("[INFO] : BLE shutdown complete\r\n");
            break;
        }


        /**********************************************************************
         * GAP events
         *********************************************************************/

        /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */
        case CY_BLE_EVT_GAP_DEVICE_CONNECTED:
        {
            printf("[INFO] : GAP device connected \r\n");
            break;
        }
        /* This event is triggered instead of 'CY_BLE_EVT_GAP_DEVICE_CONNECTED',
         * if Link Layer Privacy is enabled in component customizer
         */
        case CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE:
        {
            printf("[INFO] : GAP enhanced connection complete \r\n");

            break;
        }

        /* This event is generated when disconnected from remote device or
         * failed to establish connection
         */
        case CY_BLE_EVT_GAP_DEVICE_DISCONNECTED:
        {
            if(CY_BLE_CONN_STATE_DISCONNECTED == 
               Cy_BLE_GetConnectionState(app_conn_handle))
            {
                printf("[INFO] : GAP device disconnected\r\n");
                alert_level = CY_BLE_NO_ALERT;
                ble_start_advertisement();
            }
            break;
        }

        /* This event indicates that the GAP Peripheral device has
         * started/stopped advertising
         */
        case CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
        {
            if(CY_BLE_ADV_STATE_ADVERTISING == Cy_BLE_GetAdvertisementState())
            {
                printf("[INFO] : BLE advertisement started\r\n");
            }
            else
            {
                printf("[INFO] : BLE advertisement stopped\r\n");

                Cy_BLE_Disable();
            }
            break;
        }


        /**********************************************************************
         * GATT events
         *********************************************************************/

        /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */
        case CY_BLE_EVT_GATT_CONNECT_IND:
        {
            app_conn_handle = *(cy_stc_ble_conn_handle_t *)eventParam;
            printf("[INFO] : GATT device connected\r\n");
            break;
        }

        /* This event is generated at the GAP Peripheral end after disconnection */
        case CY_BLE_EVT_GATT_DISCONNECT_IND:
        {
            printf("[INFO] : GATT device disconnected\r\n");
            break;
        }

        /* This event indicates that the 'GATT MTU Exchange Request' is received */
        case CY_BLE_EVT_GATTS_XCNHG_MTU_REQ:
        {
            printf("[INFO] : GATT MTU Exchange Request received \r\n");
            break;
        }

        /* This event received when GATT read characteristic request received */
        case CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ:
        {
            printf("[INFO] : GATT read characteristic request received \r\n");
            break;
        }

        default:
        {
            printf("[INFO] : BLE Event 0x%lX\r\n", (unsigned long) event);
        }
    }
}
/*******************************************************************************
* Function Name: stack_event_handler
********************************************************************************
*
* Summary:
*   This is an event callback function to receive events from the BLE Component.
*
* Parameters:
*  uint32 event:      event from the BLE component
*  void* eventParam:  parameters related to the event
*
*******************************************************************************/
Function Name: stack_event_handler
Summary:
This is an event callback function to receive events from the BLE Component.

uint32 event:      event from the BLE component
void* eventParam:  parameters related to the event
Function Name : stack_event_handler Summary : This is an event callback function to receive events from the BLE Component . uint32 event : event from the BLE component void * eventParam : parameters related to the event
static void stack_event_handler(uint32_t event, void* eventParam)
{
    switch(event)
    {
        case CY_BLE_EVT_STACK_ON:
        {
            printf("[INFO] : BLE stack started \r\n");
            ble_start_advertisement();
            break;
        }
        case CY_BLE_EVT_TIMEOUT:
        {
            cy_en_ble_to_reason_code_t reason_code =
                ((cy_stc_ble_timeout_param_t*)eventParam)->reasonCode;
            switch(reason_code)
            {
                case CY_BLE_GAP_ADV_TO:
                {
                    printf("[INFO] : Advertisement timeout event \r\n");
                    break;
                }
                case CY_BLE_GATT_RSP_TO:
                {
                    printf("[INFO] : GATT response timeout\r\n");
                    break;
                }
                default:
                {
                    printf("[INFO] : BLE timeout event\r\n");
                    break;
                }
            }
            break;
        }
        case CY_BLE_EVT_LE_SET_EVENT_MASK_COMPLETE:
        {
            printf("[INFO] : Set LE mask event mask command completed\r\n");
            break;
        }
        case CY_BLE_EVT_SET_DEVICE_ADDR_COMPLETE:
        {
            printf("[INFO] : Set device address command has completed \r\n");
            break;
        }
        case CY_BLE_EVT_SET_TX_PWR_COMPLETE:
        {
            printf("[INFO] : Set Tx power command completed\r\n");
            break;
        }
        case CY_BLE_EVT_STACK_SHUTDOWN_COMPLETE:
        {
            printf("[INFO] : BLE shutdown complete\r\n");
            break;
        }
        case CY_BLE_EVT_GAP_DEVICE_CONNECTED:
        {
            printf("[INFO] : GAP device connected \r\n");
            break;
        }
        case CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE:
        {
            printf("[INFO] : GAP enhanced connection complete \r\n");
            break;
        }
        case CY_BLE_EVT_GAP_DEVICE_DISCONNECTED:
        {
            if(CY_BLE_CONN_STATE_DISCONNECTED == 
               Cy_BLE_GetConnectionState(app_conn_handle))
            {
                printf("[INFO] : GAP device disconnected\r\n");
                alert_level = CY_BLE_NO_ALERT;
                ble_start_advertisement();
            }
            break;
        }
        case CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
        {
            if(CY_BLE_ADV_STATE_ADVERTISING == Cy_BLE_GetAdvertisementState())
            {
                printf("[INFO] : BLE advertisement started\r\n");
            }
            else
            {
                printf("[INFO] : BLE advertisement stopped\r\n");
                Cy_BLE_Disable();
            }
            break;
        }
        case CY_BLE_EVT_GATT_CONNECT_IND:
        {
            app_conn_handle = *(cy_stc_ble_conn_handle_t *)eventParam;
            printf("[INFO] : GATT device connected\r\n");
            break;
        }
        case CY_BLE_EVT_GATT_DISCONNECT_IND:
        {
            printf("[INFO] : GATT device disconnected\r\n");
            break;
        }
        case CY_BLE_EVT_GATTS_XCNHG_MTU_REQ:
        {
            printf("[INFO] : GATT MTU Exchange Request received \r\n");
            break;
        }
        case CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ:
        {
            printf("[INFO] : GATT read characteristic request received \r\n");
            break;
        }
        default:
        {
            printf("[INFO] : BLE Event 0x%lX\r\n", (unsigned long) event);
        }
    }
}
static void stack_event_handler ( uint32_t event , void * eventParam ) { switch ( event ) { case CY_BLE_EVT_STACK_ON : { printf ( " \r \n " ) ; ble_start_advertisement ( ) ; break ; } case CY_BLE_EVT_TIMEOUT : { cy_en_ble_to_reason_code_t reason_code = ( ( cy_stc_ble_timeout_param_t * ) eventParam ) -> reasonCode ; switch ( reason_code ) { case CY_BLE_GAP_ADV_TO : { printf ( " \r \n " ) ; break ; } case CY_BLE_GATT_RSP_TO : { printf ( " \r \n " ) ; break ; } default : { printf ( " \r \n " ) ; break ; } } break ; } case CY_BLE_EVT_LE_SET_EVENT_MASK_COMPLETE : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_SET_DEVICE_ADDR_COMPLETE : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_SET_TX_PWR_COMPLETE : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_STACK_SHUTDOWN_COMPLETE : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_GAP_DEVICE_CONNECTED : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_GAP_ENHANCE_CONN_COMPLETE : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_GAP_DEVICE_DISCONNECTED : { if ( CY_BLE_CONN_STATE_DISCONNECTED == Cy_BLE_GetConnectionState ( app_conn_handle ) ) { printf ( " \r \n " ) ; alert_level = CY_BLE_NO_ALERT ; ble_start_advertisement ( ) ; } break ; } case CY_BLE_EVT_GAPP_ADVERTISEMENT_START_STOP : { if ( CY_BLE_ADV_STATE_ADVERTISING == Cy_BLE_GetAdvertisementState ( ) ) { printf ( " \r \n " ) ; } else { printf ( " \r \n " ) ; Cy_BLE_Disable ( ) ; } break ; } case CY_BLE_EVT_GATT_CONNECT_IND : { app_conn_handle = * ( cy_stc_ble_conn_handle_t * ) eventParam ; printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_GATT_DISCONNECT_IND : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_GATTS_XCNHG_MTU_REQ : { printf ( " \r \n " ) ; break ; } case CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ : { printf ( " \r \n " ) ; break ; } default : { printf ( " \r \n " , ( unsigned long ) event ) ; } } }
Function Name: stack_event_handler
Summary:
This is an event callback function to receive events from the BLE Component.
Function Name : stack_event_handler Summary : This is an event callback function to receive events from the BLE Component .
/**********************************************************************
         * General events
         *********************************************************************/ /* This event is received when the BLE stack is started */ /* This event is received when there is a timeout */ /* Reason for Timeout */ /* This event indicates completion of Set LE event mask */ /* This event indicates set device address command completed */ /* This event indicates set Tx Power command completed */ /* This event indicates BLE Stack Shutdown is completed */ /**********************************************************************
         * GAP events
         *********************************************************************/ /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */ /* This event is triggered instead of 'CY_BLE_EVT_GAP_DEVICE_CONNECTED',
         * if Link Layer Privacy is enabled in component customizer
         */ /* This event is generated when disconnected from remote device or
         * failed to establish connection
         */ /* This event indicates that the GAP Peripheral device has
         * started/stopped advertising
         */ /**********************************************************************
         * GATT events
         *********************************************************************/ /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */ /* This event is generated at the GAP Peripheral end after disconnection */ /* This event indicates that the 'GATT MTU Exchange Request' is received */ /* This event received when GATT read characteristic request received */