Pycom fipy connects ok with ABP but not OTAA


(Mike) #1

I have a Things Gateway setup here with a ThingsNode connecting and talking to it using ABP with no issue.

However, my poor little Pycom fipy will only connect with ABP. If I try the example below using OTAA I get not a peep on the TTN gateway and the fipy just loops printing “Not joined yet”.

Any ideas on how I can debug, see what is happening?

from network import LoRa
import time
import binascii

lora = LoRa(mode=LoRa.LORAWAN)

app_eui = binascii.unhexlify('<app eui key here>')
app_key = binascii.unhexlify('<app key here>')

lora.join(activation=LoRa.OTAA, auth=(app_eui, app_key), timeout=0)

# wait until the module has joined the network
while not lora.has_joined():
    time.sleep(2.5)
    print('Not joined yet...')

print('Network joined!')

(Arjan) #2

As with ABP a node does not really “connect” or join (but gets all its secrets during programming, so is simply always ready to send data): so with ABP you can actually send data, and see that data in the gateway traffic (and application data) in TTN Console? Or did you not try sending actual data?

Again, just to be sure: “not a peep” means that TTN Console shows absolutely nothing at all for OTAA? (Not even an OTAA Join Request, let alone a Join Accept?)


(Mike) #3

Hi Arjan

First of all, apologises if my terminology is not quite correct, still getting use to LoraWan technologises.

With ABP I can see the test bytes come through the TTN console and they get passed to my HTTP handler with no issues.

With OTAA, it never gets past the “while not lora.has_joined():” loop and there is nothing at all in the console. I have tried setting the timeout to 30000 and it just times out after 30 seconds.

Just to confirm my TTN gateway and settings are correct, I can see the registration and first data packet from my TTN node with no issues.

Just to confirm the code is correct, I have explicitly set the Lora module to use 868mhz as per “lora = LoRa(mode=LoRa.LORAWAN, region=LoRa.EU868)”. Apart from that, the code is per my example.

Regards
Mike


(Mike) #4

Just noticed that there is a “join request” in the Gateway log, but it doesn’t get acknowledged. Something at least.


(Arjan) #5

If there’s only an OTAA Join Request, but no OTAA Join Accept, then one of the following applies:

  • TTN has rejected the request due to invalid keys
  • or, TTN has elected another gateway to send the Join Accept (only applies if another gateway received the Join Request as well)
  • or, TTN has not found a gateway that is suitable to send the Join Accept at all (might apply if TTN thinks you’re using a single-channel test gateway that does not support downlinks).

If there is also a Join Accept, then somehow the node did not receive that.

See screenshots at Things Uno not joining anymore for what’s expected. Also, the “Trace” part in the gateway’s traffic in TTN Console might give you some clues.

So that TTN Node is using OTAA as well? Then TTN knows the gateway supports downlinks. You might still need to reverse the keys when using different hardware. (I don’t know if the LoPy expects MSB or LSB for its keys.)

LoRaWAN :wink:


(Mike) #6

Got there in the end, it seems that the device EUI was wrong.

I think the Pycom documentation is possibly at fault, in that when you add the node, you need to know the value assigned to the device EUI and use that value rather than the seemingly random value assigned by the TTN console.

For reference, I included the following piece of code to the example OTAA.

print(‘DeviceEui Hex Payload ’ + ‘’.join(’{:02x}’.format(x) for x in lora.mac()))

PS I never did find out how to “trace” in the gateway traffic.Sounds kinda useful.