Skip to content

Commit ce6d44b

Browse files
author
Catalin Ioana
committed
Added Pymesh library
1 parent d303ff2 commit ce6d44b

File tree

10 files changed

+659
-240
lines changed

10 files changed

+659
-240
lines changed

config.toml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,39 +1272,60 @@ theme = "doc-theme"
12721272
weight = 95
12731273

12741274
[[menu.main]]
1275-
name = "Pymesh Library API"
1276-
url = "/pymesh/library"
1277-
identifier = "pymesh@library"
1275+
name = "Pymesh LICENCE"
1276+
url = "/pymesh/licence"
1277+
identifier = "pymesh@licence"
12781278
parent = "pymesh"
12791279
weight = 10
12801280

12811281
[[menu.main]]
1282-
name = "Micropython API"
1283-
url = "/firmwareapi/pycom/network/lora/pymesh"
1284-
identifier = "pymesh@api"
1282+
name = "Simple Example"
1283+
url = "/pymesh/simple-example"
1284+
identifier = "pymesh@simple-example"
12851285
parent = "pymesh"
12861286
weight = 20
12871287

12881288
[[menu.main]]
1289-
name = "Simple Example"
1290-
url = "/pymesh/lora-mesh"
1291-
identifier = "pymesh@lora-mesh"
1289+
name = "Pymesh Library API"
1290+
url = "/pymesh/lib-api"
1291+
identifier = "pymesh@lib-api"
12921292
parent = "pymesh"
12931293
weight = 30
12941294

1295+
[[menu.main]]
1296+
name = "Pymesh Library CLI"
1297+
url = "/pymesh/lib-cli"
1298+
identifier = "pymesh@lib-cli"
1299+
parent = "pymesh"
1300+
weight = 40
1301+
1302+
[[menu.main]]
1303+
name = "Pymesh Library BLE RPC"
1304+
url = "/pymesh/lib-ble-rpc"
1305+
identifier = "pymesh@lib-ble-rpc"
1306+
parent = "pymesh"
1307+
weight = 50
1308+
12951309
[[menu.main]]
12961310
name = "Border Router Examplee"
12971311
url = "/pymesh/pymesh-br"
12981312
identifier = "pymesh@pymesh-br"
12991313
parent = "pymesh"
1300-
weight = 40
1314+
weight = 60
13011315

13021316
[[menu.main]]
13031317
name = "Advanced Security Example"
13041318
url = "/pymesh/security"
13051319
identifier = "pymesh@security"
13061320
parent = "pymesh"
1307-
weight = 50
1321+
weight = 70
1322+
1323+
[[menu.main]]
1324+
name = "Micropython API"
1325+
url = "/firmwareapi/pycom/network/lora/pymesh"
1326+
identifier = "pymesh@api"
1327+
parent = "pymesh"
1328+
weight = 90
13081329

13091330
# *** Documentation Notes
13101331
[[menu.main]]

content/pymesh/_index.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@ Pymesh is the LoRa full-mesh network technology.
1212

1313
A Mesh network acts like a net, this means that any node within the network can connect with any other node.
1414

15-
<!-- prettier-ignore -->
1615
Mesh networks essentially get rid of gateways, which decentralises the network's infrastructure. This then means that the network becomes flexible, so it can do many wonderful things – such as generate, change and fix itself. The success of the Mesh network is down to its parts, as any node within the network will automatically connect to the best radio-link available.
1716

1817
Pymesh solution works on all of our LoRa supporting development boards, the LoPy4 and FiPy as well as on our OEM modules, L01 and L04.
1918

19+
_**Note: For obtaining the Pymesh firmware please follow the steps from [Pymesh LICENCE page](/pymesh/licence).**_
20+
2021
## What does Pymesh offer you?
2122

2223
* Ad-hoc communication network over raw-LoRa radio
@@ -29,7 +30,11 @@ Pymesh solution works on all of our LoRa supporting development boards, the LoPy
2930

3031
## Let's get started!
3132

32-
* [Pymesh Micropython API](/firmwareapi/pycom/network/lora/pymesh)
33-
* [Simple Example](/pymesh/lora-mesh)
34-
* [Border Router Example](/pymesh/pymesh-br)
33+
* [Pymesh LICENCE](/pymesh/licence)
34+
* [Simple Example](/pymesh/simple-example)
35+
* [Pymesh library API](/pymesh/lib-api)
36+
* [Pymesh library CLI](/pymesh/lib-cli)
37+
* [Pymesh library BLE RPC](/pymesh/lib-ble-rpc)
38+
* [Border Router](/pymesh/pymesh-br)
3539
*[Advanced Security Example](/pymesh/security)
40+
* [Pymesh Micropython API](/firmwareapi/pycom/network/lora/pymesh)

