Create a BLE peripheral

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
PascalS
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Hi folks,

   

I'm new in the Cypress world and try to get in touch as fast as possible with the nice features of Cypress MCU's, especially with BLE components. At the moment I use the CYBLE-014008-00 BLE Module in combination with the BLE Pioneer Kit.

   

At first, I would like to create a BLE peripheral which includes some custom services and characteristics. The characteristic values should be updated when there are new values available. The new values are transferred from another MCU to the BLE Module via UART interface and a small protocol. The last day, I played a bit with the UART communication and feel well, to implement the UART interface and communicate with another MCU. I have also created two UART interrupts (TxD transfer complete / RxD buffer not empty) to implement these communication. So this part should work! I just get one warning: "Warning-1366: Setup time violation found in a path from clock (CyHFCLK) to clock (UART_IntCLK)" Maybe someone has got an idea to solve this warning?!

   

Right now, my main problem is to understand how the BLE module exactly works. In the attached example file, I initialized the BLE module with one custom service and one custom characteristic. I looked at some examples and implemented two function calls. First I use this function:

   
    

apiResult = CyBle_Start(StackEventHandler);

   
   

Afterwards I call this function in the infinity loop:

   
    

CyBle_ProcessEvents();

   
   

Now I can find and connect to my new BLE Peripheral. But how am I able to update the value of my custom characteristic? I tried to use this function:

   
    

CyBle_GattsWriteAttributeValue(&myHandle,0,&connHandle,CYBLE_GATT_DB_LOCALLY_INITIATED);

   
   

But that doesn't work. I just receive the default values, set up in the TopDesign.cysch

   

Conclusion:

   

1.   How am I able to fix the shown warning in the UART module?

   

2.   Why do I have to call the "CyBle_ProcessEvents();" function in my infinity loop? This seems a bit confusing to me.

   

3.   How am I able to update my characteristic values?

   

 

   

Thank's in advanced!

   

 

   

Pascal

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Have you checked out 100 projects in 100 days ble examples.  Here is one that you may want to study.  The one I am sending you simulates sensors for a bike.

View solution in original post

0 Likes
3 Replies
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Have you checked out 100 projects in 100 days ble examples.  Here is one that you may want to study.  The one I am sending you simulates sensors for a bike.

0 Likes
PascalS
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

Thanks for your answer!

0 Likes
PascalS
Level 4
Level 4
25 replies posted 10 replies posted 10 questions asked

How am I able to write a new descriptor value? To update the characteristics, I use the following function:

   

 

   
    

void UpdateCharacteristic(uint8* Data, uint8 len, uint16 attrHandle) 

    CYBLE_GATT_HANDLE_VALUE_PAIR_T Handle;

    

    Handle.attrHandle = attrHandle; 
    Handle.value.val = Data; 
    Handle.value.len = len;                                                                                    

    

    CyBle_GattsWriteAttributeValue(&Handle, FALSE, &cyBle_connHandle, CYBLE_GATT_DB_LOCALLY_INITIATED); 
}

   
   

 

   

To call the function:

   

 

   
    

UpdateCharacteristic(Data, sizeof(Data),CYBLE_CUSTOM_CHARACTERISTIC_CHAR_HANDLE);

    

 

   
   

This works very well. But when I try to change: "CYBLE_CUSTOM_CHARACTERISTIC_CHAR_HANDLE" into "CYBLE_CUSTOM_CHARACTERISTIC_CLIENT_CHARACTERISTIC_CONFIGURATION_DESC_HANDLE" I'm not able to update the descriptor. So do I have to change the "CYBLE_GATT_HANDLE_VALUE_PAIR_T" struct? Or is there any other issue?

   

 

   

Thanks!

   

 

   

Pascal

0 Likes