No cigar yet, at least not without modifying libraries such as TTN’s Arduino library.
The radio get freq
command seems to show the last frequency that was used by the built-in LoRaWAN stack. However, as LoRaWAN opens a receive window after transmitting, its response will be the frequency used during the RX1 or RX2 receive window. The first receive window RX1 uses the same frequency channel as the uplink. But most often RX2 is used last, both when a downlink is received (as TTN prefers RX2) and when no downlink occurred at all.
So, after the TTN library returns from ttn.sendBytes
, the uplink frequency has already been replaced by the RX1 or RX2 downlink frequency.
To circumvent this, one can change the library to await the first ok
(after the mac tx
command) and issue a radio get freq
before the first receive window is opened. For the TTN library that seems to work just fine, also when downlinks are received. In version 2.2.2, right after:
if (!sendPayload(mode, port, (uint8_t *)payload, length))
{
debugPrintMessage(ERR_MESSAGE, ERR_SEND_COMMAND_FAILED);
return TTN_ERROR_SEND_COMMAND_FAILED;
}
…add, quick & dirty but just for debugging:
// Debugging only:
// After transmitting the bytes, the RN2483 will open RX1 (same frequency)
// and possibly also RX2 (different frequency). Capture the last used
// frequency, before it is changed by opening RX2:
modemStream->write("radio get freq");
modemStream->write(SEND_MSG);
readLine(buffer, sizeof(buffer));
debugPrint(F("Sent uplink on freq: "));
debugPrintLn(buffer);