cancel
Showing results for 
Search instead for 
Did you mean: 

PSoC 4

Anonymous
Not applicable

 Hi everyone,

   

i used the example Project AN91162 to make my own Custom BLE Service. I made the all the settings on the BLE-Block. All i want is to transmit a varibale uint8 over Bluetooth to my CY8CKIT-042-BLE. But now to my problem: I can't find the datatyp of the CYBLE_GATTS_WRITE_REQ_PARAM_T or the wrReqParam.  Down below you see the Code i made. How to fill in the wrReqParam to my variable command, i made a Green comment, where i try to make this happen in the Programm. All that i try makes Errorors and doesn't work. 😕 Ideas how to make this?

   

Thanks for Help!

   

#include <project.h>

   

void GeneralEventHandler(uint32 event, void * eventParam) //eventParam contains Data written

   

{

   

    uint8 command;

   

    CYBLE_GATTS_WRITE_REQ_PARAM_T *wrReqParam;

   

    switch (event)

   

    {

   

        case CYBLE_EVT_STACK_ON:

   

            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

   

        break; 

   

        case CYBLE_EVT_GAPP_ADVERTISEMENT_START_STOP:

   

            if(CyBle_GetState() == CYBLE_STATE_DISCONNECTED)

   

            {

   

                CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

   

            }

   

        break; 

   

        case CYBLE_EVT_GAP_DEVICE_DISCONNECTED:

   

            CyBle_GappStartAdvertisement(CYBLE_ADVERTISING_FAST);

   

        break;

   

        case CYBLE_EVT_GATTS_WRITE_REQ:

   

            wrReqParam =(CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam;

   

            //Here i want to set the Value of wrReqParam to the variable "command" but how? 

   

        break;

   

        

   

        case CYBLE_EVT_GATT_DISCONNECT_IND:

   

        break; 

   

        default:

   

        break;

   

    }

   

}

   


   

void InitializeSystem(void)

   

{

   

    CyGlobalIntEnable;

   

    CyBle_Start(GeneralEventHandler);

   

}

   

int main()

   

{

   

    /* Place your initialization/startup code here (e.g. MyInst_Start()) */

   

    InitializeSystem();

   

    /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */ 

   

    for(;;)

   

    {

   

       CyBle_ProcessEvents();

   

        /* Place your application code here. */     

   

    }

   

 

   

}

0 Likes
3 Replies
Anonymous
Not applicable

 Hi ,

   

Are you writing from the client to the server?

   

I assume that you set the properties of the of the characteristic as write (not write without response).

   

 

   

Declare the variables 

   

 

   

CYBLE_GATTS_WRITE_REQ_PARAM_T wReqparam;

   

    CYBLE_GATT_ERR_CODE_T  gattError;

   

 

   

write the following code sniffet in the  switch case

   

 

   

case CYBLE_EVT_GATTS_WRITE_REQ:

   

                wReqparam=*(CYBLE_GATTS_WRITE_REQ_PARAM_T *) eventParam;

   

               gattError= CyBle_GattsWriteAttributeValue(&wReqparam.handleValPair,0,&cyBle_connHandle,CYBLE_GATT_DB_PEER_INITIATED);

   

                printf("Gatt error:%d\r\n",gattError);

   

                CyBle_GattsWriteRsp(cyBle_connHandle);

   

                break;

   

 

   

Regards,

   

Vikas

0 Likes
Anonymous
Not applicable

It's Working!

   

With this code i fill in the value to my local variable: 

   

command = *wrReqParam->handleValPair.value.val;

   

But I had to reconnect after every value written.

   

Thanks for this line, with this code, i don't have to reconnect after i wrote something to my variable:

   

CyBle_GattsWriteRsp(cyBle_connHandle);

   

Thanks alot!

0 Likes
Anonymous
Not applicable

 As the property supported by the characteristic is Write request and not Write without response, the GATT server should send back a response to the request sent.That is why, for each 'CYBLE_EVT_GATTS_WRITE_REQ' event, you need to call 'CyBle_GattsWriteRsp(cyBle_connHandle);' to send back response. 

   

If this response is not sent within a time limit, then the GATT Client will consider the link broken and disconnect.

0 Likes