cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with the length of GATT Charactersitic in BLE_p2pServer_ota example

ledi001
Senior

Hello,

here in my code I want to send the received values of the payload directly to USART2. This works fine if I send less than 20 characters. If I send more, the program chrashed.

case P2P_SERVER_UART_C_WRITE_NO_RESP_EVT:
      /* USER CODE BEGIN Service1Char3_WRITE_NO_RESP_EVT */
    	uint16_t payload_Length = p_Notification->DataTransfered.Length;	// conversion uint8 Length to uint16 payload_Length
    	if(HAL_UART_Transmit_DMA(&huart2, p_Notification->DataTransfered.p_Payload, payload_Length) != HAL_OK)
		{
			Error_Handler();
		}

When I set a breakpoint and check the value of the length, a maximum value of 20 is displayed although the variable SizeUart_C = 50 (in file p2p_server.c).

Why is this the case?
What can I do to transfer more characters?

 

2 REPLIES 2
ledi001
Senior

I would like to provide more information on this topic here.

In cubeMX i have set the length of the value to 30 and the length of the "Value length" to Variable because i also want to send less than 30 characters.

2024-11-30_09h41_19.png

 

Then I checked the variable "SizeUart_C" in the file p2p_server_app.c , which has the value 30.

2024-11-30_09h45_57.png

In my opinion, the problem must lie in this program line:

uint16_t payload_Length = p_Notification->DataTransfered.Length;

However, I cannot understand why the value of “Length” does not become > 20. If I send 19 characters, the value in "payload_Length" is 19, but if I send 22 characters or more, the value here is 20.

STTwo-32
ST Employee

Hello @ledi001 

I suggest you take a look at the chapter 8.6.9 of the AN5289. It explains how you can maximize the data throughput.

 

Best Regards.

STTwo-32 

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Announcement

We’re moving the ST Community to a new platform to give you a better and more reliable community experience.