Lorawan Gateway Implementation


(Rohitkr) #1

Hi,

I read many post in which its mentioned that code "A Lorawan gateway in Lua" which JaapBraam gave is able to support both uplink and downlink both. I ordered lua NODE MCU and i am trying to implement your code using sx1272. The output which i got is
got ip 192.168.1.124 255.255.255.0 192.168.1.1
Gateway ID 5CCF7FF42F33BB33
ntp synced using 188.166.86.92
2017-04-18 12:09:42 GMT
Unknown radio: 34
start allSF detector
router ip: 52.169.76.203
ntp synced using 188.166.86.92

i newbie for this so please tell me how should i get know what i am sending and what i am receiving and what the architecture for this model.

Please reply ASAP.
Thanks


(N0dyjeff) #2

Try "telnet 192.168.1.124". That should allow you to see the received packets along with other data being sent to TTN. You won't be able to read the payload data as it's encrypted, but you can at least see that packets are being received.

You can also type "statistics()" to get some additional data about the gateway.

I did a quick check of the SX1272 vs. the SX1276/78 that the code was written for. You might want to confirm that the code supports the SX1272. I did a quick comparison of datasheets, and it looks similar to the SX1276/78, but I couldn't say for sure.

Good luck!


(Rohitkr) #3

Thanks for the reply,

I used statistics() i got this output and when i try with "telnet 192.168.1.124" it says connection refused. Yeah I also compared both datasheet for sx1272 and sx1276 and i also won't find any differences between them and pin configuration is also same. So I think i can use sx1272 instead of sx1276 because i had sx1272 board at present.

Uptime         	        0 days, 0 hours, 5 minutes, 16 seconds
Memory free    	11296 bytes
Rx packets     	        0
Rx packets OK  	0
Rx timeouts    	        0
Rx forwarded   	0
Tx packets     	        0
Tx packets sent	0
Ack ratio      	100.0% (72/72)

(Rohitkr) #4

LoRaWanGateway
Configuration
GW_HOSTNAME "lorawangwunizen"
GW_ROUTER "router.eu.thethings.network"
GW_FREQ 868100000
GW_BW "BW125"
GW_SF "ALL"
GW_LAT "0.0"
GW_LON "0.0"
GW_ALT 0
GW_NSS 0
GW_DIO0 1
GW_DIO1 2
Statistics
Uptime 0 days, 0 hours, 6 minutes, 54 seconds
Memory free 9184 bytes
Rx packets 0
Rx packets OK 0
Rx timeouts 0
Rx forwarded 0
Tx packets 0
Tx packets sent 0
Ack ratio 100.0% (95/95)

I tried telnet 192.168.1.124. I got above mention output, I won't able to understand why i am getting RX and TX packet 0, timeout 0 sent 0. Please reply asap

Thanks


(N0dyjeff) #5

Congratulations on getting the gateway up and working so that you're able to telnet into it.

I see from your first post that you get "Unknown radio: 34" in the initial output on powering up. The code reads a version identifier from the SX1272 chip and compares it to 0x12. I wouldn't worry about the mismatch. The chip version for the SX1272 may be different than for the SX1278. The good news is that you're reading a number and not getting all 1's (0xFF) or all 0's (0x00), which tells me you probably are talking to the SX1272 successfully.

So, you're asking why you're not receiving and transmitting messages. Do you have a node working? What channel is it transmitting on? Is it the same as the gateway?
What spreading factor are you using? Have you tried changing the gateway to listen to a single spreading factor, rather than "ALL_SF"? You'll want to get the gateway receiving successfully from the node before attempting to respond to it. Remember that in the Lorawan protocol, gateways only communicate in response to messages received from nodes. So until you're receiving messages from the node, you won't see any transmit activity (and not even then unless you've given the gateway instructions to send a response). I haven't attempted to do communication the gateway to node direction, so I don't have any experience to share with that.


#6

Actually there are a few differences...

SX1272 reports a different radio type.

Setting a spreading factor is different for SX1272 (see here)

The reported RSSI value uses another offset (see here)

Feel free to add support for a SX1272 to Lorawangateway: implement support, test and make a pull request! I don't own a SX1272, so I cannot test it...


(Rohitkr) #7

