2024-10-05 03:55 AM
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?
Solved! Go to Solution.
2024-10-07 09:19 AM - edited 2024-10-07 09:19 AM
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.
2024-10-07 09:19 AM - edited 2024-10-07 09:19 AM
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.
2024-11-01 09:36 AM
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?
2024-11-01 09:41 AM
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.