You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+1-256Lines changed: 1 addition & 256 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,262 +7,7 @@ A python client for using [Meshtastic](https://www.meshtastic.org) devices. This
7
7
8
8
Full documentation including examples [here](https://meshtastic.github.io/Meshtastic-python/meshtastic/index.html).
9
9
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)
11
11
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.
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.
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.
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.
- 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
-
```
267
12
268
13
[](https://vercel.com?utm_source=meshtastic&utm_campaign=oss)
0 commit comments