meshtastic

- Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.acid.vegas/-c.git
Log | Files | Refs | Archive | README | LICENSE

commit d33930ee373a37aba87cc19da3c72a1010cf1e01
parent b8404bcd0c69891e98ef793e65e1e9184f1013c3
Author: acidvegas <acid.vegas@acid.vegas>
Date: Tue, 7 May 2024 15:33:49 -0400

Documentation improved, structured repo cleaner, mqtt is mostly finish

Diffstat:
DFIRMWARE.md | 41-----------------------------------------
DHARDWARE.md | 42------------------------------------------
DMQTT.md | 47-----------------------------------------------
MREADME.md | 17+++++++++++------
DT-DECK.md | 30------------------------------
Ricon.xbm -> assets/icon.xbm | 0
Adocs/FIRMWARE.md | 43+++++++++++++++++++++++++++++++++++++++++++
Adocs/HARDWARE.md | 49+++++++++++++++++++++++++++++++++++++++++++++++++
Adocs/MQTT.md | 50++++++++++++++++++++++++++++++++++++++++++++++++++
RSETUP.md -> docs/SETUP.md | 0
Adocs/T-DECK.md | 33+++++++++++++++++++++++++++++++++
Mmeshmqtt.py | 5+++--

12 files changed, 189 insertions(+), 168 deletions(-)

