I used to be able to get my payload decoded using this:
mosquitto_sub -h eu.thethings.network -t ‘+/devices/+/up’ -u $TTN_UID -P $TTN_AKEY -t ‘+/devices/larue_pro-mini-barometric_temp_001/up’ | jq -r ‘.payload’ | base64 --decode | od -t x1
after the update to TTN V2 I know the data segment is now payload_raw but for what ever reason, I can’t chain these pipes and get it working.
mosquitto_sub -h eu.thethings.network -t ‘+/devices/+/up’ -u $TTN_UID -P $TTN_AKEY -t ‘+/devices/larue_pro-mini-barometric_temp_001/up’ | jq -r ‘.payload_raw’ | base64 --decode | od -t x1
What I now get is the raw payload from jq but it does not pass on the pipe to base64. And this includes if I direct the mosquitto_sub output to a file using tee and then in another process tail( with follow ) that file to the rest of the pipe.
it’s a mystery I’d like to solve so any insight would be helpful.
UPDATE:
A work-around is to send the JSON message to a file:
mosquitto_sub -h eu.thethings.network -t ‘+/devices/+/up’ -u $TTN_UID -P $TTN_AKEY | tee /tmp/outfile.ttn
In another process I follow the file with tail -f and when a new line shows up, process just that line and wait again for another line. I put that in a script:
#!/bin/bash
tail -f $1 | while IFS=’’ read line; do
echo $line | jq -r ‘.payload_raw’ | base64 --decode | od -t x1
done
While not as clean/easy as a pipe chain it works.
Doug