Kerlink: OTAA joinRequest is ok, but joinAccept not received by node

Hello,

I am using mdot as node. I can see in the TTN console:
*The join requests sent by the mdot
*The join ACCEPT sent by the gateway

But my node can’t receive it.

I used this code to test OTAA on my mdot:

#include "mbed.h"
#include "mDot.h"
#include "MTSLog.h"
#include "MTSText.h"
#include <string>
#include <vector>

using namespace mts;

#define MIN(a,b) (((a)<(b))?(a):(b))
#define MAX(a,b) (((a)>(b))?(a):(b))

// AppEUI
uint8_t AppEUI[8]={...};
// AppKey
uint8_t AppKey[16]={....};

// Some defines for the LoRa configuration
/*
 * EU868 Datarates
 * ---------------
 * DR0 - SF12BW125
 * DR1 - SF11BW125
 * DR2 - SF10BW125
 * DR3 - SF9BW125
 * DR4 - SF8BW125
 * DR5 - SF7BW125
 * DR6 - SF7BW250
 *
 * US915 Datarates
 * ---------------
 * DR0 - SF10BW125
 * DR1 - SF9BW125
 * DR2 - SF8BW125
 * DR3 - SF7BW125
 * DR4 - SF8BW500
 */
#define LORA_SF mDot::DR0
#define LORA_ACK 0
#define LORA_TXPOWER 14

// Ignoring sub band for EU modules.
static uint8_t config_frequency_sub_band = 1;

// Serial via USB for debugging only
Serial pc(USBTX,USBRX);