Hi n0dyjeff,
Sorry for the late response.
Jeff : yeah i have a working node " arduino-lmic " . As you advised me to to change spreading factor from "ALL_SF" to specific SF. I changed it to SF7 and now i am able to receive packet from node to gateway.
This is the output : -
got ip 192.168.1.101 255.255.255.0 192.168.1.1
Gateway ID 5CCF7FF42F33BF04
ntp synced using 83.162.251.163
2017-05-10 10:54:26 GMT
sx1272: 34
start singleSF detector on SF7
router ip: 52.169.76.203
ntp synced using 83.162.251.163
rxpk 012ed1005ccf7ff42f33bf04 message {"rxpk":[{"rssi":-115,"stat":0,"modu":"LORA","rfch":1,"tmst":692095981,"datr":"SF7BW125","lsnr":-12,"time":"2017-05-10T11:05:52.984922Z","codr":"4/5","data":"7oeLLwC0ilVhGlG1B9UD4E4JLA9E8o9QW1o2BJcTbSPBOH5R+nmZT004s8cH/LbsjRcKcX0Cq7+sZItYW1RfAk+FOqAJiMiJaB7Lv4gTXnMowZsQ/ubIFC4+tel6yeCvgQpI70fYpea9SSqVTQ==","freq":868.100,"chan":0,"size":109}]} length 357
statistics()
statistics()
Statistics
Uptime 0 days, 0 hours, 15 minutes, 29 seconds
Memory free 11464 bytes
Rx packets 1
Rx packets OK 1
Rx timeouts 0
Rx forwarded 1
Tx packets 0
Tx packets sent 0
Ack ratio 98.1% (212/216)
my question is, i am receiving only once packet not regular. what the things i have to change so to receive it regularly.

Also i have register on TTN for gateway it always shows not connected. Please advise me how to proceed further.

Thanks and Regards
Rohit


(Rohitkr) #8

Hi JBraam,

yeah i read the datasheet for SX1276 and SX1272 and as you mention the link i notice that point and change the RSSI vale from 157 to 139 to use sdx1272 in lua code which you provided. Now the problem is i am able to receive packet only once not regular. please advise me to receive packet regularly and thanks for the link which you provided.

Please reply ASAP.

Thanks and regards
Rohit


#9

How much distance is there between your gateway and your node? Because you are testing I would expect them to be only a few meters apart.

The RSSI and LSNR values are very low! Values in that range are 'normal' for distances of several kilometers. Maybe you should check your antennas.


(Rohitkr) #10

Thanks for reply, i think its around 60cm - 70 cm both node and gateway are nearby only. Either it is problem with gateway or node side because, whenever i restart node or gateway once i receive message.

Another output which i got after restart.:-
got ip 192.168.1.101 255.255.255.0 192.168.1.1
Gateway ID 5CCF7FF42F33BF04
ntp synced using 85.255.214.66
2017-05-10 11:57:28 GMT
sx1272: 34
start singleSF detector on SF7
router ip: 52.169.76.203
ntp synced using 88.159.1.196
rxpk 010c77005ccf7ff42f33bf04 message {"rxpk":[{"rssi":-115,"stat":0,"modu":"LORA","rfch":1,"tmst":305066763,"datr":"SF7BW125","lsnr":-12,"time":"2017-05-10T12:02:28.016974Z","codr":"4/5","data":"9a+z9ank+XlpHCqaC1rg/K+czZz3/nVktk2L2/Iaj4WNXpyq3jV9LpaTP9w7k+BtHkJPEB6nV1dWikj4uUIdVSA381RopPE4M0Pea21OS73uKDytPoNI2sxcO0sRPwo//+siaRlK7OcnffXk1DmiGnCWqXSpvR+Xm7gSXpYwj6I=","freq":868.100,"chan":0,"size":128}]} length.

I mean to say sometime only i gets packet from node to gateway. i won't able to find bug. Please advise me how to proceed.

Thanks


#11

Do I understand correctly that when you restart your node, you will receive one message? Do you receive another message when you only restart your node again?

When the gateway runs in singleSF mode the reception settings will not change after the reception of a message, so it normally will continue listening for more messages...

Can you try to restart your node several times while keeping your gateway running, and check if more than one message is received?


(Rohitkr) #12

Yeah i tried but always getting only single message. i restarted several times node side, also restarted gateway too, now i am not able to receive message.

I received only 1 message and now after restart i am not able to to receive. Do i have to change something?


(Rohitkr) #13

after restart of gateway side i got this output:-

got ip 192.168.1.101 255.255.255.0 192.168.1.1
Gateway ID 5CCF7FF42F33BF04
ntp synced using 92.68.81.154
2017-05-10 13:46:31 GMT
sx1272: 34
start singleSF detector on SF7
router ip: 52.169.76.203
ntp synced using 88.159.1.196
rxpk 01e610005ccf7ff42f33bf04 message {"rxpk":[{"rssi":-113,"stat":0,"modu":"LORA","rfch":1,"tmst":849734808,"datr":"SF7BW125","lsnr":-12,"time":"2017-05-10T14:00:37.676629Z","codr":"4/5","data":"C+Fu12101KqfPeldeqYw9D7JjKlorlpGK6cyKNSQ7Ey1RzQjee9HSKG58cXioLEkmczs2bjo7xGk3hf5VSVVXrOeof8mrYl4hAkoJWsMDQ81NHeeAMuPIeWkC7aUEnsv4wWV5moIt+y9b4NYnZ9lm66cqw0rJenWQtNBYCz1aPe/n/5glT/UtSCAfpH4gKpzDcoZkCc+OwY=","freq":868.100,"chan":0,"size":152}]} length 413
ntp synced using 88.159.1.196


