I am using this MQTT-SN bridge, with no changes except that I rigged it to give a hex dump of the buffer if it does not contain a valid MQTT-SN packet.
I am experiencing a strange problem: sometimes I find the bridge works perfectly well, and other times I find the problem I describe below. I have an ESP32 microcontroller which is just publishing a message here and there to say it's alive. It queries various sensors (humidity, dust ...) as well, and publishes the results also, as you will see. It's writing to a LoRa module, and correspondingly I have a LoRa module on a USB stick which is plugged into my laptop. Then I run
./mqtt-sn-serial-bridge -b 19200 /dev/ttyUSB0
to see output like the following:
2019-09-17 12:20:18 ERROR Error reading rest of packet from serial port: 0, 22 2019-09-17 12:20:19 WARN Read 10 bytes but packet length is 165 bytes. ....|..... 0xa5 0x08 0xa0 0xa6 0x7c 0x84 0x85 0x0c 0x86 0x85 2019-09-17 12:20:19 WARN Read 17 bytes but packet length is 37 bytes. %..@..H.........f 0x25 0xc5 0x0c 0x40 0x87 0x84 0x48 0x04 0x85 0x9c 0xc4 0x85 0x88 0xc4 0x86 0xee 0x66 2019-09-17 12:20:21 WARN Read 8 bytes but packet length is 40 bytes. (.....xD 0x28 0xa5 0x04 0xc0 0xa2 0x87 0x78 0x44 2019-09-17 12:20:23 WARN Read 8 bytes but packet length is 67 bytes. C....... 0x43 0xa5 0x0a 0xc0 0x82 0x0a 0x06 0xf6
If I run
screen /dev/ttyUSB0 19200 8n1 I get something like this:
bf5fish5 is a live"b9H0.000000 relative humidity bf5PM2.5 = 10bf5PM10 = 11bf5fish5 is a live"b9H0.000000 relative humidity bf5PM2.5 = 10bf5PM10 = 11
What I found remarkable is that while screen can get human readable characters, the MQTT-SN bridge just seems to get garbage.
Does anyone have any experience with this bridge? I'm unsure whether the problem is with the bridge itself or somehow with the LoRa substrate. Or can anyone see where I'm going wrong?