The above photo shows that the payload is blank.
when sending the payload via JSON I can see the downlink and ack uplink show up in my LoraWan frames tab, so the gateway and the device are talking back and forth.
So my question is pretty much what is the difference between sending just the encoded payload compared to the JSON and why is the data field not functioning the way I am intending?
Additionally I am having problems with my CODESYS MQTT publish function - I am sure this is not the correct place to ask about this problem but hey maybe someone will know!
My client and subscriber are functioning perfectly, I am able to get analog and digital values out of my device and into my CODESYS program. When using the Publisher command It returns the status’ “done” and “No_errors” yet when looking inside the LoraWan Frames in chirpstack the GW never sends a downlink.
Here is my code:
client : MQTT.MQTTClient;
publisher : MQTT.MQTTPublish;
subscriber : MQTT.MQTTSubscribe;
data_sub : ARRAY [0..1000] OF BYTE;
pub_sub : ARRAY [0..91] OF BYTE := [ 123,34,99,111,110,102,105,114,109,101,100,
topicfilter : WSTRING(1024) := "application/2/device/a84041931187ebc6/rx";
pubfilter : WSTRING(1024) := "application/2/device/a84041931187ebc6/tx";
size: UDINT := 92;
xTurnON := TRUE;
eMQTTError=> errorcode ,
xSubscribeActive=> active ,
xDone=> DONE ,
eMQTTError=> errorcode3 );
IF j = 0 THEN
FOR i := 0 TO 999 DO
IF data_sub[i] = 34 AND data_sub[i+1] = 100 AND data_sub[i+2] = 97 AND data_sub[i+3] = 116 AND data_sub[i+4] = 97 AND data_sub[i+5] = 34 AND data_sub[i+6] = 58 AND data_sub[i+7] = 34 THEN
payloadStart := i + 8;
j := payloadStart;
you will notice the:
pub_sub : ARRAY [0…91] OF BYTE
is the array that I intend to publish. The values that I populated this array with are the direct conversion of the above JSON to Hex and then to base 10.
I am unsure why my CODESYS MQTT subscriber was so easily set up to receive uplinks but its seeming impossible to make the publisher send a Downlink.
I would really appreciate some insight on either of the issues I have explained above! I will totally cooperate so if you need additional files, pictures, or explanation please feel free to let me know!
Thank you for your time
Note: Sorry for making this post in a bunch of replies, I could only put one photo per (which I think is a little silly because the description of a problem like this requires many screenshots to be thorough)