Psoc63 example with uart service BLE.

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

cross mob
SeDo_3598816
Level 1
Level 1
First like given

Hi PSoC Team,

I'm searching for a project example with uart service BLE for the CY8CPROTO-063-BLE or any PSoC 6 BLE Pioneer Kit.

I am grateful for any information and a hint in which direction to look and what to do for a beginner at the start.

Thanks,

Sergey D.

0 Likes
1 Solution
lock attach
Attachments are accessible only for community members.

Hi Sergey,
Please look at the attached project. I did some updates. Now we have loopback when you send data from the phone (write to RX), it backs the same packet by TX notification.
Finally, you need to update functions App_UART_BLE_Rx and App_UART_BLE_Tx for your propose...

App_UART_BLE_Rx - should be an interface to send data to UART
App_UART_BLE_Tx - should be called when you received the UART packet and want to notify it via BLE.


I noticed that nRf Connect does not use exchanged MTU (during connection) for a Write Request, so if you want to send > 20 bytes, it will send by Reliable Write. Please check the Nordic-> Settings->Connectivity has enabled "Auto request max MTU". Also, you can implement handling of Reliable Write (refer to CY_BLE_EVT_GATTS_PREP_WRITE_REQ and CY_BLE_EVT_GATTS_EXEC_WRITE_REQ documentation).

Regards,
Nazar

View solution in original post

23 Replies
ShipingW_81
Moderator
Moderator
Moderator
500 replies posted 250 solutions authored 250 replies posted

As far as I know, there is no standard SPP profile provided by the Bluetooth SIG for BLE. Therefore, PSoC BLE has no such demo code for uart service BLE.

Anyway, you may be able to get useful info from the following links where this topic is fully discussed -

https://www.cypress.com/blog/problem-solver/project-020-uart-ble-bridge

UART over BLE?

Len_CONSULTRON
Level 9
Level 9
Beta tester 500 solutions authored 1000 replies posted

Sergey,

I have found multiple projects that use the UART with the PSoC 63 CPU.

Using PSoC Creator 4.3 and  menu "File\Code Example..." and setting Device family: PSoC 63 and Filer by: UART I get the following projects with UART use:

pastedImage_0.png

As a starter, I downloaded the UART_printf project compiled it and got it to work!

I'm assuming you are trying to use PSoC Creator with the CY8CPROTO-063-BLE board.  If this is the case, you MUST download the beta version of PSoC Creator 4.3.  The CYBLE-416045-02 device was not supported in earlier Creator releases.  It is now supported in the newest beta release.

Additionally once you download the project from the examples window and load the project, you need to change the device targeted for the project to the CYBLE-416045-02 device.

With this change should build, compile and allow you to program the CM4 processor.  You do need a terminal program on the host set to 115.2K 8N1 and every time you press SW2 on the board, you get a display of the count of the number of times the switch was pressed.

This should get you started with the great CY8CPROTO-063-BLE board.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

I need example with Bluetooth uart service, not a wired hardware uart.

0 Likes

Sergey,

Sorry.  I misunderstood.  I'm new to BLE.  Although I know that other BLE products from other manufacturers support UART functions as a BLE service.

I don't have an answer but found this link:  Using ble to replace bluetooth classic SPP profile - Question | Mbed that addresses your question.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Sergey,
You need use Custom services to create own UART BLE service, where define two characteristics: TX, RX.

RX Characteristic -
will be used to send data from peer device application. ATT Write Request or ATT Write Command can be used.
so your application should handle receiving this data and send to the UART interface (by using SCB-UART functions).

TX Characteristic - will be used by application to send data to the peer as notifications, so your application should handle receiving UART data and send received "full" UART packet to Peer device by BLE Notification/or Indication.

PSoC 4 example (thanks for link):

https://www.cypress.com/blog/problem-solver/project-020-uart-ble-bridge - demonstrates a custom Profile to implement a UART-BLE bridge using the BLE Pioneer Kit (PSoC 4).

