Multitech, Dragino OTAA/downlink issue

Hi, does anyone know about good document or web site which tells OTAA setting?

Using ABP was your node able to receive downlink data? Because if downlinks fail OTAA will not work as it relies on downlink of the join response.

kersing,

Thank you for your reply.

I double checked ABP behavior. So my EN can receive down link data in ABP mode.

I tried again in OTAA mode. But still it doesn’t work.

Here is the serial monitor responses.


21:11:31.774 -> 1827233: Unknown event
21:11:42.916 -> 2521943: EV_JOIN_FAILED
21:11:58.136 -> 3472702: Unknown event
21:12:09.324 -> 4173649: EV_JOIN_FAILED
21:13:09.337 -> 7925790: Unknown event
21:13:20.568 -> 8626738: EV_JOIN_FAILED


I don’t know why it shows “Unknown event”.

This is LMiC based code.


void onEvent (ev_t ev)
{
Serial.print(os_getTime());
Serial.print(": ");
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"));

  // Disable link check validation (automatically enabled
  // during join, but not supported by TTN at this time).
  LMIC_setLinkCheckMode(0);
  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;
  break;

case EV_TXCOMPLETE:
  Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)"));

  if (LMIC.txrxFlags & TXRX_ACK)
    Serial.println(F("Received ack"));

  // for debug
  Serial.println(LMIC.dataLen);

  if (LMIC.dataLen) 
  {
    Serial.println(F("Received "));
    Serial.println(LMIC.dataLen);
    Serial.println(F(" bytes of payload"));

    // downlink処理 ****************************
    uint8_t data[LMIC.dataLen];

    memcpy(&data, &(LMIC.frame + LMIC.dataBeg)[0], LMIC.dataLen);

    for(int i = 0; i < LMIC.dataLen; i++)
    {
      Serial.println(data[i]);
    }
    // *****************************************

  }

  // Schedule next transmission
  os_setTimedCallback(&sendjob, os_getTime() + sec2osticks(TX_INTERVAL), do_send);
  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;

default:
  Serial.println(F("Unknown event"));
  break;

}
}


Please let me know if I miss something.

Thank you,

Does anyone know about what’s wrong on me?

I tried to understand OTAA procedure by checking following web site.

This site tells and depicts the procedure like this :

image

After reading this explanation I’ve gotten some questions.

  1. How to use Network Session Key and Application Session Key
    Currently my end nodes join procedure succeeds, and my application can generate
    Network Session Key and Application Session Key. But those seem not to be used
    anywhere in my end nodes source code. As a result uplink does NOT happen.
    My question is how I can use generated Network Session Key and Application
    Session Key, and start uplink process.

  2. Where is Activation
    TTN application console shows “Activation”. Where can I see this action in the above
    procedure?
    First I thought it is #5: Session key generation. But time stamp of the Activation tells it
    happens between Join Request and Join Accept. Is this #2: End Device Authentication
    Session key generation?

  3. Why can NOT get EV_JOINED
    TTN gateway console tells Join Accepted. How come my end node can not get EV_JOINED?
    Are those “join” different?

Definitely I miss something. Please advise me.

I checked actual numbers onEvent (ev_t ev) function receives in my end node code. When it tells
“unknown event”, the number is 17. In lmic.h event types are defined as follows :

// Event types for event callback
enum _ev_t { EV_SCAN_TIMEOUT=1, EV_BEACON_FOUND,
EV_BEACON_MISSED, EV_BEACON_TRACKED, EV_JOINING,
EV_JOINED, EV_RFU1, EV_JOIN_FAILED, EV_REJOIN_FAILED,
EV_TXCOMPLETE, EV_LOST_TSYNC, EV_RESET,
EV_RXCOMPLETE, EV_LINK_DEAD, EV_LINK_ALIVE, EV_SCAN_FOUND,
EV_TXSTART };
typedef enum _ev_t ev_t;

