Skip to main content
GHube.1
Associate II
Jun 17, 2021 1:23 PM UTC
Question

STM32Wl getting sent Data with OnRxDone

Hello there!

I just modified the PingPong example for the NUCLEO WL55JC1 Board so I have one defined transmitter and one receiver.

As you can see in the picture, the Master transmits continuously the bytes "PING" (wich I want to replace later).

/* Send the next PING frame */
 Buffer[0] = 'P';
 Buffer[1] = 'I';
 Buffer[2] = 'N';
 Buffer[3] = 'G';
 /* We fill the buffer with numbers for the payload */
 for (i = 4; i < BufferSize; i++)
 {
 Buffer[i] = i - 4;
 }
 APP_LOG(TS_ON, VLEVEL_L, "...PING\n\r");
 
 APP_LOG(TS_ON, VLEVEL_L, "Master Tx start\n\r");
 
 Radio.SetChannel(RF_FREQUENCY);
 
 /* Add delay between TX and RX =
 time Busy_signal is ON in RX opening window */
 HAL_Delay(Radio.GetWakeupTime() + TCXO_WORKAROUND_TIME_MARGIN);
 
 Radio.Send(Buffer, BufferSize);

The transmition works and the receiver gets into the command "OnRxDone", so they're both synchronized.

After OnRxDone status = TX means its again doing a Radio.RX. If this works, again OnRxDone, and so on. But now I want to output the sent data on a COM-Port.

OnRxDone command:

static void OnRxDone(uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr)
{
 
 
#if defined(USE_BSP_DRIVER)
 BSP_LED_Off(LED_RED) ;
 BSP_LED_Toggle(LED_GREEN) ;
#elif defined(MX_BOARD_PSEUDODRIVER)
 SYS_LED_Off(SYS_LED_RED) ;
 SYS_LED_Toggle(SYS_LED_GREEN) ;
#endif /* USE_BSP_DRIVER || MX_BOARD_PSEUDODRIVER */
 
 
 APP_LOG(TS_ON, VLEVEL_L, "OnRxDone\n\r");
 APP_LOG(TS_ON, VLEVEL_L, "RssiValue=%d dBm, SnrValue=%d\n\r", rssi, snr);
 
 Radio.Sleep();
 
 BufferSize = size;
 memcpy(Buffer, payload, BufferSize);
 
 RssiValue = rssi;
 SnrValue = snr;
 State = TX;
 UTIL_SEQ_SetTask((1 << CFG_SEQ_Task_PingPong_Process), CFG_SEQ_Prio_0);
 
}

If I output just Buffer it's empty. Any advices?

Notes:

Thats the built-in "send" command:

* \brief Sends the buffer of size. Prepares the packet to be sent and sets
 * the radio in transmission
 *
 * \param [IN]: buffer Buffer pointer
 * \param [IN]: size Buffer size
 */
 void ( *Send )( uint8_t *buffer, uint8_t size );

and that the "rx" command:

* \brief Rx Done callback prototype.
 *
 * \param [IN] payload Received buffer pointer
 * \param [IN] size Received buffer size
 * \param [IN] rssi RSSI value computed while receiving the frame [dBm]
 * \param [IN] snr SNR value computed while receiving the frame [dB]
 * FSK : N/A ( set to 0 )
 * LoRa: SNR value in dB
 */
 void ( *RxDone )( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr );

Thanks in advance!

Regards

This topic has been closed for replies.

2 replies

Tesla DeLorean
Guru
Jun 17, 2021 3:19 PM UTC

>>If I output just Buffer it's empty. Any advices?

Perhaps keep the receive and transmit buffers separate, and look at what payload/size actually enter with. If size is zero nothing will get copied.

In the OnRxDone() routine enqueue the payload/size data to the buffering you have for the COM Port output.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
IREMI.1
Visitor II
Jul 2, 2021 1:23 PM UTC

Hi, how do you output the buffer?

in FW version 1.1.0 (available soon) buffer is output by the example as such :

 APP_LOG(TS_ON, VLEVEL_H, "payload. size=%d \n\r", size);

 for (int i = 0; i < PAYLOAD_LEN; i++)

 {

  APP_LOG(TS_OFF, VLEVEL_H, "%02X", Buffer[i]);

  if (i % 16 == 15)

  {

   APP_LOG(TS_OFF, VLEVEL_H, "\n\r");

  }

 }