From 8954793d112fc894bd93931ebee5a840470648e4 Mon Sep 17 00:00:00 2001 From: Jacek Radzikowski Date: Fri, 28 Jun 2024 01:13:15 -0400 Subject: [PATCH 1/8] Added gitignore --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..78ee506 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +__pycache__/ +bulletins.db +venv/ + From e59b5837e4c38c0aa15602fa0f8bc7fa86d14c55 Mon Sep 17 00:00:00 2001 From: Jacek Radzikowski Date: Fri, 28 Jun 2024 01:16:39 -0400 Subject: [PATCH 2/8] Fixed 100% SPU isage in idle loop --- server.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server.py b/server.py index 35dee8e..36ba220 100644 --- a/server.py +++ b/server.py @@ -18,6 +18,7 @@ from config_init import initialize_config, get_interface from db_operations import initialize_database from message_processing import on_receive from pubsub import pub +import time # Configure logging logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s') @@ -51,7 +52,8 @@ def main(): try: while True: - pass + time.sleep(1) + except KeyboardInterrupt: logging.info("Shutting down the server...") interface.close() From 8c9780a0c4e33590dc9aebd6e5f94d8812ddb99c Mon Sep 17 00:00:00 2001 From: Jacek Radzikowski Date: Fri, 28 Jun 2024 01:41:08 -0400 Subject: [PATCH 3/8] Fixed confusing date format --- db_operations.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db_operations.py b/db_operations.py index 0d8aaa3..b1440e8 100644 --- a/db_operations.py +++ b/db_operations.py @@ -66,7 +66,7 @@ def get_channels(): def add_bulletin(board, sender_short_name, subject, content, bbs_nodes, interface, unique_id=None): conn = get_db_connection() c = conn.cursor() - date = datetime.now().strftime('%m/%d/%Y %H:%M') + date = datetime.now().strftime('%Y-%m-%d %H:%M') if not unique_id: unique_id = str(uuid.uuid4()) c.execute( @@ -107,7 +107,7 @@ def delete_bulletin(bulletin_id, bbs_nodes, interface): def add_mail(sender_id, sender_short_name, recipient_id, subject, content, bbs_nodes, interface, unique_id=None): conn = get_db_connection() c = conn.cursor() - date = datetime.now().strftime('%m/%d/%Y %H:%M') + date = datetime.now().strftime('%Y-%m-%d %H:%M') if not unique_id: unique_id = str(uuid.uuid4()) c.execute("INSERT INTO mail (sender, sender_short_name, recipient, date, subject, content, unique_id) VALUES (?, ?, ?, ?, ?, ?, ?)", From ca04096c8e3f9776211f8d28a765b6dbdb2b2ce9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TC=C2=B2?= <130875305+TheCommsChannel@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:18:12 -0400 Subject: [PATCH 4/8] Updates for systemd This adds a service file and instructions for getting this to start at boot --- README.md | 142 +++++++++++++++++++++++++++++------------------ mesh-bbs.service | 14 +++++ 2 files changed, 103 insertions(+), 53 deletions(-) create mode 100644 mesh-bbs.service diff --git a/README.md b/README.md index 38300ef..700ebe4 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,16 @@ # TC²-BBS Meshtastic Version -[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B1OZ22Z) +[](https://ko-fi.com/B0B1OZ22Z) This is the TC²-BBS system integrated with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory. ## Setup ### Docker installation -TC²-BBS Meshtastic is available on Docker Hub -[![Docker HUB](https://icon-icons.com/downloadimage.php?id=151885&root=2530/PNG/128/&file=docker_button_icon_151885.png)](https://hub.docker.com/r/thealhu/tc2-bbs-mesh) +If you're a Docker user, TC²-BBS Meshtastic is available on Docker Hub! + +[](https://hub.docker.com/r/thealhu/tc2-bbs-mesh) ### Requirements @@ -22,79 +23,115 @@ TC²-BBS Meshtastic is available on Docker Hub 1. Clone the repository: ```sh -git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git -cd TC2-BBS-mesh +cd ~git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.gitcd TC2-BBS-mesh ``` -2. Set up a Python virtual environment: +2. Set up a Python virtual environment: -```sh +```sh python -m venv venv +``` + +3. Activate the virtual environment: + +- On Windows: + +```sh +venv\Scripts\activate ``` - -3. Activate the virtual environment: - - -- On Windows: - -```sh -venv\Scripts\activate -``` - - On macOS and Linux: ```sh source venv/bin/activate ``` -4. Install the required packages: +4. Install the required packages: -```sh +```sh pip install -r requirements.txt ``` -5. Set up the configuration in `config.ini`: - - **[interface]** - - If using `type = serial` and you have multiple devices connected, you will need to uncomment the `port =` line and enter in the port of your device. - - Linux Example: - `port = /dev/ttyUSB0` - - Windows Example: - `port = COM3` - - If using type = tcp you will need to uncomment the hostname = 192.168.x.x line and put in the IP address of your Meshtastic device - - **[sync]** - - Enter in a list of other BBS nodes you would like to sync messages and bulletins with. Separate each by comma and no spaces as shown in the example below. - You can find the nodeID in the menu under `Radio Configuration > User` for each node, or use this script for getting nodedb data from a device: - - [Meshtastic-Python-Examples/print-nodedb.py at main · pdxlocations/Meshtastic-Python-Examples (github.com)](https://github.com/pdxlocations/Meshtastic-Python-Examples/blob/main/print-nodedb.py) +5. Set up the configuration in `config.ini`: - Example Config: -```ini -[interface] -type = serial -# port = /dev/ttyUSB0 -# hostname = 192.168.x.x + **[interface]** + If using `type = serial` and you have multiple devices connected, you will need to uncomment the `port =` line and enter the port of your device. -[sync] -bbs_nodes = !f53f4abc,!f3abc123 -``` + Linux Example: + `port = /dev/ttyUSB0` + +Windows Example: + `port = COM3` + +If using type = tcp you will need to uncomment the hostname = 192.168.x.x line and put in the IP address of your Meshtastic device + + **[sync]** + Enter a list of other BBS nodes you would like to sync messages and bulletins with. Separate each by comma and no spaces as shown in the example below. + You can find the nodeID in the menu under `Radio Configuration > User` for each node, or use this script for getting nodedb data from a device: + + [Meshtastic-Python-Examples/print-nodedb.py at main · pdxlocations/Meshtastic-Python-Examples (github.com)](https://github.com/pdxlocations/Meshtastic-Python-Examples/blob/main/print-nodedb.py) + + Example Config: +```ini +[interface] +type = serial +# port = /dev/ttyUSB0 +# hostname = 192.168.x.x + +[sync] +bbs_nodes = !f53f4abc,!f3abc123 +```` ### Running the Server Run the server with: ```sh -python server.py +python server.py``` ``` Be sure you've followed the Python virtual environment steps above and activated it before running. + +## Automatically run at boot + +If you would like to have the script automatically run at boot, follow the steps below: + +1. **Edit the service file** + + First, edit the mesh-bbs.service file using your preferred text editor. The 3 following lines in that file are what we need to edit: + + ```sh + User=pi + WorkingDirectory=/home/pi/TC2-BBS-mesh + ExecStart=/home/pi/TC2-BBS-mesh/venv/bin/python3 /home/pi/TC2-BBS-mesh/server.py + ``` + + The file is currently setup for a user named 'pi' and assumes that the TC2-BBS-mesh directory is located in the home directory (which it should be if the earlier directions were followed) + + We just need to replace the 4 parts that have "pi" in those 3 lines with your username. + +2. **Configuring systemd** + From the TC2-BBS-mesh directory, run the following commands: + + `sh sudo cp mesh-bbs.service /etc/systemd/system/` + + `sh sudo systemctl enable mesh-bbs.service` + + `sh sudo systemctl start mesh-bbs.service` + + The service should be started now and should start anytime your device is powered on or rebooted. You can check the status ofk the service by running the following command: + + `sh sudo systemctl status mesh-bbs.service` + + If you need to stop the service, you can run the following: + + `sh sudo systemctl stop mesh-bbs.service` + + If you make changes to the watchlist.txt file, you will need to restart the service with the following command: + + `sh sudo systemctl restart mesh-bbs.service` + + ## Features - **Mail System**: Send and receive mail messages. @@ -106,13 +143,12 @@ Be sure you've followed the Python virtual environment steps above and activated ## Usage -You interact with the BBS by sending direct messages to the node that's connected to the system running the Python script. Sending any message to it will get a response with the main menu. +You interact with the BBS by sending direct messages to the node that's connected to the system running the Python script. Sending any message to it will get a response with the main menu. Make selections by sending messages based on the letter or number in brackets - Send M for [M]ail Menu for example. A video of it in use is available on our YouTube channel: -[![TC²-BBS-Mesh](https://img.youtube.com/vi/d6LhY4HoimU/0.jpg)](https://www.youtube.com/watch?v=d6LhY4HoimU) - +[](https://www.youtube.com/watch?v=d6LhY4HoimU) ## Thanks @@ -124,4 +160,4 @@ Big thanks to [Meshtastic](https://github.com/meshtastic) and [pdxlocations](htt ## License -GNU General Public License v3.0 +GNU General Public License v3.0 \ No newline at end of file diff --git a/mesh-bbs.service b/mesh-bbs.service new file mode 100644 index 0000000..5bf33b5 --- /dev/null +++ b/mesh-bbs.service @@ -0,0 +1,14 @@ +[Unit] +Description=TC²-BBS Meshtastic Version +After=multi-user.target + +[Service] +Type=simple +Restart=always +RestartSec=20 +User=pi +WorkingDirectory=/home/pi/TC2-BBS-mesh +ExecStart=/home/pi/TC2-BBS-mesh/venv/bin/python3 /home/pi/TC2-BBS-mesh/server.py + +[Install] +WantedBy=multi-user.target \ No newline at end of file From df340d25d641e2a8cfa8a042e6a191264f233a6e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TC=C2=B2?= <130875305+TheCommsChannel@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:24:54 -0400 Subject: [PATCH 5/8] Update README.md Link fixes to README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 700ebe4..28d93c4 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # TC²-BBS Meshtastic Version -[](https://ko-fi.com/B0B1OZ22Z) +[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/B0B1OZ22Z) This is the TC²-BBS system integrated with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory. @@ -10,7 +10,7 @@ This is the TC²-BBS system integrated with Meshtastic devices. The system allow If you're a Docker user, TC²-BBS Meshtastic is available on Docker Hub! -[](https://hub.docker.com/r/thealhu/tc2-bbs-mesh) +[![Docker HUB](https://icon-icons.com/downloadimage.php?id=151885&root=2530/PNG/128/&file=docker_button_icon_151885.png)](https://hub.docker.com/r/thealhu/tc2-bbs-mesh) ### Requirements @@ -148,7 +148,7 @@ Make selections by sending messages based on the letter or number in brackets - A video of it in use is available on our YouTube channel: -[](https://www.youtube.com/watch?v=d6LhY4HoimU) +[![TC²-BBS-Mesh](https://img.youtube.com/vi/d6LhY4HoimU/0.jpg)](https://www.youtube.com/watch?v=d6LhY4HoimU) ## Thanks From f10495a97465214155f3bc353b882ddfd691a211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TC=C2=B2?= <130875305+TheCommsChannel@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:35:19 -0400 Subject: [PATCH 6/8] Update README.md README.md fixes --- README.md | 184 +++++++++++++++++++++++++++++------------------------- 1 file changed, 99 insertions(+), 85 deletions(-) diff --git a/README.md b/README.md index 28d93c4..425bf83 100644 --- a/README.md +++ b/README.md @@ -21,65 +21,69 @@ If you're a Docker user, TC²-BBS Meshtastic is available on Docker Hub! ### Installation 1. Clone the repository: - -```sh -cd ~git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.gitcd TC2-BBS-mesh -``` + + ```sh + cd ~ + git clone https://github.com/TheCommsChannel/TC2-BBS-mesh.git + cd TC2-BBS-mesh + ``` 2. Set up a Python virtual environment: - -```sh -python -m venv venv -``` + + ```sh + python -m venv venv + ``` 3. Activate the virtual environment: - -- On Windows: - -```sh -venv\Scripts\activate -``` -- On macOS and Linux: - -```sh -source venv/bin/activate -``` + + - On Windows: + + ```sh + venv\Scripts\activate + ``` + + - On macOS and Linux: + + ```sh + source venv/bin/activate + ``` 4. Install the required packages: - -```sh -pip install -r requirements.txt -``` + + ```sh + pip install -r requirements.txt + ``` 5. Set up the configuration in `config.ini`: - - **[interface]** - If using `type = serial` and you have multiple devices connected, you will need to uncomment the `port =` line and enter the port of your device. - - Linux Example: - `port = /dev/ttyUSB0` - -Windows Example: - `port = COM3` - -If using type = tcp you will need to uncomment the hostname = 192.168.x.x line and put in the IP address of your Meshtastic device - - **[sync]** - Enter a list of other BBS nodes you would like to sync messages and bulletins with. Separate each by comma and no spaces as shown in the example below. - You can find the nodeID in the menu under `Radio Configuration > User` for each node, or use this script for getting nodedb data from a device: - - [Meshtastic-Python-Examples/print-nodedb.py at main · pdxlocations/Meshtastic-Python-Examples (github.com)](https://github.com/pdxlocations/Meshtastic-Python-Examples/blob/main/print-nodedb.py) - - Example Config: -```ini -[interface] -type = serial -# port = /dev/ttyUSB0 -# hostname = 192.168.x.x - -[sync] -bbs_nodes = !f53f4abc,!f3abc123 -```` + + **[interface]** + If using `type = serial` and you have multiple devices connected, you will need to uncomment the `port =` line and enter the port of your device. + + Linux Example: + `port = /dev/ttyUSB0` + + Windows Example: + `port = COM3` + + If using type = tcp you will need to uncomment the hostname = 192.168.x.x line and put in the IP address of your Meshtastic device. + + **[sync]** + Enter a list of other BBS nodes you would like to sync messages and bulletins with. Separate each by comma and no spaces as shown in the example below. + You can find the nodeID in the menu under `Radio Configuration > User` for each node, or use this script for getting nodedb data from a device: + + [Meshtastic-Python-Examples/print-nodedb.py at main · pdxlocations/Meshtastic-Python-Examples (github.com)](https://github.com/pdxlocations/Meshtastic-Python-Examples/blob/main/print-nodedb.py) + + Example Config: + + ```ini + [interface] + type = serial + # port = /dev/ttyUSB0 + # hostname = 192.168.x.x + + [sync] + bbs_nodes = !f53f4abc,!f3abc123 + ``` ### Running the Server @@ -91,46 +95,56 @@ python server.py``` Be sure you've followed the Python virtual environment steps above and activated it before running. - ## Automatically run at boot If you would like to have the script automatically run at boot, follow the steps below: 1. **Edit the service file** - - First, edit the mesh-bbs.service file using your preferred text editor. The 3 following lines in that file are what we need to edit: - - ```sh - User=pi - WorkingDirectory=/home/pi/TC2-BBS-mesh - ExecStart=/home/pi/TC2-BBS-mesh/venv/bin/python3 /home/pi/TC2-BBS-mesh/server.py - ``` - - The file is currently setup for a user named 'pi' and assumes that the TC2-BBS-mesh directory is located in the home directory (which it should be if the earlier directions were followed) - - We just need to replace the 4 parts that have "pi" in those 3 lines with your username. - + + First, edit the mesh-bbs.service file using your preferred text editor. The 3 following lines in that file are what we need to edit: + + ```sh + User=pi + WorkingDirectory=/home/pi/TC2-BBS-mesh + ExecStart=/home/pi/TC2-BBS-mesh/venv/bin/python3 /home/pi/TC2-BBS-mesh/server.py + ``` + + The file is currently setup for a user named 'pi' and assumes that the TC2-BBS-mesh directory is located in the home directory (which it should be if the earlier directions were followed) + + We just need to replace the 4 parts that have "pi" in those 3 lines with your username. + 2. **Configuring systemd** - From the TC2-BBS-mesh directory, run the following commands: - - `sh sudo cp mesh-bbs.service /etc/systemd/system/` - - `sh sudo systemctl enable mesh-bbs.service` - - `sh sudo systemctl start mesh-bbs.service` - - The service should be started now and should start anytime your device is powered on or rebooted. You can check the status ofk the service by running the following command: - - `sh sudo systemctl status mesh-bbs.service` - - If you need to stop the service, you can run the following: - - `sh sudo systemctl stop mesh-bbs.service` - - If you make changes to the watchlist.txt file, you will need to restart the service with the following command: - - `sh sudo systemctl restart mesh-bbs.service` - + From the TC2-BBS-mesh directory, run the following commands: + + ```sh + sudo cp mesh-bbs.service /etc/systemd/system/ + ``` + + ```sh + sudo systemctl enable mesh-bbs.service + ``` + + ```sh + sudo systemctl start mesh-bbs.service + ``` + + The service should be started now and should start anytime your device is powered on or rebooted. You can check the status ofk the service by running the following command: + + ```sh + sudo systemctl status mesh-bbs.service + ``` + + If you need to stop the service, you can run the following: + + ```sh + sudo systemctl stop mesh-bbs.service + ``` + + If you make changes to the watchlist.txt file, you will need to restart the service with the following command: + + ```sh + sudo systemctl restart mesh-bbs.service + ``` ## Features From 20e93c463b3e2c96fbb0c731b6bf9b19606f35ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TC=C2=B2?= <130875305+TheCommsChannel@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:40:49 -0400 Subject: [PATCH 7/8] Update README.md --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 425bf83..ab1a5f2 100644 --- a/README.md +++ b/README.md @@ -113,7 +113,8 @@ If you would like to have the script automatically run at boot, follow the steps We just need to replace the 4 parts that have "pi" in those 3 lines with your username. -2. **Configuring systemd** +2. **Configuring systemd** + From the TC2-BBS-mesh directory, run the following commands: ```sh @@ -174,4 +175,4 @@ Big thanks to [Meshtastic](https://github.com/meshtastic) and [pdxlocations](htt ## License -GNU General Public License v3.0 \ No newline at end of file +GNU General Public License v3.0 From 812d5087bdfe5f9ea51f2c469b8da148c1c072f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?TC=C2=B2?= <130875305+TheCommsChannel@users.noreply.github.com> Date: Fri, 28 Jun 2024 08:56:33 -0400 Subject: [PATCH 8/8] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab1a5f2..dd9c3ad 100644 --- a/README.md +++ b/README.md @@ -4,14 +4,14 @@ This is the TC²-BBS system integrated with Meshtastic devices. The system allows for message handling, bulletin boards, mail systems, and a channel directory. -## Setup - -### Docker installation +### Docker If you're a Docker user, TC²-BBS Meshtastic is available on Docker Hub! [![Docker HUB](https://icon-icons.com/downloadimage.php?id=151885&root=2530/PNG/128/&file=docker_button_icon_151885.png)](https://hub.docker.com/r/thealhu/tc2-bbs-mesh) +## Setup + ### Requirements - Python 3.x