cancel
Showing results for 
Search instead for 
Did you mean: 

I have two nucleo-stm32wl boards. I want one board to transmit and other to receive(if possible later in listen mode). I modified pingpong example as attached code. But the communication doesn't happen at all. How should I synchronize or make it work !?

gada
Associate III
static void PingPong_Process(void)
{
	Radio.Sleep();
	APP_LOG(TS_ON, VLEVEL_L, "PP Task Start\n\r");
 
	if (isMaster == true) {	//Master
		switch (State) {
			case TX_TIMEOUT:
		        APP_LOG(TS_ON, VLEVEL_L, "Master Tx timeout\n\r");
			case TX:
				HAL_Delay(1000);
				HAL_Delay(Radio.GetWakeupTime() + RX_TIME_MARGIN + random_delay);
		        APP_LOG(TS_ON, VLEVEL_L, "Master Tx start\n\r");
//		         master sends PING
		        memcpy(BufferTx, PING, sizeof(PING) - 1);
		        Radio.Send(BufferTx, PAYLOAD_LEN);
		        break;
			default:
				break;
		}
	}
	else {					//Slave
		switch (State) {
		case RX:
			if (RxBufferSize > 0) {
				if (strncmp((const char*) BufferRx, PING, sizeof(PING) - 1) == 0) {
					UTIL_TIMER_Stop(&timerLed);
//					 switch off red led
					BSP_LED_Off(LED_RED);
//					 slave toggles green led
					BSP_LED_Toggle(LED_GREEN);
//					 Add delay between RX and TX
					HAL_Delay(Radio.GetWakeupTime() + RX_TIME_MARGIN);
					APP_LOG(TS_ON, VLEVEL_L, "Slave Rx Received - Wait for New Data\n\r");
				}
				else  //valid reception but not a PING as expected
				{
					APP_LOG(TS_ON, VLEVEL_L, "Not Pin - Slave Rx Again\n\r");
				}
				Radio.Rx(RX_TIMEOUT_VALUE);
			}
			break;
		case RX_ERROR:
		case RX_TIMEOUT:
			APP_LOG(TS_ON, VLEVEL_L, "Timeout Slave Rx start\n\r");
//			  random_delay = (Radio.Random()) >> 22; /*10bits random e.g. from 0 to 1023 ms*/
			HAL_Delay(Radio.GetWakeupTime() + RX_TIME_MARGIN + random_delay);
			Radio.Rx(RX_TIMEOUT_VALUE);
			break;
		default:
			break;
		}
	}
}
 
 
In Subghz_init added following - 
  /*starts reception*/
	if (isMaster == false) {	//Slave
        APP_LOG(TS_ON, VLEVEL_L, "Slave Rx start\n\r");
		Radio.Rx(RX_TIMEOUT_VALUE + random_delay);
	}
	else { //Master
        APP_LOG(TS_ON, VLEVEL_L, "Master Tx start\n\r");
        /* master sends PING*/
        memcpy(BufferTx, PING, sizeof(PING) - 1);
        Radio.Send(BufferTx, PAYLOAD_LEN);
	}
 

1 ACCEPTED SOLUTION

Accepted Solutions
YBOUV.1
Senior
1 REPLY 1
YBOUV.1
Senior