The following examples should be a good start point for PSoC 6:

1. https://www.cypress.com/documentation/code-examples/ce222046-psoc-6-mcu-bluetooth-low-energy-ble-con... - a good example understand how to transfer data (such as UART traffic) over BLE custom service.

2. https://www.cypress.com/documentation/application-notes/an91162-creating-ble-custom-profile  - AN how to create BLE Custom service. It based for PSoc4, but main flow should be applied for PSoC6 as well (function name will be different...)

3. PSoC-6-MCU-Digital-Designs/UART/CE219656 PSoC 6 MCU UARTusing Low Level APIs at master · cypresssemi...  and PSoC-6-MCU-Digital-Designs/UART/CE221117 PSoC 6 MCU UARTusing High Level APIs at master · cypresssem...  + PSoC 6 Peripheral Driver Library: UART (SCB) - for UART part of your project.

Regards,
Nazar

Hi Nazar,

Thanks for the detailed answer.

0 Likes

Sergey,

I just found this ModusToolBox lib for SPP for BLE.  This might be what you need.

btsdk-rfcomm/COMPONENT_spp_lib at master · cypresssemiconductorco/btsdk-rfcomm · GitHub

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Len,
The library which you noticed above is related to WICED. This topic is about PSoC6 Example...

Regards,
Nazar

0 Likes

Nazar,

Can some of it be adapted to the ModusToolBox?  I believe ModusToolBox was a derivation of WICED.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Len,

Sorry for confusing... I mead, that spp_lib is part of BT SDK, which used for the CYW20719B2, CYW20721B2, CYW20819, CYW20820 and CYW89820 SoCs and do not uses for PSoC6 BLE devices. For PSoC6 BLE we used BLESS middleware for BLE functionality (GitHub - cypresssemiconductorco/bless: PSoC 6 BLE Middleware contains a comprehensive API to configu... ).

Regards,
Nazar


0 Likes
SeDo_3598816
Level 1
Level 1
First like given

photo.jpg

characteristic Value: doesn't change, notifications not received, what could be wrong??

0 Likes

Sergey,

I'm not familiar with your phone type.  However, it looks from the top right icon list that you MIGHT have "Airplane Mode" turned on.

On some phones (mine is an iPhone), "Airplane Mode" turns off BLE/Bluetooth.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Sergey,
Could you attach your project..?

Thanks,
Nazar

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Nazar,

of course i can

I will be glad of any help

0 Likes

#define NOTIFICATION_PKT_SIZE       (20)

in program attached above Notification work but:

1. if set NOTIFICATION_PKT_SIZE more than 20 notification does not work, can be in the Throughput example turned off DLE?

0 Likes

Sergey,

I've downloaded your project.  Your project is assigned to the BLE device found on the CY8CPROTO-063-BLE.  If you are using this board, this device assignment is correct.

Based on the Phone pic you provided, it appears that your PSoC board is communicating with a BLE monitor program.

The issue you are having may be simple.

The GATT_Out is a project that is paired with the GATT_In project.  I programmed one CY8CPROTO-063-BLE with GATT_Out and another CY8CPROTO-063-BLE with GATT_In as described in the "CE222046 – PSoC 6 BLE Throughput Measurement" pdf file.  It works!  However, it requires both the GATT_Out and GATT_In projects to be loaded on PSoC BLE-enabled boards.

It appears you've only provided the GATT_Out side of the equation.

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Len,

one problem, I can not send with this example more than 20 bytes

#define NOTIFICATION_PKT_SIZE       (20)

in program attached above Notification work but:

1. if set NOTIFICATION_PKT_SIZE more than 20 notification does not work, can be in the Throughput example turned off DLE?

Best regards,

Sergey.

0 Likes

Sergey,

I'm a bit of a newbie on BLE at the low-level. 

I was trying to point out that the GATT_Out program is matched with the GATT_In running on another PSoC BLE device.

