From 9bde16bde7fcc1450770f37573aa5641a3550d53 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 22 Dec 2021 15:54:17 -0800 Subject: [PATCH 1/4] fix example --- docs/software/python/usage.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/software/python/usage.md b/docs/software/python/usage.md index 2a8a325c..baf49a1d 100644 --- a/docs/software/python/usage.md +++ b/docs/software/python/usage.md @@ -7,8 +7,13 @@ sidebar_label: Python usage An example using Python 3 code to send a message to the mesh: ```python import meshtastic -interface = meshtastic.SerialInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 -interface.sendText("hello mesh") # or sendData to send binary data, see documentations for other options. +import meshtastic.serial_interface + +# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 +interface = meshtastic.serial_interface.SerialInterface() + +# or sendData to send binary data, see documentations for other options. +interface.sendText("hello mesh") interface.close() ``` From d972784b9d22d9ad5b862ce984ea1c64ac74f678 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 22 Dec 2021 15:56:28 -0800 Subject: [PATCH 2/4] Revert "fix example" This reverts commit 9bde16bde7fcc1450770f37573aa5641a3550d53. --- docs/software/python/usage.md | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/docs/software/python/usage.md b/docs/software/python/usage.md index baf49a1d..2a8a325c 100644 --- a/docs/software/python/usage.md +++ b/docs/software/python/usage.md @@ -7,13 +7,8 @@ sidebar_label: Python usage An example using Python 3 code to send a message to the mesh: ```python import meshtastic -import meshtastic.serial_interface - -# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 -interface = meshtastic.serial_interface.SerialInterface() - -# or sendData to send binary data, see documentations for other options. -interface.sendText("hello mesh") +interface = meshtastic.SerialInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 +interface.sendText("hello mesh") # or sendData to send binary data, see documentations for other options. interface.close() ``` From d77b684a7f51d62bdaf7ac97d8b6356fe03d0b1d Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 22 Dec 2021 15:58:04 -0800 Subject: [PATCH 3/4] fix example in branch this time --- docs/software/python/usage.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/docs/software/python/usage.md b/docs/software/python/usage.md index 2a8a325c..baf49a1d 100644 --- a/docs/software/python/usage.md +++ b/docs/software/python/usage.md @@ -7,8 +7,13 @@ sidebar_label: Python usage An example using Python 3 code to send a message to the mesh: ```python import meshtastic -interface = meshtastic.SerialInterface() # By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 -interface.sendText("hello mesh") # or sendData to send binary data, see documentations for other options. +import meshtastic.serial_interface + +# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 +interface = meshtastic.serial_interface.SerialInterface() + +# or sendData to send binary data, see documentations for other options. +interface.sendText("hello mesh") interface.close() ``` From 4597b76c0e78a31ffafaf6e31738a11dfd10c921 Mon Sep 17 00:00:00 2001 From: Mike Kinney Date: Wed, 22 Dec 2021 16:06:09 -0800 Subject: [PATCH 4/4] add more to the example from chrisbee input --- docs/software/python/usage.md | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/docs/software/python/usage.md b/docs/software/python/usage.md index baf49a1d..e786b3b2 100644 --- a/docs/software/python/usage.md +++ b/docs/software/python/usage.md @@ -4,16 +4,30 @@ title: Meshtastic-python usage sidebar_label: Python usage --- -An example using Python 3 code to send a message to the mesh: +An example using Python 3 code to send a message to the mesh, get and set a radio configuration preference: ```python import meshtastic import meshtastic.serial_interface -# By default will try to find a meshtastic device, otherwise provide a device path like /dev/ttyUSB0 +# By default will try to find a meshtastic device, +# otherwise provide a device path like /dev/ttyUSB0 interface = meshtastic.serial_interface.SerialInterface() +# or something like this +# interface = meshtastic.serial_interface.SerialInterface(devPath='/dev/cu.usbmodem53230050571') # or sendData to send binary data, see documentations for other options. interface.sendText("hello mesh") + +ourNode = interface.getNode('^local') +print(f'Our node preferences:{ourNode.radioConfig.preferences}') + +# update a value +print('Changing a preference...') +ourNode.radioConfig.preferences.gps_update_interval = 60 + +print(f'Our node preferences now:{ourNode.radioConfig.preferences}') +ourNode.writeConfig() + interface.close() ```