2021-09-17 12:57 AM
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);
}
Solved! Go to Solution.
2021-09-17 01:04 AM
Hi @gada ,
you could better start with the PER application in
best regards,
2021-09-17 01:04 AM
Hi @gada ,
you could better start with the PER application in
best regards,