BLE-UART Bridge: How to send continuous UART String?

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

cross mob
Anonymous
Not applicable

Hello,

   

 

   

I am working with project 20 (BLE UART Bridge) of the 100 project in 100 days site, http://www.cypress.com/file/66366/download and having trouble sending a string over from the PSoC to the bluetooth dongle.

   

 

   

I am using the CY8CKIT-042-BLE PSoC 4 kit. In terms of the bridge between the psoc and the dongle, that works fine. What I am trying to do is; after the psoc and dongle have connected, I want the PSoC to continuously send a string (UART String) to the bluetooth with 1 second delay, then a different string, then another 1 second delay. It would be similar to the classic blinking code, but with strings. When I view the Com port for the the dongle with a terminal program, it should just keep repeating the same received set of strings over and over. 

   

 

   

I am really lost in here, What would i need to change in the main code of the psoc, to allow for a continuous string to be sent over the bluetooth after it has connected?

0 Likes
1 Solution
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

David here is the response from the Cypress Engineer.

   


Central Project should send data to the Peripheral Project (Test 1 and Test 2) without any UART interface. If that is the application, then it can be done over the same custom profile. If you check the Central Project, data is sent using: CyBle_GattcWriteWithoutResponse(cyBle_connHandle, &uartTxDataWriteCmd); We also have a statement: uartTxDataWriteCmd.value.val = uartTxData; Here the "uartTxData" is received over UART. Instead, we can hard-code this to the required array to be transmitted and also change the length of the bytes (uartTxDataWriteCmd.value.len ) to the required number of bytes to be sent.
This routine is in the App_Uart.c at line # 100-112. I hope this is what you need to resolve this issue.

View solution in original post

0 Likes
11 Replies
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

David I have been working with another forum user on this issue. Ble example 20 has some issues with the documentation and the example given doesn't work unless you have local echo turned off in your terminal programs.  Also the UBS serial link doesn't support Xon and X off or flow control.  If you look at the end of the Document you will see a file transfer example that allows transfer of files.  Please send me your code so that I can determine what you are trying to do.  

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

I detected some malware in your download.

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

It's really no different from what it looks like itself except for 4 lines I put in the main while loop:

   

UART_UartPutString("\n\rTest 1");
CyDelay(1000u);
UART_UartPutString("\n\rTest 2");
CyDelay(1000u);

   

I don't really know too well how the serial communication works between the bridge. If i type in the terminal of the psoc, then it does appear in the terminal of the dongle. The same can be said about the file transfer example. but when I just want those 4 lines to work so it sends those strings to the dongle, then it doesn't appear on the dongles terminal.

   

 

   

perhaps i am using an incorrect format? or line of code? sorry If I sound clueless, I am new to this hardware/software

0 Likes
Anonymous
Not applicable

Really? Weird, sorry I am not sure why that would do that.

   

 

   

Well it basically came from the github site was where i got it:https://github.com/cypresssemiconductorco/PSoC-4-BLE/tree/master/100_Projects_in_100_Days/Day020_BLE...

   

 

   

As I mentioned, all I did so far was add those 4 lines in the main while loop after where it says "CyBle_ProcessEvents();"

   

 

   

All I need it to do is, when the 4 commands get called, I should see those test1 and test2 strings appear on the terminal of the dongle port.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        I am out of my office for about an hour .I will add your code to my working program and see what happens.   
0 Likes
Anonymous
Not applicable

Thank you!

   

 

   

Any input really helps. 

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received
        David: Once you have these programs running on your Pioneer Ble and the dongle. You have a UART bridge and if you want to send the Test And Test messages these must come from the terminal programs not from the Ble Central or the dongle program. There are some terminal programs that allow scripts or programs to run on them. Then you can send the data from them.   
0 Likes
Anonymous
Not applicable

that is just the thing though, I don't want the terminal programs to be the one that sends those messages, I want the psoc to be programmed to send those messages from the central program, to the dongle, without any terminal program interference.

   

Will it not allow for this to happen?

0 Likes
Anonymous
Not applicable

So another thing I took into consideration was that the bluetooth dongle would have to be set so it continuously is reading, after the connection has been established, and then just print whatever message it receives from the PSoC, on the terminal program (thats where the UART_to_BLE_Peripheral would come from, and have to change slightly). I noticed in the code this particular case set:

   

        case CYBLE_EVT_GATTC_READ_BY_TYPE_RSP:
            readResponse = (CYBLE_GATTC_READ_BY_TYPE_RSP_PARAM_T *) eventParam;
            if(0 == memcmp((uint8 *)&(readResponse->attrData.attrValue[5]), (uint8 *)uartTxAttrUuid, 16)){
                txCharHandle = readResponse->attrData.attrValue[3];
                txCharHandle |= (readResponse->attrData.attrValue[4] << 8);
                infoExchangeState |= TX_ATTR_HANDLE_FOUND;
            }
            else if(0 == memcmp((uint8 *)&(readResponse->attrData.attrValue[5]), (uint8 *)uartRxAttrUuid, 16)){
                rxCharHandle = readResponse->attrData.attrValue[3];
                rxCharHandle |= (readResponse->attrData.attrValue[4] << 8);
                infoExchangeState |= RX_ATTR_HANDLE_FOUND;    
            }

   

 

   

which  if I understand it, is that the peripheral should be the set of code that does the reading, so the dongle should just continue reading as the PSoC would have to continue sending the value?

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

David here is the response from the Cypress Engineer.

   


Central Project should send data to the Peripheral Project (Test 1 and Test 2) without any UART interface. If that is the application, then it can be done over the same custom profile. If you check the Central Project, data is sent using: CyBle_GattcWriteWithoutResponse(cyBle_connHandle, &uartTxDataWriteCmd); We also have a statement: uartTxDataWriteCmd.value.val = uartTxData; Here the "uartTxData" is received over UART. Instead, we can hard-code this to the required array to be transmitted and also change the length of the bytes (uartTxDataWriteCmd.value.len ) to the required number of bytes to be sent.
This routine is in the App_Uart.c at line # 100-112. I hope this is what you need to resolve this issue.

0 Likes
Anonymous
Not applicable

Hi,David! I meet the same problem as yours. I want to transmit the ADC data constantly through BLE. I have read the reference but have no idea. Have you overcome all the difficulties? Can you give me some suggestions?

0 Likes