Hello. I’m looking for some guidance on how best to publish data to a separate app server. I have an instance of LoraServer running and ThingsBoard running on a different computer. At first I thought I could get Thingsboard to subscribe to an mtqq topic but it seems its an mtqq server as well. I tried the http integration but couldn’t get that to work I think because ThingsBoard is expecting a flat name pair json format and Loraserver is sending the whole lorawan datapacket:
https://thingsboard.io/docs/reference/protocols/
{“applicationID”:“1”,“applicationName”:“testapp”,“deviceName”:“seeeduino”,“devEUI”:“xxxxf6064bfdxxxx”,“rxInfo”:[{“mac”:“xxxx40ffff29xxxx”,“rssi”:-49,“loRaSNR”:7.2,“name”:“LairdRG191”,“latitude”:xx.xxxx,“longitude”:-xxx.xxxx,“altitude”:0}],“txInfo”:{“frequency”:904300000,“dataRate”:{“modulation”:“LORA”,“bandwidth”:125,“spreadFactor”:7},“adr”:true,“codeRate”:“4/5”},“fCnt”:358,“fPort”:8,“data”:“A4gHybTumY0BrIQ=”,“object”:{“gpsLocation”:{“3”:{“latitude”:51.0388,“longitude”:-114.0339,“altitude”:1097}}}}
I finally got Thingsboard to accept data by forwarding mtqq messages with a python script. Notice I had to pull out just the geolocation data before publishing to Thingsboard:
def on_connect(client, userdata, flags, rc):
print("Connected with result code "+str(rc))
client.subscribe(“application/1/node/xxxxf6064bfdxxxx/#”)
def on_message(client, userdata, msg):
print(msg.payload.decode())
a=json.loads(msg.payload.decode())
print(json.dumps(a[‘object’][‘gpsLocation’][‘3’]))
pclient.publish(“v1/devices/me/telemetry”,json.dumps(a[‘object’][‘gpsLocation’][‘3’]))
I feel like I’m publishing to Thingsboard the hard way. What is the proper way of doing this? Can I use the http integration by formatting the data first? What have other people done? Thanks.