I switched OFF the LORA Gateway just before message 7 was send out…yet at 22:55:26.436 I get “send success”…even the RUI stack printed +EVT:SEND_CONFIRMED_FAILED(4)…but api.lorawan.send() returned all good.
Subsequent messages shows “Send Fail”, which is correct. I find it that the very first message that is suppose to be lost shows as “Send Success”
What is the best practice to make sure I check for successful delivery?
The result of api.lorawan.send() is only showing that the uplink could be successfully enqueued. It does not mean that the packet is actually sent out.
The +EVT: messages are telling whether the uplink was transmitted.
Best is to use the callbacks that RUI3 provides for TX finished, RX data received, Join request result
RX callback will only be called if there is data from the LNS, could be a downlink packet or just a MAC command (fPort == 0)
TX callback is always called after TX/RX cycle finished.
You get the TX result from the status of the callback void sendCallback(int32_t status)
Example:
void sendCallback(int32_t status)
{
MYLOG("TX-CB", "TX status %d", status);
// digitalWrite(LED_BLUE, LOW);
tx_active = false;
if (status != RAK_LORAMAC_STATUS_OK)
{
cfm_error += 1;
}
switch (status)
{
case RAK_LORAMAC_STATUS_OK:
MYLOG("TX-CB", "Service performed successfully");
break;
case RAK_LORAMAC_STATUS_ERROR:
MYLOG("TX-CB", "An error occurred during the execution of the service");
break;
case RAK_LORAMAC_STATUS_TX_TIMEOUT:
MYLOG("TX-CB", "A Tx timeout occurred");
break;
case RAK_LORAMAC_STATUS_RX1_TIMEOUT:
MYLOG("TX-CB", "An Rx timeout occurred on receive window 1");
break;
case RAK_LORAMAC_STATUS_RX2_TIMEOUT:
MYLOG("TX-CB", "An Rx timeout occurred on receive window 2");
break;
case RAK_LORAMAC_STATUS_RX1_ERROR:
MYLOG("TX-CB", "An Rx error occurred on receive window 1");
break;
case RAK_LORAMAC_STATUS_RX2_ERROR:
MYLOG("TX-CB", "An Rx error occurred on receive window 2");
break;
case RAK_LORAMAC_STATUS_JOIN_FAIL:
MYLOG("TX-CB", "An error occurred in the join procedure");
break;
case RAK_LORAMAC_STATUS_DOWNLINK_REPEATED:
MYLOG("TX-CB", "A frame with an invalid downlink counter was received. The downlink counter of the frame was equal to the local copy of the downlink counter of the node.");
break;
case RAK_LORAMAC_STATUS_TX_DR_PAYLOAD_SIZE_ERROR:
MYLOG("TX-CB", "The MAC could not retransmit a frame since the MAC decreased the datarate. The payload size is not applicable for the datarate.");
break;
case RAK_LORAMAC_STATUS_DOWNLINK_TOO_MANY_FRAMES_LOSS:
MYLOG("TX-CB", "The node has lost MAX_FCNT_GAP or more frames.");
break;
case RAK_LORAMAC_STATUS_ADDRESS_FAIL:
MYLOG("TX-CB", "An address error occurred");
break;
case RAK_LORAMAC_STATUS_MIC_FAIL:
MYLOG("TX-CB", "Message integrity check failure");
break;
case RAK_LORAMAC_STATUS_MULTICAST_FAIL:
MYLOG("TX-CB", "Multicast error occurred");
break;
case RAK_LORAMAC_STATUS_BEACON_LOCKED:
MYLOG("TX-CB", "Beacon locked");
break;
case RAK_LORAMAC_STATUS_BEACON_LOST:
MYLOG("TX-CB", "Beacon lost");
break;
case RAK_LORAMAC_STATUS_BEACON_NOT_FOUND:
MYLOG("TX-CB", "Beacon not found");
break;
}
}
Problem is the same, void sendCallback(int32_t status) is not reporting the FIRST packet that gets dropped, only from the 2nd packet onwards is it reporting correctly.