Skip to content

Commit eec3f72

Browse files
authored
Merge pull request #186 from mkinney/docs
migrate docs to main project docs
2 parents 7d75fd6 + adb797d commit eec3f72

File tree

4 files changed

+10
-257
lines changed

4 files changed

+10
-257
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
README
2+
docs/
23
build
34
dist
45
*.egg-info

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ test:
66
install:
77
pip install .
88

9+
# generate the docs (for local use)
10+
docs:
11+
pdoc3 --html -f --output-dir docs meshtastic
12+
913
# lint the codebase
1014
lint:
1115
pylint meshtastic

README.md

Lines changed: 1 addition & 256 deletions
Original file line numberDiff line numberDiff line change
@@ -7,262 +7,7 @@ A python client for using [Meshtastic](https://www.meshtastic.org) devices. This
77

88
Full documentation including examples [here](https://meshtastic.github.io/Meshtastic-python/meshtastic/index.html).
99

10-
Installation is easily done through the Python package installer pip (note, you must use pip version 20 or later):
10+
The library api is documented [here](https://meshtastic-python.vercel.app/meshtastic/index.html)
1111

12-
- check that your computer has the required serial drivers installed, if not download them from [here](https://www.silabs.com/developers/usb-to-uart-bridge-vcp-drivers).
13-
- check that your computer has Python 3 installed.
14-
- check that your computer has "pip3" installed, if not follow [this guide](https://www.makeuseof.com/tag/install-pip-for-python/).
15-
- check that pytap2 is installed by pip3. If not, install it:
16-
17-
```
18-
sudo pip3 install --upgrade pytap2
19-
```
20-
21-
- install meshtastic:
22-
23-
```
24-
sudo pip3 install --upgrade meshtastic
25-
```
26-
27-
An example using Python 3 code to send a message to the mesh:
28-
29-
```
30-
import meshtastic
31-
interface = meshtastic.serial_interface.SerialInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0
32-
interface.sendText("hello mesh") # or sendData to send binary data, see documentations for other options.
33-
interface.close()
34-
```
35-
36-
For the rough notes/implementation plan see [TODO](https://github.com/meshtastic/Meshtastic-python/blob/master/TODO.md).
37-
38-
## Command line tool
39-
40-
This pip package will also install a "meshtastic" command line executable, which displays packets sent over the network as JSON and lets you see serial debugging information from the meshtastic devices. The source code for this tool is also a good [example](https://github.com/meshtastic/Meshtastic-python/blob/master/meshtastic/__main__.py) of a 'complete' application that uses the meshtastic python API.
41-
42-
NOTE: This command is not run inside of python; you run it from your operating system shell prompt directly. If when you type "meshtastic" it doesn't find the command and you are using Windows: Check that the python "scripts" directory [is in your path](https://datatofish.com/add-python-to-windows-path/).
43-
44-
To display a (partial) list of the available commands:
45-
46-
```
47-
meshtastic -h
48-
```
49-
50-
### Changing device settings
51-
52-
You can also use this tool to set any of the device parameters which are stored in persistent storage. For instance, here's how to set the device
53-
to keep the bluetooth link alive for eight hours (any usage of the bluetooth protcol from your phone will reset this timer)
54-
55-
```
56-
meshtastic --set wait_bluetooth_secs 28800
57-
Connected to radio...
58-
Setting preference wait_bluetooth_secs to 28800
59-
Writing modified preferences to device...
60-
```
61-
62-
Or to set a node at a fixed position and never power up the GPS.
63-
64-
```
65-
meshtastic --setlat 25.2 --setlon -16.8 --setalt 120
66-
```
67-
68-
Or to configure an ESP32 based board to join a wifi network as a station (wifi support in the device code is coming soon):
69-
70-
```
71-
meshtastic --set wifi_ap_mode false --set wifi_ssid mywifissid --set wifi_password mywifipsw
72-
```
73-
74-
Or to configure an ESP32 to run as a Wifi access point:
75-
76-
```
77-
meshtastic --set wifi_ap_mode true --set wifi_ssid mywifissid --set wifi_password mywifipsw
78-
```
79-
80-
Once an a node is connected to a Wi-Fi network, you can use the `--host` option to access it instead of using the USB serial bridge:
81-
82-
```
83-
meshtastic --host Meshtastic-0123.lan --info --nodes
84-
```
85-
86-
For a full list of preferences which can be set (and their documentation) see [here](https://meshtastic.org/docs/developers/protobufs/api#radioconfiguserpreferences).
87-
88-
### Changing channel settings
89-
90-
The channel settings can be changed similiarly. Either by using a standard (sharable) meshtastic URL or you can set partiular channel parameters (for advanced users).
91-
92-
The URL is constructed automatically based off of the current channel settings. So if you want to customize a channel you could do something like:
93-
94-
```
95-
meshtastic --ch-set name mychan --ch-set channel_num 4 --info
96-
```
97-
98-
This will change some channel params and then show device info (which will include the current channel URL)
99-
100-
You can even set the channel preshared key to a particular AES128 or AES256 sequence.
101-
102-
```
103-
meshtastic --ch-set psk 0x1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b1a1a1a1a2b2b2b2b --info
104-
```
105-
106-
Use "--ch-set psk none" to turn off encryption.
107-
108-
Use "--ch-set psk random" will assign a new (high quality) random AES256 key to the primary channel (similar to what the Android app does when making new channels).
109-
110-
Use "--ch-set psk default" to restore the standard 'default' (minimally secure, because it is in the source code for anyone to read) AES128 key.
111-
112-
All "ch-set" commands will default to the primary channel at index 0, but can be applied to other channels with the "ch-index" parameter:
113-
114-
```
115-
meshtastic --ch-index 1 --ch-set name mychan --ch-set channel_num 4 --info
116-
```
117-
118-
## Ham radio support
119-
120-
Meshtastic is designed to be used without a radio operator license. If you do have a license you can set your operator ID and turn off encryption with:
121-
122-
```
123-
meshtastic --port /dev/ttyUSB1 --set-ham KI1345
124-
Connected to radio
125-
Setting Ham ID to KI1345 and turning off encryption
126-
Writing modified channels to device
127-
```
128-
129-
## Changing multiple settings from a yaml file
130-
131-
You can put parameters into a yaml file to update multiple values. See the [example_config.yaml](example_config.yaml).
132-
133-
This is how you might call it:
134-
135-
```
136-
meshtastic --configure example_config.yaml
137-
```
138-
139-
## FAQ/common problems
140-
141-
This is a collection of common questions and answers from our friendly forum.
142-
143-
### [Permission denied: ‘/dev/ttyUSB0’](https://meshtastic.discourse.group/t/question-on-permission-denied-dev-ttyusb0/590/3?u=geeksville)
144-
145-
This indicates an OS permission problem for access by your user to the USB serial port. Typically this is fixed by the following.
146-
147-
```
148-
sudo usermod -a -G dialout $USER
149-
```
150-
151-
This adds the "dialout" group to your user. You'll need to obtain a new login session (for example, by logging out and logging back in) for the group change (and thus permission change) to take effect.
152-
153-
## Mac OS Big Sur
154-
155-
There is a problem with Big Sur and pyserial. The workaround is to install a newer version of pyserial:
156-
157-
```
158-
pip3 install -U --pre pyserial
159-
```
160-
161-
Afterwards you can use the Meshtastic python client again on MacOS.
162-
163-
## A note to developers of this lib
164-
165-
We use the visual-studio-code default python formatting conventions (autopep8). So if you use that IDE you should be able to use "Format Document" and not generate unrelated diffs. If you use some other editor, please don't change formatting on lines you haven't changed.
166-
167-
If you need to build a new release you'll need:
168-
169-
```
170-
apt install pandoc
171-
sudo pip3 install markdown pdoc3 webencodings pyparsing twine autopep8 pylint pytest pytest-cov
172-
```
173-
174-
For development, you will probably want to run:
175-
176-
```
177-
pip3 install -r requirements.txt
178-
```
179-
180-
To lint, run:
181-
182-
```
183-
pylint meshtastic
184-
```
185-
186-
To test, first install this code locally, then run pytest:
187-
188-
```
189-
pip3 install .
190-
pytest
191-
```
192-
193-
Possible options for testing:
194-
195-
- For more verbosity, add "-v" or even "-vv" like this:
196-
197-
```
198-
pytest -vv
199-
```
200-
201-
- To run just unit tests:
202-
203-
```
204-
pytest
205-
# or (more verbosely)
206-
pytest -m unit
207-
# or
208-
make
209-
```
210-
211-
- To run just integration tests:
212-
213-
```
214-
pytest -m int
215-
```
216-
217-
- To run the smoke test with only one device connected serially (aka smoke1):
218-
219-
```
220-
pytest -m smoke1
221-
```
222-
223-
CAUTION: Running smoke1 will reset values on the device, including the region to 1 (US).
224-
Be sure to hit the reset button on the device after the test is completed.
225-
226-
- To run the smoke test with only two device connected serially (aka smoke2):
227-
228-
```
229-
pytest -m smoke2
230-
```
231-
232-
- To run the wifi smoke test:
233-
234-
```
235-
pytest -m smokewifi
236-
```
237-
238-
- To run a specific test:
239-
240-
```
241-
pytest -msmoke1 meshtastic/tests/test_smoke1.py::test_smoke1_info
242-
# or to run a specific smoke2 test
243-
pytest -m smoke2 meshtastic/tests/test_smoke2.py::test_smoke2_info
244-
# or to run a specific smoke_wifi test
245-
pytest -m smokewifi meshtastic/tests/test_smoke_wifi.py::test_smokewifi_info
246-
```
247-
248-
- To add another classification of tests such as "unit" or "smoke1", see [pytest.ini](pytest.ini).
249-
250-
- To see the unit test code coverage:
251-
252-
```
253-
pytest --cov=meshtastic
254-
# or if want html coverage report
255-
pytest --cov-report html --cov=meshtastic
256-
# or
257-
make cov
258-
```
259-
260-
- To see slowest unit tests, you can run:
261-
262-
```
263-
pytest --durations=0
264-
# or
265-
make slow
266-
```
26712

26813
[![Powered by Vercel](https://raw.githubusercontent.com/abumalick/powered-by-vercel/master/powered-by-vercel.svg)](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)

bin/regen-docs.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,4 @@
1-
pdoc3 --html -f --output-dir docs meshtastic
1+
# Note: Docs are generated from this command below, albeit from Vercel.
2+
# The docs/ dir is not used and is no longer commited.
3+
# see sachaw if you have questions
4+
pdoc3 --html -f --output-dir docs meshtastic

0 commit comments

Comments
 (0)