Does GATT_Out work for you with NOTIFICATION_PKT_SIZE < 20 bytes?

Len

Len
"Engineering is an Art. The Art of Compromise."
0 Likes

Hi Sergey,

Field lengths are set as 20 for RX, TX characteristics in BLE Customizer (see 'GATT Settings' tab). Please change it to max values what you need.

Regards,

Nazar

0 Likes

Hi Nazar,
i change RX, TX characteristics to 200 and NOTIFICATION_PKT_SIZE       (200)

and notifications stop coming. Notifications work if 20bytes, if i set NOTIFICATION_PKT_SIZE  21 or more, notifications stop coming.

0 Likes
lock attach
Attachments are accessible only for community members.

Hi Sergey,
Please look at the attached project. I did some updates. Now we have loopback when you send data from the phone (write to RX), it backs the same packet by TX notification.
Finally, you need to update functions App_UART_BLE_Rx and App_UART_BLE_Tx for your propose...

App_UART_BLE_Rx - should be an interface to send data to UART
App_UART_BLE_Tx - should be called when you received the UART packet and want to notify it via BLE.


I noticed that nRf Connect does not use exchanged MTU (during connection) for a Write Request, so if you want to send > 20 bytes, it will send by Reliable Write. Please check the Nordic-> Settings->Connectivity has enabled "Auto request max MTU". Also, you can implement handling of Reliable Write (refer to CY_BLE_EVT_GATTS_PREP_WRITE_REQ and CY_BLE_EVT_GATTS_EXEC_WRITE_REQ documentation).

Regards,
Nazar

Hi Nazar,

thanks it helped Nordic-> Settings->Connectivity has enabled "Auto request max MTU".

some terminals app do not call CY_BLE_EVT_GATTS_XCNHG_MTU_REQ

BDhandle : 0x10

CY_BLE_EVT_DATA_LENGTH_CHANGE

Setting PHY.[bdHandle 0x10]

Updating the Phy.....

SET PHY updated to 2 Mbps

UPDATE PHY parameters

CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

CY_BLE_EVT_GATTS_XCNHG_MTU_REQ negotiated = 247

CY_BLE_EVT_GATTS_WRITE_... [15] 2

CY_BLE_EVT_STACK_BUSY_STATUS: 1

CY_BLE_EVT_STACK_BUSY_STATUS: 0

CY_BLE_EVT_STACK_BUSY_STATUS: 1

CY_BLE_EVT_STACK_BUSY_STATUS: 0

CY_BLE_EVT_STACK_BUSY_STATUS: 1

CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

CY_BLE_EVT_STACK_BUSY_STATUS: 0

CY_BLE_EVT_STACK_BUSY_STATUS: 1

CY_BLE_EVT_DATA_LENGTH_CHANGE

Setting PHY.[bdHandle 0x10]

Updating the Phy.....

SET PHY updated to 2 Mbps

CY_BLE_EVT_STACK_BUSY_STATUS: 0

CY_BLE_EVT_STACK_BUSY_STATUS: 1

CY_BLE_EVT_STACK_BUSY_STATUS: 0

CY_BLE_EVT_STACK_BUSY_STATUS: 1

CY_BLE_EVT_STACK_BUSY_STATUS: 0

CY_BLE_EVT_STACK_BUSY_STATUS: 1

UPDATE PHY parameters

BDhandle : 0x10

CY_BLE_EVT_DATA_LENGTH_CHANGE

Setting PHY.[bdHandle 0x10]

Updating the Phy.....

SET PHY updated to 2 Mbps

UPDATE PHY parameters

CY_BLE_EVT_GAP_CONNECTION_UPDATE_COMPLETE

CY_BLE_EVT_GATTS_WRITE_... [15] 2

Couldn't send notification. [CY_BLE_ERROR_INVALID_PARAMETER]

Regards,

Sergey

0 Likes