Whilst testing LMIC (MCCI version, although that not important), got OTAA working - I was looking at proving downlinks and found this code on a website, its not mine so credit to whoever it was.
case EV_TXCOMPLETE:
Serial.print(millis());
Serial.print(" - ");
Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));
if (LMIC.txrxFlags & TXRX_ACK)
Serial.println(F("Received ack"));
if (LMIC.dataLen) {
Serial.println(F("Received "));
Serial.print(LMIC.dataLen);
Serial.println(F(" bytes of payload"));
Serial.print("txCnt :"); Serial.println(LMIC.txCnt);
Serial.print("txrxFlags :"); Serial.println(LMIC.txrxFlags);
Serial.print("dataBeg :"); Serial.println(LMIC.dataBeg);
for (int i = 0; i < LMIC.dataLen; i++) {
if (LMIC.frame[LMIC.dataBeg + i] < 0x10) {
Serial.print(F("0"));
}
Serial.print(LMIC.frame[LMIC.dataBeg + i], HEX);
}
}
Serial.println("");
// Schedule next transmission
powerdown=true;
break;
I thought it was pretty cool, using the console you can then schedule a downlink and validate it in the device logs, even showing the payload too.
... done sleeping
716: EV_TXSTART
716: Packet queued
717: 189464 - EV_TXCOMPLETE (includes waiting for RX windows)
Received
6 bytes of payload
txCnt :0
txrxFlags :17
dataBeg :9
ABCDEFFEDCBA
718: EV_TXSTART
go to sleep ...
Works like a charm, anyway I thought I would share what I found - again I cant take credit, thanks to the author whoever they are.