improved the structure of the network examples

This commit is contained in:
gijsio
2020-08-19 10:23:28 +02:00
parent 77eefea8dd
commit df2488b9e9
7 changed files with 67 additions and 26 deletions

View File

@@ -46,5 +46,5 @@ Always attach the appropriate antenna when using a wireless connection (LoRa / S
### Power
Do not use the 3.3V pin **in combination with** the Vin pin to supply the device as this will damage the voltage regulator on the board.
### Antennas
### Antenna placement
Always attach the appropriate antenna when using a wireless connection (LoRa / LTE). For WiFi / BLE, it is not mandatory to use an external antenna when you did not explicitly specify this in your code.

View File

@@ -6,7 +6,7 @@ title: 'Networks'
The Pycom devices support several different types of networks.
We have the WiFi and Bluetooth connections:
* [WiFi](../networks/wifi/)
* [WiFi](../networks/wlan/)
* [Bluetooth Low Energy](../networks/ble/)
* [LoRa](../networks/lora/)
* [Sigfox]( ../networks/sigfox/)

View File

@@ -6,7 +6,11 @@ aliases:
- chapter/tutorials/all/ble
---
At present, basic BLE functionality is available. More features will be implemented in the near future, such as pairing. This page will be updated in line with these features.
On this page we cover
1. [Scanning for BLE devices](#scan-for-ble-devices)
2. [Connecting to a BLE device](#connect-to-a-ble-device)
1. [Retrieve data](#connect-to-a-ble-device-and-retrieve-data)
2. [Retrieve manufacturer](#connect-to-a-ble-device-and-get-name-and-manufacturer-data)
## Scan for BLE devices
@@ -47,7 +51,7 @@ while True:
print("Connected to device with addr = {}".format(ubinascii.hexlify(adv.mac)))
```
## Connect to a BLE Device and retrieve data
### Connect to a BLE Device and retrieve data
Connecting to a device named 'Heart Rate' and receiving data from it's services.
@@ -81,7 +85,7 @@ while True:
time.sleep(0.050)
```
## Connect to a BLE device and get name and manufacturer data
### Connect to a BLE device and get name and manufacturer data
Using `resolve_adv_data()` to attempt to retrieve the name and manufacturer data from the advertiser.

View File

@@ -6,6 +6,12 @@ aliases:
The following tutorials demonstrate the use of the LoRa functionality on the LoPy. LoRa can work in 2 different modes; **LoRa-MAC** (which we also call Raw-LoRa) and **LoRaWAN** mode.
> Note: LoRa will not work with Pygate firmware loaded on your device. It will return a `/event_groups.c:498 (xEventGroupClearBits)- assert failed!` error.
When using Lora, **Always** connect the appropriate LoRa antenna to your device. See the figures below for the correct antenna placement
| Lopy | Lopy4 | Fipy |
|:---|:---|:---|
| ![](/gitbook/assets/lora_pigtail_ant_lopy.png) | ![](/gitbook/assets/lora_sigfox_pigtail_ant_lopy4.png) | ![](/gitbook/assets/lora_sigfox_pigtail_ant_fipy.png) |
* **LoRaWAN mode** implements the full LoRaWAN stack for a class A device. It supports both OTAA and ABP connection methods, as well as advanced features like adding and removing custom channels to support "special" frequencies plans like the those used in New Zealand. There are two basic ways of accessing the LoraWAN network:
* [LoRaWAN ABP](../lora/lorawan-abp/)
* [LoRaWAN OTAA](../lora/lorawan-otaa/)

View File

@@ -6,6 +6,15 @@ aliases:
The following tutorial demonstrates the use of the LTE CAT-M1 and NB-IoT functionality on cellular enabled Pycom modules.
> Before you start, make sure that your Simcard is registered and activated with your carrier.
When using the SigFox network, **Always** connect the appropriate LoRa antenna to your device. See the figures below for the correct antenna placement
| Gpy | Fipy |
|---|---|
| ![](/gitbook/assets/lte_ant_gpy.png) | ![](/gitbook/assets/lte_ant_fipy.png) |
GPy and FiPy support both LTE CAT-M1 and NB-IoT. These are newer, low power, long range, cellular protocols. They are not the same as the full version of 2G/3G/LTE supported by cell phones, and require your local carriers to support them. At the time of writing, CAT-M1 and NB-IoT connectivity is not widely available so be sure to check with local carriers if support is available where you are. Together with the SIM card, the provider will supply you with configuration details: Usually band and APN. Use these in the example code below.
```python

View File

@@ -6,8 +6,20 @@ aliases:
- chapter/tutorials/sigfox
---
Before you start, make sure that your device was registered with [Sigfox](/gettingstarted/registration/sigfox).
> Before you start, make sure that your device was registered with [Sigfox](/gettingstarted/registration/sigfox).
When using the SigFox network, **Always** connect the appropriate LoRa antenna to your device. See the figures below for the correct antenna placement
| Lopy4 | Fipy |
|---|---|
| ![](/gitbook/assets/lora_sigfox_pigtail_ant_lopy4.png) | ![](/gitbook/assets/lora_sigfox_pigtail_ant_fipy.png) |
On this page we cover
1. [Connecting to Sigfox](#connecting-to-sigfox)
2. [Disengaging Sequence Numbers](#disengaging-sequence-numbers)
## Connecting to SigFox
The following tutorials demonstrate how to register and get started with the SiPy. The board can be configured for operation in various countries based upon specified RCZ zones (see the `Sigfox` class for more info). The SiPy, LoPy 4, and FiPy supports both uplink and downlink `Sigfox` messages as well as device to device communication via its FSK Mode `Sigfox`.
```python
@@ -30,10 +42,8 @@ s.setsockopt(socket.SOL_SIGFOX, socket.SO_RX, False)
s.send(bytes([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]))
```
> Please ensure that there is an antenna connected to your device before sending/receiving Sigfox messages as in proper use (e.g. without an antenna), may damage the device.
## Disengage Sequence Number
## Disengaging Sequence Numbers
If your are experiencing issues with Sigfox connectivity, this could be due to the sequence number being out of sync. To prevent replay on the network, the Sigfox protocol uses sequence numbers. If there is a large difference between the sequence number sent by the device and the one expected by the backend, your message is dropped by the network.

View File

@@ -6,17 +6,17 @@ aliases:
- chapter/tutorials/networks/wlan
---
The WLAN (WiFi) is a system feature of all Pycom devices, therefore it is enabled by default.
The WLAN (WiFi) is a system feature of all Pycom devices, therefore it is enabled by default. The development boards include an on-board antenna by default, so no external antenna is needed to get started. When deploying your solution, you might want to concider using the external antenna to increase the wireless range.
>Note: Changing the WLAN settings while using the Telnet server might break the wireless connection to the device permanently. Please use caution or a USB cable :)
>Note: Changing the WLAN settings while using the Telnet server might break the wireless connection to the device permanently. Please use caution, or a USB cable :)
On this page, we cover:
1. [Connecting to the Device](#connecting-to-the-device)
2. [Connecting to a home Router](#connecting-to-a-router)
* [Scanning for networks](#scan-for-wifi-networks)
* [Assigning a static IP Address](#Assigning-a-Static-IP-Address)
* [Connecting to multiple networks](#Multiple-Networks-using-a-Static-IP-Address)
* [Connecting to a WPA2 Enterprise Network](#Connecting-to-a-WPA2-Enterprise-network)
* [Assigning a static IP Address](#assigning-a-static-ip-address)
* [Connecting to multiple networks](#multiple-networks-using-a-static-ip-address)
* [Connecting to a WPA2 Enterprise Network](#connecting-to-a-wpa2-enterprise-network)
3. [Using an external Antenna](#using-an-external-antenna)
@@ -143,30 +143,42 @@ if machine.reset_cause() != machine.SOFT_RESET:
```
## Connecting to a WPA2-Enterprise network
There are two types of WPA2-Enterprise networks.
* **Connecting with EAP-TLS:**
Before connecting, obtain and copy the public and private keys to the device, e.g. under location `/flash/cert`. If it is required to validate the server's public key, an appropriate CA certificate (chain) must also be provided.
```python
from network import WLAN
```python
from network import WLAN
wlan = WLAN(mode=WLAN.STA)
wlan.connect(ssid='mywifi', auth=(WLAN.WPA2_ENT,), identity='myidentity', ca_certs='/flash/cert/ca.pem', keyfile='/flash/cert/client.key', certfile='/flash/cert/client.crt')
```
wlan = WLAN(mode=WLAN.STA)
wlan.connect(ssid='mywifi', auth=(WLAN.WPA2_ENT,), identity='myidentity', ca_certs='/flash/cert/ca.pem', keyfile='/flash/cert/client.key', certfile='/flash/cert/client.crt')
```
* **Connecting with EAP-PEAP or EAP-TTLS:**
In case of EAP-PEAP (or EAP-TTLS), the client key and certificate are not necessary, only a username and password pair. If it is required to validate the server's public key, an appropriate CA certificate (chain) must also be provided.
```python
from network import WLAN
```python
from network import WLAN
wlan = WLAN(mode=WLAN.STA)
wlan.connect(ssid='mywifi', auth=(WLAN.WPA2_ENT, 'username', 'password'), identity='myidentity', ca_certs='/flash/cert/ca.pem')
```
wlan = WLAN(mode=WLAN.STA)
wlan.connect(ssid='mywifi', auth=(WLAN.WPA2_ENT, 'username', 'password'), [identity='myidentity', ca_certs='/flash/cert/ca.pem'])
```
## Using an external antenna
Connect a WiFi antenna to this U.FL connector on your development board.
![](/gitbook/assets/wifi_pigtail_ant_lopy4.png)
Connect a WiFi antenna to this U.FL connector on your development board. This works the same on all variants. The antenna switch is connected to `P12`.
![](/gitbook/assets/wifi_pigtail_ant_lopy4.png)
To switch the signal towards the external antenna, use
```python
from network import WLAN
wlan = WLAN()
wlan.antenna(WLAN.EXT_ANT)
```