Skip to content

Commit 1bb063f

Browse files
committed
README.md update.
1 parent a260d7a commit 1bb063f

File tree

1 file changed

+72
-15
lines changed

1 file changed

+72
-15
lines changed

README.md

Lines changed: 72 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33

44
This code wraps all the functions necessary to make your object work with Live Objects.
55

6-
You can declare parameters, which you can later update OTA from Live objects. You can also create commands to trigger actions remotely.
7-
Only thing you must do yourself is connecting the board with internet.
6+
You can declare parameters, which you can later update OTA from Live objects. You can also create commands to trigger actions remotely.
7+
Only thing you must do yourself is connecting the board with internet.
88

99
Code uses MQTT connection to exchange data with Live objects under the hood to keep your parameters up to date or execute the commands received without you having to take care of them (apart from writing the code of these commands, of course).
1010

1111
## Compatibility ##
12-
| System | Connectivity | MQTT | MQTTS |
13-
|:--------------|-----------------|:----:|:-----:|
14-
| Linux | Delivered by OS | OK | OK |
15-
| Windows | Delivered by OS | OK | OK |
16-
| Raspberry Pi | Delivered by OS | OK | OK |
17-
| ESP8266 | WiFi | OK | - |
18-
| ESP32 | WiFi | OK | OK |
19-
| LoPy (Pycom) | WiFi | OK | - |
20-
| GPy (Pycom) | WiFi, LTE | OK | - |
12+
| System | MQTT | MQTTS |
13+
|:--------------|:----:|:-----:|
14+
| Linux | OK | OK |
15+
| Windows | OK | OK |
16+
| Raspberry Pi | OK | OK |
17+
| ESP8266 | OK | - |
18+
| ESP32 | OK | OK |
19+
| LoPy (Pycom) | OK | - |
20+
| GPy (Pycom) | OK | - |
2121

2222
## Prerequisites / dependecies ##
2323
This code needs a few libraries to run:
@@ -168,6 +168,60 @@ def foo():
168168
lo.disconnect()
169169
```
170170

171+
### Changing default carrier to connect to the network ###
172+
173+
Every board has its own default carrier for connection to the network (see below).
174+
175+
| System | Default carrier | Optional carrier |
176+
|:--------------|:---------------:|:----------------:|
177+
| Linux | Delivered by OS | - |
178+
| Windows | Delivered by OS | - |
179+
| Raspberry Pi | Delivered by OS | - |
180+
| ESP8266 | Wi-Fi | - |
181+
| ESP32 | Wi-Fi | - |
182+
| LoPy (Pycom) | Wi-Fi | - |
183+
| GPy (Pycom) | Wi-Fi | LTE |
184+
185+
For GPy you can switch connectivity to optional carrier. You need to do change in `Connection` class in `Connection.py`
186+
from:
187+
```Python
188+
def __init__(self, debug=True):
189+
self.__board = LiveObjects.BoardsFactory(net_type=LiveObjects.BoardsInterface.DEFAULT_CARRIER)
190+
...
191+
```
192+
to:
193+
```Python
194+
def __init__(self, debug=True):
195+
self.__board = LiveObjects.BoardsFactory(net_type=LiveObjects.BoardsInterface.LTE)
196+
...
197+
```
198+
Then GPy will connect via LTE network.
199+
200+
### Adding new boards ###
201+
202+
There is possibility to add your new type of board supporting Python/uPython.
203+
You need to add your own class in `hal.py`.
204+
Below code shows basic constructor:
205+
```Python
206+
def __init__(self, net_type):
207+
self._lang_id = BoardsInterface.MICROPYTHON
208+
self._net_type = BoardsInterface.WIFI if net_type == BoardsInterface.DEFAULT_CARRIER else net_type
209+
self._carrier_capability = (BoardsInterface.WIFI,)
210+
self._wifi_tls_capability = False
211+
self._credentials = super().create_credentials(self._net_type)
212+
```
213+
Basic fields meaning:
214+
- **_lang_id**: used Python dialect: PYTHON / MICROPYTHON,
215+
- **_net_type**: used type of network: WIFI / LTE / network delivered by OS / ...
216+
- **_carrier_capability**: _tuple_ containing supported type(s) of network,
217+
- **_wifi_tls_capability**: _True_ if TLS is supported and MQTTS could be used,
218+
- **_credentials**: required credentials depended on network type: SSID/PASS for Wi-Fi, PIN/APN for LTE etc.
219+
220+
If other specific fields are necessary you need to define them.
221+
You need to override specific methods - e.g. `connect` which is depended on type of board.
222+
All specific functions are placed at the end of `hal.py`.
223+
If your board needs function supporting its equipment you need to put it in this place.
224+
171225

172226
# Installation guide for uPython #
173227
## Example for ESP32 / ESP8266 ##
@@ -181,16 +235,17 @@ def foo():
181235
1. Preparation
182236

183237
Change **\<APIKEY\>** in `credentials.py` to one you generated.\
184-
Change **\<WIFI_SSID\>** and **\<WIFI_PASS\>** suitable to your WiFi.
185-
238+
Change **\<WIFI_SSID\>** and **\<WIFI_PASS\>** suitable to your Wi-Fi or
239+
change **\<PIN\>** and **\<APN_NAME\>** suitable to your SIM card.
186240

187241
2. Copy files into device
188242
```Shell
189243
>ampy -pCOMXX put umqttrobust.py
190244
>ampy -pCOMXX put simple.py
191245
>ampy -pCOMXX put LiveObjects // It will copy directory with its content
192246
```
193-
3. Prepare your script and save it as `main.py` then copy file into device. You can use one of example ones (`1_send_data.py`, ...) renaming it to `main.py`
247+
3. Prepare your script and save it as `main.py` then copy file into device.
248+
You can use one of example ones (`1_send_data.py`, ...) renaming it to `main.py`
194249
```Shell
195250
>ampy -pCOMXX put main.py
196251
```
@@ -202,6 +257,7 @@ Change **\<WIFI_SSID\>** and **\<WIFI_PASS\>** suitable to your WiFi.
202257
Ctrl + C Stops currently running script
203258

204259
### Summary ###
260+
205261
After all steps content of the device should look like below:
206262
```Shell
207263
>ampy -pCOMXX ls
@@ -220,7 +276,8 @@ After all steps content of the device should look like below:
220276

221277
## Example for LoPy / GPy ##
222278

223-
You can do the steps as above but better is to use [Pymakr plug-in](https://pycom.io/products/supported-networks/pymakr/) for **Visual Studio Code** or **Atom** delivered by [Pycom](https://pycom.io/). Plug-in supports code development, its upload to board and communication with board.
279+
You can do the steps as above but better is to use [Pymakr plug-in](https://pycom.io/products/supported-networks/pymakr/) for **Visual Studio Code** or **Atom** delivered by [Pycom](https://pycom.io/).
280+
Plug-in supports code development, its upload to the board and communication with board.
224281

225282
## Troubleshooting ##
226283
If you are getting 'MQTT exception: 5' check your api key

0 commit comments

Comments
 (0)