content/pymesh/lib-api.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: "Pymesh Library API"
3+
aliases:
4+
- pymesh/lib-api
5+
---
6+
7+
## Overview
8+
9+
This Micropython library is included as frozen scripts in the Pymesh firmware release.
10+
11+
Code is open-sourced in [pycom-libraries repository](https://github.com/pycom/pycom-libraries/tree/master/lib/pymesh).
12+
13+
It is easily customisable and contributions are highly recommend using [Github PRs](https://github.com/pycom/pycom-libraries/pulls).
14+
15+
### Main features
16+
17+
* Start Pymesh over LoRa on 863Mhz, bandwidth 250kHz, spreading-factor 7 (please check `pymesh_config.py` defaults for exact values).
18+
* Pymesh parameters are automatically saved in NVM, so in the next restart/deepsleep, the node will try to maintain its IP addresses and connections with neighbour nodes.
19+
* Start Bluetooth LE server with name `PyGo <LoRa MAC>`
20+
* BLE is used with an RPC protocol, presented int [Pymesh library BLE RPC](/pymesh/lib-ble-rpc)
21+
* Internal CLI for controlling/triggering Pymesh features, as explained in [Pymesh library CLI](/pymesh/lib-cli).
22+
23+
### Color coding LED
24+
25+
The LED color represents the state of the node in the Mesh network.
26+
27+
```
28+
29+
Blinking - Send/Receive packet
30+
Magenta - LEADER
31+
Green - ROUTER
32+
White - CHILD,
33+
Red - Searching / Detached from any Pymesh
34+
Cyan - SINGLE LEADER (no other Router in the same Pymesh)
35+
```
36+
37+
## Example of usage
38+
39+
A simple example of usage is in the [main.py](https://github.com/pycom/pycom-libraries/blob/master/lib/pymesh/main.py).
40+
41+
## Specifications
42+
43+
It can be easily customised, by modifying any file from [/lib folder](https://github.com/pycom/pycom-libraries/tree/master/lib/pymesh/lib) and flashing it to the board. Automatically the uploaded file will be executed instead of the _frozen_ one, already embedded into the binary firmware.
44+
45+
### Structure
46+
47+
* `pymesh.py`
48+
* contains all the methods accessible from `main.py`
49+
* `cli.py`
50+
* [Pymesh library CLI](/pymesh/lib-cli)
51+
* BLE services
52+
* `ble_rpc.py`
53+
* [Pymesh library BLE RPC](/pymesh/lib-ble-rpc)
54+
* `ble_services.py`
55+
* setting BLE server
56+
* auxiliary files:
57+
* `pymesh-debug.py`
58+
* debugging on levels, allowing dynamically changing debug level
59+
* `pymesh-config.py`
60+
* reading/writing Pymesh configuration file
61+
* `gps.py`
62+
* maintaining location coordinates, as an extension `Pytrack` GPS can be used
63+
* Mesh internals
64+
* `mesh-interface.py`
65+
* methods to inquire Mesh-internal parameters
66+
* `mesh-internal.py` and `loramesh.py`
67+
* 2 layers of internal mesh maintenance

content/pymesh/lib-ble-rpc.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
title: "Pymesh Library Bluetooth LE RPC"
3+
aliases:
4+
- pymesh/simple-example
5+
---
6+
7+
## RPC protocol
8+
9+
It is implemented in [ble_rpc.py](https://github.com/pycom/pycom-libraries/blob/master/lib/pymesh/lib/ble_rpc.py).
10+
11+
In the class `RPCHandler` methods can be added to expand RPC set.
12+
13+
The internal RPC are calling methods from file `mesh_interface.py`.
14+
15+
## Methods
16+
17+
#### mesh_is_connected()
18+
19+
This returns `True` if Node is connected to a Pymesh.
20+
21+
#### mesh_ip()
22+
23+
This returns the IP RLOC16 in a string.
24+
25+
#### set_gps(latitude, longitude)
26+
27+
This sets the location coordinates.
28+
29+
#### get_mesh_mac_list()
30+
31+
This returns list of distinct MAC address that are in this mesh network, for example `[mac1, mac2, mac 3]`.`
32+
33+
#### get_mesh_pairs()
34+
35+
This returns list of pairs that is a mesh connection, as shown bellow:
36+
37+
```
38+
[
39+
('mac1', 'mac2', rssi),
40+
('mac1', 'mac3', rssi),
41+
#...
42+
]
43+
```
44+
45+
#### get_node_info(mac_id = ' ')
46+
47+
This returns the node data for a specified mac address, or own data id `mac_id` is not specified. Node data is dictionary with the following structure:
48+
```
49+
{
50+
'ip': 4c00, # last 2bytes from the ip v6 RLOC16 address
51+
'r': 3, # not_connected:0 | child:1 | leader:2 | router:3
52+
'a': 100, # age[sec], time since last info about this node
53+
'nn' : 20 # neighbours number
54+
'nei': { # neighbours enumerated, if any
55+
(mac, ip, role, rssi, age),
56+
(mac, ip, role, rssi, age)
57+
}
58+
'l': { # location, if available
59+
'lng': 7,
60+
'lat': 20,
61+
},
62+
'b' : { # BLE infos
63+
'a': 100 # age, seconds since last ping with that device, None if properly disconnected
64+
'id': '<UUID>' # 16byte
65+
'n': '', # name, max. 16 chars
66+
}
67+
}
68+
```
69+
70+
#### send_message(data)
71+
72+
This sends a message with another node. It return True if there is buffer to store it (to be sent).
73+
74+
`data` is a dictionary with the following structure:
75+
```
76+
{
77+
'to': 0x5,
78+
'b': 'text',
79+
'id': 12345,
80+
'ts': 123123123,
81+
}
82+
```
83+
84+
85+
#### send_message_was_sent(mac, msg_id)
86+
87+
This checks if acknowledge was received for the specified `mac` and `msg_id`. It returns `True` if message was delivered.
88+
89+
#### receive_message()
90+
91+
This returns the received messages, in a dictionary with the next structure:
92+
```
93+
{
94+
'b': 'text',
95+
'from': 'ble_device_id',
96+
'ts': 123123123,
97+
'id': '<uuid>',
98+
}
99+
```

0 commit comments

Comments
 (0)