Announcements
Community Announcement : Welcome to the NEW Cypress Developer Community.
cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

Sanyika
New Contributor II

Hi,

How to know which enum element is behind a value ?
When I read a characteristic value, I can see the BLE stack send an event code 57 (decimal) but I don't know what is mean.
This code is send on my EventHandler function.

Thank you

0 Likes
1 Solution
Sanyika
New Contributor II

It was a mistake on my side, the code 57 was in hexa base (0x57),
It is corresponding to CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ

View solution in original post

0 Likes
6 Replies
Yugandhar
Moderator
Moderator

Hello, 

Could you please let me know the version of BLE component which you are using ?

Thanks,

P Yugandhar.

0 Likes
Sanyika
New Contributor II

It's the version 3.66

0 Likes
Yugandhar
Moderator
Moderator

Hello, 

Could you please let me know how many bytes are printing for eventhandler and also the profile which used in BLE ?

Please share your project for checking at our end ?

If not the complete project, then please share the BLE portion.

Thanks,

P Yugandhar.

0 Likes
Sanyika
New Contributor II
void EventHandler(uint32 event, void* eventParam)
{
	/* Local variable to store the data received as part of the Write request 
	* events */
	CYBLE_GATTS_WRITE_REQ_PARAM_T *wrReqParam;
    CYBLE_API_RESULT_T bleApiResult;
    CYBLE_STATE_T bleState;
    switch(event)
    {
        case CYBLE_EVT_STACK_ON:
			/* This event is received when component is Started */
			
			/* Set restartAdvertisement flag to allow calling Advertisement 
			* API from main function */
            Task_DebugPrintf("Info     : BLE - Stack on", 0u);
			bleApiResult = CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
            
            /* Check if the operation was successful */
            if(bleApiResult == CYBLE_ERROR_OK )
            {
//                CyBle_ProcessEvents();
                Task_DebugPrintf("Success  : BLE - Advertisement API", 0u);
            }
            else
            {
                Task_DebugPrintf("Failure! : BLE - Advertisement API, "\
                                 "Error code:", bleApiResult);
            } 
			
			break;
        case CYBLE_EVT_TIMEOUT:
            Task_DebugPrintf("Info     : BLE - Event timeout", 0u);
			break;
        /* This event indicates that some internal HW error has occurred */    
	    case CYBLE_EVT_HARDWARE_ERROR:
            Task_DebugPrintf("Error!   : BLE - Internal hardware error", 0u);
		    break;
        /**********************************************************
        *                       GAP Events
        ***********************************************************/
		case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:
			
			/* If the current BLE state is Disconnected, then the Advertisement
			* Start Stop event implies that advertisement has stopped */
            bleState = CyBle_GetState();
            switch(bleState)
            {
                case CYBLE_STATE_ADVERTISING:
                    ChangeLedStatus(BLE_LED_ADVERTISSING);
                    Task_DebugPrintf("Info     : BLE - Advertisement start event",0u);
                    break;
                case CYBLE_STATE_DISCONNECTED:
                    ChangeLedStatus(BLE_LED_OFF);
                    Task_DebugPrintf("Info     : BLE - Advertisement stop event",0u);
    			    //CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
                    break;
                default:
                    Task_DebugPrintf("Info     : BLE - Advertisement event, code : ",bleState);
                    break;
            }
			break;
        
        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:
			/* This event is received when device is disconnected */
			
			/* Set restartAdvertisement flag to allow calling Advertisement 
			* API from main function */
			//CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);
            Task_DebugPrintf("Info     : BLE - GAP device disconnected", 0u);
            DisconnectEventHandler();
			
			/* Set flag to allow system to go to Deep Sleep */
			//shut_down_led = TRUE;
            ChangeLedStatus(BLE_LED_DISCONNECT);
			break;
            
        case CYBLE_EVT_GAP_DEVICE_CONNECTED:
            Task_DebugPrintf("Info     : BLE - GAP device connected", 0u);
            ChangeLedStatus(BLE_LED_CONNECTED);
            break;
            
            
        case CYBLE_EVT_GAPC_CONNECTION_UPDATE_COMPLETE:
            break;
            
        /**********************************************************
        *                       GATT Events
        ***********************************************************/
        case CYBLE_EVT_GATT_CONNECT_IND:
			/* This event is received when device is connected over GATT level */
			Task_DebugPrintf("Info     : BLE - GATT connection established",
                              0u);
            
			/* Update attribute handle on GATT Connection*/
            connectionHandle = *(CYBLE_CONN_HANDLE_T  *)eventParam;
			
			/* This flag is used in application to check connection status */
			deviceConnected = TRUE;
			break;
            
        case CYBLE_EVT_GATT_DISCONNECT_IND:
			/* This event is received when device is disconnected */
			
			/* Update deviceConnected flag*/
			deviceConnected = FALSE;
            
            Task_DebugPrintf("Info     : BLE - GATT disconnection occurred ",
                              0u);
            
            //place to reset value of different element when is disconencting (reset char value)
            
			/* Reset the isConnectionUpdateRequested flag to allow sending
			* connection parameter update request in next connection */
			isConnectionUpdateRequested = TRUE;
			
			break;
            
        case CYBLE_EVT_GATTS_WRITE_REQ:
			/* This event is received when Central device sends a Write command on an Attribute */
            wrReqParam = (CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam;
            
			//Process all characstic
			
			/* Send the response to the write request received. */
			WriteRequestHandler(wrReqParam);
			
			break;
            
        case CYBLE_EVT_GATTS_INDICATION_DISABLED:
            Task_DebugPrintf("Info     : BLE - GATTS INDICATION DISABLED ",0u);
            break;
            
        case CYBLE_EVT_GATTS_INDICATION_ENABLED:
            Task_DebugPrintf("Info     : BLE - GATTS INDICATION ENABLED ",0u);
            break;
            
        case CYBLE_EVT_GATTC_INDICATION:
            Task_DebugPrintf("Info     : BLE - GATTC INDICATION",0u);
            break;
        
        case CYBLE_EVT_L2CAP_CONN_PARAM_UPDATE_RSP:
				/* If L2CAP connection parameter update response received, reset application flag */
            	isConnectionUpdateRequested = FALSE;
            break;
			
		case CYBLE_EVT_STACK_BUSY_STATUS:
			/* This event is generated when the internal stack buffer is full and no more
			* data can be accepted or the stack has buffer available and can accept data.
			* This event is used by application to prevent pushing lot of data to stack. */
			
			/* Extract the present stack status */
            busyStatus = * (uint8*)eventParam;
            break;  
            
        default:
            Task_DebugPrintf("Info     : BLE - Event code: ", event);
       	 	break;
    }   	/* switch(event) */
}

 

 

0 Likes
Sanyika
New Contributor II

Sanyika_0-1629897278198.png

It's when I read value, I get code 57

 

0 Likes
Sanyika
New Contributor II

It was a mistake on my side, the code 57 was in hexa base (0x57),
It is corresponding to CYBLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ

View solution in original post

0 Likes