Skip to main content
ledi001
Associate III
October 5, 2024
Solved

BLE_p2pServer example with STM32WBA55 - How can i forward a payload tu UART?

  • October 5, 2024
  • 1 reply
  • 1082 views

Hi,

I use the BLE_p2pServer example as a basis and would like to forward the transmitted data directly to the UART1 interface. My idea would be to use here (in p2p_server_app.c) a HAL_UART_Transmit_DMA() function, but I fail to access the data due to an incorrect type conversion.

 

case P2P_SERVER_LED_C_WRITE_NO_RESP_EVT:
 /* USER CODE BEGIN Service1Char1_WRITE_NO_RESP_EVT */
 if(p_Notification->DataTransfered.p_Payload[1] == 0x01)
 {
 	// HAL_UART_Transmit_DMA(huart, pData, Size); ... here i want to insert the UART transmission funkction
 BSP_LED_On(LED_BLUE);
 LOG_INFO_APP("-- P2P APPLICATION SERVER : LED1 ON\n"); 
 P2P_SERVER_APP_Context.LedControl.Led1 = 0x01; /* LED1 ON */
 }
 if(p_Notification->DataTransfered.p_Payload[1] == 0x00)
 {
 BSP_LED_Off(LED_BLUE);
 LOG_INFO_APP("-- P2P APPLICATION SERVER : LED1 OFF\n"); 
 P2P_SERVER_APP_Context.LedControl.Led1 = 0x00; /* LED1 OFF */
 }
 /* USER CODE END Service1Char1_WRITE_NO_RESP_EVT */
 break;

 

In p2p_server.h are the typedef structures as follows:

 

typedef struct
{
 uint8_t *p_Payload;
 uint8_t Length;
} P2P_SERVER_Data_t;

typedef struct
{
 P2P_SERVER_OpcodeEvt_t EvtOpcode;
 P2P_SERVER_Data_t DataTransfered;
 uint16_t ConnectionHandle;
 uint16_t AttributeHandle;
 uint8_t ServiceInstance;
} P2P_SERVER_NotificationEvt_t;

 

Can someone tell me how I can access the data correctly?

Best answer by STTwo-32

Hello @ledi001 

The USART1 on the BLE_p2p Server example is configured and reserved for trace and debug. I suggest you use another API to send your payload.

Best Regards.

STTwo-32 

1 reply

STTwo-32
STTwo-32Best answer
Technical Moderator
October 7, 2024

Hello @ledi001 

The USART1 on the BLE_p2p Server example is configured and reserved for trace and debug. I suggest you use another API to send your payload.

Best Regards.

STTwo-32 

ledi001
ledi001Author
Associate III
November 1, 2024

Hello @STTwo-32 

now, i have implementet USART2. It seems that the example BLE_p2pServer_ota works with an operating system? For me, it is very difficult to find out where i can insert my user code.

If, for example, I want to forward certain data to a UART2 interface via DMA after a connection has been established, where is the right place to insert a HAL_UART_Tx_DMA transmission function in the code?

In the example provided, the function to check the payload is queried in the p2p_server_app.c file:

if(p_Notification->DataTransfered.p_Payload[1] == 0x01)
 {
 BSP_LED_On(LED_BLUE);
 LOG_INFO_APP("-- P2P APPLICATION SERVER : LED1 ON\n"); 
 P2P_SERVER_APP_Context.LedControl.Led1 = 0x01; /* LED1 ON */
 }
 if(p_Notification->DataTransfered.p_Payload[1] == 0x00)
 {
 BSP_LED_Off(LED_BLUE);
 LOG_INFO_APP("-- P2P APPLICATION SERVER : LED1 OFF\n"); 
 P2P_SERVER_APP_Context.LedControl.Led1 = 0x00; /* LED1 OFF */
 }

Is this the right place to insert a HAL_UART_Tx_DMA transmission function?

STTwo-32
Technical Moderator
November 1, 2024

Hello @ledi001 

This is a new question. 

Could you please close this post by selecting a best answer to the original post. And open a new thread on the ST Community with maximum details. 

Best Regards.

STTwo-32