Using the Built-in NS

I have a RAK7289V2 gateway and my end nodes use RFM95W modules controlled using the LMIC library on Arduino-based Atmega328p MCUs. Packets appear on the dashboard Packet Capture, but the the nodes are “never seen” on LoRa>Applications. I want to use the built-in network server and to access the packets using MTTQ.fx on my my laptop. The packets are not seen by MTTQ either, and I think that problem is related to the feature that the nodes are never seen on LoRa>Applications. All keys are properly set both on LMIC and on the gateway. I am wondering if using White List packet filters could solve this. Any thoughts?

Welcome @fauxmg to RAK forum :slight_smile:

Seen packets on the Packet Capture doesn’t mean the payload was accepted on the application. If you can provide us logs on the device side both on the Built-in LNS Application and on the LMIC code, that would be help. The device is likely not joining the network successfully or there is error on the uplinks.

Here is my LMIC code: #include <lmic.h>
#include <hal/hal.h>
#include <SPI.h>

// End Device: Quinto

uint8_t sendPacket[3] = {0x01, 0xAB};

// Application Keys:
static const u1_t APPKEY[16] = { 0xd3, 0xe3, 0xb0, 0x1c, 0x12, 0x3d, 0xb2, 0x54, 0x74, 0xe9, 0x34, 0x64, 0xa0, 0x15, 0xba, 0x0e };
static const u1_t APPEUI[8] = { 0x41, 0x1f, 0x2e, 0x9d, 0x69, 0x67, 0x46, 0xe7 };

// Device Keys:
static const u1_t DEVEUI[8] = {0x2a, 0xce, 0x6e, 0xd7, 0x74, 0x64, 0x42, 0x1b};
static const u4_t DEVADDR = 0x8FF4F50B;
static const u1_t APPSKEY[16] = {0x51, 0xd8, 0xc8, 0xc3, 0x36, 0xbc, 0x05, 0x86, 0x26, 0x26, 0xa9, 0xe9, 0xdb, 0xc1, 0xd1, 0x67};
static const u1_t NWKSKEY[16] = {0x60, 0x34, 0x12, 0xd5, 0x1f, 0x1d, 0xc6, 0x75, 0x61, 0xb7, 0xfc, 0x4e, 0x8b, 0x40, 0x9d, 0x27};

// Define the job to be scheduled
static osjob_t sendjob;

void os_getArtEui (u1_t* buf) { }
void os_getDevEui (u1_t* buf) { }
void os_getDevKey (u1_t* buf) { }

void setup() {
Serial.begin(9600);
Serial.println(F(“Starting”));

// Initialize LMIC
os_init();

// Reset the MAC state
LMIC_reset();

// Set static session parameters
LMIC_setSession(0x0, DEVADDR, NWKSKEY, APPSKEY);

for (int i = 0; i < 72; ++i) {
    LMIC_disableChannel(i);
}

LMIC_selectSubBand(0);

// Disable link check validation
LMIC_setLinkCheckMode(0);

// Set data rate for TX, RX1
LMIC_setDrTxpow(DR_SF7, 14);

// Define the spreading factor for the RX2 window
LMIC.dn2Dr = DR_SF8;

// Start sending
do_send(&sendjob);

}

// Pinmap
const lmic_pinmap lmic_pins = {
.nss = 10,
.rxtx = LMIC_UNUSED_PIN,
.rst = 9,
.dio = {A3, A2, A1},
};

void loop() {
os_runloop_once();
}

