[pymesh] adapted for release v.1.0.1, pybytes v1.5.2 (fw 1.20.2.rc11)

This commit is contained in:
Catalin Ioana
2020-07-13 18:36:40 +03:00
parent f66172afe1
commit 05761571c5
5 changed files with 57 additions and 50 deletions

View File

@@ -8,14 +8,12 @@ Below there is a code example that should be implemented in the main.py file. Th
```python
import time
import pycom
if pybytes is not None:
if pybytes.__pymesh:
pymesh = pybytes.__pymesh
if pybytes.__pymesh and pybytes.__pymesh.__pymesh:
pymesh = pybytes.__pymesh.__pymesh
while True:
free_mem = pycom.get_free_heap()
pkt = "Hello, from " + str(pymesh.__pymesh.mac()) + ", time " + str(time.time()) + ", mem " + str(free_mem)
pkt = "Hello, from " + str(pymesh.mac())
pybytes.send_signal(1, pkt)
time.sleep(20)
```
@@ -23,3 +21,5 @@ if pybytes is not None:
Every time a data is sent trough Pymesh, the node's monitoring data is also sent. This monitoring data contains information as the number of neighbors, loRa mac, IP, role, age, and location.
Some of this information can be seen in the Pymesh Monitoring view or in section Signal, in the device interface in Pybytes.
For additional `pymesh` methods, check the open-source [Pymesh Library](https://github.com/pycom/pycom-libraries/tree/master/pymesh/pymesh_frozen) and the corresponding [Pymesh documentation](/pymesh/).

View File

@@ -15,7 +15,7 @@ Mesh networks essentially get rid of gateways, which decentralises the network's
Pymesh works on all of our LoRa supporting development boards, the LoPy4 and FiPy as well as on our OEM modules, L01 and L04.
_**Note: For obtaining the Pymesh firmware please follow the steps from [Pymesh LICENCE page](/pymesh/licence).**_
_**Note: For obtaining the Pymesh firmware please follow the steps from [Pybytes - Pymesh integration](/pybytes/pymeshintegration/).**_
## What does Pymesh offer you?

View File

@@ -8,7 +8,7 @@ aliases:
This Micropython library is included as frozen scripts in the Pymesh firmware release.
The code is open-sourced in [pycom-libraries repository](https://github.com/pycom/pycom-libraries/tree/master/lib/pymesh).
The code is open-sourced in [pycom-libraries repository](https://github.com/pycom/pycom-libraries/blob/master/pymesh/pymesh_frozen/lib/pymesh.py).
It is easily customisable and contributions are welcome using [Github PRs](https://github.com/pycom/pycom-libraries/pulls).

View File

@@ -1,47 +1,50 @@
---
title: "Pymesh Library CLI"
title: "Obtaining Pymesh"
aliases:
- pymesh/simple-example
---
## Licensing process
## Obtaining Pymesh
In order to receive access to the Pymesh firmware releases (for Lopy4, Fipy, L01 or L04), the next process should be followed:
1. Complete the <a href="/gitbook/assets/pymesh/Pymesh_Licence_Copyright_Notice.pdf" target="\_blank"> the Pymesh LICENCE PDF document</a>, sign it and send us by [this email](mailto:catalin@pycom.io?subject=[Pymesh_LICENCE]).
1. You will receive by email an archive containing the images for all boards.
1. Extract the corresponding image, for example Lopy4.tar.gz, and upload the firmware to your board, using the [Pycom Firmware Update Tool](https://pycom.io/downloads/), similar in the following image:
<img src="/gitbook/assets/pymesh/pymesh_firmware_update.png" alt="Pymesh Firmware Update" width="500"/>
In order to receive access to the Pymesh firmware releases (for Lopy4, Fipy, L01 or L04), please follow the steps from [Pybytes - Pymesh integration](/pybytes/pymeshintegration/).
## Test Pymesh firmware loading
### Method 1
The simplest way to check if the Pymesh class has been successfully installed is to try the following code, directly in REPL:
The simplest way to check if the Pymesh class has been successfully instantiated (and started inside Pybytes) is to try the following code, directly in REPL:
```python
>>> from network import LoRa
>>> lora = LoRa(mode=LoRa.LORA)
>>> mesh = lora.Mesh()
# todo: add try/except for checking pybytes object exists
>>> pymesh = pybytes.__pymesh.__pymesh
>>> pymesh.cli_start()
>h
List of available commands
br - enable/disable or display the current Border Router functionality
brs - send packet for Mesh-external, to BR, if any
buf - display buffer info
config - print config file contents
debug - set debug level
gps - get/set location coordinates
h - help, list of commands
ip - display current IPv6 unicast addresses
mac - set or display the current LoRa MAC address
mml - display the Mesh Mac List (MAC of all nodes inside this Mesh), also inquires Leader
mp - display the Mesh Pairs (Pairs of all nodes connections), also inquires Leader
ot - sends command to openthread internal CLI
pause - suspend Pymesh
resume - resume Pymesh
rm - verifies if any message was received
rst - reset NOW, including NVM Pymesh IPv6
s - send message
self - display all info about current node
sleep - deep-sleep
stop - close this CLI
tx_pow - set LoRa TX power in dBm (2-20)
ws - verifies if message sent was acknowledged
```
### Method 2
Upload the `main.py` from the [Simple Example](/pymesh/simple-example).
## FAQ
Q: **I've received an error, such as `(LoadProhibited). Exception was unhandled.`, what should I do?**
A: In some cases, the NVM partition needs to be formatted. For this a format of whole Flash Memory should be performed.
This can be done using the cli version of the `Firmware Update Tool`, so please navigate where the app was installed (search for pycom-fwtool-cli executable) and execute:
```
pycom-fwtool-cli -p <PORT> erase_all
```
`<PORT>` should be replaced with the actual USB COM port, for example:
* on Windows `COM10`
* on Linux `/dev/ttyACM0`
* on MacOS `/dev/tty.usbmodemPy8eaa911`

View File

@@ -6,16 +6,19 @@ aliases:
## What is Pymesh micropython library?
The Pymesh Micropython library is a set of frozen scripts in the Pymesh firmware binary release.
The Pymesh Micropython library is a set of frozen scripts in the Pymesh firmware binary release; the [open-source scripts are available on github](https://github.com/pycom/pycom-libraries/tree/master/pymesh/pymesh_frozen)
[Open-source on github](https://github.com/pycom/pycom-libraries/tree/master/pymesh/pymesh_frozen)
It allows users to access Pymesh in a few lines of code, as shown in the following code snippet.
Additionally, users can install the Pymesh mobile application which is available [here for both iOS and Android platforms](https://github.com/pycom/pycom-libraries/tree/master/pymesh/mobile_app). It allows users to connect over BLE to a Pymesh node and find out network information.
If Pybytes is used, then Pymesh is already started and pymesh object can be obtained by simply using (`main-pybytes.py` from github):
```python
# todo: add try/except for checking pybytes object exists
pymesh = pybytes.__pymesh.__pymesh
```
If Pybytes is not used, then the Pymesh network has to be started manually. The is shown in the following code snippet (`main.py` from github):
```python
import pycom
import time
@@ -52,9 +55,7 @@ pymesh_config = PymeshConfig.read_config()
#initialize Pymesh
pymesh = Pymesh(pymesh_config, new_message_cb)
mac = pymesh.mac()
# based on LoRa MAC address, some nodes could be forced to be
# sleep-end-devices (always Child) or to have increased Leader priority
# mac = pymesh.mac()
# if mac > 10:
# pymesh.end_device(True)
# elif mac == 5:
@@ -82,21 +83,24 @@ pymesh.send_mess(5, "Hello World")
# pymesh.br_set(PymeshConfig.BR_PRIORITY_NORM, new_br_message_cb)
# remove Border Router function from current node
#pymesh.br_remove()
# pymesh.br_remove()
# send data for Mesh-external, basically to the BR
# ip = "1:2:3::4"
# port = 5555
# pymesh.send_mess_external(ip, port, "Hello World")
print("done Pymesh init, forever loop, exit/stop with Ctrl+C multiple times")
# set BR with callback
print("done Pymesh init, CLI is started, h - help/command list, stop - CLI will be stopped")
pymesh.cli_start()
# while True:
# time.sleep(3)
while True:
time.sleep(3)
```
Additionally, users can install the Pymesh mobile application which is available [here for both iOS and Android platforms](https://github.com/pycom/pycom-libraries/tree/master/pymesh/mobile_app). It allows users to connect over BLE to a Pymesh node and find out network information.
## Output
An example of possible output is below.