cancel
Showing results for 
Search instead for 
Did you mean: 

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

ledi001
Senior

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?

1 ACCEPTED SOLUTION

Accepted Solutions
STTwo-32
ST Employee

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 

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.

View solution in original post

3 REPLIES 3
STTwo-32
ST Employee

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 

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.

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?

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 

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.