// LMIC event handler
void onEvent(ev_t ev) {
Serial.print(os_getTime());
Serial.print(“: up count=”);
Serial.println(LMIC.seqnoUp);
switch(ev) {
case EV_SCAN_TIMEOUT:
Serial.println(F(“EV_SCAN_TIMEOUT”));
break;
case EV_BEACON_FOUND:
Serial.println(F(“EV_BEACON_FOUND”));
break;
case EV_BEACON_MISSED:
Serial.println(F(“EV_BEACON_MISSED”));
break;
case EV_BEACON_TRACKED:
Serial.println(F(“EV_BEACON_TRACKED”));
break;
case EV_JOINING:
Serial.println(F(“EV_JOINING”));
break;
case EV_JOINED:
Serial.println(F(“EV_JOINED”));
break;
case EV_RFU1:
Serial.println(F(“EV_RFU1”));
break;
case EV_JOIN_FAILED:
Serial.println(F(“EV_JOIN_FAILED”));
break;
case EV_REJOIN_FAILED:
Serial.println(F(“EV_REJOIN_FAILED”));
break;
case EV_TXCOMPLETE:
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.println(LMIC.dataLen);
Serial.println(F(” bytes of payload”));
}
// Schedule next transmission after 5 seconds
os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(5), do_send);

        // Store frame counters after transmission
        //storeFrameCounters();
        break;
    case EV_LOST_TSYNC:
        Serial.println(F("EV_LOST_TSYNC"));
        break;
    case EV_RESET:
        Serial.println(F("EV_RESET"));
        break;
    case EV_RXCOMPLETE:
        // data received in ping slot
        Serial.println(F("EV_RXCOMPLETE"));
        break;
    case EV_LINK_DEAD:
        Serial.println(F("EV_LINK_DEAD"));
        break;
    case EV_LINK_ALIVE:
        Serial.println(F("EV_LINK_ALIVE"));
        break;
    case EV_SCAN_FOUND:
        Serial.println(F("EV_SCAN_FOUND"));
        break;
    case EV_TXSTART:
        Serial.println(F("EV_TXSTART"));
        break;
    default:
        Serial.print(F("Unknown event: "));
        Serial.println((int)ev);
        break;
}

}

static void do_send(osjob_t* j) {
// Check if there is not a current TX/RX job running
if (LMIC.opmode & OP_TXRXPEND) {
Serial.println(F(“OP_TXRXPEND, not sending”));
} else {
// Prepare upstream data transmission at the next possible time.
LMIC_setTxData2(1, sendPacket, sizeof(sendPacket), 0);
Serial.println(F(“Packet queued”));
}
}