#14

Are you sure the messages you receive are from your node?

I would expect the node to send similar messages each time, but I see payloads of 109, 128 and 152 bytes.

What payload is your node supposed to send? Can you post some logging of your node?


(Arjan) #15

Also, using the nice:

...shows the packets might not be LoRaWAN at all:

This cannot be decoded.

Cannot be decoded either.

Without knowing the key to validate the MIC (if there is any), it decodes to a Join Request but it's far too long for that.

Try to increase that to a few meters.


(N0dyjeff) #16

Hi Rohit,

I see there have already been responses. My original response was sent to the wrong place. I'll provide it here just in case it may add something to the conversation.

It's not entirely clear that the packet you've received originated at your node. I say that because the signal strength and S/N ratio are both very low. If the node was anywhere within 100 meters of you, the RSSI and S/N indications would be much higher. For example, on my system, with the node in the adjacent room, I see RSSI of -65 and lsnr of 9. I am guessing that you're actually receiving a packet from a distant node, not your arduino-lmic.

Is your arduino-lmic set up to transmit on only one channel? If not, it will randomly select a channel to send a packet on. Since your gateway receives only one channel, it will only receive those packets transmitted on the channel it's monitoring.

As far as the gateway registration goes ("not connected"), I've had the same problems. It's a known issues on TTN with single channel gateways. I don't have any more help for you on that.

Regards,
Jeff


(Rohitkr) #18

Hi JBraam,

Sorry for delay reply.

Payload is just Hello World as it is mention in your code which is available in github (arduino-lmic). Same code which is available there, i used that one only..

yeah here is few logging of my node side
Starting
Packet queued
369338: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
1122287: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
1920702: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
2730812: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
3476643: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
4202779: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
4984323: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
5694206: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
6452182: EV_TXCOMPLETE (includes waiting for RX windows)
Packet queued
7159004: EV_TXCOMPLETE (includes waiting for RX windows)


(Rohitkr) #19

Yeah i hope so because i am unable to receive single packet but when i commented few channel i got three packet but with different payload length like 256, 357, 359.....

LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band

// LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI); // g-band
// LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK, DR_FSK), BAND_MILLI); // g2-band

Also in gateway side instead of SF_ALL i changed to single SF7... because if i use SF_ALL its shows
Gateway ID 5CCF7FF42F33BB33
ntp synced using 52.187.42.158
2017-05-11 12:31:46 GMT
sx1272: 34
start allSF detector
router ip: 52.169.76.203
ntp synced using 52.187.42.158
rx timeout 9 rssi 45
rx timeout 9 rssi 46
rx timeout 9 rssi 45
rx timeout 9 rssi 45
rx timeout 9 rssi 51
rx timeout 9 rssi 51
rx timeout 9 rssi 53
rx timeout 8 rssi 53
rx timeout 8 rssi 53
rx timeout 8 rssi 53
rx timeout 9 rssi 22

it is continuously.... but whenever i supposed to change from SF_ALL to SF7 at that i receive single packet...


(Rohitkr) #20

Hi jeff,

yeah i configured my arduino-limic to only single channel....

  LMIC_setupChannel(0, 868100000, DR_RANGE_MAP(DR_SF12, DR_SF7),  BAND_CENTI);      // g-band

// LMIC_setupChannel(1, 868300000, DR_RANGE_MAP(DR_SF12, DR_SF7B), BAND_CENTI); // g-band
// LMIC_setupChannel(2, 868500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(3, 867100000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(4, 867300000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(5, 867500000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(6, 867700000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(7, 867900000, DR_RANGE_MAP(DR_SF12, DR_SF7), BAND_CENTI); // g-band
// LMIC_setupChannel(8, 868800000, DR_RANGE_MAP(DR_FSK, DR_FSK), BAND_MILLI); // g2-band

Only channel 0 is enabled rest all are commented.

I am not able to understand whether it is problem with gateway side or node side :pensive:


(Rohitkr) #21

Hi arjanvanb,

Thanks for the reply...

Yeah i increased few meter 1 metre - 2 metre but still not able to receive continuously....