Could use a nudge with best practice for API comms

I am slowly plugging along and learning more and more about ChirpStack. I am liking it more and more, but at each new phase, I seem to get myself confused again.

I now have a RAK7246 running as a gateway with the chirpstack OS running on it. It seems to work great and I am catching all sorts of uplink/downlink data flowing. Yahoo!!

Now I want to deal with that data via an app instead. I figured I would start with Python for now. Using the example on here, I am able to (it appears) grab the JWT.

Q1 - Where did the JWT come from? I never set anything up, so is that a default value that is in all the units.

Q2 - I think that I need to poll for that value everytime my app starts to setup an authenticated link, right?

Q3 - Now what? I am having issues finding good examples that show just the super simple stuff. Like, how to pull the data out of the db or something like that. If I got to something like http://192.168.1.252:8080/api#!/DeviceProfileService/List, I can see some commands, but it is more of just a shell command. I try to run that from within my Python script, but I get

os.system(“curl -X GET --header "Accept: application/json" "http://192.168.1.252:8080/api/device-profiles\”")

{“error”:“authentication failed: get token from context error: no authorization-data in metadata”,“code”:16,“message”:“authentication failed: get token from context error: no authorization-data in metadata”,“details”:}0

I think you are thinking too complex :wink: You do not pull data from ChirpStack Application Server, it pushes it to one of the available integrations. For example you could setup a HTTP endpoint in your favorite language and let ChirpStack Application Server post to that endpoint. Integrations can be setup through the web-interface and global integrations can be setup in the chirpstack-application-server.toml config file. Examples:

https://www.chirpstack.io/application-server/integrations/http/

Me? Overcomplicate things? Never! :innocent:

So what do you recommend as the dirt simpliest way to go? I just want the information from the uplinked packets right now. Payload for sure, RSSI, LoRaSNR, eui would be nice. Uni-directional only. Starting out as dirt simple as I can :grin:

Some updates. I was able to add http integration and see my data getting pushed to postb.in. Yeah!!!

So then I tried to add an additional link: 127.0.0.1 and then see if I can listen to it over nc or telnet, but I don’t see anything coming out. I am attempting to do this on the pi itself, so nc for sure is a busybox stripped down verstion (maybe telnet as well).

What simple thing am I overlooking?

Aug 26 20:19:38 raspberrypi0-wifi user.info chirpstack-application-server[304]: time=“2020-08-26T20:19:38Z” level=info msg=“integration/http: publishing event” ctx_id=182e3e7e-de0d-4e99-a796-6ab17dd3f794 dev_eui=001e06767b27a921 event_type=up url=“http://127.0.0.1?event=up
Aug 26 20:19:38 raspberrypi0-wifi user.err chirpstack-application-server[304]: time=“2020-08-26T20:19:38Z” level=error msg=“integration/http: publish event error” ctx_id=182e3e7e-de0d-4e99-a796-6ab17dd3f794 dev_eui=001e06767b27a921 error="http request error: Post "http://127.0

which service on your raspberry listening http port and process http requests ?

I figured that the data will get posted from the server to that IP, then I tried listening with netcat as well as telnet.

to serve http post requests you are need the web server
otherwise it won’t work

Ah, I thought I could just listen an make sure that there was data passing through without having to setup a server.

I must be missing something because it seems redundant since there is already a server running on the device for the chirpstack stuff.

how you are using nc ?

nc 127.0.0.1 4544

There are no other options for the pi version on it.

even “nc -lp 80” ?
it may exist

I can’t do -lp
I have no other options except device and port.
It is very stripped down

then try to use tcpdump

no dice as well. I am using the chirpstack-os image and it is very lightweight, and has no apt-get capabilities either.

then it is not clear what goal you are trying to achieve?
create a complete integration on the other side that will allow you to fully work with the payload.

I appreciate the help, I am probably just muddling things.

All I want to do is have a way to monitor the uplinked data to the gateway. The Gateway is also running chirpstack. I don’t really care how I do it in the end, but based on advice on the boards here, it seemed like http integration was the way to go. If you have a suggestion of a different way to handle it, I would gladly try that out :slight_smile:

just suscribe to mqtt topic and you will see all needed data

Holy Toledo!!! That seems to be what I need. I used mosquito_sub on the command line and I got the data back I wanted. I will research more because I assume there is a way to do it via Python or C.

You rock!

One more question if I may.
Is there an easy way to get the RSSI and LoRaSNR? I tried using

mosquitto_sub -t “gateway/+/event/up” -v

But what I end up with is mostly gibberish. I am assuming it is due to the encoding, but obviously the application data was decoded properly, so is there a place to get that information cleanly?

By default the payloads are in protobuf format for size and speed. You could switch them to JSON in the gateway and NS configs for human readability, or write code to decode the protobufs and do what you need with them. Either way you need to decode them, really.