Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add poetry and pyenv support #104

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.12
142 changes: 72 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ If you're a Docker user, TC²-BBS Meshtastic is available on Docker Hub!

### Requirements

- Python 3.x
- Python 3.12
- Meshtastic
- pypubsub

### Update and Install Git

```sh
sudo apt update
sudo apt upgrade
Expand All @@ -29,76 +29,76 @@ 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.git
cd TC2-BBS-mesh
```

2. Set up a Python virtual environment:
```sh
python -m venv venv
```
2. Set up a `Pyenv`

2.1 Follow instructions [here](https://github.com/pyenv/pyenv?tab=readme-ov-file#installation).

2.2 Install Python 3.12

3. Activate the virtual environment:

- On Windows:

```sh
venv\Scripts\activate
```

- On macOS and Linux:

```sh
source venv/bin/activate
pyenv install 3.12
```

4. Install the required packages:

2.3 Set your environment

```sh
pyenv local 3.12
```

3. Set up a `Poetry`

Follow instructions [here](https://python-poetry.org/docs/#installation).

4. Install the required packages

```sh
pip install -r requirements.txt
poetry install
```

5. Rename `example_config.ini`:
5. Rename `example_config.ini`

```sh
mv example_config.ini config.ini
```

6. Set up the configuration in `config.ini`:
6. Set up the configuration in `config.ini`:

You'll need to open up the config.ini file in a text editor and make your changes following the instructions below
**[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:

**[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]
type = serial
# port = /dev/ttyUSB0
# hostname = 192.168.x.x

[sync]
bbs_nodes = !f53f4abc,!f3abc123
```

### Running the Server
Expand All @@ -112,6 +112,7 @@ python server.py
Be sure you've followed the Python virtual environment steps above and activated it before running.

## Command line arguments

```
$ python server.py --help

Expand Down Expand Up @@ -139,77 +140,78 @@ options:
MQTT topic to subscribe
```



## 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 of 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 need to restart the service, you can do so with the following command:

```sh
sudo systemctl restart mesh-bbs.service
```

2. **Viewing Logs**

Viewing past logs:

```sh
journalctl -u mesh-bbs.service
```

Viewing live logs:

```sh
journalctl -u mesh-bbs.service -f
```

## Radio Configuration

Note: There have been reports of issues with some device roles that may allow the BBS to communicate for a short time, but then the BBS will stop responding to requests.
Note: There have been reports of issues with some device roles that may allow the BBS to communicate for a short time, but then the BBS will stop responding to requests.

The following device roles have been working:

The following device roles have been working:
- **Client**
- **Router_Client**

Expand All @@ -224,7 +226,7 @@ The following device roles have been working:

## 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:
Expand Down
Loading