diff --git a/FIRMWARE.md b/FIRMWARE.md
@@ -1,40 +0,0 @@
-# Meshtastic Firmware Hacks
-
-## Prerequisite
-- Download & install [PlatformIO](https://platformio.org/platformio-ide)
-
-- `git clone https://github.com/meshtastic/firmware.git`
-
-- `cd firmware && git submodule update --init`
-
-## Customization
-###### Custom Boot Logo
-- Use [XMB Viewer](https://windows87.github.io/xbm-viewer-converter/) to convert an image to XMB
-
-- The data from this goes in `firmware/src/graphics/img/icon.xbm`
-
-###### Custom boot message
-- Navigate to `firmware/src/graphics/Screen.cpp`
-
-- Find & replace `const char *title = "meshtastic.org";` with your custom message.
-
-###### Custom screen color
- - Navigate to `src/graphics/TFTDisplay.cpp`
-
- - Find & replace `#define TFT_MESH COLOR565(0xFF, 0x00, 0x00)` with your custom color. *(The one shown here is for RED mode >:))*
-
- ###### Custom alert sound (for T-Deck & devices with a buzzer)
- - From the mobile app, click the 3 dots on the top right, and select `Radio configuration`
- - Under `Module configuration`, select `External Notification`
-- Scroll down & you will see a `Ringtone` option that takes [RTTTL](https://en.wikipedia.org/wiki/Ring_Tone_Text_Transfer_Language) formatted tones.
-
-As far as I know, at the time of writing this, the only way to change the Ringtone is from the App. While this is not a "firmware" related thing, I included it in this file because it was difficult to find this setting...
-
- ## Compile & flash firmware
- - Select `PlatformIO: Pick Project Environment` & select your board.
- - Run `PLatformIO: Build` to compile the firmware.
- - Place device in DFU mode & plug in to the computer
- - Do `PlatformIO: Upload` to send the firmware to the device
- - Press the RESET button or reboot your device.
-
- See [here](https://meshtastic.org/docs/development/firmware/build/) for more information building & flashing custom firmware.
-\ No newline at end of file
diff --git a/HARDWARE.md b/HARDWARE.md
@@ -1,41 +0,0 @@
-# Hardware
-
-## Meshtastic Devices
-###### LilyGo T-Deck
-This is the ONLY standalone device for Meshtastic that does not require a phone to use it!
-
-![](.screens/tdeck.png)
-
-- [T-Deck](https://www.lilygo.cc/products/t-deck)
-- [Case](https://www.printables.com/model/741124-lilygo-t-deck-case) *(You can 3D print it yourself, or follow the Etsy link on here to buy one)*
-- [Antenna](https://www.amazon.com/dp/B086ZG5WBR)
-- [GPS](https://www.amazon.com/dp/B09LQDG1HY) *(There may be a better 15mm option for the case above..)*
-- [Battery](https://www.amazon.com/dp/B0BG82T39Y) *(The battery you get depends on the size of the case you order, contact me if you need help)*
-
-___
-
-###### LilyGo T-Beam
-
-Popular device, I personally use it for my home station
-
-![](.screens/tbeam.png)
-
-- [T-Beam](https://www.lilygo.cc/en-ca/products/t-beam-v1-1-esp32-lora-module?variant=43059202719925)
-___
-
-###### Heltec Lora 32 V3
-Great as a keychain for on the go meshtastic! Can power it directly from your phone if you want.
-
-![](.screens/heltec.png)
-
-- [Heltec Lora 32 V3](https://heltec.org/project/wifi-lora-32-v3/)
-
-___
-
-###### WisBlock
-These devices use an nrf52 chip instead of an esp32 chip. They are EXTREMELY low powered and are the best for solar nodes
-
-![](.screens/wisblock.png)
-
-- [WisBlock Starter Kit](https://store.rakwireless.com/products/wisblock-starter-kit?variant=41786685063366)
-**Note:** Make sure you get the nrf52 Arduino core and ensure you get the right frequency for your location.
-\ No newline at end of file
diff --git a/MQTT.md b/MQTT.md
@@ -1,46 +0,0 @@
-###### default.conf
-```
-# Insecure
-listener 1883
-
-# TLS/SSL
-listener 8883
-acl_file /etc/mosquitto/conf.d/aclfile
-protocol mqtt
-require_certificate false
-certfile /etc/mosquitto/certs/cert.pem
-cafile /etc/mosquitto/certs/fullchain.pem
-keyfile /etc/mosquitto/certs/privkey.pem
-
-listener 8083
-protocol websockets
-certfile /etc/mosquitto/certs/cert.pem
-cafile /etc/mosquitto/certs/fullchain.pem
-keyfile /etc/mosquitto/certs/privkey.pem
-```
-
-###### /etc/mosquitto/conf.d/aclfile
-```
-user acidvegas
-topic readwrite msh/#
-
-user mate
-topic readwrite msh/#
-
-pattern write $SYS/broker/connection/%c/state
-```
-
-###### mosquito.conf
-```
-pid_file /run/mosquitto/mosquitto.pid
-
-per_listener_settings true
-allow_anonymous false
-persistence true
-persistence_location /var/lib/mosquitto
-password_file /etc/mosquitto/passwd
-
-log_dest file /var/log/mosquitto/mosquitto.log
-
-include_dir /etc/mosquitto/conf.d
-```
-\ No newline at end of file
diff --git a/README.md b/README.md
@@ -4,23 +4,28 @@ This repository serves as a collection of resources created in my journey to lea
 
 The goal here is to create simple & clean modules to interface with the hardware in a way that can be used to expand the possibilities of the devices capabilities.
 
-The hardware I am experimenting with: [Lilygo T-Deck](https://www.lilygo.cc/products/t-deck), [Lilygo T-Beam](https://www.lilygo.cc/products/t-beam-v1-1-esp32-lora-module), [Heltec Lora 32 v3](https://heltec.org/project/wifi-lora-32-v3/), and [RAK Wireless 4631](https://store.rakwireless.com/products/wisblock-core-modules?variant=42440631419078)
-
 ![](.screens/htpdeck.png)
 
 ## Documentation
-- [Firmware Hacks & Customization](./FIRMWARE.md)
+- [Hardware Options](./docs/HARDWARE.md)
 - [Setup Hardware](./SETUP.md)
+- [Setup a T-Deck](./docs/T-DECK.md)
+- [Firmware Hacks & Customization](./docs/FIRMWARE.md)
+- [MQTT Notes](./docs/MQTT.md)
+
+## Code
+- [Meshtastic Serial/TCP Interface](./meshapi.py)
+- [Meshtastic MQTT Interface](./meshmqtt.py)
+- [Meshtastic IRC Relay / Bridge](./meshirc.py)
 
 ## Bugs & Issues
 - Devices must have Wifi turned off when going mobile. Upon leaving my house with WiFi still enabled, the UI & connection was EXTREMELY laggy & poor. Couldn't even type well...
 - Devices using a MQTT with TLS will reboot loop.
-- A fix for the reboot loop is simply disabling MQTT over serial with `meshtastic --set mqtt.enabled false`
-- `event_node` event is called **AS** we are defining the interface, so using `self.interface` in that callback will error.
+- A fix for the reboot loop is simply disabling MQTT over serial with `meshtastic --set mqtt.tls_enabled false`
+- Enabling JSON with MQTT causes messages to not be encrypted in the MQTT server..
 
 ## Roadmap
 - Asyncronous meshtastic interface
-- MQTT interface with working decryption
 - Documentation on MQTT bridging for high availability
 - Bridge for IRC to allow channel messages to relay over Meshtastic & all Meshtastic events to relay into IRC. *(IRC to Meshtastic will require a command like `!mesh <message here>` to avoid overloading the traffic over LoRa)*
 
diff --git a/T-DECK.md b/T-DECK.md
@@ -1,29 +0,0 @@
-# LilyGo T-Deck Notes
-
-![](.screens/htpdeck.png)
-
-## Parts
-- [T-Deck](https://www.lilygo.cc/products/t-deck)
-- [Case](https://www.printables.com/model/741124-lilygo-t-deck-case) *(You can 3D print it yourself, or follow the Etsy link on here to buy one)*
-- [Antenna](https://www.amazon.com/dp/B086ZG5WBR)
-- [GPS](https://www.amazon.com/dp/B09LQDG1HY) *(There may be a better 15mm option for the case above..)*
-- [Battery](https://www.amazon.com/dp/B0BG82T39Y) *(The battery you get depends on the size of the case you order, contact me if you need help)*
-
-**WARNING:** Do not power on the device until the antenna is plugged in! Even to flash the firmware, or for testing, make sure your antenna is plugged in or you can fry the radio!
-
-## GPS Installation
-The T-Deck has a grove connector for the GPS. Personally, I do not use a grove connector for mine, I removed the Grove input and soldered directly to the board.
-
-**WARNING**: Be careful taking off the grove! Snip the front points, and then use a soldering iron to loosen the metal on the 4 contact back points. You can VERY easily pull the solder pads right off if you just try to rip the grove connector off without loosening the solder points. If you pull off a solder pad, you're pretty much boned on having a GPS module.
-
-![](.screens/solder_pads_lol.png)
-
-*Above: Picture of solder pads accidentally pulled off lol...*
-
-You will see VCC, GND, RX & TX points on both the T-Deck & the GPS. Solder wires to match these points, but switch RX & TX. So do VCC to VCC, GND to GND, and then ensure that RX is soldered to TX, and TX is soldered to RX. It's confusing, I know, but that's China based hardware for you...
-
-## Flashing
-Simply plug in the T-Deck via USB and connect to a computer, then visit the [Meshtastic Web Flasher](https://flasher.meshtastic.org) and select your hardware & firmware version. Your device should show up as a serial device on /dev/ttyUSB0 or /dev/ttyAMC0. If you do not see your device, try adding your user to the dialout group. See [SETUP.md](./SETUP.md) for information on how to setup the device once it is flashed with Meshtastic.
-
-## Issues
-- Turn off WiFi completely if you plan to use this on-the-go. The device has an ESP32 chip which will always preffer WiFi over Bluetooth, so if you leave the house with this thign, it will constantly keep trying to connect to your WiFi & really degrade the performance of the board.
-\ No newline at end of file
diff --git a/icon.xbm b/assets/icon.xbm
diff --git a/docs/FIRMWARE.md b/docs/FIRMWARE.md
@@ -0,0 +1,42 @@
+# Meshtastic Firmware Hacks
+
+## Prerequisite
+- Download & install [PlatformIO](https://platformio.org/platformio-ide)
+
+- `git clone https://github.com/meshtastic/firmware.git`
+
+- `cd firmware && git submodule update --init`
+
+## Customization
+###### Custom Boot Logo
+- Use [XMB Viewer](https://windows87.github.io/xbm-viewer-converter/) to convert an image to XMB
+
+- The data from this goes in `firmware/src/graphics/img/icon.xbm`
+
+You can use the provided [icon.xbm](../assets/icon.xbm) for a rad GTA:SA fist to show up on boot.
+
+###### Custom boot message
+- Navigate to `firmware/src/graphics/Screen.cpp`
+
+- Find & replace `const char *title = "meshtastic.org";` with your custom message.
+
+###### Custom screen color
+ - Navigate to `src/graphics/TFTDisplay.cpp`
+
+ - Find & replace `#define TFT_MESH COLOR565(0xFF, 0x00, 0x00)` with your custom color. *(The one shown here is for RED mode >:))*
+
+ ###### Custom alert sound (for T-Deck & devices with a buzzer)
+ - From the mobile app, click the 3 dots on the top right, and select `Radio configuration`
+ - Under `Module configuration`, select `External Notification`
+- Scroll down & you will see a `Ringtone` option that takes [RTTTL](https://en.wikipedia.org/wiki/Ring_Tone_Text_Transfer_Language) formatted tones.
+
+As far as I know, at the time of writing this, the only way to change the Ringtone is from the App. While this is not a "firmware" related thing, I included it in this file because it was difficult to find this setting...
+
+ ## Compile & flash firmware
+ - Select `PlatformIO: Pick Project Environment` & select your board.
+ - Run `PLatformIO: Build` to compile the firmware.
+ - Place device in DFU mode & plug in to the computer
+ - Do `PlatformIO: Upload` to send the firmware to the device
+ - Press the RESET button or reboot your device.
+
+ See [here](https://meshtastic.org/docs/development/firmware/build/) for more information building & flashing custom firmware.
+\ No newline at end of file
diff --git a/docs/HARDWARE.md b/docs/HARDWARE.md
@@ -0,0 +1,48 @@
+# Hardware
+> A simple overview of popular hardware options for Meshtastic usage
+
+## LilyGo T-Deck
+![](.screens/tdeck.png)
+
+###### Information
+This is the only FULL stand-alone device that I know of for Meshtastic, that once provisioned, you do not need a phone or computer to interface with it. The device comes with a touchscreen, full keyboard, built in speaker, and more.
+
+| Item | Cost | Description |
+| ---- | ---- | ----------- |
+| [T-Deck](https://www.lilygo.cc/products/t-deck) | $50 | The main LoRa microcontroller device |
+| [Case](https://www.printables.com/model/741124-lilygo-t-deck-case) | Free or $25 | You can 3D print it yourself, or follow the Etsy link and buy one | 
+| [Antenna](https://www.amazon.com/Connector-868-915MHz-Lora32u4-Internet-WIshiOT/dp/B07LCKNN4H) | 14$ | External antenna for better range | 
+| [GPS](https://www.amazon.com/dp/B09LQDG1HY) | 18$ | There may be a better 15mm option for the case above.. | 
+| [Battery](https://www.amazon.com/dp/B0BG82T39Y) | Varies | The battery you get depends on the size of the case you order, contact me if you need help |
+
+___
+
+## LilyGo T-Beam
+![](.screens/tbeam.png)
+
+###### Information
+Very popular Meshtastic device. I personally use this for my home station
+
+| Item | Cost | Description |
+| ---- | ---- | ----------- |
+| [T-Beam](https://www.lilygo.cc/en-ca/products/t-beam-v1-1-esp32-lora-module?variant=43059202719925) | 32$ | The main LoRa board |
+| [Case](https://www.printables.com/model/127253-t-beam-case-for-meshtastic-v5) | Free | You can maybe find this case on Etsy or 3D print it yourself |
+
+___
+
+## Heltec Lora 32 V3
+Great as a keychain for on the go meshtastic! Can power it directly from your phone if you want.
+
+![](.screens/heltec.png)
+
+- [Heltec Lora 32 V3](https://heltec.org/project/wifi-lora-32-v3/)
+
+___
+
+## WisBlock
+These devices use an nrf52 chip instead of an esp32 chip. They are EXTREMELY low powered and are the best for solar nodes
+
+![](.screens/wisblock.png)
+
+- [WisBlock Starter Kit](https://store.rakwireless.com/products/wisblock-starter-kit?variant=41786685063366)
+**Note:** Make sure you get the nrf52 Arduino core and ensure you get the right frequency for your location.
+\ No newline at end of file
diff --git a/docs/MQTT.md b/docs/MQTT.md
@@ -0,0 +1,49 @@
+# Meshtastic MQTT
+> Work in progress still, come back later...
+
+###### default.conf
+```
+# Insecure
+listener 1883
+
+# TLS/SSL
+listener 8883
+acl_file /etc/mosquitto/conf.d/aclfile
+protocol mqtt
+require_certificate false
+certfile /etc/mosquitto/certs/cert.pem
+cafile /etc/mosquitto/certs/fullchain.pem
+keyfile /etc/mosquitto/certs/privkey.pem
+
+listener 8083
+protocol websockets
+certfile /etc/mosquitto/certs/cert.pem
+cafile /etc/mosquitto/certs/fullchain.pem
+keyfile /etc/mosquitto/certs/privkey.pem
+```
+
+###### /etc/mosquitto/conf.d/aclfile
+```
+user acidvegas
+topic readwrite msh/#
+
+user mate
+topic readwrite msh/#
+
+pattern write $SYS/broker/connection/%c/state
+```
+
+###### mosquito.conf
+```
+pid_file /run/mosquitto/mosquitto.pid
+
+per_listener_settings true
+allow_anonymous false
+persistence true
+persistence_location /var/lib/mosquitto
+password_file /etc/mosquitto/passwd
+
+log_dest file /var/log/mosquitto/mosquitto.log
+
+include_dir /etc/mosquitto/conf.d
+```
+\ No newline at end of file
diff --git a/SETUP.md b/docs/SETUP.md
diff --git a/docs/T-DECK.md b/docs/T-DECK.md
@@ -0,0 +1,32 @@
+# Meshtastic on a T-Deck
+
+![](.screens/htpdeck.png)
+
+## Parts
+- [T-Deck](https://www.lilygo.cc/products/t-deck)
+- [Case](https://www.printables.com/model/741124-lilygo-t-deck-case)
+    - You can 3D print it yourself, or you can buy one on Etsy from the link above.
+- [Antenna](https://www.amazon.com/Connector-868-915MHz-Lora32u4-Internet-WIshiOT/dp/B07LCKNN4H)
+    - The T-Deck has an I-PEX connection point for antennas. I used an I-PEX-to-SMA adapter so I could screw on a little 2dbi antenna.
+- [GPS]https://www.amazon.com/Teyleten-Robot-Dual-Mode-Positioning-Replacement/dp/B09LQDG1HY)
+    - There may be a better 15mm option for the case above...this is just what I used.
+- [Battery](https://www.amazon.com/AKZYTUE-5000mAh-Battery-Rechargeable-Connector/dp/B07TXJ5XXZ/)
+    - The battery you get depends on the size of the case you order. Do your measurements, contact me if you need help.
+
+## GPS Installation
+The T-Deck has a grove connector for the GPS, but for using this inside of a case, I decided to remove the connector and solder the GPS directly to the board.
+
+###### Soldering
+You will see VCC, GND, RX & TX points on both the T-Deck & the GPS. Solder wires to match these points, but switch RX & TX. So do VCC to VCC, GND to GND, and then ensure that RX is soldered to TX, and TX is soldered to RX.
+
+###### WARNING
+Be careful taking off the grove! Snip the front connnection points and then use a soldering iron to loosen the metal on the 4 back side connection points. You can VERY easily pull the solder pads right off if you just try to rip the grove connector off without loosening the solder points. If you pull off a solder pad, you're pretty much boned on having a GPS module. This has happened to ALOT of people with these things.
+
+![](.screens/solder_pads_lol.png)
+
+*Above: Picture of solder pads accidentally pulled off lol...*
+
+## Flashing
+###### **WARNING:** Do not power on the device until the antenna is plugged in! Even to flash the firmware, or for testing, make sure your antenna is plugged in or you can fry the radio!
+
+Simply plug in the T-Deck via USB and connect to a computer, then visit the [Meshtastic Web Flasher](https://flasher.meshtastic.org) and select your hardware & firmware version. Your device should show up as a serial device on /dev/ttyUSB0 or /dev/ttyAMC0. If you do not see your device, try adding your user to the dialout group. See [SETUP.md](./SETUP.md) for information on how to setup the device once it is flashed with Meshtastic.
+\ No newline at end of file
diff --git a/meshmqtt.py b/meshmqtt.py
@@ -209,8 +209,9 @@ if __name__ == '__main__':
 	# Enable TLS/SSL if the --tls flag is set
 	if args.tls:
 		import ssl
-		client.tls_set(cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLSv1_2)
-		client.tls_insecure_set(False)
+		client.tls_set()
+		#client.tls_set(cert_reqs=ssl.CERT_REQUIRED, tls_version=ssl.PROTOCOL_TLSv1_2)
+		#client.tls_insecure_set(False)
 
 	# Set the callbacks
 	client.on_connect     = on_connect