Implementing Custom BLE Service with Modus Toolbox

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

cross mob
benjaminpaik
Level 2
Level 2
10 questions asked 10 sign-ins 5 questions asked

I am currently trying to create an application in Modus Toolbox that implements a basic custom BLE service with two characteristics: one to write a byte of data and one to read a byte of data from a phone client. Since I couldn't find any BLE tutorials for Modus Toolbox, I have been using a combination of the "BLE_Battery_Level_FreeRTOS" example, the "Cypress PSoC 6 Bluetooth Low Energy Middleware Library 3.50" quick start guide, and the PSOC Creator BLE tutorial videos as references, but it has been somewhat difficult to figure out the correct approach. I feel like I understand more or less what needs to be done, but cannot get the PSOC 6 device to show up on my phone (while the "BLE_Battery_Level_FreeRTOS" example works as expected). I essentially started with an empty project, added the FreeRTOS and BLE libraries, used the Bluetooth Configurator to provide the same settings from the "BLE_Battery_Level_FreeRTOS" example (except for replacing the battery service with my custom service), added the "BLESS_HOST BLESS_CONTROLLER" to the components in my makefile, and copied the "ble_task.c/ble_task.h" files from the example to my project. I made some edits to the "ble_task" files to match my application by removing the "bas_event_handler", commenting out the "BATTERY_LEVEL_UPDATE" case, removing all references to the status led, modifying the code from the CY_BLE_EVT_GATTS_READ_CHAR_VAL_ACCESS_REQ case to simply increment and return a byte, and adding a case for "CY_BLE_EVT_GATTS_WRITE_REQ" (based on the PSOC Creator "SimpleBLEPeripheral" example to update a PWM value to an LED based on the written byte value). My main function calls the standard initialization routines, sets up the LED PWM, creates the BLE task (the only task in my application), and starts the FreeRTOS scheduler. After programming the board, the device does not appear to be advertising to my phone. Using debug mode, I've determined that the BLE initialization routine completes successfully. I figured I may not have setup my custom service correctly, but I don't think that should have affected the advertising. I would appreciate any ideas as to what my problem/s might be.

Also, I was a bit confused about the proper way to respond to BLE events. Specifically it appears as though some actions are handled in the main loop after Cy_BLE_ProcessEvents(), while other actions are handled in the corresponding case of the "stack_event_handler". Both of these seem essentially equivalent to me, so I'm not sure how to decide where these functions should go.

My custom service characteristics are setup like this:

benjaminpaik_0-1612672421584.png 

benjaminpaik_1-1612672458951.png

 

 

0 Likes
1 Solution
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Please refer to the "PSoC 6 MCU: BLE Throughput Measurement (FreeRTOS)" code example from the Modus Tool Box. This code example demonstrates BLE throughput measurement (using GATT layer notifications and GATT write command) using PSoC 6 BLE MCU.
This code example has two applications:
1.BLE GATT Server Throughput Measurement: This application sends GATT notifications and calculates BLE Tx throughput, and receives GATT Writes and calculates BLE Rx throughput.
2. BLE GATT Client Throughput Measurement: This application sends GATT write commands and calculates BLE Tx throughput, and receives GATT notifications and calculates BLE Rx throughput.
You can refer to the BLE GATT Server project for your application. It has one custom service with two custom characteristics which includes Read, Write, Write without response and Notify properties.
Please let me know if this helps.

Thanks,
P Yugandhar.

View solution in original post

0 Likes
1 Reply
Yugandhar
Moderator
Moderator
Moderator
500 solutions authored 1000 replies posted 5 likes given

Hello,

Please refer to the "PSoC 6 MCU: BLE Throughput Measurement (FreeRTOS)" code example from the Modus Tool Box. This code example demonstrates BLE throughput measurement (using GATT layer notifications and GATT write command) using PSoC 6 BLE MCU.
This code example has two applications:
1.BLE GATT Server Throughput Measurement: This application sends GATT notifications and calculates BLE Tx throughput, and receives GATT Writes and calculates BLE Rx throughput.
2. BLE GATT Client Throughput Measurement: This application sends GATT write commands and calculates BLE Tx throughput, and receives GATT notifications and calculates BLE Rx throughput.
You can refer to the BLE GATT Server project for your application. It has one custom service with two custom characteristics which includes Read, Write, Write without response and Notify properties.
Please let me know if this helps.

Thanks,
P Yugandhar.

0 Likes