From e465e1b925d7b07d99a23aa350e538a61546df30 Mon Sep 17 00:00:00 2001 From: Aline Date: Wed, 6 May 2020 09:49:46 +0200 Subject: [PATCH] feat: pymesh code example --- content/pybytes/pymeshIntegration/_index.md | 10 ++++++-- content/pybytes/pymeshIntegration/example.md | 25 ++++++++++++++++++++ 2 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 content/pybytes/pymeshIntegration/example.md diff --git a/content/pybytes/pymeshIntegration/_index.md b/content/pybytes/pymeshIntegration/_index.md index 0abefc8..9d3a345 100644 --- a/content/pybytes/pymeshIntegration/_index.md +++ b/content/pybytes/pymeshIntegration/_index.md @@ -3,10 +3,16 @@ title: "Pymesh Integration" aliases: --- +## What does Pymesh integration offer you? + This documentation is a quick introduction to the new Pymesh integration features on Pybytes. The Pymesh integration is here to help Pymesh firmware deployment and to monitor Pymesh node's health. -[**Pymesh Provisioning**](/pybytes/pymeshintegration/provisioning) +## Let's get started! -[**Pymesh Monitoring**](/pybytes/pymeshintegration/monitoring) +* [Pymesh Provisioning](/pybytes/pymeshintegration/provisioning) + +* [Pymesh code example](/pybytes/pymeshintegration/example) + +* [Pymesh Monitoring](/pybytes/pymeshintegration/monitoring) diff --git a/content/pybytes/pymeshIntegration/example.md b/content/pybytes/pymeshIntegration/example.md new file mode 100644 index 0000000..c7cf32f --- /dev/null +++ b/content/pybytes/pymeshIntegration/example.md @@ -0,0 +1,25 @@ +## Pymesh example code + +After Pymesh provisioning, the devices have the correct Pymesh firmware. + +Once Pymesh is provisioned with Pybytes it starts automatically during the Pybytes initialization, but it is not sending any data yet. + +Below there is a code example that should be implemented in the main.py file. This example sends data trough the Pymesh every 20 seconds. + +```python +import time +import pycom + +if pybytes is not None: + if pybytes.__pymesh: + pymesh = pybytes.__pymesh + while True: + free_mem = pycom.get_free_heap() + pkt = "Hello, from " + str(pymesh.__pymesh.mac()) + ", time " + str(time.time()) + ", mem " + str(free_mem) + pybytes.send_signal(1, pkt) + time.sleep(20) +``` + +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.