Irregular execution of relay commands

Hi, I use Chirpstack Server + RAK7246 + RAK11310 + RAK19007 to control relay.
I take “LoRaWAN_OTAA_ABP” example and add:
pinMode(WB_IO2, OUTPUT);
digitalWrite(WB_IO2, HIGH);
pinMode(WB_IO4, OUTPUT);

"void lorawan_rx_handler(lmh_app_data_t *app_data)
Serial.printf(“LoRa Packet received on port %d, size:%d, rssi:%d, snr:%d, data:%s\n”,
app_data->port, app_data->buffsize, app_data->rssi, app_data->snr, app_data->buffer);
uint8_t relay_command = *app_data->buffer;
Serial.println(“LED on”);
digitalWrite(WB_IO4, LOW);
Serial.println(“LED off”);
digitalWrite(WB_IO4, HIGH);
It’s worked, i can send commands to relay, but I noticed that not all commands are executed, the gateway sends commands, but the relay does not respond, sometimes more often, sometimes less often, I can’t find the dependency. Maybe it’s something in the loop code, the rx command comes at the wrong time and ignored, but my knowledge is not enough to understand how to fix it.
Pls, help newbie :slight_smile:

Hi @chud.wy ,

Was the data received by the RAK11310 when you send command from the gateway? Also, take note that if you operate on Class A, you can only receive the command after each uplinks.

I know, switched to Class C.

I don’t know, because Sketch breaks with serial port open
but 8 of 10 times (approx) it works correctly, the relay switches.
Apparently it is necessary to deal with other problems first and then return to this one.