ronoth / LoStik

LoRaWAN compatible USB test device
MIT License
134 stars 40 forks source link

Add example for The Things Network #4

Closed mbgg closed 5 years ago

mbgg commented 6 years ago

This adds a small program to show how to connect the device to The Things Network backend.

Citrullin commented 6 years ago

@mbgg What do you expect as payload? Tried: test 0x1 1h

But the program is just responding with:

error: argument --payload/-p: invalid hex value:
mbgg commented 6 years ago

you are right. I'll fix that and send a new pull request.

Citrullin commented 6 years ago

You can also just fix it in your branch. It will automatically updated in this PR.:)

mbgg commented 6 years ago

Changes in this version:

Citrullin commented 6 years ago

@mbgg Wouldn't make it sense to use ascii which is then converted to hex?

mbgg commented 6 years ago

@Citrullin we convert ascii to int in the argparse type lambda. Problem is, that I didn't find how to print hex values using %.16x, that's why I store it as int. BTW casts to int in line 46-50 shouldn't be needed anymore.

mbgg commented 6 years ago

@Citrullin any comments on that?

Citrullin commented 6 years ago

@mbgg I am going to take a look into it .

WA4OSH commented 6 years ago

In the example. I would send a string of hex representing three channels all Cayenne encoded: 1. Temperature at 20 deg c 2. Humidity 50% and 3. GPS location for Beaverton. OR. Stretch goal: a.couple of switches on the Cayenne console turn on and off the LEDs on the LoStik.

WA4OSH commented 6 years ago

It's very easy to setup a LoStik app on TTN and set its integration to Cayenne. It's also not hard to setup Cayenne.

WA4OSH commented 6 years ago

The other example would build an IFTTT example.

Citrullin commented 6 years ago
lorawan_sender.py: error: argument --appkey/-a: invalid <lambda> value: '7929233E8412329F0D9B2B20FF92043F'

Command used:

./lorawan_sender.py --appkey 7929233E8412329F0D9B2B20FF92043F --appeui [APP_EUI] --deveui [DEVEUI] --payload A1F3
lolsborn commented 5 years ago

I found out recently that I was not getting emails with PR requests / github issues recently 👎 I'm in the midst of moving right now, but plan to get this tested and merged in before the new year. Thanks for the PR and I'm sorry it's taken so long for me to take a look at it.

mbgg commented 5 years ago

./lorawan_sender.py --appkey 7929233E8412329F0D9B2B20FF92043F --appeui [APP_EUI] --deveui [DEVEUI] --payload A1F3

you have to pass hexadecimal values using 0x prefix

lolsborn commented 5 years ago

I just found the code that I had written to do LoRaWAN and created another PR here https://github.com/lolsborn/LoStik/pull/6 to compare. I haven't had time to compare against your work, but my code does handle both otaa and abp and I've admittedly tested mostly abp. When I get some time this week I'll compare them a bit closer and hopefully combine the best of them.

WA4OSH commented 5 years ago

The following Cayenne encoded payload sends two channels - temperature 17.0C and humidity 57%: 016700AA026872

01 - channel 1 67 - temperature 00AA - 170 = 17.0 degrees C 02 - channel 2 68 - humidity 72 - 57 %

If you set your payload format to Cayenne LLP and add Cayenne as an integration type, you can quickly build a Cayenne dashboard to show the data.

lolsborn commented 5 years ago

I'm not merging this PR, but it was used along with the prior LoRaWAN branch I had started to provide the current example script which I know people have used successfully and I have been bug-fixing. I appreciate the work here and did use bits of the code as reference to see how other people had implemented things.