int main()
{
    int32_t ret;
    mDot* dot;
    std::vector<uint8_t> send_data;
    std::vector<uint8_t> recv_data;
    std::vector<uint8_t> nwkId;
    std::vector<uint8_t> nwkKey;

    pc.baud(115200);
    pc.printf("TTN OTAA mDot\n\r");

    // get a mDot handle
    dot = mDot::getInstance();

    dot->setLogLevel(MTSLog::TRACE_LEVEL);

    logInfo("Checking Config");

    uint8_t *it = AppEUI;
    for (uint8_t i = 0; i<8; i++)
        nwkId.push_back((uint8_t) *it++);
    
    it = AppKey;
    for (uint8_t i = 0; i<16; i++)
        nwkKey.push_back((uint8_t) *it++);

    logInfo("Resetting Config");
    // reset to default config so we know what state we're in
    dot->resetConfig();

    // Set Spreading Factor, higher is lower data rate, smaller packets but longer range
    // Lower is higher data rate, larger packets and shorter range.
    logInfo("Set SF");
    if((ret = dot->setTxDataRate( LORA_SF )) != mDot::MDOT_OK) {
        logError("Failed to set SF %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo("Set TxPower");
    if((ret = dot->setTxPower( LORA_TXPOWER )) != mDot::MDOT_OK) {
        logError("Failed to set Tx Power %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo("Set Public mode");
    if((ret = dot->setPublicNetwork(true)) != mDot::MDOT_OK) {
        logError("failed to set Public Mode %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo("Set AUTO_OTA Join mode");
    if((ret = dot->setJoinMode(mDot::AUTO_OTA)) != mDot::MDOT_OK) {
        logError("Failed to set AUTO_OTA Join Mode %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo("Set Ack");
    // 1 retries on Ack, 0 to disable
    if((ret = dot->setAck( LORA_ACK)) != mDot::MDOT_OK) {
        logError("Failed to set Ack %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    // Library ignores the frequency sub band for 868MHz in EU
    if ((ret = dot->setFrequencySubBand(config_frequency_sub_band)) != mDot::MDOT_OK) {
        logError("Failed to set frequency sub band %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo("Set Network Id");
    if ((ret = dot->setNetworkId(nwkId)) != mDot::MDOT_OK) {
        logError("Failed to set Network Id %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }
    logInfo("Set Network Key");
    if ((ret = dot->setNetworkKey(nwkKey)) != mDot::MDOT_OK) {
        logError("Failed to set Network Id %d:%s", ret, mDot::getReturnCodeString(ret).c_str());
    }

    logInfo("Saving Config");
    // Save config
    if (! dot->saveConfig()) {
        logError("failed to save configuration");
    }

    pc.printf("Device ID {");
    std::vector<uint8_t> deviceId;
    deviceId = dot->getDeviceId();
    for (std::vector<uint8_t>::iterator it = deviceId.begin() ; it != deviceId.end(); ++it) {
        pc.printf("0x%2.2X",*it );
        pc.printf("%s", it != (deviceId.end() -1 ) ? ", " : " " );
    }
    pc.printf("}\r\n");

    std::vector<uint8_t> netId;
    pc.printf("Network Id/App EUI {");
    netId = dot->getNetworkId();
    for (std::vector<uint8_t>::iterator it = netId.begin() ; it != netId.end(); ++it) {
        pc.printf("0x%2.2X", *it );
        pc.printf("%s", it != (netId.end() -1 ) ? ", " : " " );
    }
    pc.printf("}\r\n");

    std::vector<uint8_t> netKey;
    pc.printf("Network Key/App Key {");
    netKey = dot->getNetworkKey();
    for (std::vector<uint8_t>::iterator it = netKey.begin() ; it != netKey.end(); ++it) {
        pc.printf("0x%2.2X", *it );
        pc.printf("%s", it != (netKey.end() -1 ) ? ", " : " " );
    }
    pc.printf("}\r\n");

    logInfo("Joining Network");
    while ((ret = dot->joinNetwork()) != mDot::MDOT_OK) {
        logError("failed to join network [%d][%s]", ret, mDot::getReturnCodeString(ret).c_str());
        wait_ms(dot->getNextTxMs() + 1);
    }

    logInfo("Joined Network");

}

and this is what I got in the debug:

[TRACE] Enable centi band
[TRACE] Initiating join...
[TRACE] Join Network - Auto OTA
[TRACE] Join attempt #4
[DEBUG] Send Join Packet with DR0
[TRACE] Number of enabled channels: 3 Mask: 00ff
[TRACE] Check freq: 0 - 868100000
[TRACE] Preparing frame
[TRACE] FRAME_TYPE_JOIN_REQ
[DEBUG] txPower: 14 AntG: 3 radioPower: 11
[INFO] TX Frequency: 868100000 SF: 12 BW: 125 kHz POW: 11 dBm
[DEBUG] Time on air: 23 bytes 1482 ms
[DEBUG] Time off air: 148200 ms duty-cycle: 1.0 %
[TRACE] Rx Window 1 - Frequency: 868100000 BW: 0 SF: 12
[TRACE] Rx Window 2 - Frequency: 869525000 BW: 0 SF: 12
[TRACE] Windows Expired
[ERROR] Failed to join network
[ERROR] failed to join network [-4][Join Error]

On the gateway, here is the JOIN_ACCEPT:

{
  "gw_id": "...",
  "payload": "IIahjicSMdDMqdc4EejLQxW+VZpnfJ8EOoXdrIw4lBT3",
  "lora": {
    "spreading_factor": 12,
    "bandwidth": 125,
    "air_time": 1810432000
  },
  "coding_rate": "4/5",
  "timestamp": "2017-08-08T15:56:26.114Z",
  "frequency": 869525000
}

Any idea what is wrong? or how can I debug the issue? is there any way to see logs in the kerlink?

Thanks!

Hi,

I think the problem is the time on air.
According to your logs it is around 1482ms, which is a very high number.
The solution would be to move the node closer to the nearest usable gateway.

well my node was very close to the gateway so I move it some meters away . The time on air depends on the SF but even with small time on air, the problem persist:

SF=7:

[TRACE] Enable centi band
[TRACE] Initiating join...
[TRACE] Join Network - Auto OTA
[TRACE] Join attempt #14
[DEBUG] Send Join Packet with DR5
[TRACE] Number of enabled channels: 3 Mask: 00ff
[TRACE] Check freq: 1 - 868300000
[TRACE] Preparing frame
[TRACE] FRAME_TYPE_JOIN_REQ
[DEBUG] txPower: 14 AntG: 3 radioPower: 11
[INFO] TX Frequency: 868300000 SF: 7 BW: 125 kHz POW: 11 dBm
[DEBUG] Time on air: 23 bytes 61 ms
[DEBUG] Time off air: 6100 ms duty-cycle: 1.0 %
[TRACE] Rx Window 1 - Frequency: 868300000 BW: 0 SF: 7
[TRACE] Rx Window 2 - Frequency: 869525000 BW: 0 SF: 12
[TRACE] Enable centi band
[TRACE] Windows Expired
[ERROR] Failed to join network
[ERROR] failed to join network [-4][Join Error]

TTN console, time on air 71.9ms:

{
  "gw_id": "eui-0000024b0803094c",
  "payload": "INbniAhMqK++ckoLI+SInW9HgRc2igivTG3alsyt5Giz",
  "lora": {
    "spreading_factor": 7,
    "bandwidth": 125,
    "air_time": 71936000
  },
  "coding_rate": "4/5",
  "timestamp": "2017-08-09T07:20:48.616Z",
  "frequency": 868300000
}

SF:12

[TRACE] Enable centi band
[TRACE] Initiating join...
[TRACE] Join Network - Auto OTA
[TRACE] Join attempt #13
[DEBUG] Send Join Packet with DR0
[TRACE] Number of enabled channels: 3 Mask: 00ff
[TRACE] Check freq: 1 - 868300000
[TRACE] Preparing frame
[TRACE] FRAME_TYPE_JOIN_REQ
[DEBUG] txPower: 14 AntG: 3 radioPower: 11
[INFO] TX Frequency: 868300000 SF: 12 BW: 125 kHz POW: 11 dBm
[DEBUG] Time on air: 23 bytes 1482 ms
[DEBUG] Time off air: 148200 ms duty-cycle: 1.0 %
[TRACE] Rx Window 1 - Frequency: 868300000 BW: 0 SF: 12
[TRACE] Rx Window 2 - Frequency: 869525000 BW: 0 SF: 12
[TRACE] Windows Expired
[ERROR] Failed to join network
[ERROR] failed to join network [-4][Join Error]

TTn concole, time on air 1810ms:

{
  "gw_id": "eui-0000024b0803094c",
  "payload": "IIdYFA0V+XO0vdNpKBqqgvBKLvc9rwyueFU5kd9gbhHi",
  "lora": {
    "spreading_factor": 12,
    "bandwidth": 125,
    "air_time": 1810432000
  },
  "coding_rate": "4/5",
  "timestamp": "2017-08-09T07:18:22.733Z",
  "frequency": 869525000
}

On the poly_packet_forwarder logs, I got this:

### [UPSTREAM] ###
# RF packets received by concentrator: 0
# CRC_OK: 0.00%, CRC_FAIL: 0.00%, NO_CRC: 0.00%
# RF packets forwarded: 0 (0 bytes)
# PUSH_DATA datagrams sent: 1 (111 bytes)
# PUSH_DATA acknowledged: 0.00%
### [DOWNSTREAM] ###
# PULL_DATA sent: 3 (0.00% acknowledged)
# PULL_RESP(onse) datagrams received: 0 (0 bytes)
# RF packets sent to concentrator: 0 (0 bytes)
# TX errors: 0

Any way to have more debug logs?

Hi @Sabrina,
I´ve got a very similar problem, how have you fixed it?
At first everything worked fine until I´ve updated the Gateway to Firmware PROD_FW=wirmaV2_wirnet_v3.1-rc3. Now the packet forwarder is running, ttn receives the join request, but the join accept is not received by the node.

can someone help?

I’ve got the same issue here :frowning:
Anybody fixed it?

jep, I changed the Firewall Settings at the gateway

Same problem here, what did you change?

If I look at the /etc/sysconfig/network file, it says that the firewall is off (=no)