data_gathering/client_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");
            Cy_BLE_GAPC_StartScan(CY_BLE_SCANNING_FAST, 0);
            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;
        }

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

        /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */
        case CY_BLE_EVT_GAPC_SCAN_PROGRESS_RESULT: {
        	cy_stc_ble_gapc_adv_report_param_t *scanProgressParam = (cy_stc_ble_gapc_adv_report_param_t *) eventParam;
        	findAdvInfo(scanProgressParam->data, scanProgressParam->dataLen);

        	if(currentAdvInfo.name_len > 0) {
				currentAdvInfo.name[currentAdvInfo.name_len] = '\0';
				if(!strcmp(currentAdvInfo.name, "RSSI-Server-1")) {
					rssi_values[0] = found_mask & 1 ? rssi_values[0] : scanProgressParam->rssi;
					found_mask |= 1;
				} else if(!strcmp(currentAdvInfo.name, "RSSI-Server-2")) {
					rssi_values[1] = found_mask & 2 ? rssi_values[1] : scanProgressParam->rssi;
					found_mask |= 2;
				} else if(!strcmp(currentAdvInfo.name, "RSSI-Server-3")) {
					rssi_values[2] = found_mask & 4 ? rssi_values[2] : scanProgressParam->rssi;
					found_mask |= 4;
				}
        	}
        	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;
        }

        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");
            Cy_BLE_GAPC_StartScan(CY_BLE_SCANNING_FAST, 0);
            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_GAPC_SCAN_PROGRESS_RESULT: {
        	cy_stc_ble_gapc_adv_report_param_t *scanProgressParam = (cy_stc_ble_gapc_adv_report_param_t *) eventParam;
        	findAdvInfo(scanProgressParam->data, scanProgressParam->dataLen);
        	if(currentAdvInfo.name_len > 0) {
				currentAdvInfo.name[currentAdvInfo.name_len] = '\0';
				if(!strcmp(currentAdvInfo.name, "RSSI-Server-1")) {
					rssi_values[0] = found_mask & 1 ? rssi_values[0] : scanProgressParam->rssi;
					found_mask |= 1;
				} else if(!strcmp(currentAdvInfo.name, "RSSI-Server-2")) {
					rssi_values[1] = found_mask & 2 ? rssi_values[1] : scanProgressParam->rssi;
					found_mask |= 2;
				} else if(!strcmp(currentAdvInfo.name, "RSSI-Server-3")) {
					rssi_values[2] = found_mask & 4 ? rssi_values[2] : scanProgressParam->rssi;
					found_mask |= 4;
				}
        	}
        	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;
        }
        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 " ) ; Cy_BLE_GAPC_StartScan ( CY_BLE_SCANNING_FAST , 0 ) ; 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_GAPC_SCAN_PROGRESS_RESULT : { cy_stc_ble_gapc_adv_report_param_t * scanProgressParam = ( cy_stc_ble_gapc_adv_report_param_t * ) eventParam ; findAdvInfo ( scanProgressParam -> data , scanProgressParam -> dataLen ) ; if ( currentAdvInfo . name_len > 0 ) { currentAdvInfo . name [ currentAdvInfo . name_len ] = ' \0 ' ; if ( ! strcmp ( currentAdvInfo . name , " " ) ) { rssi_values [ 0 ] = found_mask & 1 ? rssi_values [ 0 ] : scanProgressParam -> rssi ; found_mask |= 1 ; } else if ( ! strcmp ( currentAdvInfo . name , " " ) ) { rssi_values [ 1 ] = found_mask & 2 ? rssi_values [ 1 ] : scanProgressParam -> rssi ; found_mask |= 2 ; } else if ( ! strcmp ( currentAdvInfo . name , " " ) ) { rssi_values [ 2 ] = found_mask & 4 ? rssi_values [ 2 ] : scanProgressParam -> rssi ; found_mask |= 4 ; } } break ; } case CY_BLE_EVT_GATT_CONNECT_IND : { app_conn_handle = * ( cy_stc_ble_conn_handle_t * ) eventParam ; 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 */ /**********************************************************************
         * GAP events
         *********************************************************************/ /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */ /**********************************************************************
         * GATT events
         *********************************************************************/ /* This event is generated at the GAP Peripheral end after connection
         * is completed with peer Central device
         */