-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmeshClass.py
More file actions
36 lines (23 loc) · 1.21 KB
/
meshClass.py
File metadata and controls
36 lines (23 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
""" Class for configuring and sending messages over a serial connected Meshtastic device."""
import meshtastic
import meshtastic.serial_interface
class meshtasticConn(object):
"""Object class for communication channel on a Meshtastic mesh.
:param port: A string, serial interface connected to meshtastic radio."""
def __init__(self, port):
self._port = meshtastic.serial_interface.SerialInterface(port)
self.config = self.localConfig()
def changePort(self, port):
"""Change the port serial interface used to connect to meshastic radio.
:param port: A string, serial interface connected to meshtastic radio."""
self._port = meshtastic.serial_interface.SerialInterface(port)
def localConfig(self):
"""Fetch local configuration of Meshtastic radio.
:returns: A string, configuration of radio."""
conf = self._port.getNode('^local')
self.config = conf.localConfig
return conf.localConfig
def sendMessage(self, message):
"""Send provided message to Mesh.
:param message: A string, message to send to mesh."""
self._port.sendText(message)