And here is a portion of the gateway log between receipt of one packet and receipt of the next: Tue May 28 09:46:09 2024 user.info lora_pkt_fwd[5132]: INFO: Received pkt from mote: 8FF4F50B (fcnt=12)
Tue May 28 09:46:09 2024 user.debug lora_pkt_fwd[5132]: Uplink Frame :
Tue May 28 09:46:09 2024 user.debug lora_pkt_fwd[5132]: 40 0B F5 F4 8F 82 0C 00
Tue May 28 09:46:09 2024 user.debug lora_pkt_fwd[5132]: 03 07 AF D1 FC A9
Tue May 28 09:46:09 2024 user.info lora_pkt_fwd[5132]: src/lora_pkt_fwd.c:3270:thread_up(): nb_pkt 1 send_report 0
Tue May 28 09:46:09 2024 user.info lora_pkt_fwd[5132]: src/lora_pkt_fwd.c:3144:dgram_push_pkt(): buff_index 272 buff_size 8169
Tue May 28 09:46:09 2024 user.info lora_pkt_fwd[5132]: JSON up: {“rxpk”:[{“jver”:1,“tmst”:525030013,“time”:“2024-05-28T13:46:11.495955Z”,“tmms”:1400939189495,“chan”:1,“rfch”:2,“freq”:904.100000,“mid”: 8,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“rssis”:-51,“lsnr”:13.8,“foff”:-2864,“rssi”:-50,“size”:14,“data”:“QAv19I+CDAADB6/R/Kk=”}]}
Tue May 28 09:46:09 2024 daemon.info gwBridge[12030]: gwBridgeReadCB: Frame size 295
Tue May 28 09:46:09 2024 daemon.info gwBridge[12030]: Enter gwBridgeFrameRcv, mdCreateEvent 0 Frame Len 295
Tue May 28 09:46:09 2024 daemon.info gwBridge[12030]: Uplink Packet from Gateway ac1f09fffe0fe947
Tue May 28 09:46:09 2024 daemon.info gwBridge[12030]: Uplink - {“rxpk”:[{“jver”:1,“tmst”:525030013,“time”:“2024-05-28T13:46:11.495955Z”,“tmms”:1400939189495,“chan”:1,“rfch”:2,“freq”:904.100000,“mid”: 8,“stat”:1,“modu”:“LORA”,“datr”:“SF7BW125”,“codr”:“4/5”,“rssis”:-51,“lsnr”:13.8,“foff”:-2864,“rssi”:-50,“size”:14,“data”:“QAv19I+CDAADB6/R/Kk=”}]}
Tue May 28 09:46:09 2024 daemon.info nwkSrv[12030]: Enter nsEventUplinkRcvCB, gwforward data len: 368, payload len: 14
Tue May 28 09:46:09 2024 daemon.info nwkSrv[12030]: Receive uplink message type 2
Tue May 28 09:46:09 2024 user.info lora_pkt_fwd[5132]: INFO: [up] PUSH_ACK received in 0 ms
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: mote 2ace6ed77464421b 8ff4f50b frame-count uplink - 12
Tue May 28 09:46:09 2024 daemon.info nwkSrv[12030]: nsDeduplicateFrameTimerHandler: Mote Devaddr: 0x8ff4f50b FCnt: 12 Best signal quality: 115
Tue May 28 09:46:09 2024 daemon.info nwkSrv[12030]: nsParseMacCommand: MAC commands in FOpts
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: lwParseMacCmd: receive mac cmd
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: mac-cmd: 03 07
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: lwParseMacCmd: mote 2ace6ed77464421b LINK_ADR_ANS status:0x07
Tue May 28 09:46:09 2024 daemon.info db[12030]: dbUpdateMoteEntry : SQL UPDATE moteTable SET DevAddr = ‘8ff4f50b’, NwksKey = ‘603412d51f1dc67561b7fc4e8b409d27’, AppsKey = ‘51d8c8c336bc05862626a9e9dbc1d167’, fCntUp = ‘0000000c’, fCntDown = ‘0000000b’, LastSeen = ‘6655e021’, Channel = ‘00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000’, ChanMask = ‘ffff00000000000000030000’, ChanMaskCtrl = ‘00’, GatewayID = ‘ac1f09fffe0fe947’, MoteSession0 = ‘0303000c00001ea070083740420f000000000000000000000000000000000000’, MoteStatUplink = 30136, MoteStatDownlink = 8653, MoteStatLost = 4294937299, MoteStatRSSI = ‘7e0000005b500000bf23000022000000fe0000000000000000000000’, MoteStatSNR = ‘01000000de6d0000c4060000070000006b000000820000001c0000000500000’, MoteStatDR = ‘d50000002500000017000000a77400000000000000000000000000000000000’, ClassBEnable = ‘0’, ClassBPingSlotPeriod
Tue May 28 09:46:09 2024 daemon.info nwkSrv[12030]: nsClassAProcessDataDown: ADR bit is set, record snr history then process ADR Req
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: us915_moteDataRateValidate : DataRate 4 validate NOK
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: us915_moteDataRateValidate : DataRate 3 validate OK
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: lwADR: Adjusting DR: 3 TxPwIdx: 3
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: Enqueue-mac-cmd: 03 36 ff ff 00
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: Dequeue-mac-cmd: 03 36 ff ff 00
Tue May 28 09:46:09 2024 daemon.info lorawan[12030]: lwDataDownComplete: Tx-DataDown DevAddr:0x8ff4f50b, Size: 17, FCnt: 11
Tue May 28 09:46:09 2024 daemon.info nwkSrv[12030]: 8ff4f50b send downlink via gw ac1f09fffe0fe947
Tue May 28 09:46:09 2024 daemon.info db[12030]: dbUpdateMoteEntry : SQL UPDATE moteTable SET DevAddr = ‘8ff4f50b’, NwksKey = ‘603412d51f1dc67561b7fc4e8b409d27’, AppsKey = ‘51d8c8c336bc05862626a9e9dbc1d167’, fCntUp = ‘0000000c’, fCntDown = ‘0000000c’, LastSeen = ‘6655e021’, Channel = ‘00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000’, ChanMask = ‘ffff00000000000000030000’, ChanMaskCtrl = ‘00’, GatewayID = ‘ac1f09fffe0fe947’, MoteSession0 = ‘0303000c00001ea070083740420f000000000000000000000000000000000000’, MoteStatUplink = 30136, MoteStatDownlink = 8654, MoteStatLost = 4294937299, MoteStatRSSI = ‘7e0000005b500000bf23000022000000fe0000000000000000000000’, MoteStatSNR = ‘01000000de6d0000c4060000070000006b000000820000001c0000000500000’, MoteStatDR = ‘d50000002500000017000000a77400000000000000000000000000000000000’, ClassBEnable = ‘0’, ClassBPingSlotPeriod
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: Enter gwBridgeRcvNsDownlinkCB, pkt len: 312, payload size: 17
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: gwBridgeParseDownlink: gen gateway ac1f09fffe0fe947 downlink
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: gwBridgePullRespToken, [232:207] pull resp token:59599 devaddr: 0x8ff4f50b
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: gwBridgePullRespToken, found devaddr: 0x8ff4f50b
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: gwBridgeGenUdpDownlink, txpkt json: {“txpk”:{“imme”:false,“tmst”:526030013,“freq”:923.900000,“rfch”:2,“powe”:14,“modu”:“LORA”,“datr”:“SF7BW500”,“codr”:“4/5”,“ipol”:true,“size”:17,“data”:“YAv19I+FCwADNv//AE+MaK0=”}}
Tue May 28 09:46:10 2024 user.info lora_pkt_fwd[5132]: INFO: [down] PULL_RESP received - token[232:207] :slight_smile:
Tue May 28 09:46:10 2024 user.info lora_pkt_fwd[5132]: JSON down: {“txpk”:{“imme”:false,“tmst”:526030013,“freq”:923.900000,“rfch”:2,“powe”:14,“modu”:“LORA”,“datr”:“SF7BW500”,“codr”:“4/5”,“ipol”:true,“size”:17,“data”:“YAv19I+FCwADNv//AE+MaK0=”}}
Tue May 28 09:46:10 2024 user.debug lora_pkt_fwd[5132]: DownLink Frame :
Tue May 28 09:46:10 2024 user.debug lora_pkt_fwd[5132]: 60 0B F5 F4 8F 85 0B 00
Tue May 28 09:46:10 2024 user.debug lora_pkt_fwd[5132]: 03 36 FF FF 00 4F 8C 68
Tue May 28 09:46:10 2024 user.debug lora_pkt_fwd[5132]: AD
Tue May 28 09:46:10 2024 user.info lora_pkt_fwd[5132]: INFO: Packet ENQUENUE SUCCESS on SX1301/SX1302: 1
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: gwBridgeReadCB: Frame size 12
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: Enter gwBridgeFrameRcv, mdCreateEvent 0 Frame Len 12
Tue May 28 09:46:10 2024 daemon.info gwBridge[12030]: Uplink Packet from Gateway ac1f09fffe0fe947
Tue May 28 09:46:10 2024 user.debug lora_pkt_fwd[5132]: gps sat : 6, gps mod : A, gps status: 1
Tue May 28 09:46:10 2024 user.debug lora_pkt_fwd[5132]: DEBUG: peek packet with count_us=523354531 at index 0
Tue May 28 09:46:10 2024 user.info lora_pkt_fwd[5132]: src/lora_pkt_fwd.c:4423:thread_jit(): lgw_send done on rf_chain 1: count_us=523354531
Tue May 28 09:46:11 2024 user.info lora_pkt_fwd[5132]: src/lora_pkt_fwd.c:2697:fetch_packets(): Current time: 2024-05-28 13:46:11 UTC
Tue May 28 09:46:11 2024 user.debug lora_pkt_fwd[5132]: rrd_statistic_up 376 uplinkTqByAirtime : dr = 3, timeonair = 41, tm = 1716903971
Tue May 28 09:46:11 2024 user.debug lora_pkt_fwd[5132]: rrd_statistic_up 378 uplinkTqByPkt : dr = 3, tm = 1716903971
Tue May 28 09:46:11 2024 user.debug lora_pkt_fwd[5132]: rrd_statistic_up 380 ChanBusyByAirtime chan 14, timeonair = 41, tm = 1716903971
Tue May 28 09:46:11 2024 user.info lora_pkt_fwd[5132]: INFO: Received pkt from mote: 8FF4F50B (fcnt=13)

Packets are all lost on the AS… I’m frustrated! Happy for help! Thanks!