mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-26 22:09:20 +01:00
GitBook: [master] 331 pages modified
This commit is contained in:
committed by
gitbook-bot
parent
f179b56b33
commit
514f62ebce
6
tutorials/lte/README.md
Normal file
6
tutorials/lte/README.md
Normal file
@@ -0,0 +1,6 @@
|
||||
# LTE Examples
|
||||
|
||||
The following tutorials demonstrate the use of the LTE CAT-M1 and NB-IoT functionality on cellular enabled Pycom modules.
|
||||
|
||||
Our cellular modules support both LTE CAT-M1 and NB-IoT, these are new lower power, long range, cellular protocols. These 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.
|
||||
|
||||
43
tutorials/lte/cat-m1.md
Normal file
43
tutorials/lte/cat-m1.md
Normal file
@@ -0,0 +1,43 @@
|
||||
# CAT-M1
|
||||
|
||||
{% hint style="info" %}
|
||||
Please ensure you have the latest Sequans modem firmware for the best network compatibility. Instructions for this can be found [here](firmware.md).
|
||||
{% endhint %}
|
||||
|
||||
The LTE Cat M1 service gives full IP access through the cellular modem.
|
||||
|
||||
Once the `lte.connect()` function has completed all the IP socket functions - including SSL - will be routed through this connection. This mean any code using WLAN can be adapted to Cat M1 by simply adding the connection setup step first and disconnect after.
|
||||
|
||||
For example to connect over LTE Cat M1 to Google's web server over secure SSL:
|
||||
|
||||
```python
|
||||
import socket
|
||||
import ssl
|
||||
import time
|
||||
from network import LTE
|
||||
|
||||
lte = LTE() # instantiate the LTE object
|
||||
lte.attach() # attach the cellular modem to a base station
|
||||
while not lte.isattached():
|
||||
time.sleep(0.25)
|
||||
lte.connect() # start a data session and obtain an IP address
|
||||
while not lte.isconnected():
|
||||
time.sleep(0.25)
|
||||
|
||||
s = socket.socket()
|
||||
s = ssl.wrap_socket(s)
|
||||
s.connect(socket.getaddrinfo('www.google.com', 443)[0][-1])
|
||||
s.send(b"GET / HTTP/1.0\r\n\r\n")
|
||||
print(s.recv(4096))
|
||||
s.close()
|
||||
|
||||
lte.disconnect()
|
||||
lte.dettach()
|
||||
```
|
||||
|
||||
This also applies to our MQTT and AWS examples.
|
||||
|
||||
**IMPORTANT:** Once the LTE radio is initialised, it must be de-initialised before going to deepsleep in order to ensure minimum power consumption. This is required due to the LTE radio being powered independently and allowing use cases which require the system to be taken out from deepsleep by an event from the LTE network \(data or SMS received for instance\).
|
||||
|
||||
When using the expansion board and the FiPy together, the RTS/CTS jumpers **MUST** be removed as those pins are being used by the LTE radio. Keeping those jumpers in place will lead to erratic operation and higher current consumption specially while in deepsleep.
|
||||
|
||||
179
tutorials/lte/firmware.md
Normal file
179
tutorials/lte/firmware.md
Normal file
@@ -0,0 +1,179 @@
|
||||
# Modem Firmware Update
|
||||
|
||||
{% hint style="info" %}
|
||||
This article is only related to GPy, FiPy, and G01 boards
|
||||
{% endhint %}
|
||||
|
||||
{% hint style="danger" %}
|
||||
**Important**: When upgrading your modem for the first time, even if you have updated it in the past with the old firmware update method, you **MUST** use the "recovery" upgrade method described below. Otherwise you will risk breaking your module
|
||||
{% endhint %}
|
||||
|
||||
Please read the following instructions carefully as there are some significant changes compared to the previous updater version.
|
||||
|
||||
Most importantly, the updater is now integrated in the latest stable firmware release \(we will also publish a new development and pybytes firmware in the coming days\), so you no longer need to upload any scripts to your module. The built-in updater will take precedence over any scripts uploaded.
|
||||
|
||||
Please start with the following steps:
|
||||
|
||||
1. Upgrade the Pycom Firmware Updater tool to latest version
|
||||
2. Select Firmware Type `stable` in the communication window to upgrade to version `v1.18.1.r1`
|
||||
|
||||
You can find the different versions of firmwares available here: [https://software.pycom.io/downloads/sequans2.html](https://software.pycom.io/downloads/sequans2.html)
|
||||
|
||||
There are two packages available, one for the latest CAT-M1 firmware, and another for the latest NB-IoT firmware.
|
||||
|
||||
After unpacking the zip archive, you will find each firmware packages contains two files, one being the firmware file \(`CATM1-38638.dup` or `NB1-37781.dup`\) and the `updater.elf` file, which is required when using the "recovery" firmware update method or if a previous upgrade failed and the modem is in recovery mode.
|
||||
|
||||
Please note that the `updater.elf` file is only around 300K so you can also store it inside the flash file system of the module. The firmware dup files will NOT fit into the available `/flash` file system on the module, so you either need to use an SD card or upload it directly from your computer.
|
||||
|
||||
## Via SD card
|
||||
|
||||
To transfer the firmware files onto the SD card you have two options:
|
||||
|
||||
1. Format your SD card as with the FAT file system and then copy the files onto the card using your computer
|
||||
2. Make sure your SD card has an MBR and a single primary partition, the format it directly on the module and mount it.
|
||||
3. Transfer the firmware files onto the SD card using FTP. Please ensure the transfer is successful and that the file on the module has the same size as the original file.
|
||||
|
||||
```python
|
||||
from machine import SD
|
||||
|
||||
sd = SD()
|
||||
os.mkfs(sd) # format SD card
|
||||
os.mount(sd, '/sd') # mount it
|
||||
os.listdir('/sd') # list its content
|
||||
```
|
||||
|
||||
Once you copied/uploaded the firmware files on to the SD card you can flash the LTE modem using the following command:
|
||||
|
||||
To flash the CAT-M1 firmware onto your device:
|
||||
|
||||
```python
|
||||
import sqnsupgrade
|
||||
sqnsupgrade.run('/sd/CATM1-38638.dup', '/sd/updater.elf')
|
||||
```
|
||||
|
||||
To flash the NB-IoT firmware onto your device:
|
||||
|
||||
```python
|
||||
import sqnsupgrade
|
||||
sqnsupgrade.run('/sd/NB1-37781.dup', '/sd/updater.elf')
|
||||
```
|
||||
|
||||
Please note you can directly flash the desired firmware onto your module, it is not necessary to upgrade to the latest CAT-M1 firmware before switching to NB-IoT.
|
||||
|
||||
If you have already mounted the SD card, please use the path you used when mounting it. Otherwise, if an absolute path other than `/flash` is specified, the script will automatically mount the SD card using the path specified.
|
||||
|
||||
Once update is finished successfully you will have a summary of new updated versions. The full output from the upgrade will looks similar to this:
|
||||
|
||||
```text
|
||||
<<< Welcome to the SQN3330 firmware updater >>>
|
||||
Attempting AT wakeup...
|
||||
Starting STP (DO NOT DISCONNECT POWER!!!)
|
||||
Session opened: version 1, max transfer 8192 bytes
|
||||
Sending 54854 bytes: [########################################] 100%
|
||||
Bootrom updated successfully, switching to upgrade mode
|
||||
Attempting AT auto-negotiation...
|
||||
Session opened: version 1, max transfer 2048 bytes
|
||||
Sending 306076 bytes: [########################################] 100%
|
||||
Attempting AT wakeup...
|
||||
Upgrader loaded successfully, modem is in upgrade mode
|
||||
Attempting AT wakeup...
|
||||
Starting STP ON_THE_FLY
|
||||
Session opened: version 1, max transfer 8192 bytes
|
||||
Sending 5996938 bytes: [########################################] 100%
|
||||
Code download done, returning to user mode
|
||||
Resetting (DO NOT DISCONNECT POWER!!!)................
|
||||
Upgrade completed!
|
||||
Here's the current firmware version:
|
||||
|
||||
SYSTEM VERSION
|
||||
==============
|
||||
FIRMWARE VERSION
|
||||
Bootloader0 : 5.1.1.0 [33080]
|
||||
Bootloader1 : 5.1.1.0 [38638]
|
||||
Bootloader2* : 5.1.1.0 [38638]
|
||||
NV Info : 1.1,0,0
|
||||
Software : 5.1.1.0 [38638] by robot-soft at 2018-08-20 09:51:46
|
||||
UE : 5.0.0.0d
|
||||
COMPONENTS
|
||||
ZSP0 : 1.0.99-13604
|
||||
ZSP1 : 1.0.99-12341
|
||||
```
|
||||
|
||||
{% hint style="info" %}
|
||||
|
||||
After you have updated your modem once using the recovery method, you can now flash your modem again using just the `CATM1-38638.dup` or `NB1-37781.dup` file without specifying the `updater.elf` file. However, should the upgrade fail, your modem may end up in recovery mode and you will need the `updater.elf` file again. The updater will check for this and prompt you if using the `updater.elf` file is necessary.
|
||||
|
||||
Example output using just the firmware file:
|
||||
|
||||
```text
|
||||
<<< Welcome to the SQN3330 firmware updater >>>
|
||||
Attempting AT wakeup...
|
||||
|
||||
Starting STP ON_THE_FLY
|
||||
Session opened: version 1, max transfer 8192 bytes
|
||||
Sending 5996938 bytes: [########################################] 100%
|
||||
Code download done, returning to user mode
|
||||
Resetting (DO NOT DISCONNECT POWER!!!)............................................................................
|
||||
Upgrade completed!
|
||||
Here's the current firmware version:
|
||||
|
||||
SYSTEM VERSION
|
||||
==============
|
||||
FIRMWARE VERSION
|
||||
Bootloader0 : 5.1.1.0 [33080]
|
||||
Bootloader1* : 5.1.1.0 [38638]
|
||||
Bootloader2 : 5.1.1.0 [38638]
|
||||
NV Info : 1.1,0,0
|
||||
Software : 5.1.1.0 [38638] by robot-soft at 2018-08-20 09:51:46
|
||||
UE : 5.0.0.0d
|
||||
COMPONENTS
|
||||
ZSP0 : 1.0.99-13604
|
||||
ZSP1 : 1.0.99-12341
|
||||
```
|
||||
|
||||
## Via UART Serial Interface
|
||||
|
||||
If you can't use an SD card to hold the firmware images, you can use the existing UART interface you have with the board to load these firmware files from your Computer.
|
||||
|
||||
You will need the following software installed on your computer:
|
||||
|
||||
1. [Python 3](https://www.python.org/downloads), if it's not directly available through your OS distributor
|
||||
2. [PySerial](https://pythonhosted.org/pyserial/pyserial.html#installation)
|
||||
|
||||
You will also need to download the following Python scripts: [https://github.com/pycom/pycom-libraries/tree/master/lib/sqnsupgrade](https://github.com/pycom/pycom-libraries/tree/master/lib/sqnsupgrade)
|
||||
|
||||
First, you need to prepare your modem for upgrade mode by using the following commands:
|
||||
|
||||
### **Commands to run on the Pycom module**
|
||||
|
||||
```python
|
||||
import sqnsupgrade
|
||||
sqnsupgrade.uart(True)
|
||||
```
|
||||
|
||||
After this command is executed a message will be displayed asking you to close the port.
|
||||
|
||||
```text
|
||||
Going into MIRROR mode... please close this terminal to resume the upgrade via UART
|
||||
```
|
||||
|
||||
### **Commands to be run on your computer**
|
||||
|
||||
You must close the terminal/Atom or Visual Studio Code console to run the following commands from your computer:
|
||||
|
||||
Go to the directory where you saved the `sqnsupgrade` scripts run the following commands in terminal
|
||||
|
||||
```python
|
||||
$ python3
|
||||
Python 3.6.5 (default, Apr 25 2018, 14:23:58)
|
||||
[GCC 4.2.1 Compatible Apple LLVM 9.1.0 (clang-902.0.39.1)] on darwin
|
||||
Type "help", "copyright", "credits" or "license" for more information.
|
||||
>>>
|
||||
>>> import sqnsupgrade
|
||||
>>> sqnsupgrade.run('Serial_Port', '/path/to/CATM1-38638.dup', '/path/to/updater.elf')
|
||||
```
|
||||
|
||||
## Retrying process
|
||||
|
||||
In case of any failure or interruption to the process of LTE modem upgrade you can repeat the same steps **after doing a hard reset to the board \(i.e disconnecting and reconnecting power\), pressing the reset button is not enough.**
|
||||
|
||||
20
tutorials/lte/imei.md
Normal file
20
tutorials/lte/imei.md
Normal file
@@ -0,0 +1,20 @@
|
||||
# Module IMEI
|
||||
|
||||
In order to retrieve the IMEI of your cellular enabled Pycom module you will firstly need to make sure you are on firmware version `1.17.0.b1` or higher. You can check your firmware version by running the following code on you device via the interactive REPL.
|
||||
|
||||
```python
|
||||
>>> import os
|
||||
>>> os.uname()
|
||||
(sysname='GPy', nodename='GPy', release='1.17.0.b1', version='v1.8.6-849-d0dc708 on 2018-02-27', machine='GPy with ESP32')
|
||||
```
|
||||
|
||||
Once you have a compatible firmware, you can run the following code to get your modules IMEI number:
|
||||
|
||||
```python
|
||||
from network import LTE
|
||||
lte = LTE()
|
||||
lte.send_at_cmd('AT+CGSN=1')
|
||||
```
|
||||
|
||||
You’ll get a return string like this `\r\n+CGSN: "354347xxxxxxxxx"\r\n\r\nOK`. The value between the double quotes is your IMEI.
|
||||
|
||||
41
tutorials/lte/nb-iot.md
Normal file
41
tutorials/lte/nb-iot.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# NB-IoT
|
||||
|
||||
## LTE class for Narrow Band IoT
|
||||
|
||||
{% hint style="info" %}
|
||||
As shipped, Pycom modules only support CAT-M1, in order to use NB-IoT you need to flash a different firmware to the Sequans modem. Instructions for this can be found [here](firmware.md).
|
||||
{% endhint %}
|
||||
|
||||
### Current NB-IoT limitations
|
||||
|
||||
At the moment the NB-IoT firmware supplied by Sequans only support Ericsson base stations configured for In-Band mode. Standalone and guard-band modes will be supported in a later release. Support for Huawei base stations is also limited and only lab testing with Huawei eNodeB is recommended at the moment. Full support for Huawei is planned for early Q2 2018.
|
||||
|
||||
## NB-IoT usage
|
||||
|
||||
Example with Vodafone:
|
||||
|
||||
```python
|
||||
from network import LTE
|
||||
|
||||
lte = LTE()
|
||||
lte.send_at_cmd('AT+CFUN=0')
|
||||
lte.send_at_cmd('AT!="clearscanconfig"')
|
||||
lte.send_at_cmd('AT!="addscanfreq band=20 dl-earfcn=6300"')
|
||||
lte.send_at_cmd('AT!="zsp0:npc 1"')
|
||||
lte.send_at_cmd('AT+CGDCONT=1,"IP","nb.inetd.gdsp"')
|
||||
lte.send_at_cmd('AT+CFUN=1')
|
||||
|
||||
while not lte.isattached():
|
||||
pass
|
||||
|
||||
lte.connect()
|
||||
while not lte.isconnected():
|
||||
pass
|
||||
|
||||
# now use socket as usual...
|
||||
```
|
||||
|
||||
**IMPORTANT:** Once the LTE radio is initialised, it must be de-initialised before going to deepsleep in order to ensure minimum power consumption. This is required due to the LTE radio being powered independently and allowing use cases which require the system to be taken out from deepsleep by an event from the LTE network \(data or SMS received for instance\).
|
||||
|
||||
When using the expansion board and the FiPy together, the RTS/CTS jumpers **MUST** be removed as those pins are being used by the LTE radio. Keeping those jumpers in place will lead to erratic operation and higher current consumption specially while in deepsleep.
|
||||
|
||||
Reference in New Issue
Block a user