17th event seems to be EV_TXSTART. But in my end node code, onEvent () function, the event is
not defined. It’s strange. My end node codes seems to be wrong!!

Can you provide correct endo node code, please?

Which Arduino LMIC are you using - not just the repro name, but which version please.

descartes,

Thank you for your reply. I’m not sure the version … It’s 2 years old, and slightly modified by Japanese agent. I’m pretty sure it’s too old. Please tell me the latest ang greatest version.

Whilst it has recently been deprecated, I am currently using this on Arduino + radio chip based devices:

You will have to set the I/O (pins) for the board you are using.

descartes,

Thanks! I’ll try.

I tried to implement some files from following library.

onEvent() function seems to treat events correctly. Serial console shows no “Unknown even”. This
is good. But still EV_JOIN_FAILED remains. This is not good.

image

I realized even if my EN tells “EV_TXSTART”, it does nothing. Currently EN code treat the event like
this :

    case EV_TXSTART:
        Serial.println(F("EV_TXSTART"));
        break;

<Question 1>
So question is what should EN do once it receives “EX_TXSTART”?


And I did another try. I took a look at the following notes.

Problems with downlink and OTAA

Uplink will often work right away, but sometimes downlink (and thus also OTAA) will not work directly. In practice, this is often due to inaccuracies in the receive window timing (see the previous section for details). If you run into problems with OTAA or downlink, it is a good idea to relax the RX mode timings to see if that helps by adding this to your setup somewhere:

LMIC_setClockError(MAX_CLOCK_ERROR * 10 / 100);

This function is intended to compensate for clock inaccuracy (up to ±10% in this example), but that also works to compensate for inaccuracies due to software delays. The downside of this compensation is a longer receive window, which means a higher battery drain. So if this helps, you might want to try to lower the percentage (i.e. lower the 10 in the above call), often 1% works well already.

And I tried some “relaxation” parameters, like 10, 20 etc. But still EN tells “EV_FAILED”.

<Question 2>
What should I consider if I can use setClockError() function?

Please give me any advice!

This, this every time. Start simple, test ABP uplinks AND downlinks, especially downlinks, because if your device is not able to receive, OTAA joins will never work.

Hi, descartes,

As I said above ABP works. So My EN can receive. My concern is OTAA.
Form today I continue my development using ABP. But I need OTAA.

Please advise me.

Could you let me know the proper process of LMiC event procedure?

As I showed above first my EN tells EV_JOINIG. After that EV_TXTSTART, and
EV_JOIN_FAILED comes. What is the correct process?

Please let me know.

Haven’t you changed library since?

Can you confirm that you have received downlinks when in ABP mode.

Until we absolutely know that your module can receive, it is pointless trying to debug something that for me, just works.

Hi, descartes,

I’ve changed library. My EN can receive downlinks in ABP mode, but can NOT receive in OTAA mode.

OK, so we can assume for now the hardware is OK.

The events are being reported correctly - so we need to check the setup on TTN - make sure all the keys match up.

Do you have access to a gateway so that you see the join requests coming in and see if the join accept is being transmitted. You can see this on the TTN gateway console as well.

The events are being reported correctly - so we need to check the setup on TTN - make sure all the keys match up.

I double-checked all the keys, LSB/MSB first setting. The keys are all correct.

Do you have access to a gateway so that you see the join requests coming in and see if the join accept is being transmitted. You can see this on the TTN gateway console as well.

I can see join request/accept on the TTN gateway console. And I can see activation on TTN application console.

Hi,

Could anyone let me know what will happen inside End Node software after getting EV_TXSTART?
Why it fails, EV_JOIN_FAILED? What did my End Node miss?

Seems very strange as you say that downlinks work for ABP.

The only other possibility is overload - how far apart is the device & the gateway?

Try or look at this code https://github.com/m2mlorawan/NodeSketch/blob/master/Example01.ino
Uncomment and select line OTAA.

I used it to join OTAA and try downlink. Both work OK.

Somsak