Lostik+RaspberryPi+LairdGW Setup issues

Setup:
Broadcast: Raspberry Pi ZeroW with Lostik adapter.
Gateway: Laird RG191 - sitting approximately 30 ft from Pi.
Location: California, USA

This is the output of the test program:

%python3 senderp_otaa.py /dev/ttyUSB0
using port:  /dev/ttyUSB0
sent cmd: b'sys reset' -> got: b'RN2903 1.0.3 Aug  8 2017 15:11:09\r\n'
Setting channel parameters:
sent cmd: b'mac pause' -> got: b'4294967245\r\n'
sent cmd: b'radio set pwr 14' -> got: b'ok\r\n'
sent cmd: b'radio set sf sf10' -> got: b'ok\r\n'
sent cmd: b'radio set bw 125' -> got: b'ok\r\n'
sent cmd: b'radio set freq 923300000' -> got: b'ok\r\n'
sent cmd: b'mac resume' -> got: b'ok\r\n'
Getting channel parameters:
sent cmd: b'radio get bt' -> got: b'0.5\r\n'
sent cmd: b'radio get mod' -> got: b'lora\r\n'
sent cmd: b'radio get freq' -> got: b'923300000\r\n'
sent cmd: b'radio get pwr' -> got: b'14\r\n'
sent cmd: b'radio get sf' -> got: b'sf10\r\n'
sent cmd: b'radio get afcbw' -> got: b'41.7\r\n'
sent cmd: b'radio get bitrate' -> got: b'50000\r\n'
sent cmd: b'radio get fdev' -> got: b'25000\r\n'
sent cmd: b'radio get prlen' -> got: b'8\r\n'
sent cmd: b'radio get crc' -> got: b'on\r\n'
sent cmd: b'radio get iqi' -> got: b'off\r\n'
sent cmd: b'radio get cr' -> got: b'4/5\r\n'
sent cmd: b'radio get wdt' -> got: b'15000\r\n'
sent cmd: b'radio get bw' -> got: b'125\r\n'
Setting LoRaWAN parameters:
sent cmd: b'mac set ch dcycle 0 9' -> got: b'invalid_param\r\n'
sent cmd: b'mac set ch dcycle 1 99' -> got: b'invalid_param\r\n'
sent cmd: b'mac set ch dcycle 2 99' -> got: b'invalid_param\r\n'
sent cmd: b'mac set appkey 1Bxxxxxredactedxxxx05' -> got: b'ok\r\n'
sent cmd: b'mac set appeui 70xxxxxxredactedxxxxB' -> got: b'ok\r\n'
sent cmd: b'mac save' -> got: b'ok\r\n'
Joining... got: b'ok\r\n'
Joining... got: b''
Joining... got: b'denied\r\n'
Joining... got: b''
Joining... got: b''
Joining... got: b''
Joining... got: b''

Here’s the code snippet of trying to join:

ser.write(b'mac join otaa\r\n')
rval = ''
while "accepted" not in rval:
    rval = str(ser.readline())
    if (DEBUGMODE==1):
        print('Joining... got: '+rval)

I get an OK when I try to join otaa, but never seem to get an ‘accepted’ response.

Very occasionally I seem to get a message passed through to the TTN. (There seems to be no relationship to me setting SF or BW) . I would have thought that with my own gateway (which is connected and shows up on TTN maps) I would have no problem with a radio connection.

Can someone give me some hints on how best to connect or at least troubleshoot my set up?

Here’s some screenshots of the various systems (redacted for Keys, MacAdd etc)

GatewayTraffic LairdGWSetup ThingRequest

Does the TTN console gateway page show a join reply?

1 Like

Yes - but only once in a blue moon. I must have run that same test 20-30 times this morning and I only see one join request.GatewayTraffic

If you see only one request on the gateway out of dozens that suggests to me your node is not configured correctly. The rn2903 by default uses 64 channels, however your gateway just listens on 8 of them. You need to modify your code to disable the other channels.
Check the TTN device library source for the right initialization sequence for US915.

Thank you. That CPP code is for an arduino. I’m on a Rpi. Is this something I need to recompile onto a Pi? Is there a simple set of commands to (say):

disable all channels.
enable the right 8 channels.

No, you need to find the subset of code required for US915 configuration and write equivalent python code.

That is basically what the US915 initialisation code does.

I modified that US915 CPP into a python script (anyone in the future who wants it, let me know - it’s ugly but it worked!) Basically changes 8,9,10,11,12,13,14,15,and 65 are on. Now when I run my test script with these commands, the unit communicates with the Sentrius Gateway every time. I see traffic on the gateway (Join requests) and I see the same join requests on the TTN console, however I never get an accepted message allowing me to send a real payload.

using port:  /dev/ttyUSB0
sent cmd: b'sys reset' -> got: b'RN2903 1.0.3 Aug  8 2017 15:11:09\r\n'
Setting channel parameters:
sent cmd: b'mac pause' -> got: b'4294967245\r\n'
sent cmd: b'radio set pwr 14' -> got: b'ok\r\n'
sent cmd: b'radio set sf sf10' -> got: b'ok\r\n'
sent cmd: b'radio set bw 125' -> got: b'ok\r\n'
sent cmd: b'radio set freq 923300000' -> got: b'ok\r\n'
sent cmd: b'mac resume' -> got: b'ok\r\n'
Getting channel parameters:
sent cmd: b'radio get bt' -> got: b'0.5\r\n'
sent cmd: b'radio get mod' -> got: b'lora\r\n'
sent cmd: b'radio get freq' -> got: b'923300000\r\n'
sent cmd: b'radio get pwr' -> got: b'14\r\n'
sent cmd: b'radio get sf' -> got: b'sf10\r\n'
sent cmd: b'radio get afcbw' -> got: b'41.7\r\n'
sent cmd: b'radio get bitrate' -> got: b'50000\r\n'
sent cmd: b'radio get fdev' -> got: b'25000\r\n'
sent cmd: b'radio get prlen' -> got: b'8\r\n'
sent cmd: b'radio get crc' -> got: b'on\r\n'
sent cmd: b'radio get iqi' -> got: b'off\r\n'
sent cmd: b'radio get cr' -> got: b'4/5\r\n'
sent cmd: b'radio get wdt' -> got: b'15000\r\n'
sent cmd: b'radio get bw' -> got: b'125\r\n'
Setting LoRaWAN parameters:
sent cmd: b'mac set ch dcycle 0 9' -> got: b'invalid_param\r\n'
sent cmd: b'mac set ch dcycle 1 99' -> got: b'invalid_param\r\n'
sent cmd: b'mac set ch dcycle 2 99' -> got: b'invalid_param\r\n'
sent cmd: b'mac set ch status 0 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 1 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 2 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 3 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 4 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 5 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 6 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 7 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 8 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 8 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 9 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 9 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 10 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 10 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 11 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 11 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 12 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 12 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 13 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 13 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 14 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 14 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 15 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch drrange 15 0 3' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 16 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 17 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 18 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 19 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 20 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 21 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 22 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 23 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 24 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 25 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 26 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 27 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 28 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 29 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 30 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 31 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 32 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 33 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 34 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 35 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 36 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 37 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 38 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 39 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 40 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 41 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 42 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 43 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 44 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 45 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 46 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 47 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 48 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 49 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 50 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 51 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 52 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 53 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 54 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 55 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 56 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 57 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 58 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 59 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 60 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 61 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 62 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 63 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 64 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 65 on' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 66 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 67 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 68 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 69 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 70 off' -> got: b'ok\r\n'
sent cmd: b'mac set ch status 71 off' -> got: b'ok\r\n'
sent cmd: b'mac set pwridx 5' -> got: b'ok\r\n'
sent cmd: b'mac set appkey REDACTED' -> got: b'ok\r\n'
sent cmd: b'mac set appeui REDACTED' -> got: b'ok\r\n'
sent cmd: b'mac save' -> got: b'ok\r\n'
Joining... got: b'ok\r\n'
Joining... got: b''
Joining... got: b'denied\r\n'
Joining... got: b''
Joining... got: b''

The piece of code that tries to join is as follows:

while "accepted" not in rval:
    rval = str(ser.readline())
    print('Joining... got: '+rval)

Any reason why I can never join?

Plenty of options.

Go to the TTN console, gateway page and check for join traffic. (NOT the page on the Sentrius, the one on the TTN network). Also go to the application page and check for join traffic. Capture and show. Don’t bother to redact any data because everything displayed is ‘public’ information. (DevEUI and AppEUI are not secret, just the AppKey and that is not displayed).

I see the traffic on the Laird and I see the join traffic on the Gateway section of the TTN, but nothing in the Application or Devices Traffic/Data section.
Screen Shot 2020-06-28 at 1.22.40 PM Screen Shot 2020-06-28 at 1.28.08 PM Screen Shot 2020-06-28 at 1.27.41 PM Screen Shot 2020-06-28 at 1.27.31 PM Screen Shot 2020-06-28 at 1.24.04 PM

Have you checked the DevEUI and AppEUI of the device match those in the application? Looking at the screenshots I think they don’t… And OTAA only works if DevEUI, AppEUI and AppKey match.

Well that was it! Somehow the DEVEUI was no longer being set. Once I added that back in, everything lit up. Thank you!!