initial commit

This commit is contained in:
Emmanuel Florent
2019-06-17 14:24:53 +02:00
parent 78c4b4c9a1
commit 48e3a22c9e
820 changed files with 12172 additions and 3158 deletions

BIN
.DS_Store vendored Normal file

Binary file not shown.

58
404.txt Normal file
View File

@@ -0,0 +1,58 @@
http://localhost:1313/pybytes/dashboard/connect/
http://localhost:1313/firmwareapi/pycom/network/lora/lora.md
http://localhost:1313/tutorials/lte/nb-iot/firmware
http://localhost:1313/pybytes/introduction/dashboard
http://localhost:1313/firmwareapi/pycom/machine/pin/pin.md
http://localhost:1313/gettingstarted/introduction/connection/
http://localhost:1313/gettingstarted/introduction/installation/
http://localhost:1313/pybytes/introduction/getstarted
http://localhost:1313/pybytes/introduction/integrations/
http://localhost:1313/products/datasheets/boards/pytrack.md
http://localhost:1313/firmwareapi/micropython/ustruct/uzlib/
http://localhost:1313/firmwareapi/pycom/network/wlan/wlan.md
http://localhost:1313/pybytes/introduction/connect/
http://localhost:1313/advance/downgrade/cli.md
http://localhost:1313/development/wipy2
http://localhost:1313/products/datasheets/development/wipy3
http://localhost:1313/getting-started/hardwaresetup/readme/wipy
http://localhost:1313/quick
http://localhost:1313/firmwareapi/notes/pycom/machine/timer.md
http://localhost:1313/products/datasheets/oem/g01
http://localhost:1313/tutorials/pytrack/pysense
http://localhost:1313/products/datasheets/development/lopy4
http://localhost:1313/firmwareapi/micropython/builtin/builtin
http://localhost:1313/advance/downgrade/cli
http://localhost:1313/gettingstarted/introduction/registration/
http://localhost:1313/gitbook/assets/lopy%20%282%29.png
http://localhost:1313/pybytes/connect/flash/quick
http://localhost:1313/products/datasheets/development/fipy
http://localhost:1313/boards/deepsleep/
http://localhost:1313/firmwareapi/notes/pycom/machine/pin
http://localhost:1313/products/datasheets/oem/w01
http://localhost:1313/datasheets/development/wipy2/wipy3
http://localhost:1313/datasheets/oem/l01_reference/universal_reference
http://localhost:1313/products/datasheets/boards/expansion3.md
http://localhost:1313/notes.md
http://localhost:1313/gettingstarted/introduction/programming/
http://localhost:1313/tutorials/lte/cat-m1/firmware
http://localhost:1313/getting-started/hardwaresetup/readme/lopy
http://localhost:1313/products/datasheets/oem/l01
http://localhost:1313/products/datasheets/oem/l04
http://localhost:1313/products/datasheets/oem/universal_reference
http://localhost:1313/pybytes/connect/quick/flash
http://localhost:1313/introduction
http://localhost:1313/products/datasheets/development/sipy
http://localhost:1313/firmwareapi/pycom/machine/sd/sd.md
http://localhost:1313/products/datasheets/boards/pysense.md
http://localhost:1313/products/datasheets/development/gpy
http://localhost:1313/getting-started/hardwaresetup/readme/lopy4
http://localhost:1313/products/datasheets/development/lopy
http://localhost:1313/firmwareapi/pycom/network/lora.md
http://localhost:1313/products/datasheets/boards/pyscan.md
http://localhost:1313/products/datasheets/oem/l01_reference
http://localhost:1313/firmwareapi/micropython/usocket/usocket.md
http://localhost:1313/pycom/aes
FINISHED --2019-06-17 14:18:41--
Total wall clock time: 2.2s
Downloaded: 250 files, 7.8M in 0.08s (96.7 MB/s)

View File

@@ -1,13 +1,43 @@
# Introduction
# local visualization
Welcome to the Pycom documentation site. We recommend reading through all the sections to familiarise yourself with the various tools and features available to you to help you develop on your Pycom module.
.md files are in the content folder, the theme forlder contains the theme.
To get started, read through the Getting Started guide then feel free to jump straight into the tutorials and examples in Tutorials & Examples to begin building your projects.
install Hugo and run it on the current directory.
```
brew install hugo
hugo serve
```
* [Products](products.md)
* [Getting Started](gettingstarted/introduction.md)
* [Tutorials](tutorials/introduction.md)
* [Product Info](datasheets/introduction.md)
* [API Documentation](firmwareapi/introduction.md)
* [Pybytes](pybytes/introduction.md)
The file config.toml contains the global .toml
# First generation of publish branch
Some commands that have been used for building:
- ```
# it clone gh-pages in ./tmp/ and appy all .md files
./reclone.sh
# generate toc, title, redirects
python3 migration.py
# apply this changes to remove remaining not needed slashes protections
rpl -R '\)' ')' *
rpl -R '(' '(' *
# use carrefully but there should be not .html in content
# find "./content/" -name "*.html" -exec rm {} \;
# then finally fix link self to images
rpl -R "gitbook/assets/" "gitbook/assets/" *
rpl -R "../gitbook/assets" "/gitbook/assets" content
rpl -R "..//gitbook/assets" "/gitbook/assets" content
rpl -R "" "'" content
rpl -R "✔" "✔" content
rpl -R "(../" "(/"
# get the images in static
cp tmp/pydocs/gitbook/assets/* static/gitbook/assets/
```
# detect broken links
```
wget -o 404.txt -r --spider http://localhost:1313
cat ~/output.txt | grep -B 7 404 | grep "\-\-20"
```

View File

@@ -1,217 +0,0 @@
# Table of contents
* [Introduction](README.md)
* [Pycom Products](products.md)
## Getting Started
* [Introduction](gettingstarted/introduction.md)
* [Hardware Setup](gettingstarted/connection/README.md)
* [LoPy](gettingstarted/connection/lopy.md)
* [LoPy 4](gettingstarted/connection/lopy4.md)
* [SiPy](gettingstarted/connection/sipy.md)
* [GPy](gettingstarted/connection/gpy.md)
* [FiPy](gettingstarted/connection/fipy.md)
* [WiPy](gettingstarted/connection/wipy.md)
* [Software](gettingstarted/installation/README.md)
* [Drivers](gettingstarted/installation/drivers.md)
* [Updating Firmware](gettingstarted/installation/firmwaretool.md)
* [Pymakr](gettingstarted/installation/pymakr.md)
* [Programming the modules](gettingstarted/programming/README.md)
* [Introduction to MicroPython](gettingstarted/programming/micropython.md)
* [MicroPython Examples](gettingstarted/programming/examples.md)
* [Your first Pymakr project](gettingstarted/programming/first-project.md)
* [REPL](gettingstarted/programming/repl/README.md)
* [Serial USB \(UART\)](gettingstarted/programming/repl/serial.md)
* [Telnet REPL](gettingstarted/programming/repl/telnet.md)
* [FTP](gettingstarted/programming/ftp.md)
* [Safe boot](gettingstarted/programming/safeboot.md)
* [Device Registration](gettingstarted/registration/README.md)
* [Sigfox](gettingstarted/registration/sigfox.md)
* [Cellular](gettingstarted/registration/cellular.md)
* [LoRaWAN](gettingstarted/registration/lora/README.md)
* [The Things Network](gettingstarted/registration/lora/ttn.md)
* [Objenious](gettingstarted/registration/lora/objenious.md)
## Pymakr Plugin
* [Installation](pymakr/installation/README.md)
* [Atom](pymakr/installation/atom.md)
* [Visual Studio Code](pymakr/installation/vscode.md)
* [Tools/Features](pymakr/toolsfeatures.md)
* [Settings](pymakr/settings.md)
## Pytrack, Pysense, Pyscan
* [Introduction](pytrackpysense/introduction.md)
* [Installing Software](pytrackpysense/installation/README.md)
* [Updating Firmware](pytrackpysense/installation/firmware.md)
* [Installing Drivers - Windows 7](pytrackpysense/installation/drivers.md)
* [Installing Libraries](pytrackpysense/installation/libraries.md)
* [API Reference](pytrackpysense/apireference/README.md)
* [Pytrack](pytrackpysense/apireference/pytrack.md)
* [Pysense](pytrackpysense/apireference/pysense.md)
* [Pyscan](pytrackpysense/apireference/pyscan.md)
* [Sleep](pytrackpysense/apireference/sleep.md)
## Tutorials & Examples
* [Introduction](tutorials/introduction.md)
* [All Pycom Device Examples](tutorials/all/README.md)
* [REPL](tutorials/all/repl.md)
* [WLAN](tutorials/all/wlan.md)
* [Bluetooth](tutorials/all/ble.md)
* [HTTPS](tutorials/all/https.md)
* [MQTT](tutorials/all/mqtt.md)
* [AWS](tutorials/all/aws.md)
* [ADC](tutorials/all/adc.md)
* [I2C](tutorials/all/i2c.md)
* [Onewire Driver](tutorials/all/owd.md)
* [Threading](tutorials/all/threading.md)
* [RGB LED](tutorials/all/rgbled.md)
* [Timers](tutorials/all/timers.md)
* [PIR Sensor](tutorials/all/pir.md)
* [Modbus](tutorials/all/modbus.md)
* [OTA update](tutorials/all/ota.md)
* [RMT](tutorials/all/rmt.md)
* [Socket](tutorials/all/socket.md)
* [Touch](tutorials/all/touch.md)
* [LoRa Examples](tutorials/lora/README.md)
* [LoRa-MAC \(Raw LoRa\)](tutorials/lora/lora-mac.md)
* [LoRaWAN with OTAA](tutorials/lora/lorawan-otaa.md)
* [LoRaWAN with ABP](tutorials/lora/lorawan-abp.md)
* [LoRa-MAC Nano-Gateway](tutorials/lora/lora-mac-nano-gateway.md)
* [LoPy to LoPy](tutorials/lora/module-module.md)
* [LoRaWAN Nano-Gateway](tutorials/lora/lorawan-nano-gateway.md)
* [RN2483 to LoPy](tutorials/lora/rn2483-to-lopy.md)
* [LoRa Mesh](tutorials/lora/lora-mesh.md)
* [PyMesh Border Router](tutorials/lora/pymesh-br.md)
* [Sigfox Examples](tutorials/sigfox.md)
* [LTE Examples](tutorials/lte/README.md)
* [CAT-M1](tutorials/lte/cat-m1.md)
* [NB-IoT](tutorials/lte/nb-iot.md)
* [Module IMEI](tutorials/lte/imei.md)
* [Modem Firmware Update](tutorials/lte/firmware.md)
* [Pytrack Examples](tutorials/pytrack.md)
* [Pysense Examples](tutorials/pysense.md)
* [Pyscan Examples](tutorials/pyscan.md)
## Firmware & API Reference
* [Introduction](firmwareapi/introduction.md)
* [Pycom Modules](firmwareapi/pycom/README.md)
* [machine](firmwareapi/pycom/machine/README.md)
* [ADC](firmwareapi/pycom/machine/adc.md)
* [DAC](firmwareapi/pycom/machine/dac.md)
* [I2C](firmwareapi/pycom/machine/i2c.md)
* [Pin](firmwareapi/pycom/machine/pin.md)
* [PWM](firmwareapi/pycom/machine/pwm.md)
* [RTC](firmwareapi/pycom/machine/rtc.md)
* [SPI](firmwareapi/pycom/machine/spi.md)
* [UART](firmwareapi/pycom/machine/uart.md)
* [WDT](firmwareapi/pycom/machine/wdt.md)
* [Timer](firmwareapi/pycom/machine/timer.md)
* [SD](firmwareapi/pycom/machine/sd.md)
* [CAN](firmwareapi/pycom/machine/can.md)
* [RMT](firmwareapi/pycom/machine/rmt.md)
* [network](firmwareapi/pycom/network/README.md)
* [WLAN](firmwareapi/pycom/network/wlan.md)
* [Server](firmwareapi/pycom/network/server.md)
* [Bluetooth](firmwareapi/pycom/network/bluetooth/README.md)
* [GATT](firmwareapi/pycom/network/bluetooth/gatt.md)
* [GATTCConnection](firmwareapi/pycom/network/bluetooth/gattcconnection.md)
* [GATTCService](firmwareapi/pycom/network/bluetooth/gattccservice.md)
* [GATTCCharacteristic](firmwareapi/pycom/network/bluetooth/gattccharacteristic.md)
* [GATTSService](firmwareapi/pycom/network/bluetooth/gattsservice.md)
* [GATTSCharacteristic](firmwareapi/pycom/network/bluetooth/gattscharacteristic.md)
* [LoRa](firmwareapi/pycom/network/lora/README.md)
* [Pymesh](firmwareapi/pycom/network/lora/pymesh.md)
* [Sigfox](firmwareapi/pycom/network/sigfox.md)
* [LTE](firmwareapi/pycom/network/lte.md)
* [AES](firmwareapi/pycom/aes.md)
* [pycom](firmwareapi/pycom/pycom.md)
* [MicroPython Modules](firmwareapi/micropython/README.md)
* [micropython](firmwareapi/micropython/micropython.md)
* [uctypes](firmwareapi/micropython/uctypes.md)
* [sys](firmwareapi/micropython/sys.md)
* [uos](firmwareapi/micropython/uos.md)
* [array](firmwareapi/micropython/array.md)
* [cmath](firmwareapi/micropython/cmath.md)
* [math](firmwareapi/micropython/math.md)
* [gc](firmwareapi/micropython/gc.md)
* [ubinascii](firmwareapi/micropython/ubinascii.md)
* [ujson](firmwareapi/micropython/ujson.md)
* [ure](firmwareapi/micropython/ure.md)
* [usocket](firmwareapi/micropython/usocket.md)
* [select](firmwareapi/micropython/select.md)
* [utime](firmwareapi/micropython/utime.md)
* [uhashlib](firmwareapi/micropython/uhashlib.md)
* [ussl](firmwareapi/micropython/ussl.md)
* [ucrypto](firmwareapi/micropython/ucrypto.md)
* [ustruct](firmwareapi/micropython/ustruct/README.md)
* [uzlib](firmwareapi/micropython/ustruct/uzlib.md)
* [\_thread](firmwareapi/micropython/_thread.md)
* [Builtin](firmwareapi/micropython/builtin.md)
* [Notes](firmwareapi/notes.md)
## Product Info, Datasheets
* [Introduction](datasheets/introduction.md)
* [Development Modules](datasheets/development/README.md)
* [WiPy 2.0](datasheets/development/wipy2.md)
* [WiPy 3.0](datasheets/development/wipy3.md)
* [LoPy](datasheets/development/lopy.md)
* [LoPy 4](datasheets/development/lopy4.md)
* [SiPy](datasheets/development/sipy.md)
* [GPy](datasheets/development/gpy.md)
* [FiPy](datasheets/development/fipy.md)
* [OEM Modules](datasheets/oem/README.md)
* [W01](datasheets/oem/w01.md)
* [L01](datasheets/oem/l01.md)
* [L04](datasheets/oem/l04.md)
* [G01](datasheets/oem/g01.md)
* [L01 OEM Baseboard Reference](datasheets/oem/l01_reference.md)
* [Universal OEM Baseboard Reference](datasheets/oem/universal_reference.md)
* [Expansion Boards and Shields](datasheets/boards/README.md)
* [Expansion Board 3.0](datasheets/boards/expansion3.md)
* [Pytrack](datasheets/boards/pytrack.md)
* [Pysense](datasheets/boards/pysense.md)
* [Pyscan](datasheets/boards/pyscan.md)
* [Expansion Board 2.0](datasheets/boards/expansion2.md)
* [Deep Sleep Shield](datasheets/boards/deepsleep/README.md)
* [Deep Sleep API](datasheets/boards/deepsleep/api.md)
* [Notes](datasheets/notes.md)
## Pybytes
* [Introduction](pybytes/introduction.md)
* [Getting Started with Pybytes](pybytes/getstarted.md)
* [Add a device to Pybytes](pybytes/connect/README.md)
* [Connect to Pybytes: Quick Add](pybytes/connect/quick.md)
* [Connect to Pybytes: Flash Pybytes library manually](pybytes/connect/flash.md)
* [Add Sigfox device](pybytes/connect/sigfox/README.md)
* [DevKit contract](pybytes/connect/sigfox/devkit.md)
* [Custom contract](pybytes/connect/sigfox/custom.md)
* [Visualise data from your device](pybytes/dashboard.md)
* [Integrations](pybytes/integrations/README.md)
* [Amazon IoT](pybytes/integrations/amazon-iot.md)
## Documentation Notes
* [Introduction](docnotes/introduction.md)
* [Syntax](docnotes/syntax.md)
* [REPL vs Scripts](docnotes/replscript.md)
* [Mesh Networks](docnotes/mesh-networks.md)
## Advanced Topics
* [Firmware Downgrade](advance/downgrade.md)
* [CLI Updater](advance/cli.md)
* [SecureBoot and Encryption](advance/encryption.md)
* [License](advance/license.md)
## Have a question?
* [Ask on the Forum](https://forum.pycom.io)

1293
config.toml Normal file

File diff suppressed because it is too large Load Diff

BIN
content/.DS_Store vendored Normal file

Binary file not shown.

15
content/README.md Normal file
View File

@@ -0,0 +1,15 @@
---
title: "Introduction"
aliases:
---
Welcome to the Pycom documentation site. We recommend reading through all the sections to familiarise yourself with the various tools and features available to you to help you develop on your Pycom module.
To get started, read through the Getting Started guide then feel free to jump straight into the tutorials and examples in Tutorials & Examples to begin building your projects.
* [Products](products)
* [Getting Started](gettingstarted/introduction)
* [Tutorials](tutorials/introduction)
* [Product Info](datasheets/introduction)
* [API Documentation](firmwareapi/introduction)
* [Pybytes](pybytes/introduction)

221
content/SUMMARY.md Normal file
View File

@@ -0,0 +1,221 @@
---
title: ""
aliases:
- SUMMARY.html
- SUMMARY.md
---
* [Introduction](README)
* [Pycom Products](products)
## Getting Started
* [Introduction](gettingstarted/introduction)
* [Hardware Setup](gettingstarted/connection/README)
* [LoPy](gettingstarted/connection/lopy)
* [LoPy 4](gettingstarted/connection/lopy4)
* [SiPy](gettingstarted/connection/sipy)
* [GPy](gettingstarted/connection/gpy)
* [FiPy](gettingstarted/connection/fipy)
* [WiPy](gettingstarted/connection/wipy)
* [Software](gettingstarted/installation/README)
* [Drivers](gettingstarted/installation/drivers)
* [Updating Firmware](gettingstarted/installation/firmwaretool)
* [Pymakr](gettingstarted/installation/pymakr)
* [Programming the modules](gettingstarted/programming/README)
* [Introduction to MicroPython](gettingstarted/programming/micropython)
* [MicroPython Examples](gettingstarted/programming/examples)
* [Your first Pymakr project](gettingstarted/programming/first-project)
* [REPL](gettingstarted/programming/repl/README)
* [Serial USB (UART)](gettingstarted/programming/repl/serial)
* [Telnet REPL](gettingstarted/programming/repl/telnet)
* [FTP](gettingstarted/programming/ftp)
* [Safe boot](gettingstarted/programming/safeboot)
* [Device Registration](gettingstarted/registration/README)
* [Sigfox](gettingstarted/registration/sigfox)
* [Cellular](gettingstarted/registration/cellular)
* [LoRaWAN](gettingstarted/registration/lora/README)
* [The Things Network](gettingstarted/registration/lora/ttn)
* [Objenious](gettingstarted/registration/lora/objenious)
## Pymakr Plugin
* [Installation](pymakr/installation/README)
* [Atom](pymakr/installation/atom)
* [Visual Studio Code](pymakr/installation/vscode)
* [Tools/Features](pymakr/toolsfeatures)
* [Settings](pymakr/settings)
## Pytrack, Pysense, Pyscan
* [Introduction](pytrackpysense/introduction)
* [Installing Software](pytrackpysense/installation/README)
* [Updating Firmware](pytrackpysense/installation/firmware)
* [Installing Drivers - Windows 7](pytrackpysense/installation/drivers)
* [Installing Libraries](pytrackpysense/installation/libraries)
* [API Reference](pytrackpysense/apireference/README)
* [Pytrack](pytrackpysense/apireference/pytrack)
* [Pysense](pytrackpysense/apireference/pysense)
* [Pyscan](pytrackpysense/apireference/pyscan)
* [Sleep](pytrackpysense/apireference/sleep)
## Tutorials & Examples
* [Introduction](tutorials/introduction)
* [All Pycom Device Examples](tutorials/all/README)
* [REPL](tutorials/all/repl)
* [WLAN](tutorials/all/wlan)
* [Bluetooth](tutorials/all/ble)
* [HTTPS](tutorials/all/https)
* [MQTT](tutorials/all/mqtt)
* [AWS](tutorials/all/aws)
* [ADC](tutorials/all/adc)
* [I2C](tutorials/all/i2c)
* [Onewire Driver](tutorials/all/owd)
* [Threading](tutorials/all/threading)
* [RGB LED](tutorials/all/rgbled)
* [Timers](tutorials/all/timers)
* [PIR Sensor](tutorials/all/pir)
* [Modbus](tutorials/all/modbus)
* [OTA update](tutorials/all/ota)
* [RMT](tutorials/all/rmt)
* [Socket](tutorials/all/socket)
* [Touch](tutorials/all/touch)
* [LoRa Examples](tutorials/lora/README)
* [LoRa-MAC (Raw LoRa)](tutorials/lora/lora-mac)
* [LoRaWAN with OTAA](tutorials/lora/lorawan-otaa)
* [LoRaWAN with ABP](tutorials/lora/lorawan-abp)
* [LoRa-MAC Nano-Gateway](tutorials/lora/lora-mac-nano-gateway)
* [LoPy to LoPy](tutorials/lora/module-module)
* [LoRaWAN Nano-Gateway](tutorials/lora/lorawan-nano-gateway)
* [RN2483 to LoPy](tutorials/lora/rn2483-to-lopy)
* [LoRa Mesh](tutorials/lora/lora-mesh)
* [PyMesh Border Router](tutorials/lora/pymesh-br)
* [Sigfox Examples](tutorials/sigfox)
* [LTE Examples](tutorials/lte/README)
* [CAT-M1](tutorials/lte/cat-m1)
* [NB-IoT](tutorials/lte/nb-iot)
* [Module IMEI](tutorials/lte/imei)
* [Modem Firmware Update](tutorials/lte/firmware)
* [Pytrack Examples](tutorials/pytrack)
* [Pysense Examples](tutorials/pysense)
* [Pyscan Examples](tutorials/pyscan)
## Firmware & API Reference
* [Introduction](firmwareapi/introduction)
* [Pycom Modules](firmwareapi/pycom/README)
* [machine](firmwareapi/pycom/machine/README)
* [ADC](firmwareapi/pycom/machine/adc)
* [DAC](firmwareapi/pycom/machine/dac)
* [I2C](firmwareapi/pycom/machine/i2c)
* [Pin](firmwareapi/pycom/machine/pin)
* [PWM](firmwareapi/pycom/machine/pwm)
* [RTC](firmwareapi/pycom/machine/rtc)
* [SPI](firmwareapi/pycom/machine/spi)
* [UART](firmwareapi/pycom/machine/uart)
* [WDT](firmwareapi/pycom/machine/wdt)
* [Timer](firmwareapi/pycom/machine/timer)
* [SD](firmwareapi/pycom/machine/sd)
* [CAN](firmwareapi/pycom/machine/can)
* [RMT](firmwareapi/pycom/machine/rmt)
* [network](firmwareapi/pycom/network/README)
* [WLAN](firmwareapi/pycom/network/wlan)
* [Server](firmwareapi/pycom/network/server)
* [Bluetooth](firmwareapi/pycom/network/bluetooth/README)
* [GATT](firmwareapi/pycom/network/bluetooth/gatt)
* [GATTCConnection](firmwareapi/pycom/network/bluetooth/gattcconnection)
* [GATTCService](firmwareapi/pycom/network/bluetooth/gattccservice)
* [GATTCCharacteristic](firmwareapi/pycom/network/bluetooth/gattccharacteristic)
* [GATTSService](firmwareapi/pycom/network/bluetooth/gattsservice)
* [GATTSCharacteristic](firmwareapi/pycom/network/bluetooth/gattscharacteristic)
* [LoRa](firmwareapi/pycom/network/lora/README)
* [Pymesh](firmwareapi/pycom/network/lora/pymesh)
* [Sigfox](firmwareapi/pycom/network/sigfox)
* [LTE](firmwareapi/pycom/network/lte)
* [AES](firmwareapi/pycom/aes)
* [pycom](firmwareapi/pycom/pycom)
* [MicroPython Modules](firmwareapi/micropython/README)
* [micropython](firmwareapi/micropython/micropython)
* [uctypes](firmwareapi/micropython/uctypes)
* [sys](firmwareapi/micropython/sys)
* [uos](firmwareapi/micropython/uos)
* [array](firmwareapi/micropython/array)
* [cmath](firmwareapi/micropython/cmath)
* [math](firmwareapi/micropython/math)
* [gc](firmwareapi/micropython/gc)
* [ubinascii](firmwareapi/micropython/ubinascii)
* [ujson](firmwareapi/micropython/ujson)
* [ure](firmwareapi/micropython/ure)
* [usocket](firmwareapi/micropython/usocket)
* [select](firmwareapi/micropython/select)
* [utime](firmwareapi/micropython/utime)
* [uhashlib](firmwareapi/micropython/uhashlib)
* [ussl](firmwareapi/micropython/ussl)
* [ucrypto](firmwareapi/micropython/ucrypto)
* [ustruct](firmwareapi/micropython/ustruct/README)
* [uzlib](firmwareapi/micropython/ustruct/uzlib)
* [\_thread](firmwareapi/micropython/_thread)
* [Builtin](firmwareapi/micropython/builtin)
* [Notes](firmwareapi/notes)
## Product Info, Datasheets
* [Introduction](datasheets/introduction)
* [Development Modules](datasheets/development/README)
* [WiPy 2.0](datasheets/development/wipy2)
* [WiPy 3.0](datasheets/development/wipy3)
* [LoPy](datasheets/development/lopy)
* [LoPy 4](datasheets/development/lopy4)
* [SiPy](datasheets/development/sipy)
* [GPy](datasheets/development/gpy)
* [FiPy](datasheets/development/fipy)
* [OEM Modules](datasheets/oem/README)
* [W01](datasheets/oem/w01)
* [L01](datasheets/oem/l01)
* [L04](datasheets/oem/l04)
* [G01](datasheets/oem/g01)
* [L01 OEM Baseboard Reference](datasheets/oem/l01_reference)
* [Universal OEM Baseboard Reference](datasheets/oem/universal_reference)
* [Expansion Boards and Shields](datasheets/boards/README)
* [Expansion Board 3.0](datasheets/boards/expansion3)
* [Pytrack](datasheets/boards/pytrack)
* [Pysense](datasheets/boards/pysense)
* [Pyscan](datasheets/boards/pyscan)
* [Expansion Board 2.0](datasheets/boards/expansion2)
* [Deep Sleep Shield](datasheets/boards/deepsleep/README)
* [Deep Sleep API](datasheets/boards/deepsleep/api)
* [Notes](datasheets/notes)
## Pybytes
* [Introduction](pybytes/introduction)
* [Getting Started with Pybytes](pybytes/getstarted)
* [Add a device to Pybytes](pybytes/connect/README)
* [Connect to Pybytes: Quick Add](pybytes/connect/quick)
* [Connect to Pybytes: Flash Pybytes library manually](pybytes/connect/flash)
* [Add Sigfox device](pybytes/connect/sigfox/README)
* [DevKit contract](pybytes/connect/sigfox/devkit)
* [Custom contract](pybytes/connect/sigfox/custom)
* [Visualise data from your device](pybytes/dashboard)
* [Integrations](pybytes/integrations/README)
* [Amazon IoT](pybytes/integrations/amazon-iot)
## Documentation Notes
* [Introduction](docnotes/introduction)
* [Syntax](docnotes/syntax)
* [REPL vs Scripts](docnotes/replscript)
* [Mesh Networks](docnotes/mesh-networks)
## Advanced Topics
* [Firmware Downgrade](advance/downgrade)
* [CLI Updater](advance/cli)
* [SecureBoot and Encryption](advance/encryption)
* [License](advance/license)
## Have a question?
* [Ask on the Forum](https://forum.pycom.io)

15
content/_index.md Normal file
View File

@@ -0,0 +1,15 @@
---
title: "Introduction"
aliases:
---
Welcome to the Pycom documentation site. We recommend reading through all the sections to familiarise yourself with the various tools and features available to you to help you develop on your Pycom module.
To get started, read through the Getting Started guide then feel free to jump straight into the tutorials and examples in Tutorials & Examples to begin building your projects.
* [Products](products)
* [Getting Started](gettingstarted/introduction)
* [Tutorials](tutorials/introduction)
* [Product Info](datasheets/introduction)
* [API Documentation](firmwareapi/introduction)
* [Pybytes](pybytes/introduction)

View File

@@ -1,5 +1,10 @@
# CLI Updater
---
title: "CLI Updater"
aliases:
- advance/cli.html
- advance/cli.md
- chapter/advance/cli
---
## Command Line Update Utility
#### Windows
@@ -15,7 +20,7 @@ In order to get access to the CLI tool on macOS, you will need to right click on
#### Linux
In the [Ubuntu 14.04 LTS](https://software.pycom.io/findupgrade?product=pycom-firmware-updater&type=all&platform=unix&redirect=true) \(and newer\) version of the updater tool, `pycom-fwtool-cli` is installed in `/usr/local/bin`. In the [Generic Linux](https://software.pycom.io/findupgrade?product=pycom-firmware-updater&type=all&platform=unix&redirect=true) package, the tool is extracted into folder `./pyupgrade`
In the [Ubuntu 14.04 LTS](https://software.pycom.io/findupgrade?product=pycom-firmware-updater&type=all&platform=unix&redirect=true) (and newer) version of the updater tool, `pycom-fwtool-cli` is installed in `/usr/local/bin`. In the [Generic Linux](https://software.pycom.io/findupgrade?product=pycom-firmware-updater&type=all&platform=unix&redirect=true) package, the tool is extracted into folder `./pyupgrade`
### Usage
@@ -65,7 +70,7 @@ optional arguments:
## How to use the Parameters
{% hint style="info" %}
{{{% hint style="info" %}}}
The CLI tool uses a combination of global and command specific parameters. The **order of parameters** is **important** to avoid ambiguity.
`pycom-fwtool-cli [global parameters] [command] [command parameters]`
@@ -73,7 +78,7 @@ The CLI tool uses a combination of global and command specific parameters. The *
While `pycom-fwtool-cli -h` shows help for global parameters and a list of available commands, command specific parameters can be viewed using `pycom-fwtool-cli [command] -h`
The parameter `-r, --reset` has been added as a courtesy for users of 3rd party ESP32 products. This functionality is **not supported** by the Expansion Board 2.0 and may cause this tool to crash or hang in certain circumstances.
{% endhint %}
{{< /hint >}}
### Global Parameters
@@ -118,7 +123,7 @@ On Windows:
COM6 [Pytrack] [USB VID:PID=04D8:F013 SER=Py343434 LOCATION=20-2]
```
{% hint style="info" %}
{{{% hint style="info" %}}}
This is the only command that does not require any additional parameters.
All other commands require that **the serial port is specified either through the** `-p` **/** `--port` **option or through environment variable** `ESPPORT` You can optionally specify the speed either through `-s` / `--speed` or via environment variable `ESPBAUD`. The default speed is `921600`. The maximum speed for read operations on PIC based expansion boards & shields is `230400`. The speed will be reduced automatically if necessary.
@@ -126,7 +131,7 @@ All other commands require that **the serial port is specified either through th
#### Special note for Expansion Board 2.0
You will need to have a **jumper wire** connected between `G23` and `GND` to use any of the commands below. You will also need to **press the reset button** either before running each command or at least before running the first command. To avoid having to press the reset button again after each command, you can use the `-c` / `--continuation` option. The first command connecting to the device **MUST NOT** use the `-c` / `--continuation` option. This is to make sure a program called `_stub_` is uploaded onto the device. This `_stub_` cannot be uploaded more than once, so you need to tell the cli tool that the `_stub_` is already running, which is done through using the `-c` / `--continuation` option.
{% endhint %}
{{< /hint >}}
#### chip\_id
@@ -259,13 +264,13 @@ optional arguments:
Set extra preferences
```
{% hint style="info" %}
Note: The local `pybytes_config.json` file is overwritten when making any modifications using this command \(requires Pybytes firmware `1.17.5.b6` or higher and Firmware updater `1.14.3`\).
{% endhint %}
{{{% hint style="info" %}}}
Note: The local `pybytes_config.json` file is overwritten when making any modifications using this command (requires Pybytes firmware `1.17.5.b6` or higher and Firmware updater `1.14.3`).
{{< /hint >}}
#### cb
Read/Write config block \(LPMAC, Sigfox PAC & ID, etc.\). You can find the structure of this block [here.](https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/pycom_config.h#L24)
Read/Write config block (LPMAC, Sigfox PAC & ID, etc.). You can find the structure of this block [here.](https://github.com/pycom/pycom-micropython-sigfox/blob/master/esp32/pycom_config.h#L24)
```text
usage: pycom-fwtool-cli -p PORT cb [-h] [-f FILE] [-b] [-r]
@@ -325,7 +330,7 @@ To restore your OTA block: `$pycom-fwtool-cli -p PORT ota -r -f backup.ota`
#### lpwan
Get/Set LPWAN parameters saved to non-volatile storage. Please see [here](../firmwareapi/pycom/network/lora.md##loranvramsave) for more details.
Get/Set LPWAN parameters saved to non-volatile storage. Please see [here](/firmwareapi/pycom/network/lora.md##loranvramsave) for more details.
```text
usage: pycom-fwtool-cli -p PORT lpwan [-h] [--region REGION]

View File

@@ -1,10 +1,15 @@
# Firmware Downgrade
---
title: "Firmware Downgrade"
aliases:
- advance/downgrade.html
- advance/downgrade.md
- chapter/advance/downgrade
---
The firmware upgrade tool usually updates your device to the latest available firmware version. If you require to downgrade your device to a previous firmware there are two methods to achieve this.
{% hint style="info" %}
{{{% hint style="info" %}}}
If you are using an Expansion Board 1.0 or 2.0, you will need to have a jumper connected between `G23` and `GND` to use either procedure below. You will also need to press the reset button before beginning.
{% endhint %}
{{< /hint >}}
You can obtain previous firmware versions here:
@@ -15,9 +20,9 @@ You can obtain previous firmware versions here:
* [FiPy](https://software.pycom.io/downloads/FiPy.html)
* [LoPy4](https://software.pycom.io/downloads/LoPy4.html)
{% hint style="info" %}
Prior to version `1.16.0.b1` the firmware for modules with LoRa functionality was frequency specific. From `1.16.0.b1` and onward, the firmware is region agnostic and this can either be set programatically or via the config block \(see [here](cli.md#lpwan)\).
{% endhint %}
{{{% hint style="info" %}}}
Prior to version `1.16.0.b1` the firmware for modules with LoRa functionality was frequency specific. From `1.16.0.b1` and onward, the firmware is region agnostic and this can either be set programatically or via the config block (see [here](cli.md#lpwan)).
{{< /hint >}}
## GUI
@@ -25,13 +30,13 @@ As of version `1.12.0.b0` of the firmware update tool, you can now provide a `.t
When you start the update tool you will see the following screen:
![](../.gitbook/assets/downgrade_gui%20%281%29.png)
![](/gitbook/assets/downgrade_gui%20%281%29.png)
When you tick the `Flash from local file` option, an address bar will appear. Click the `...` button and locate the `.tar(.gz)` file with the firmware you wish to flash to your device. From this point the updater will behave just like a regular update but using the local file instead of downloading the latest.
## Command line
You can also use the [CLI](cli.md) version of the update tool to downgrade your device. Will need to get a `.tar` or `.tar.gz` archive of the firmware you wish to upload to the board. Then run the following commands:
You can also use the [CLI](cli) version of the update tool to downgrade your device. Will need to get a `.tar` or `.tar.gz` archive of the firmware you wish to upload to the board. Then run the following commands:
```bash
$ pycom-fwtool-cli -v -p PORT flash -t /path/to/firmware/archive.tar.gz

View File

@@ -1,13 +1,18 @@
# SecureBoot and Encryption
---
title: "SecureBoot and Encryption"
aliases:
- advance/encryption.html
- advance/encryption.md
- chapter/advance/encryption
---
## Summary
In order to encrypt your firmware, you will need to build it from source. Our firmware source code can be found [here](https://github.com/pycom/pycom-micropython-sigfox/), along with instructions on how to build it. Below you will find specific instructions on how generate keys, build and flash encrypted firmware.
1. Obtain keys \(for Secure Boot and Flash Encryption\)
1. Obtain keys (for Secure Boot and Flash Encryption)
2. Flash keys and parameters in `efuses`
3. Compile bootloader and application with `make SECURE=on`
4. Flash: bootloader-digest at address `0x0` and encrypted; all the others \(partitions and application\) encrypted, too.
4. Flash: bootloader-digest at address `0x0` and encrypted; all the others (partitions and application) encrypted, too.
## Prerequisites
@@ -32,7 +37,7 @@ or, as an artifact of the make build process, on the same directory level as Mak
make BOARD=GPY SECURE=on TARGET=boot
```
To flash the keys \(`flash_encryption_key.bin` and `secure-bootloader-key.bin`\) into the efuses \(write and read protected\) run the following commands \(ignoring the lines that start with `#`\):
To flash the keys (`flash_encryption_key.bin` and `secure-bootloader-key.bin`) into the efuses (write and read protected) run the following commands (ignoring the lines that start with `#`):
_**Note: Irreversible operations**_
@@ -49,7 +54,7 @@ python $IDF_PATH/components/esptool_py/esptool/espefuse.py --port /dev/ttyUSB0 b
python $IDF_PATH/components/esptool_py/esptool/espefuse.py --port /dev/ttyUSB0 burn_efuse ABS_DONE_0
```
**If the keys are not written in efuse, before flashing the bootloader, then random keys will be generated by the ESP32, they can never be read nor re-written, so bootloader can never be updated. Even more, the application can be re-flashed \(by USB\) just 3 more times.**
**If the keys are not written in efuse, before flashing the bootloader, then random keys will be generated by the ESP32, they can never be read nor re-written, so bootloader can never be updated. Even more, the application can be re-flashed (by USB) just 3 more times.**
## Makefile options
@@ -71,7 +76,7 @@ make BOARD=GPY SECURE=on flash
## Flashing
For flashing the `bootloader-reflash-digest.bin` has to be written at address 0x0, instead of the `bootloader.bin` \(at address `0x1000`\).
For flashing the `bootloader-reflash-digest.bin` has to be written at address 0x0, instead of the `bootloader.bin` (at address `0x1000`).
Build is done using `SECURE=on` option; additionally, all the binaries are pre-encrypted.
@@ -95,9 +100,9 @@ The OTA should be done using the pre-encrypted application image.
Because the encryption is done based on the physical flash address, there are 2 application binaries generated:
* `gpy.bin_enc_0x10000` which has to be written at default factory address: `0x10000`
* `gpy.bin_enc_0x1A0000` which has to be written at the `ota_0` partition address \(`0x1A0000`\)
* `gpy.bin_enc_0x1A0000` which has to be written at the `ota_0` partition address (`0x1A0000`)
{% hint style="info" %}
Hint: on MicroPython interface, the method `pycom.ota_slot()` responds with the address of the next OTA partition available \(either `0x10000` or `0x1A0000`\).
{% endhint %}
{{{% hint style="info" %}}}
Hint: on MicroPython interface, the method `pycom.ota_slot()` responds with the address of the next OTA partition available (either `0x10000` or `0x1A0000`).
{{< /hint >}}

View File

@@ -1,16 +1,20 @@
# License
---
title: "License"
aliases:
- advance/license.html
- advance/license.md
---
The MIT License (MIT)
The MIT License \(MIT\)
Copyright (c) 2013-2015 Damien P. George, and others
Copyright \(c\) 2013-2015 Damien P. George, and others
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files \(the “Software”\), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright \(c\) 2017, Pycom Limited.
Copyright (c) 2017, Pycom Limited.
This software is licensed under the GNU GPL version 3 or any later version, with permitted additional terms. For more information see the Pycom Licence v1.0 document supplied with this file, or available at [https://www.pycom.io/opensource/licensing](https://www.pycom.io/opensource/licensing)

View File

@@ -0,0 +1,48 @@
---
title: ""
aliases:
---
The follow pages contain all information relating to each product, for examples: pinouts, spec sheets, relevant examples and notes.
## Development Modules
{{% refname "development/wipy2.md" %}}
{{% refname "development/wipy3.md" %}}
{{% refname "development/lopy.md" %}}
{{% refname "development/lopy4.md" %}}
{{% refname "development/sipy.md" %}}
{{% refname "development/gpy.md" %}}
{{% refname "development/fipy.md" %}}
## OEM modules
{{% refname "oem/w01.md" %}}
{{% refname "oem/l01.md" %}}
{{% refname "oem/g01.md" %}}
{{% refname "oem/l01\_reference.md" %}}
{{% refname "oem/universal\_reference.md" %}}
## Expansion Boards and Shields
{{% refname "boards/expansion3.md" %}}
{{% refname "boards/pytrack.md" %}}
{{% refname "boards/pysense.md" %}}
{{% refname "boards/pyscan.md" %}}
{{% refname "boards/expansion2.md" %}}
{{% refname "boards/deepsleep/" %}}

View File

@@ -0,0 +1,20 @@
---
title: "Expansion Boards and Shields"
aliases:
- product-info/boards
- chapter/datasheets/boards
---
This section contains all of the datasheets for the Pycom Expansion Boards and Shields. This includes the Expansion Board, Pytrack, Pysense and Deep Sleep Shield.
{{% refname "expansion3.md" %}}
{{% refname "pytrack.md" %}}
{{% refname "pysense.md" %}}
{{% refname "pyscan.md" %}}
{{% refname "expansion2.md" %}}
{{% refname "deepsleep/" %}}

View File

@@ -0,0 +1,18 @@
---
title: "Expansion Boards and Shields"
aliases:
---
This section contains all of the datasheets for the Pycom Expansion Boards and Shields. This includes the Expansion Board, Pytrack, Pysense and Deep Sleep Shield.
{{% refname "expansion3.md" %}}
{{% refname "pytrack.md" %}}
{{% refname "pysense.md" %}}
{{% refname "pyscan.md" %}}
{{% refname "expansion2.md" %}}
{{% refname "deepsleep/" %}}

View File

@@ -0,0 +1,24 @@
---
title: "Deep Sleep Shield"
aliases:
- product-info/boards/deepsleep
- chapter/datasheets/boards/deepsleep
---
The schematic of the Deep Sleep Shield is available as a PDF File.
{% file src="..//gitbook/assets/deepsleep-schematic.pdf" caption="Deep Sleep Schematic" %}
## Pinout
The pinout of the Deep Sleep Shield is available as a PDF File
{% file src="..//gitbook/assets/deepsleep-pinout.pdf" caption="Deep Sleep Pinout" %}
![](//gitbook/assets/deepsleep-pinout%20%281%29.png)
{{{% hint style="info" %}}}
To correctly connect a WiPy 2.0, LoPy or SiPy to the Deep Sleep Shield, align the white triangle on the Shield with the LED of the Pycom Device. Once the Pycom Device is seated onto the Deep Sleep Shield, this can then be connected to the Expansion Board
{{< /hint >}}
![](//gitbook/assets/deepsleep-image-1.jpg)

View File

@@ -1,20 +1,22 @@
# Deep Sleep Shield
---
title: "Deep Sleep Shield"
aliases:
---
The schematic of the Deep Sleep Shield is available as a PDF File.
{% file src="../../../.gitbook/assets/deepsleep-schematic.pdf" caption="Deep Sleep Schematic" %}
{% file src="..//gitbook/assets/deepsleep-schematic.pdf" caption="Deep Sleep Schematic" %}
## Pinout
The pinout of the Deep Sleep Shield is available as a PDF File
{% file src="../../../.gitbook/assets/deepsleep-pinout.pdf" caption="Deep Sleep Pinout" %}
{% file src="..//gitbook/assets/deepsleep-pinout.pdf" caption="Deep Sleep Pinout" %}
![](../../../.gitbook/assets/deepsleep-pinout%20%281%29.png)
![](//gitbook/assets/deepsleep-pinout%20%281%29.png)
{% hint style="info" %}
{{{% hint style="info" %}}}
To correctly connect a WiPy 2.0, LoPy or SiPy to the Deep Sleep Shield, align the white triangle on the Shield with the LED of the Pycom Device. Once the Pycom Device is seated onto the Deep Sleep Shield, this can then be connected to the Expansion Board
{% endhint %}
{{< /hint >}}
![](../../../.gitbook/assets/deepsleep-image-1.jpg)
![](//gitbook/assets/deepsleep-image-1.jpg)

View File

@@ -1,5 +1,11 @@
# Deep Sleep API
---
title: "Deep Sleep API"
aliases:
- datasheets/boards/deepsleep/api.html
- datasheets/boards/deepsleep/api.md
- product-info/boards/deepsleep/api
- chapter/datasheets/boards/deepsleep/api
---
This chapter describes the library which controls the Deep Sleep Shield. This includes the controls for external interrupts and timer setup of the deep sleep functionality.
To use this library, please upload the associated [Deep Sleep Library](https://github.com/pycom/pycom-libraries/tree/master/deepsleep) to `/lib` on the target Pycom device.
@@ -31,11 +37,11 @@ ds.go_to_sleep(60) # go to sleep for 60 seconds
## DeepSleep
The Deep Sleep Shield allows for waking up via a user trigger and also via an external interrupt \(i.e. Accelerometer, Button\).
The Deep Sleep Shield allows for waking up via a user trigger and also via an external interrupt (i.e. Accelerometer, Button).
### Constructors
#### class DeepSleep\(\)
#### class DeepSleep()
Creates a DeepSleep object, that will control the board's sleep features. For example;
@@ -45,51 +51,51 @@ ds = DeepSleep()
### Methods
#### deepsleep.enable\_auto\_poweroff\(\)
#### deepsleep.enable\_auto\_poweroff()
This method allows for a critical battery voltage to be set. For example, if the external power source \(e.g. LiPo Cell\) falls below `3.3V`, turn off the Pycom device. This is intended to protect the hardware from under voltage.
This method allows for a critical battery voltage to be set. For example, if the external power source (e.g. LiPo Cell) falls below `3.3V`, turn off the Pycom device. This is intended to protect the hardware from under voltage.
#### deepsleep.enable\_pullups\(pins\)
#### deepsleep.enable\_pullups(pins)
This method allows for pull-up pins to be enabled. For example, if an external trigger occurs, wake the Pycom device from Deep Sleep. `pins` may be passed into the method as a list, i.e. `['P17', 'P18']`.
#### deepsleep.disable\_pullups\(pins\)
#### deepsleep.disable\_pullups(pins)
This method allows for pull-up pins to be disabled. For example, if an external trigger occurs, wake the Pycom device from Deep Sleep. `pins` may be passed into the method as a list, i.e. `['P17', 'P18']`.
#### deepsleep.enable\_wake\_on\_raise\(pins\)
#### deepsleep.enable\_wake\_on\_raise(pins)
This method allows for pull-up pins to trigger on a rising voltage. For example, if an external rising voltage triggers occurs, wake the Pycom device from Deep Sleep. `pins` may be passed into the method as a list, i.e. `['P17', 'P18']`.
#### deepsleep.disable\_wake\_on\_raise\(pins\)
#### deepsleep.disable\_wake\_on\_raise(pins)
This method allows for disabling pull-up pins that trigger on a rising voltage. `pins` may be passed into the method as a list, i.e. `['P17', 'P18']`.
#### deepsleep.enable\_wake\_on\_fall\(pins\)
#### deepsleep.enable\_wake\_on\_fall(pins)
This method allows for pull-up pins to trigger on a falling voltage. For example, if an external falling voltage triggers occurs, wake the Pycom device from Deep Sleep. `pins` may be passed into the method as a list, i.e. `['P17', 'P18']`.
#### deepsleep.disable\_wake\_on\_fall\(pins\)
#### deepsleep.disable\_wake\_on\_fall(pins)
This method allows for disabling pull-up pins that trigger on a falling voltage. `pins` may be passed into the method as a list, i.e. `['P17', 'P18']`.
#### deepsleep.get\_wake\_status\(\)
#### deepsleep.get\_wake\_status()
This method returns the status of the pins at wakeup from deep sleep. The method returns a `dict` with the states of `wake`, `P10`, `P17`, `P18`.
#### deepsleep.set\_min\_voltage\_limit\(value\)
#### deepsleep.set\_min\_voltage\_limit(value)
This method relates to the `enable_auto_poweroff` method and allows the user to specify the minimum power off voltage as a value.
#### deepsleep.go\_to\_sleep\(seconds\)
#### deepsleep.go\_to\_sleep(seconds)
This method sends the board into deep sleep for a period of `seconds` or until an external interrupt has triggered \(see `set_pullups`\).
This method sends the board into deep sleep for a period of `seconds` or until an external interrupt has triggered (see `set_pullups`).
#### deepsleep.hw\_reset\(\)
#### deepsleep.hw\_reset()
This method resets the PIC controller and resets it to the state previous to the pins/min-voltage being set.
{% hint style="info" %}
{{{% hint style="info" %}}}
Please note that more functionality is being added weekly to these libraries. If a required feature is not available, feel free to contribute with a pull request at the [Pycom Libraries](https://github.com/pycom/pycom-libraries) GitHub repository.
{% endhint %}
{{< /hint >}}

View File

@@ -0,0 +1,32 @@
---
title: "Expansion Board 2.0"
aliases:
- datasheets/boards/expansion2.html
- datasheets/boards/expansion2.md
- product-info/boards/expansion2
- chapter/datasheets/boards/expansion2
---
![](/gitbook/assets/expansion2.png)
## Pinout
The pinout of the Expansion Board is available as a PDF File
{% file src="/gitbook/assets/expansion2-pinout.pdf" caption="Expansion Board 2 Pinout" %}
![](/gitbook/assets/expansion2-pinout-1.png)
{{{% hint style="danger" %}}}
Be gentle when plugging/unplugging from the USB connector. Whilst the USB connector is soldered and is relatively strong, if it breaks off it can be very difficult to fix.
{{< /hint >}}
## Battery Charger
The Expansion Board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, the Expansion Board will charge the battery (if connected). When the `CHG` jumper is present the battery will be charged at `450mA`. If this value is too high for your application, removing the jumper lowers the charge current to `100mA`.
## Specsheets
The specsheet of the Expansion Board is available as a PDF File.
{% file src="/gitbook/assets/expansion2-specsheet.pdf" caption="Expansion Board 2 Datasheet" %}

View File

@@ -1,28 +1,34 @@
# Expansion Board 3.0
![](../../.gitbook/assets/expansion3%20%281%29.png)
---
title: "Expansion Board 3.0"
aliases:
- datasheets/boards/expansion3.html
- datasheets/boards/expansion3.md
- product-info/boards/expansion3
- chapter/datasheets/boards/expansion3
---
![](/gitbook/assets/expansion3%20%281%29.png)
## Pinout
The pinout of the Expansion Board is available as a PDF File
{% file src="../../.gitbook/assets/expansion3-pinout.pdf" caption="Expansion Board 3 Pinout" %}
{% file src="/gitbook/assets/expansion3-pinout.pdf" caption="Expansion Board 3 Pinout" %}
![](../../.gitbook/assets/expansion3-pinout-1.png)
![](/gitbook/assets/expansion3-pinout-1.png)
{% hint style="danger" %}
{{{% hint style="danger" %}}}
Be gentle when plugging/unplugging from the USB connector. Whilst the USB connector is soldered and is relatively strong, if it breaks off it can be very difficult to fix.
{% endhint %}
{{< /hint >}}
## Battery Charger
The Expansion Board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, the Expansion Board will charge the battery \(if connected\). When the `CHG` jumper is present the battery will be charged at `450mA`. If this value is too high for your application, removing the jumper lowers the charge current to `100mA`.
The Expansion Board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, the Expansion Board will charge the battery (if connected). When the `CHG` jumper is present the battery will be charged at `450mA`. If this value is too high for your application, removing the jumper lowers the charge current to `100mA`.
## Specsheets
The specsheet of the Expansion Board is available as a PDF File.
{% file src="../../.gitbook/assets/expansion3-specsheet-1.pdf" caption="Expansion Board 3 Datasheet" %}
{% file src="/gitbook/assets/expansion3-specsheet-1.pdf" caption="Expansion Board 3 Datasheet" %}
## Differences between v2.0 and v3.0
@@ -40,5 +46,5 @@ The specsheet of the Expansion Board is available as a PDF File.
## Troubleshooting
* If PIC stays in bootloader mode, the [`dfu-util` update](../../pytrackpysense/installation/firmware.md) should be performed
* If PIC stays in bootloader mode, the [`dfu-util` update](/../pytrackpysense/installation/firmware) should be performed

View File

@@ -1,15 +1,21 @@
# Pyscan
![](../../.gitbook/assets/pyscan-new%20%281%29.png)
---
title: "Pyscan"
aliases:
- datasheets/boards/pyscan.html
- datasheets/boards/pyscan.md
- product-info/boards/pyscan
- chapter/datasheets/boards/pyscan
---
![](/gitbook/assets/pyscan-new%20%281%29.png)
## Pyscan Libraries
* Pyscan libraries to use the RFID/NFC reader are located [here](https://github.com/pycom/pycom-libraries/tree/master/pyscan)
* The accelerometer library is [here](https://github.com/pycom/pycom-libraries/blob/master/pytrack/lib/LIS2HH12.py)
{% hint style="info" %}
{{{% hint style="info" %}}}
For the time being, we recommend to upload the `MFRC630.mpy` file via FTP due to current limitations of Pymakr that will be fixed shortly.
{% endhint %}
{{< /hint >}}
Libraries for the rest of the components will be added soon.
@@ -21,7 +27,7 @@ Libraries for the rest of the components will be added soon.
## Driver
The Windows 7 driver for Pyscan is located [here](../../pytrackpysense/installation/firmware.md).
The Windows 7 driver for Pyscan is located [here](/../pytrackpysense/installation/firmware).
For other Operating Systems there's no driver required.
@@ -29,17 +35,17 @@ For other Operating Systems there's no driver required.
The pinout of the Pyscan is available as a PDF File
{% file src="../../.gitbook/assets/pyscan-pinout.pdf" caption="Pyscan Pinout" %}
{% file src="/gitbook/assets/pyscan-pinout.pdf" caption="Pyscan Pinout" %}
![](../../.gitbook/assets/pyscan-pinout-1.png)
![](/gitbook/assets/pyscan-pinout-1.png)
## Battery Charger
The board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, it will charge the battery \(if connected\).
The board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, it will charge the battery (if connected).
## Specsheets
The specsheet of the Pyscan is available as a PDF File.
{% file src="../../.gitbook/assets/pyscan-specsheet.pdf" caption="Pyscan Datasheet" %}
{% file src="/gitbook/assets/pyscan-specsheet.pdf" caption="Pyscan Datasheet" %}

View File

@@ -0,0 +1,28 @@
---
title: "Pysense"
aliases:
- datasheets/boards/pysense.html
- datasheets/boards/pysense.md
- product-info/boards/pysense
- chapter/datasheets/boards/pysense
---
![](/gitbook/assets/pysense%20%281%29.png)
## Pinout
The pinout of the Pysense is available as a PDF File
{% file src="/gitbook/assets/pysense-pinout.pdf" caption="Pysense Pinout" %}
![](/gitbook/assets/pysense-pinout-1.png)
## Battery Charger
The board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, it will charge the battery (if connected).
## Specsheets
The specsheet of the Pysense is available as a PDF File.
{% file src="/gitbook/assets/pysense-specsheet.pdf" caption="Pysense Datasheet" %}

View File

@@ -0,0 +1,28 @@
---
title: "Pytrack"
aliases:
- datasheets/boards/pytrack.html
- datasheets/boards/pytrack.md
- product-info/boards/pytrack
- chapter/datasheets/boards/pytrack
---
![](/gitbook/assets/pytrack%20%282%29.png)
## Pinout
The pinout of the Pytrack is available as a PDF File
{% file src="/gitbook/assets/pytrack-pinout.pdf" caption="Pytrack Pinout" %}
![](/gitbook/assets/pytrack-pinout-1.png)
## Battery Charger
The board features a single cell Li-Ion/Li-Po charger. When the board is being powered via the micro USB connector, it will charge the battery (if connected).
## Specsheets
The specsheet of the Pytrack is available as a PDF File.
{% file src="/gitbook/assets/pytrack-specsheet-1.pdf" caption="Pytrack Datasheet" %}

View File

@@ -0,0 +1,22 @@
---
title: "Development Modules"
aliases:
- product-info/development
- chapter/datasheets/development
---
This section contains all of the datasheets for the Pycom Development Devices. This includes the WiPy 2.0 and 3.0, LoPy, LoPy 4, SiPy, GPy, and FiPy.
{{% refname "wipy2.md" %}}
{{% refname "wipy3.md" %}}
{{% refname "lopy.md" %}}
{{% refname "lopy4.md" %}}
{{% refname "sipy.md" %}}
{{% refname "gpy.md" %}}
{{% refname "fipy.md" %}}

View File

@@ -0,0 +1,20 @@
---
title: "Development Modules"
aliases:
---
This section contains all of the datasheets for the Pycom Development Devices. This includes the WiPy 2.0 and 3.0, LoPy, LoPy 4, SiPy, GPy, and FiPy.
{{% refname "wipy2.md" %}}
{{% refname "wipy3.md" %}}
{{% refname "lopy.md" %}}
{{% refname "lopy4.md" %}}
{{% refname "sipy.md" %}}
{{% refname "gpy.md" %}}
{{% refname "fipy.md" %}}

View File

@@ -0,0 +1,66 @@
---
title: "FiPy"
aliases:
- datasheets/development/fipy.html
- datasheets/development/fipy.md
- product-info/development/fipy
- chapter/datasheets/development/fipy
---
![](/gitbook/assets/fipy-1.png)
**Store**: [Buy Here](http://www.pycom.io/fipy)
**Getting Started:** [Click Here](/../gettingstarted/connection/fipy)
## Pinout
The pinout of the FiPy is available as a PDF File
{% file src="/gitbook/assets/fipy-pinout.pdf" caption="FiPy Pinout" %}
![](/gitbook/assets/fipy-pinout.png)
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Datasheet
The datasheet of the FiPy is available as a PDF File.
{% file src="/gitbook/assets/fipy-specsheet-1.pdf" caption="FiPy Datasheet" %}
The drawing of the LTE-M antenna is available as a PDF File.
{% file src="/gitbook/assets/lte-m-antenna-drawing.pdf" caption="LTE-M Antenna Drawing" %}
## Notes
### WiFi
By default, upon boot the FiPy will create a WiFi access point with the SSID `fipy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`.
The RF switch that selects between the on-board and external antenna is connected to `P12`, for this reason using `P12` should be avoided unless WiFi is disabled in your application.
### Power
The `Vin` pin on the FiPy can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the FiPy, otherwise the on-board regulator will be damaged.
### AT Commands
The AT commands for the Sequans Monarch modem on the FiPy are available in a PDF file.
{% file src="/gitbook/assets/monarch\_4g-ez\_lr5110\_atcommands\_referencemanual\_rev3\_noconfidential-2.pdf" caption="AT Commands for Sequans" %}
## Tutorials
Tutorials on how to the FiPy module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the FiPy:
* [WiFi connection](/../tutorials/all/wlan)
* [LoRaWAN node](/../tutorials/lora/lorawan-abp)
* [LoRaWAN nano gateway](/../tutorials/lora/lorawan-nano-gateway)
* [Sigfox](/../tutorials/sigfox)
* [LTE CAT-M1](/../tutorials/lte/cat-m1)
* [NB-IoT](/../tutorials/lte/nb-iot)
* [BLE](/../tutorials/all/ble)

View File

@@ -0,0 +1,63 @@
---
title: "GPy"
aliases:
- datasheets/development/gpy.html
- datasheets/development/gpy.md
- product-info/development/gpy
- chapter/datasheets/development/gpy
---
![](/gitbook/assets/gpy-1.png)
**Store**: [Buy Here](http://www.pycom.io/gpy)
**Getting Started:** [Click Here](/../gettingstarted/connection/gpy)
## Pinout
The pinout of the GPy is available as a PDF File
{% file src="/gitbook/assets/gpy-pinout.pdf" caption="GPy Pinout" %}
![](/gitbook/assets/gpy-pinout.png)
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Datasheet
The datasheet of the GPy is available as a PDF File.
{% file src="/gitbook/assets/gpy-specsheet.pdf" caption="GPy Datasheet" %}
The drawing of the LTE-M antenna is available as a PDF File.
{% file src="/gitbook/assets/lte-m-antenna-drawing.pdf" caption="LTE-M Antenna Drawing" %}
## Notes
### WiFi
By default, upon boot the GPy will create a WiFi access point with the SSID `gpy-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`.
The RF switch that selects between the on-board and external antenna is connected to `P12`, for this reason using `P12` should be avoided unless WiFi is disabled in your application.
### Power
The `Vin` pin on the GPy can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the GPy, otherwise the on-board regulator will be damaged.
### AT Commands
The AT commands for the Sequans Monarch modem on the GPy are available in a PDF file.
{% file src="/gitbook/assets/monarch\_4g-ez\_lr5110\_atcommands\_referencemanual\_rev3\_noconfidential-1.pdf" caption="AT Commands for Sequans" %}
## Tutorials
Tutorials on how to the GPy module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the GPy:
* [WiFi connection](/../tutorials/all/wlan)
* [LTE CAT-M1](/../tutorials/lte/cat-m1)
* [NB-IoT](/../tutorials/lte/nb-iot)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,28 +1,34 @@
# LoPy
![](../../.gitbook/assets/lopy-1.png)
---
title: "LoPy"
aliases:
- datasheets/development/lopy.html
- datasheets/development/lopy.md
- product-info/development/lopy
- chapter/datasheets/development/lopy
---
![](/gitbook/assets/lopy-1.png)
**Store**: [Buy Here](http://www.pycom.io/lopy)
**Getting Started:** [Click Here](../../gettingstarted/connection/lopy.md)
**Getting Started:** [Click Here](/../gettingstarted/connection/lopy)
## Pinout
The pinout of the LoPy is available as a PDF File
{% file src="../../.gitbook/assets/lopy-pinout.pdf" caption="LoPy Pinout" %}
{% file src="/gitbook/assets/lopy-pinout.pdf" caption="LoPy Pinout" %}
![](../../.gitbook/assets/lopy-pinout.png)
![](/gitbook/assets/lopy-pinout.png)
{% hint style="info" %}
Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed in Software.
{% endhint %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Datasheet
The datasheet of the LoPy is available as a PDF File.
{% file src="../../.gitbook/assets/lopy-specsheet.pdf" caption="LoPy Datasheet" %}
{% file src="/gitbook/assets/lopy-specsheet.pdf" caption="LoPy Datasheet" %}
## Notes
@@ -36,14 +42,14 @@ The `Vin` pin on the LoPy can be supplied with a voltage ranging from `3.5v` to
### Deep Sleep
Due to a couple issues with the LoPy design the module draws more current than it should while in deep sleep. The DC-DC switching regulator always stays in high performance mode which is used to provide the lowest possible output ripple when the modules is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode, the quiescent current goes down to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain, and therefore not usable during deep sleep. This causes the regulator to always stay in PWM mode, keeping its quiescent current at 10mA. Alongside this the flash chip doesn't enter power down mode because the CS pin is floating during deep sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](../boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either on a timer or via pin interrupt. With the deep sleep shield the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured.
Due to a couple issues with the LoPy design the module draws more current than it should while in deep sleep. The DC-DC switching regulator always stays in high performance mode which is used to provide the lowest possible output ripple when the modules is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode, the quiescent current goes down to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain, and therefore not usable during deep sleep. This causes the regulator to always stay in PWM mode, keeping its quiescent current at 10mA. Alongside this the flash chip doesn't enter power down mode because the CS pin is floating during deep sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](/boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either on a timer or via pin interrupt. With the deep sleep shield the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured.
## Tutorials
Tutorials on how to the LoPy module can be found in the [examples](../../tutorials/introduction.md) section of this documentation. The following tutorials might be of specific interest for the LoPy:
Tutorials on how to the LoPy module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the LoPy:
* [WiFi connection](../../tutorials/all/wlan.md)
* [LoRaWAN node](../../tutorials/lora/lorawan-abp.md)
* [LoRaWAN nano gateway](../../tutorials/lora/lorawan-nano-gateway.md)
* [BLE](../../tutorials/all/ble.md)
* [WiFi connection](/../tutorials/all/wlan)
* [LoRaWAN node](/../tutorials/lora/lorawan-abp)
* [LoRaWAN nano gateway](/../tutorials/lora/lorawan-nano-gateway)
* [BLE](/../tutorials/all/ble)

View File

@@ -0,0 +1,54 @@
---
title: "LoPy 4"
aliases:
- datasheets/development/lopy4.html
- datasheets/development/lopy4.md
- product-info/development/lopy4
- chapter/datasheets/development/lopy4
---
![](/gitbook/assets/lopy4-1.png)
**Store**: [Buy Here](http://www.pycom.io/lopy4)
**Getting Started:** [Click Here](/../gettingstarted/connection/lopy4)
## Pinout
The pinout of the LoPy4 is available as a PDF File
{% file src="/gitbook/assets/lopy4-pinout.pdf" caption="LoPy4 Pinout" %}
![](/gitbook/assets/lopy4-pinout.png)
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Datasheet
The datasheet of the LoPy4 is available as a PDF File.
{% file src="/gitbook/assets/lopy4-specsheet-1.pdf" caption="LoPy4 Datasheet" %}
## Notes
### WiFi
By default, upon boot the LoPy4 will create a WiFi access point with the SSID `lopy4-wlan-XXXX`, where `XXXX` is a random 4-digit number, and the password `www.pycom.io`.
The RF switch that selects between the on-board and external antenna is connected to `P12`, for this reason using `P12` should be avoided unless WiFi is disabled in your application.
### Power
The `Vin` pin on the LoPy4 can be supplied with a voltage ranging from `3.5v` to `5.5v`. The `3.3v` pin on the other hand is output **only**, and must not be used to feed power into the LoPy4, otherwise the on-board regulator will be damaged.
## Tutorials
Tutorials on how to the LoPy4 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the LoPy4:
* [WiFi connection](/../tutorials/all/wlan)
* [LoRaWAN node](/../tutorials/lora/lorawan-abp)
* [LoRaWAN nano gateway](/../tutorials/lora/lorawan-nano-gateway)
* [Sigfox](/../tutorials/sigfox)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,28 +1,34 @@
# SiPy
![](../../.gitbook/assets/sipy-2.png)
---
title: "SiPy"
aliases:
- datasheets/development/sipy.html
- datasheets/development/sipy.md
- product-info/development/sipy
- chapter/datasheets/development/sipy
---
![](/gitbook/assets/sipy-2.png)
**Store**: [Buy Here](http://www.pycom.io/sipy)
**Getting Started:** [Click Here](../../gettingstarted/connection/sipy.md)
**Getting Started:** [Click Here](/../gettingstarted/connection/sipy)
## Pinout
The pinout of the SiPy is available as a PDF File
{% file src="../../.gitbook/assets/sipy-pinout.pdf" caption="SiPy Pinout" %}
{% file src="/gitbook/assets/sipy-pinout.pdf" caption="SiPy Pinout" %}
![](../../.gitbook/assets/sipy-pinout.png)
![](/gitbook/assets/sipy-pinout.png)
{% hint style="info" %}
Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed in Software.
{% endhint %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Datasheet
The datasheet of the SiPy is available as a PDF File.
{% file src="../../.gitbook/assets/sipy-specsheet.pdf" caption="SiPy Datasheet" %}
{% file src="/gitbook/assets/sipy-specsheet.pdf" caption="SiPy Datasheet" %}
## Notes
@@ -36,13 +42,13 @@ The `Vin` pin on the SiPy can be supplied with a voltage ranging from `3.5v` to
### Deep Sleep
Due to a couple issues with the SiPy design the module draws more current than it should while in deep sleep. The DC-DC switching regulator always stays in high performance mode which is used to provide the lowest possible output ripple when the modules is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode, the quiescent current goes down to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain, and therefore not usable during deep sleep. This causes the regulator to always stay in PWM mode, keeping its quiescent current at 10mA. Alongside this the flash chip doesn't enter power down mode because the CS pin is floating during deep sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](../boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either on a timer or via pin interrupt. With the deep sleep shield the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured.
Due to a couple issues with the SiPy design the module draws more current than it should while in deep sleep. The DC-DC switching regulator always stays in high performance mode which is used to provide the lowest possible output ripple when the modules is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode, the quiescent current goes down to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain, and therefore not usable during deep sleep. This causes the regulator to always stay in PWM mode, keeping its quiescent current at 10mA. Alongside this the flash chip doesn't enter power down mode because the CS pin is floating during deep sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](/boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either on a timer or via pin interrupt. With the deep sleep shield the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured.
## Tutorials
Tutorials on how to the SiPy module can be found in the [examples](../../tutorials/introduction.md) section of this documentation. The following tutorials might be of specific interest for the SiPy:
Tutorials on how to the SiPy module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the SiPy:
* [WiFi connection](../../tutorials/all/wlan.md)
* [Sigfox](../../tutorials/sigfox.md)
* [BLE](../../tutorials/all/ble.md)
* [WiFi connection](/../tutorials/all/wlan)
* [Sigfox](/../tutorials/sigfox)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,28 +1,34 @@
# WiPy 2.0
---
title: "WiPy 2.0"
aliases:
- datasheets/development/wipy2.html
- datasheets/development/wipy2.md
- product-info/development/wipy2
- chapter/datasheets/development/wipy2
---
![](/gitbook/assets/wipy2-1.png)
![](../../.gitbook/assets/wipy2-1.png)
**Store**: Discontinued, See [WiPy3](wipy3)
**Store**: Discontinued, See [WiPy3](wipy3.md)
**Getting Started:** [Click Here](../../gettingstarted/connection/wipy.md)
**Getting Started:** [Click Here](/../gettingstarted/connection/wipy)
## Pinout
The pinout of the WiPy2 is available as a PDF File.
{% file src="../../.gitbook/assets/wipy2-pinout.pdf" caption="WiPy 2 Pinout" %}
{% file src="/gitbook/assets/wipy2-pinout.pdf" caption="WiPy 2 Pinout" %}
![](../../.gitbook/assets/wipy2-pinout.png)
![](/gitbook/assets/wipy2-pinout.png)
{% hint style="info" %}
Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed in Software.
{% endhint %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Datasheet
The datasheet of the WiPy2 is available as a PDF File.
{% file src="../../.gitbook/assets/wipy2-specsheet.pdf" caption="WiPy 2 Datasheet" %}
{% file src="/gitbook/assets/wipy2-specsheet.pdf" caption="WiPy 2 Datasheet" %}
## Notes
@@ -36,12 +42,12 @@ The `Vin` pin on the WiPy2 can be supplied with a voltage ranging from `3.5v` to
### Deep Sleep
Due to a couple issues with the WiPy2 design the module draws more current than it should while in deep sleep. The DC-DC switching regulator always stays in high performance mode which is used to provide the lowest possible output ripple when the modules is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode, the quiescent current goes down to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain, and therefore not usable during deep sleep. This causes the regulator to always stay in PWM mode, keeping its quiescent current at 10mA. Alongside this the flash chip doesn't enter power down mode because the CS pin is floating during deep sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](../boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either on a timer or via pin interrupt. With the deep sleep shield the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured.
Due to a couple issues with the WiPy2 design the module draws more current than it should while in deep sleep. The DC-DC switching regulator always stays in high performance mode which is used to provide the lowest possible output ripple when the modules is in use. In this mode, it draws a quiescent current of 10mA. When the regulator is put into ECO mode, the quiescent current goes down to 10uA. Unfortunately, the pin used to control this mode is out of the RTC domain, and therefore not usable during deep sleep. This causes the regulator to always stay in PWM mode, keeping its quiescent current at 10mA. Alongside this the flash chip doesn't enter power down mode because the CS pin is floating during deep sleep. This causes the flash chip to consume around 2mA of current. To work around this issue a ["deep sleep shield"](/boards/deepsleep/) is available that attaches to the module and allows power to be cut off from the device. The device can then be re-enabled either on a timer or via pin interrupt. With the deep sleep shield the current consumption during deep sleep is between 7uA and 10uA depending on the wake sources configured.
## Tutorials
Tutorials on how to the WiPy2 module can be found in the [examples](../../tutorials/introduction.md) section of this documentation. The following tutorials might be of specific interest for the WiPy2:
Tutorials on how to the WiPy2 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the WiPy2:
* [WiFi connection](../../tutorials/all/wlan.md)
* [BLE](../../tutorials/all/ble.md)
* [WiFi connection](/../tutorials/all/wlan)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,35 +1,41 @@
# WiPy 3.0
![](../../.gitbook/assets/wipy3.png)
---
title: "WiPy 3.0"
aliases:
- datasheets/development/wipy3.html
- datasheets/development/wipy3.md
- product-info/development/wipy3
- chapter/datasheets/development/wipy3
---
![](/gitbook/assets/wipy3.png)
**Store**: [Buy Here](http://www.pycom.io/wipy-3)
**Getting Started:** [Click Here](../../gettingstarted/connection/wipy.md)
**Getting Started:** [Click Here](/../gettingstarted/connection/wipy)
## Pinout
The pinout of the WiPy3 is available as a PDF File.
{% file src="../../.gitbook/assets/wipy3-pinout.pdf" caption="WiPy3 Pinout" %}
{% file src="/gitbook/assets/wipy3-pinout.pdf" caption="WiPy3 Pinout" %}
![](../../.gitbook/assets/wipy3-pinout.png)
![](/gitbook/assets/wipy3-pinout.png)
{% hint style="info" %}
Please note that the PIN assignments for UART1 \(TX1/RX1\), SPI \(CLK, MOSI, MISO\) and I2C \(SDA, SCL\) are defaults and can be changed in Software.
{% endhint %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Differences from WiPy 2.0
* Deep sleep current draw fixed, now only 19.7µA
* Upgraded RAM from 512KB to 4MB
* Upgraded External FLASH from 4MB to 8MB
* Antenna select pin moved from GPIO16 to GPIO21 \(P12\)
* Antenna select pin moved from GPIO16 to GPIO21 (P12)
## Datasheet
The datasheet of the WiPy3 is available as a PDF File.
{% file src="../../.gitbook/assets/wipy3-specsheet.pdf" caption="WiPy3 Datasheet" %}
{% file src="/gitbook/assets/wipy3-specsheet.pdf" caption="WiPy3 Datasheet" %}
## Notes
@@ -45,8 +51,8 @@ The `Vin` pin on the WiPy3 can be supplied with a voltage ranging from `3.5v` to
## Tutorials
Tutorials on how to the WiPy3 module can be found in the [examples](../../tutorials/introduction.md) section of this documentation. The following tutorials might be of specific interest for the WiPy3:
Tutorials on how to the WiPy3 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the WiPy3:
* [WiFi connection](../../tutorials/all/wlan.md)
* [BLE](../../tutorials/all/ble.md)
* [WiFi connection](/../tutorials/all/wlan)
* [BLE](/../tutorials/all/ble)

View File

@@ -0,0 +1,52 @@
---
title: "Introduction"
aliases:
- datasheets/introduction.html
- datasheets/introduction.md
- product-info
- chapter/datasheets
---
The follow pages contain all information relating to each product, for examples: pinouts, spec sheets, relevant examples and notes.
## Development Modules
{{% refname "development/wipy2.md" %}}
{{% refname "development/wipy3.md" %}}
{{% refname "development/lopy.md" %}}
{{% refname "development/lopy4.md" %}}
{{% refname "development/sipy.md" %}}
{{% refname "development/gpy.md" %}}
{{% refname "development/fipy.md" %}}
## OEM modules
{{% refname "oem/w01.md" %}}
{{% refname "oem/l01.md" %}}
{{% refname "oem/g01.md" %}}
{{% refname "oem/l01\_reference.md" %}}
{{% refname "oem/universal\_reference.md" %}}
## Expansion Boards and Shields
{{% refname "boards/expansion3.md" %}}
{{% refname "boards/pytrack.md" %}}
{{% refname "boards/pysense.md" %}}
{{% refname "boards/pyscan.md" %}}
{{% refname "boards/expansion2.md" %}}
{{% refname "boards/deepsleep/" %}}

View File

@@ -1,5 +1,11 @@
# Notes
---
title: "Notes"
aliases:
- datasheets/notes.html
- datasheets/notes.md
- product-info/notes
- chapter/datasheets/notes
---
## Powering with an external power source
The devices can be powered by a battery or other external power source.
@@ -10,17 +16,17 @@ When powering via `VIN`:
* The input voltage must be between `3.4V` and `5.5V`.
{% hint style="danger" %}
{{{% hint style="danger" %}}}
Please **DO NOT** power the board via the `3.3V` pin as this may damage the device. ONLY use the `VIN` pin for powering Pycom devices.
{% endhint %}
{{< /hint >}}
The battery connector for the Expansion Board is a **JST PHR-2** variant. The Expansion Board exposes the male connector and an external battery should use a female adapter in order to connect and power the expansion board. The polarity of the battery should be checked before being plugged into the expansion board, the cables may require swapping.
{% hint style="danger" %}
{{{% hint style="danger" %}}}
The `GPIO` pins of the modules are **NOT** `5V` tolerant, connecting them to voltages higher than `3.3V` might cause irreparable damage to the device.
{% endhint %}
{{< /hint >}}
{% hint style="danger" %}
Static electricity can damage components on the device and may destroy them. If there is a lot of static electricity in the area \(e.g. dry and cold climates\), take extra care not to shock the device. If the device came in a ESD bag \(Silver packaging\), the best way to store and carry the device is inside this bag as it will be protected against static discharges.
{% endhint %}
{{{% hint style="danger" %}}}
Static electricity can damage components on the device and may destroy them. If there is a lot of static electricity in the area (e.g. dry and cold climates), take extra care not to shock the device. If the device came in a ESD bag (Silver packaging), the best way to store and carry the device is inside this bag as it will be protected against static discharges.
{{< /hint >}}

View File

@@ -0,0 +1,18 @@
---
title: "OEM Modules"
aliases:
- product-info/oem
- chapter/datasheets/oem
---
This section contains all of the datasheets for the Pycom OEM Devices. This includes the W01, L01, L04, and G01.
{{% refname "w01.md" %}}
{{% refname "l01.md" %}}
{{% refname "g01.md" %}}
{{% refname "l01\_reference.md" %}}
{{% refname "universal\_reference.md" %}}

View File

@@ -0,0 +1,16 @@
---
title: "OEM Modules"
aliases:
---
This section contains all of the datasheets for the Pycom OEM Devices. This includes the W01, L01, L04, and G01.
{{% refname "w01.md" %}}
{{% refname "l01.md" %}}
{{% refname "g01.md" %}}
{{% refname "l01\_reference.md" %}}
{{% refname "universal\_reference.md" %}}

View File

@@ -0,0 +1,49 @@
---
title: "G01"
aliases:
- datasheets/oem/g01.html
- datasheets/oem/g01.md
- product-info/oem/g01
- chapter/datasheets/oem/g01
---
![](/gitbook/assets/g01-1.png)
## Pinout
The pinout of the G01 is available as a PDF File
{% file src="/gitbook/assets/g01-pinout.pdf" caption="G01 Pinout" %}
![](/gitbook/assets/g01-pinout.png)
## Specsheets
The specsheet of the G01 is available as a PDF File.
{% file src="/gitbook/assets/g01-specsheet.pdf" caption="G01 Datasheet" %}
## Drawings
The drawings for the G01 is available as a PDF File.
{% file src="/gitbook/assets/g01-drawing.pdf" caption="G01 Drawings" %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## AT Commands
The AT commands for the Sequans Monarch modem on the G01 are available in a PDF file.
{% file src="/gitbook/assets/monarch\_4g-ez\_lr5110\_atcommands\_referencemanual\_rev3\_noconfidential-3.pdf" caption="AT Commands for Sequans" %}
## Tutorials
Tutorials on how to the G01 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the G01:
* [WiFi connection](/../tutorials/all/wlan)
* [LTE CAT-M1](/../tutorials/lte/cat-m1)
* [NB-IoT](/../tutorials/lte/nb-iot)
* [BLE](/../tutorials/all/ble)

View File

@@ -0,0 +1,43 @@
---
title: "L01"
aliases:
- datasheets/oem/l01.html
- datasheets/oem/l01.md
- product-info/oem/l01
- chapter/datasheets/oem/l01
---
![](/gitbook/assets/l01-1.png)
## Pinout
The pinout of the L01 is available as a PDF File
{% file src="/gitbook/assets/l01-pinout.pdf" caption="L01 Pinout" %}
![](/gitbook/assets/l01-pinout.png)
## Specsheets
The specsheet of the L01 is available as a PDF File.
{% file src="/gitbook/assets/l01-specsheet-1.pdf" caption="L01 Datasheet" %}
## Drawings
The drawings for the L01 is available as a PDF File.
{% file src="/gitbook/assets/l01-drawing.pdf" caption="L01 Drawing" %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Tutorials
Tutorials on how to the L01 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the L01:
* [WiFi connection](/../tutorials/all/wlan)
* [LoRaWAN node](/../tutorials/lora/lorawan-abp)
* [LoRaWAN nano gateway](/../tutorials/lora/lorawan-nano-gateway)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,12 +1,18 @@
# L01 OEM Baseboard Reference
![](../../.gitbook/assets/l01-reference%20%281%29.png)
---
title: "L01 OEM Baseboard Reference"
aliases:
- datasheets/oem/l01_reference.html
- datasheets/oem/l01_reference.md
- product-info/oem/l01_reference
- chapter/datasheets/oem/l01_reference
---
![](/gitbook/assets/l01-reference%20%281%29.png)
The L01 OEM reference board is a reference design suitable L01 as well as W01 making it possible to have a single PCB design that can accommodate both OEM modules.
{% hint style="info" %}
If you require a reference board for the L04 or G01, this design is **not** suitable as it does not feature a SIM slot or the double antenna connection. For the G01 or L04 please use the [Universal OEM Baseboard Reference](universal_reference.md)
{% endhint %}
{{{% hint style="info" %}}}
If you require a reference board for the L04 or G01, this design is **not** suitable as it does not feature a SIM slot or the double antenna connection. For the G01 or L04 please use the [Universal OEM Baseboard Reference](universal_reference)
{{< /hint >}}
## Features
@@ -27,19 +33,19 @@ If you require a reference board for the L04 or G01, this design is **not** suit
The layout of the L01 baseboard reference is available as a PDF File
{% file src="../../.gitbook/assets/l01-oem-layout.pdf" caption="L01 OEM Layout" %}
{% file src="/gitbook/assets/l01-oem-layout.pdf" caption="L01 OEM Layout" %}
![](../../.gitbook/assets/l01-oem-layout-1.png)
![](/gitbook/assets/l01-oem-layout-1.png)
## Schematic
The schematic of the L01 baseboard reference is available as a PDF File.
{% file src="../../.gitbook/assets/l01-oem-schematic.pdf" caption="L01 OEM Schematic" %}
{% file src="/gitbook/assets/l01-oem-schematic.pdf" caption="L01 OEM Schematic" %}
## Altium Project and Gerber Files
The Altium Project and Gerber files are also available as a ZIP File.
{% file src="../../.gitbook/assets/l01-oem-baseboard-ref.zip" caption="L01 OEM Altium Project and Gerber Files" %}
{% file src="/gitbook/assets/l01-oem-baseboard-ref.zip" caption="L01 OEM Altium Project and Gerber Files" %}

View File

@@ -0,0 +1,44 @@
---
title: "L04"
aliases:
- datasheets/oem/l04.html
- datasheets/oem/l04.md
- product-info/oem/l04
- chapter/datasheets/oem/l04
---
![](/gitbook/assets/l04-1.png)
## Pinout
The pinout of the L04 is available as a PDF File
{% file src="/gitbook/assets/l04-pinout.pdf" caption="L04 Pinout" %}
![](/gitbook/assets/l04-pinout.png)
## Specsheets
The specsheet of the L04 is available as a PDF File.
{% file src="/gitbook/assets/l04-specsheet.pdf" caption="L04 Datasheet" %}
## Drawings
The drawings for the L04 is available as a PDF File.
{% file src="/gitbook/assets/l04-drawing.pdf" caption="L04 Drawings" %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Tutorials
Tutorials on how to the L04 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the L04:
* [WiFi connection](/../tutorials/all/wlan)
* [LoRaWAN node](/../tutorials/lora/lorawan-abp)
* [LoRaWAN nano gateway](/../tutorials/lora/lorawan-nano-gateway)
* [Sigfox](/../tutorials/sigfox)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,16 +1,22 @@
# Universal OEM Baseboard Reference
![](../../.gitbook/assets/universal_reference%20%281%29.png)
---
title: "Universal OEM Baseboard Reference"
aliases:
- datasheets/oem/universal_reference.html
- datasheets/oem/universal_reference.md
- product-info/oem/universal_reference
- chapter/datasheets/oem/universal_reference
---
![](/gitbook/assets/universal_reference%20%281%29.png)
The universal OEM reference board is a reference design suitable W01, L01, L04 and G01 OEM modules, making it possible to have a single PCB design that can accommodate all our OEM modules.
{% hint style="info" %}
{{{% hint style="info" %}}}
If you require a reference board for the G01, only this design is suitable. The L01 reference board does not contain the necessary SIM slot.
{% endhint %}
{{< /hint >}}
## Features
* Suits all OEM modules \(L01, L04, W01, G01\)
* Suits all OEM modules (L01, L04, W01, G01)
* On-board 2.4GHz antenna for WiFi and Bluetooth, with the ability to switch
to a external antenna via a U.FL connector.
@@ -27,19 +33,19 @@ If you require a reference board for the G01, only this design is suitable. The
The layout of the OEM baseboard reference is available as a PDF File
{% file src="../../.gitbook/assets/oem-universal-layout.pdf" caption="OEM Layout" %}
{% file src="/gitbook/assets/oem-universal-layout.pdf" caption="OEM Layout" %}
![](../../.gitbook/assets/oem-universal-layout-1.png)
![](/gitbook/assets/oem-universal-layout-1.png)
## Schematic
The schematic of the OEM baseboard reference is available as a PDF File.
{% file src="../../.gitbook/assets/oem-universal-schematic.pdf" caption="OEM Schematic" %}
{% file src="/gitbook/assets/oem-universal-schematic.pdf" caption="OEM Schematic" %}
## Altium Project and Gerber Files
The Altium Project and Gerber files are also available as a ZIP File.
{% file src="../../.gitbook/assets/oem-universal-baseboard-ref.zip" caption="OEM Altium Project and Gerber Files" %}
{% file src="/gitbook/assets/oem-universal-baseboard-ref.zip" caption="OEM Altium Project and Gerber Files" %}

View File

@@ -0,0 +1,41 @@
---
title: "W01"
aliases:
- datasheets/oem/w01.html
- datasheets/oem/w01.md
- product-info/oem/w01
- chapter/datasheets/oem/w01
---
![](/gitbook/assets/w01%20%281%29.png)
## Pinout
The pinout of the W01 is available as a PDF File
{% file src="/gitbook/assets/w01-pinout.pdf" caption="W01 Pinout" %}
![](/gitbook/assets/w01-pinout.png)
## Specsheets
The specsheet of the W01 is available as a PDF File.
{% file src="/gitbook/assets/w01-specsheet-1.pdf" caption="W01 Datasheet" %}
## Drawings
The drawings for the W01 is available as a PDF File.
{% file src="/gitbook/assets/w01-drawing.pdf" caption="W01 Drawings" %}
{{{% hint style="info" %}}}
Please note that the PIN assignments for UART1 (TX1/RX1), SPI (CLK, MOSI, MISO) and I2C (SDA, SCL) are defaults and can be changed in Software.
{{< /hint >}}
## Tutorials
Tutorials on how to the W01 module can be found in the [examples](/../tutorials/introduction) section of this documentation. The following tutorials might be of specific interest for the W01:
* [WiFi connection](/../tutorials/all/wlan)
* [BLE](/../tutorials/all/ble)

View File

@@ -1,4 +1,6 @@
# Introduction
---
title: ""
aliases:
---
The Pycom documentation aims to be straightforward and to adhere to typical Python documentation to allow for ease of understanding. However, there may be some unusual features for those not used to Python documentation or that are new to the MicroPython Language. This section of the documentation aims to provide clarity for any of the design specifics that might be confusing for those new to Python and this style of documentation.

View File

@@ -0,0 +1,9 @@
---
title: "Introduction"
aliases:
- docnotes/introduction.html
- docnotes/introduction.md
- chapter/docnotes
---
The Pycom documentation aims to be straightforward and to adhere to typical Python documentation to allow for ease of understanding. However, there may be some unusual features for those not used to Python documentation or that are new to the MicroPython Language. This section of the documentation aims to provide clarity for any of the design specifics that might be confusing for those new to Python and this style of documentation.

View File

@@ -0,0 +1,9 @@
---
title: "Mesh Networks"
aliases:
- docnotes/mesh-networks.html
- docnotes/mesh-networks.md
- chapter/docnotes/mesh-networks
---
Mesh Networking is currently under development. Please click [here](/tutorials/lora/lora-mesh) for the documentation. Please keep in mind that this document is still only informational.

View File

@@ -1,5 +1,10 @@
# REPL vs Scripts
---
title: "REPL vs Scripts"
aliases:
- docnotes/replscript.html
- docnotes/replscript.md
- chapter/docnotes/replscript
---
Users of this documentation should be aware that examples given in the docs are under the expectation that they are being executed using the MicroPython REPL. This means that when certain functions are called, their output may not necessarily be printed to the console if they are run from a script. When using the REPL many classes/functions automatically produce a printed output displaying the return value of the function to the console. The code snippet below demonstrates some examples of classes/functions that might display this behaviour.
## Basic Arithmetic

View File

@@ -1,12 +1,17 @@
# Syntax
---
title: "Syntax"
aliases:
- docnotes/syntax.html
- docnotes/syntax.md
- chapter/docnotes/syntax
---
The Pycom documentation follows standard Python Library format using the popular Sphinx Docs tool. There are some notable points regarding the syntax of classes, methods and constants. Please see the notes below and familiarise yourself with the specific details before reviewing the documentation.
## Keyword Arguments
`Keyword Arguments` refer to the arguments that are passed into a constructor \(upon referencing a class object\). When passing values into a MicroPython constructor it is not always required to specify the name of the argument and instead rely on the order of the arguments passed as to describe what they refer to. In the example below, it can be seen that the argument `mode` is passed into the `i2c.init()` method without specifying a name.
`Keyword Arguments` refer to the arguments that are passed into a constructor (upon referencing a class object). When passing values into a MicroPython constructor it is not always required to specify the name of the argument and instead rely on the order of the arguments passed as to describe what they refer to. In the example below, it can be seen that the argument `mode` is passed into the `i2c.init()` method without specifying a name.
The values of the arguments \(as seen in the examples/docs\) refer to the default values that are passed into the constructor if nothing is provided.
The values of the arguments (as seen in the examples/docs) refer to the default values that are passed into the constructor if nothing is provided.
```python
i2c.init(mode, * , baudrate=100000, pins=(SDA, SCL))
@@ -26,7 +31,7 @@ It is important to note that there are certain class methods that can only accep
## Keyword
An astrik `*` in a method description \(in the docs\), denotes that the following arguments require a keyword, i.e. `pin='P16'` in the example below.
An astrik `*` in a method description (in the docs), denotes that the following arguments require a keyword, i.e. `pin='P16'` in the example below.
```python
adc.channel(* , pin, attn=ADC.ATTN_0DB)
@@ -67,7 +72,7 @@ pycom.rgbled(color=0xFF0000) # Incorrect
pycom.rgbled(0xFF0000) # Correct
```
Another example of a method that only accepts value input. In this case, the `RTC.init()` method require a value \(`tuple`\) input for the `datetime`. It will not accept a keyword.
Another example of a method that only accepts value input. In this case, the `RTC.init()` method require a value (`tuple`) input for the `datetime`. It will not accept a keyword.
```python
rtc.init(datetime)
@@ -83,13 +88,13 @@ rtc.init((2014, 5, 1, 4, 13, 0, 0, 0)) # Correct
## Constants
The `constants` section of a library within the docs refers to specific values from that librarys class. These might be used when constructing an object from that class or when utilising a method from within that class. These are generally listed by the library name followed by the specific value. See the example below:
The `constants` section of a library within the docs refers to specific values from that library's class. These might be used when constructing an object from that class or when utilising a method from within that class. These are generally listed by the library name followed by the specific value. See the example below:
```python
I2C.MASTER()
```
{% hint style="info" %}
{{{% hint style="info" %}}}
Be aware that you can only reference these constants upon importing and constructing a object from a library.
{% endhint %}
{{< /hint >}}

View File

@@ -1,15 +1,17 @@
# Introduction
This chapter describes modules \(function and class libraries\) that are built into MicroPython. There are a number of categories for the available modules:
---
title: ""
aliases:
---
This chapter describes modules (function and class libraries) that are built into MicroPython. There are a number of categories for the available modules:
* Modules which implement a subset of standard Python functionality and are not intended to be extended by the user.
* Modules which implement a subset of Python functionality, with a provision for extension by the user \(via Python code\).
* Modules which implement a subset of Python functionality, with a provision for extension by the user (via Python code).
* Modules which implement MicroPython extensions to the Python standard libraries.
* Modules specific to a particular port and thus not portable.
## Note about the availability of modules and their contents
This documentation in general aspires to describe all modules and functions/classes which are implemented in MicroPython. However, MicroPython is highly configurable, and each port to a particular board/embedded system makes available only a subset of MicroPython libraries. For officially supported ports, there is an effort to either filter out non-applicable items, or mark individual descriptions with “Availability:” clauses describing which ports provide a given feature. With that in mind, please still be warned that some functions/classes in a module \(or even the entire module\) described in this documentation may be unavailable in a particular build of MicroPython on a particular board. The best place to find general information of the availability/non-availability of a particular feature is the “General Information” section which contains information pertaining to a specific port.
This documentation in general aspires to describe all modules and functions/classes which are implemented in MicroPython. However, MicroPython is highly configurable, and each port to a particular board/embedded system makes available only a subset of MicroPython libraries. For officially supported ports, there is an effort to either filter out non-applicable items, or mark individual descriptions with “Availability:” clauses describing which ports provide a given feature. With that in mind, please still be warned that some functions/classes in a module (or even the entire module) described in this documentation may be unavailable in a particular build of MicroPython on a particular board. The best place to find general information of the availability/non-availability of a particular feature is the “General Information” section which contains information pertaining to a specific port.
Beyond the built-in libraries described in this documentation, many more modules from the Python standard library, as well as further MicroPython extensions to it, can be found in the [micropython-lib](https://github.com/micropython/micropython-lib) repository.

View File

@@ -0,0 +1,20 @@
---
title: "Introduction"
aliases:
- firmwareapi/introduction.html
- firmwareapi/introduction.md
- chapter/firmwareapi
---
This chapter describes modules (function and class libraries) that are built into MicroPython. There are a number of categories for the available modules:
* Modules which implement a subset of standard Python functionality and are not intended to be extended by the user.
* Modules which implement a subset of Python functionality, with a provision for extension by the user (via Python code).
* Modules which implement MicroPython extensions to the Python standard libraries.
* Modules specific to a particular port and thus not portable.
## Note about the availability of modules and their contents
This documentation in general aspires to describe all modules and functions/classes which are implemented in MicroPython. However, MicroPython is highly configurable, and each port to a particular board/embedded system makes available only a subset of MicroPython libraries. For officially supported ports, there is an effort to either filter out non-applicable items, or mark individual descriptions with “Availability:” clauses describing which ports provide a given feature. With that in mind, please still be warned that some functions/classes in a module (or even the entire module) described in this documentation may be unavailable in a particular build of MicroPython on a particular board. The best place to find general information of the availability/non-availability of a particular feature is the “General Information” section which contains information pertaining to a specific port.
Beyond the built-in libraries described in this documentation, many more modules from the Python standard library, as well as further MicroPython extensions to it, can be found in the [micropython-lib](https://github.com/micropython/micropython-lib) repository.

View File

@@ -0,0 +1,13 @@
---
title: "MicroPython Modules"
aliases:
- chapter/firmwareapi/micropython
---
The following list contains the standard Python libraries, MicroPython-specific libraries and Pycom specific modules that are available on the Pycom devices.
The standard Python libraries have been "micro-ified" to fit in with the philosophy of MicroPython. They provide the core functionality of that module and are intended to be a drop-in replacement for the standard Python library.
{{{% hint style="info" %}}}
Some modules are available by an u-name, and also by their non-u-name. The non-u-name can be overridden by a file of that name in your package path. For example, `import json` will first search for a file `json.py` or directory `json` and load that package if it's found. If nothing is found, it will fallback to loading the built-in `ujson` module.
{{< /hint >}}

View File

@@ -1,10 +1,12 @@
# MicroPython Modules
---
title: "MicroPython Modules"
aliases:
---
The following list contains the standard Python libraries, MicroPython-specific libraries and Pycom specific modules that are available on the Pycom devices.
The standard Python libraries have been "micro-ified" to fit in with the philosophy of MicroPython. They provide the core functionality of that module and are intended to be a drop-in replacement for the standard Python library.
{% hint style="info" %}
{{{% hint style="info" %}}}
Some modules are available by an u-name, and also by their non-u-name. The non-u-name can be overridden by a file of that name in your package path. For example, `import json` will first search for a file `json.py` or directory `json` and load that package if it's found. If nothing is found, it will fallback to loading the built-in `ujson` module.
{% endhint %}
{{< /hint >}}

View File

@@ -1,6 +1,11 @@
# \_thread
This module provides low-level primitives for working with multiple threads \(also called light-weight processes or tasks\) — multiple threads of control sharing their global data space. For synchronisation, simple locks \(also called mutexes or binary semaphores\) are provided.
---
title: "_thread"
aliases:
- firmwareapi/micropython/_thread.html
- firmwareapi/micropython/_thread.md
- chapter/firmwareapi/micropython/_thread
---
This module provides low-level primitives for working with multiple threads (also called light-weight processes or tasks) — multiple threads of control sharing their global data space. For synchronisation, simple locks (also called mutexes or binary semaphores) are provided.
When a thread specific error occurs a `RuntimeError` exception is raised.
@@ -21,25 +26,25 @@ for i in range(2):
## Methods
#### \_thread.start\_new\_thread\(function, args\[, kwargs\]\)
#### \_thread.start\_new\_thread(function, args\[, kwargs\])
Start a new thread and return its identifier. The thread executes the function with the argument list args \(which must be a tuple\). The optional `kwargs` argument specifies a dictionary of keyword arguments. When the function returns, the thread silently exits. When the function terminates with an unhandled exception, a stack trace is printed and then the thread exits \(but other threads continue to run\).
Start a new thread and return its identifier. The thread executes the function with the argument list args (which must be a tuple). The optional `kwargs` argument specifies a dictionary of keyword arguments. When the function returns, the thread silently exits. When the function terminates with an unhandled exception, a stack trace is printed and then the thread exits (but other threads continue to run).
#### \_thread.exit\(\)
#### \_thread.exit()
Raise the `SystemExit` exception. When not caught, this will cause the thread to exit silently.
#### \_thread.allocate\_lock\(\)
#### \_thread.allocate\_lock()
Return a new lock object. Methods of locks are described below. The lock is initially unlocked.
#### \_thread.get\_ident\(\)
#### \_thread.get\_ident()
Return the `thread identifier` of the current thread. This is a nonzero integer. Its value has no direct meaning; it is intended as a magic cookie to be used e.g. to index a dictionary of thread-specific data. Thread identifiers may be recycled when a thread exits and another thread is created.
#### \_thread.stack\_size\(\[size\]\)
#### \_thread.stack\_size(\[size\])
Return the thread stack size \(in bytes\) used when creating new threads. The optional size argument specifies the stack size to be used for subsequently created threads, and must be `0` \(use platform or configured default\) or a positive integer value of at least `4096` \(4KiB\). 4KiB is currently the minimum supported stack size value to guarantee sufficient stack space for the interpreter itself.
Return the thread stack size (in bytes) used when creating new threads. The optional size argument specifies the stack size to be used for subsequently created threads, and must be `0` (use platform or configured default) or a positive integer value of at least `4096` (4KiB). 4KiB is currently the minimum supported stack size value to guarantee sufficient stack space for the interpreter itself.
## Objects
@@ -55,9 +60,9 @@ Used for synchronisation between threads
Lock objects have the following methods:
#### lock.acquire\(waitflag=1, timeout=-1\)
#### lock.acquire(waitflag=1, timeout=-1)
Without any optional argument, this method acquires the lock unconditionally, if necessary waiting until it is released by another thread \(only one thread at a time can acquire a lock — thats their reason for existence\).
Without any optional argument, this method acquires the lock unconditionally, if necessary waiting until it is released by another thread (only one thread at a time can acquire a lock — that's their reason for existence).
If the integer `waitflag` argument is present, the action depends on its value: if it is zero, the lock is only acquired if it can be acquired immediately without waiting, while if it is nonzero, the lock is acquired unconditionally as above.
@@ -65,11 +70,11 @@ If the floating-point timeout argument is present and positive, it specifies the
The return value is `True` if the lock is acquired successfully, `False` if not.
#### lock.release\(\)
#### lock.release()
Releases the lock. The lock must have been acquired earlier, but not necessarily by the same thread.
#### lock.locked\(\)
#### lock.locked()
Return the status of the lock: `True` if it has been acquired by some thread, `False` if not.

View File

@@ -1,22 +1,27 @@
# array
---
title: "array"
aliases:
- firmwareapi/micropython/array.html
- firmwareapi/micropython/array.md
- chapter/firmwareapi/micropython/array
---
See [Python array](https://docs.python.org/3/library/array.html) for more information.
Supported format codes: `b, B, h, H, i, I, l, L, q, Q, f, d` \(the latter 2 depending on the floating-point support\).
Supported format codes: `b, B, h, H, i, I, l, L, q, Q, f, d` (the latter 2 depending on the floating-point support).
## Classes
#### class array.array\(typecode\[, iterable\]\)
#### class array.array(typecode\[, iterable\])
Create array with elements of given type. Initial contents of the array are given by an iterable. If it is not provided, an empty array is created.
## Methods
#### array.append\(val\)
#### array.append(val)
Append new element to the end of array, growing it.
#### array.extend\(iterable\)
#### array.extend(iterable)
Append new elements as contained in an iterable to the end of array, growing it.

View File

@@ -0,0 +1,131 @@
---
title: "Builtin"
aliases:
- firmwareapi/micropython/builtin.html
- firmwareapi/micropython/builtin.md
- chapter/firmwareapi/micropython/builtin
---
All builtin functions are described here. They are also available via [builtins](builtin) module.
abs()
all()
any()
bin()
class bool
class bytearray
class bytes
callable()
chr()
class method()
compile()
class complex
class dict
dir()
divmod()
enumerate()
eval()
exec()
filter()
class float
class frozenset
getattr()
globals()
hasattr()
hash()
hex()
id()
input()
class int
isinstance()
issubclass()
iter()
len()
class list
locals()
map()
max()
class memoryview
min()
next()
class object
oct()
open()
ord()
pow()
print()
property()
range()
repr()
reversed()
round()
class set
setattr()
sorted()
staticmethod()
class str
sum()
super()
class tuple
type()
zip()

View File

@@ -1,47 +1,52 @@
# cmath
---
title: "cmath"
aliases:
- firmwareapi/micropython/cmath.html
- firmwareapi/micropython/cmath.md
- chapter/firmwareapi/micropython/cmath
---
The `cmath` module provides some basic mathematical functions for working with complex numbers. Floating point support required for this module.
## Methods
#### cmath.cos\(z\)
#### cmath.cos(z)
Return the cosine of `z`.
#### cmath.exp\(z\)
#### cmath.exp(z)
Return the exponential of `z`.
#### cmath.log\(z\)
#### cmath.log(z)
Return the natural logarithm of `z`. The branch cut is along the negative real axis.
#### cmath.log10\(z\)
#### cmath.log10(z)
Return the base-10 logarithm of `z`. The branch cut is along the negative real axis.
#### cmath.phase\(z\)
#### cmath.phase(z)
Returns the phase of the number `z`, in the range \(-pi, +pi\).
Returns the phase of the number `z`, in the range (-pi, +pi).
#### cmath.polar\(z\)
#### cmath.polar(z)
Returns, as a tuple, the polar form of `z`.
#### cmath.rect\(r, phi\)
#### cmath.rect(r, phi)
Returns the complex number with modulus `r` and phase `phi`.
#### cmath.sin\(z\)
#### cmath.sin(z)
Return the sine of `z`.
#### cmath.sqrt\(z\)
#### cmath.sqrt(z)
Return the square-root of `z`.
## Constants
* `cmath.e`: Base of the natural logarithm
* `cmath.pi`: The ratio of a circles circumference to its diameter
* `cmath.pi`: The ratio of a circle's circumference to its diameter

View File

@@ -1,24 +1,29 @@
# gc
---
title: "gc"
aliases:
- firmwareapi/micropython/gc.html
- firmwareapi/micropython/gc.md
- chapter/firmwareapi/micropython/gc
---
## Methods
#### gc.enable\(\)
#### gc.enable()
Enable automatic garbage collection.
#### gc.disable\(\)
#### gc.disable()
Disable automatic garbage collection. Heap memory can still be allocated, and garbage collection can still be initiated manually using `gc.collect()`.
#### gc.collect\(\)
#### gc.collect()
Run a garbage collection.
#### gc.mem\_alloc\(\)
#### gc.mem\_alloc()
Return the number of bytes of heap RAM that are allocated.
#### gc.mem\_free\(\)
#### gc.mem\_free()
Return the number of bytes of available heap RAM.

View File

@@ -1,163 +1,168 @@
# math
---
title: "math"
aliases:
- firmwareapi/micropython/math.html
- firmwareapi/micropython/math.md
- chapter/firmwareapi/micropython/math
---
The math module provides some basic mathematical functions for working with floating-point numbers. Floating point support required for this module.
## Methods
#### math.acos\(x\)
#### math.acos(x)
Return the inverse cosine of `x`.
#### math.acosh\(x\)
#### math.acosh(x)
Return the inverse hyperbolic cosine of `x`.
#### math.asin\(x\)
#### math.asin(x)
Return the inverse sine of `x`.
#### math.asinh\(x\)
#### math.asinh(x)
Return the inverse hyperbolic sine of `x`.
#### math.atan\(x\)
#### math.atan(x)
Return the inverse tangent of `x`.
#### math.atan2\(y, x\)
#### math.atan2(y, x)
Return the principal value of the inverse tangent of `y/x`.
#### math.atanh\(x\)
#### math.atanh(x)
Return the inverse hyperbolic tangent of `x`.
#### math.ceil\(x\)
#### math.ceil(x)
Return an integer, being x rounded towards positive infinity.
#### math.copysign\(x, y\)
#### math.copysign(x, y)
Return x with the sign of `y`.
#### math.cos\(x\)
#### math.cos(x)
Return the cosine of `x`.
#### math.cosh\(x\)
#### math.cosh(x)
Return the hyperbolic cosine of `x`.
#### math.degrees\(x\)
#### math.degrees(x)
Return radians `x` converted to degrees.
#### math.erf\(x\)
#### math.erf(x)
Return the error function of `x`.
#### math.erfc\(x\)
#### math.erfc(x)
Return the complementary error function of `x`.
#### math.exp\(x\)
#### math.exp(x)
Return the exponential of `x`.
#### math.expm1\(x\)
#### math.expm1(x)
Return `exp(x) - 1`.
#### math.fabs\(x\)
#### math.fabs(x)
Return the absolute value of `x`.
#### math.floor\(x\)
#### math.floor(x)
Return an integer, being `x` rounded towards negative infinity.
#### math.fmod\(x, y\)
#### math.fmod(x, y)
Return the remainder of `x/y`.
#### math.frexp\(x\)
#### math.frexp(x)
Decomposes a floating-point number into its mantissa and exponent. The returned value is the tuple `(m, e)` such that `x == m * 2**e` exactly. If `x == 0` then the function returns `(0.0, 0)`, otherwise the relation `0.5 <= abs(m) < 1` holds.
#### math.gamma\(x\)
#### math.gamma(x)
Return the gamma function of `x`.
#### math.isfinite\(x\)
#### math.isfinite(x)
Return `True` if `x` is finite.
#### math.isinf\(x\)
#### math.isinf(x)
Return `True` if `x` is infinite.
#### math.isnan\(x\)
#### math.isnan(x)
Return `True` if `x` is not-a-number
#### math.ldexp\(x, exp\)
#### math.ldexp(x, exp)
Return `x * (2**exp)`.
#### math.lgamma\(x\)
#### math.lgamma(x)
Return the natural logarithm of the gamma function of `x`.
#### math.log\(x\)
#### math.log(x)
Return the natural logarithm of `x`.
#### math.log10\(x\)
#### math.log10(x)
Return the base-10 logarithm of `x`.
#### math.log2\(x\)
#### math.log2(x)
Return the base-2 logarithm of `x`.
#### math.modf\(x\)
#### math.modf(x)
Return a tuple of two floats, being the fractional and integral parts of `x`. Both return values have the same sign as `x`.
#### math.pow\(x, y\)
#### math.pow(x, y)
Returns `x` to the power of `y`.
#### math.radians\(x\)
#### math.radians(x)
Return degrees `x` converted to radians.
#### math.sin\(x\)
#### math.sin(x)
Return the sine of `x`.
#### math.sinh\(x\)
#### math.sinh(x)
Return the hyperbolic sine of `x`.
#### math.sqrt\(x\)
#### math.sqrt(x)
Return the square root of `x`.
#### math.tan\(x\)
#### math.tan(x)
Return the tangent of `x`.
#### math.tanh\(x\)
#### math.tanh(x)
Return the hyperbolic tangent of `x`.
#### math.trunc\(x\)
#### math.trunc(x)
Return an integer, being `x` rounded towards `0`.
## Constants
* `math.e`: Base of the natural logarithm
* `math.pi`: The ratio of a circles circumference to its diameter
* `math.pi`: The ratio of a circle's circumference to its diameter

View File

@@ -1,14 +1,19 @@
# micropython
---
title: "micropython"
aliases:
- firmwareapi/micropython/micropython.html
- firmwareapi/micropython/micropython.md
- chapter/firmwareapi/micropython/micropython
---
## Methods
#### micropython.alloc\_emergency\_exception\_buf\(size\)
#### micropython.alloc\_emergency\_exception\_buf(size)
Allocate size bytes of RAM for the emergency exception buffer \(a good size is around 100 bytes\). The buffer is used to create exceptions in cases when normal RAM allocation would fail \(eg within an interrupt handler\) and therefore give useful traceback information in these situations.
Allocate size bytes of RAM for the emergency exception buffer (a good size is around 100 bytes). The buffer is used to create exceptions in cases when normal RAM allocation would fail (eg within an interrupt handler) and therefore give useful traceback information in these situations.
A good way to use this function is to place it at the start of a main script \(e.g. `boot.py` or `main.py`\) and then the emergency exception buffer will be active for all the code following it.
A good way to use this function is to place it at the start of a main script (e.g. `boot.py` or `main.py`) and then the emergency exception buffer will be active for all the code following it.
#### micropython.const\(expr\)
#### micropython.const(expr)
Used to declare that the expression is a constant so that the compile can optimise it. The use of this function should be as follows:
@@ -23,35 +28,35 @@ Constants declared this way are still accessible as global variables from outsid
This const function is recognised directly by the MicroPython parser and is provided as part of the `micropython` module mainly so that scripts can be written which run under both CPython and MicroPython, by following the above pattern.
#### micropython.opt\_level\(\[level\]\)
#### micropython.opt\_level(\[level\])
If `level` is given then this function sets the optimisation level for subsequent compilation of scripts, and returns `None`. Otherwise it returns the current optimisation level.
#### micropython.mem\_info\(\[verbose\]\)
#### micropython.mem\_info(\[verbose\])
Print information about currently used memory. If the `verbose` argument is given then extra information is printed.
The information that is printed is implementation dependent, but currently includes the amount of stack and heap used. In verbose mode it prints out the entire heap indicating which blocks are used and which are free.
#### micropython.qstr\_info\(\[verbose\]\)
#### micropython.qstr\_info(\[verbose\])
Print information about currently interned strings. If the `verbose` argument is given then extra information is printed.
The information that is printed is implementation dependent, but currently includes the number of interned strings and the amount of RAM they use. In verbose mode it prints out the names of all RAM-interned strings.
#### micropython.stack\_use\(\)
#### micropython.stack\_use()
Return an integer representing the current amount of stack that is being used. The absolute value of this is not particularly useful, rather it should be used to compute differences in stack usage at different points.
#### micropython.heap\_lock\(\)
#### micropython.heap\_lock()
#### micropython.heap\_unlock\(\)
#### micropython.heap\_unlock()
Lock or unlock the heap. When locked no memory allocation can occur and a `MemoryError` will be raised if any heap allocation is attempted.
These functions can be nested, i.e. `heap_lock()` can be called multiple times in a row and the lock-depth will increase, and then `heap_unlock()` must be called the same number of times to make the heap available again.
#### micropython.kbd\_intr\(chr\)
#### micropython.kbd\_intr(chr)
Set the character that will raise a `KeyboardInterrupt` exception. By default this is set to 3 during script execution, corresponding to `Ctrl-C`. Passing `-1` to this function will disable capture of `Ctrl-C`, and passing `3` will restore it.

View File

@@ -1,6 +1,11 @@
# select
This module provides functions to wait for events on streams \(select streams which are ready for operations\).
---
title: "select"
aliases:
- firmwareapi/micropython/select.html
- firmwareapi/micropython/select.md
- chapter/firmwareapi/micropython/select
---
This module provides functions to wait for events on streams (select streams which are ready for operations).
## Pyboard specifics
@@ -8,11 +13,11 @@ Polling is an efficient way of waiting for read/write activity on multiple objec
## Methods
#### select.poll\(\)
#### select.poll()
Create an instance of the `Poll` class.
#### select.select\(rlist, wlist, xlist\[, timeout\]\)
#### select.select(rlist, wlist, xlist\[, timeout\])
Wait for activity on a set of objects.
@@ -22,7 +27,7 @@ This function is provided for compatibility and is not efficient. Usage of `Poll
### Methods
#### poll.register\(obj\[, eventmask\]\)
#### poll.register(obj\[, eventmask\])
Register `obj` for polling. `eventmask` is logical OR of:
@@ -33,17 +38,17 @@ Register `obj` for polling. `eventmask` is logical OR of:
`eventmask` defaults to `select.POLLIN | select.POLLOUT`.
#### poll.unregister\(obj\)
#### poll.unregister(obj)
Unregister `obj` from polling.
#### poll.modify\(obj, eventmask\)
#### poll.modify(obj, eventmask)
Modify the `eventmask` for `obj`.
#### poll.poll\(\[timeout\]\)
#### poll.poll(\[timeout\])
Wait for at least one of the registered objects to become ready. Returns list of \(`obj`, `event`, ...\) tuples, `event` element specifies which events happened with a stream and is a combination of `select.POLL*` constants described above. There may be other elements in tuple, depending on a platform and version, so dont assume that its size is 2. In case of timeout, an empty list is returned.
Wait for at least one of the registered objects to become ready. Returns list of (`obj`, `event`, ...) tuples, `event` element specifies which events happened with a stream and is a combination of `select.POLL*` constants described above. There may be other elements in tuple, depending on a platform and version, so don't assume that its size is 2. In case of timeout, an empty list is returned.
Timeout is in milliseconds.

View File

@@ -1,40 +1,45 @@
# sys
---
title: "sys"
aliases:
- firmwareapi/micropython/sys.html
- firmwareapi/micropython/sys.md
- chapter/firmwareapi/micropython/sys
---
## Methods
#### sys.exit\(retval=0\)
#### sys.exit(retval=0)
Terminate current program with a given exit code. Underlyingly, this function raise as `SystemExit` exception. If an argument is given, its value given as an argument to `SystemExit`.
#### sys.print\_exception\(exc, file=sys.stdout\)
#### sys.print\_exception(exc, file=sys.stdout)
Print exception with a traceback to a file-like object file \(or `sys.stdout` by default\).
Print exception with a traceback to a file-like object file (or `sys.stdout` by default).
{% hint style="info" %}
{{{% hint style="info" %}}}
**Difference to CPython**
This is simplified version of a function which appears in the traceback module in CPython. Unlike `traceback.print_exception()`, this function takes just exception value instead of exception type, exception value, and traceback object; file argument should be positional; further arguments are not supported. CPython-compatible traceback module can be found in `micropython-lib`.
{% endhint %}
{{< /hint >}}
## Constants
* `sys.argv`: A mutable list of arguments the current program was started with.
* `sys.byteorder`: The byte order of the system \("little" or "big"\).
* `sys.byteorder`: The byte order of the system ("little" or "big").
* `sys.implementation`: Object with information about the current Python implementation. For MicroPython, it has following attributes:
* _name_ - string "micropython"
* _version_ - tuple \(major, minor, micro\), e.g. \(1, 7, 0\)
* _version_ - tuple (major, minor, micro), e.g. (1, 7, 0)
This object is the recommended way to distinguish MicroPython from other Python implementations \(note that it still may not exist in the very minimal ports\).
This object is the recommended way to distinguish MicroPython from other Python implementations (note that it still may not exist in the very minimal ports).
{% hint style="info" %}
{{{% hint style="info" %}}}
**Difference to CPython**
CPython mandates more attributes for this object, but the actual useful bare minimum is implemented in MicroPython.
{% endhint %}
{{< /hint >}}
* `sys.maxsize`: Maximum value which a native integer type can hold on the current platform, or maximum value representable by MicroPython integer type, if its smaller than platform max value \(that is the case for MicroPython ports without long int support\).
* `sys.maxsize`: Maximum value which a native integer type can hold on the current platform, or maximum value representable by MicroPython integer type, if it's smaller than platform max value (that is the case for MicroPython ports without long int support).
This attribute is useful for detecting "bitness" of a platform \(32-bit vs 64-bit, etc.\). Its recommended to not compare this attribute to some value directly, but instead count number of bits in it:
This attribute is useful for detecting "bitness" of a platform (32-bit vs 64-bit, etc.). It's recommended to not compare this attribute to some value directly, but instead count number of bits in it:
```python
bits = 0
@@ -53,7 +58,7 @@ else:
* `sys.modules`: Dictionary of loaded modules. On some ports, it may not include builtin modules.
* `sys.path`: A mutable list of directories to search for imported modules.
* `sys.platform`: The platform that MicroPython is running on. For OS/RTOS ports, this is usually an identifier of the OS, e.g. `linux`. For baremetal ports, it is an identifier of a board, e.g. `pyboard` for the original MicroPython reference board. It thus can be used to distinguish one board from another. If you need to check whether your program runs on MicroPython \(vs other Python implementation\), use `sys.implementation` instead.
* `sys.platform`: The platform that MicroPython is running on. For OS/RTOS ports, this is usually an identifier of the OS, e.g. `linux`. For baremetal ports, it is an identifier of a board, e.g. `pyboard` for the original MicroPython reference board. It thus can be used to distinguish one board from another. If you need to check whether your program runs on MicroPython (vs other Python implementation), use `sys.implementation` instead.
* `sys.stderr`: Standard error stream.
* `sys.stdin`: Standard input stream.
* `sys.stdout`: Standard output stream.

View File

@@ -1,28 +1,33 @@
# ubinascii
This module implements conversions between binary data and various encodings of it in ASCII form \(in both directions\).
---
title: "ubinascii"
aliases:
- firmwareapi/micropython/ubinascii.html
- firmwareapi/micropython/ubinascii.md
- chapter/firmwareapi/micropython/ubinascii
---
This module implements conversions between binary data and various encodings of it in ASCII form (in both directions).
## Methods
#### ubinascii.hexlify\(data\[, sep\]\)
#### ubinascii.hexlify(data\[, sep\])
Convert binary data to hexadecimal representation. Returns bytes string.
{% hint style="info" %}
{{{% hint style="info" %}}}
**Difference to CPython**
If additional argument, `sep` is supplied, it is used as a separator between hexadecimal values.
{% endhint %}
{{< /hint >}}
#### ubinascii.unhexlify\(data\)
#### ubinascii.unhexlify(data)
Convert hexadecimal data to binary representation. Returns bytes string. \(i.e. inverse of `hexlify`\)
Convert hexadecimal data to binary representation. Returns bytes string. (i.e. inverse of `hexlify`)
#### ubinascii.a2b\_base64\(data\)
#### ubinascii.a2b\_base64(data)
Convert Base64-encoded data to binary representation. Returns bytes string.
#### ubinascii.b2a\_base64\(data\)
#### ubinascii.b2a\_base64(data)
Encode binary data in Base64 format. Returns string.

View File

@@ -1,14 +1,19 @@
# ucrypto
This module provides native support for cryptographic algorithms. Its loosely based on PyCrypto.
---
title: "ucrypto"
aliases:
- firmwareapi/micropython/ucrypto.html
- firmwareapi/micropython/ucrypto.md
- chapter/firmwareapi/micropython/ucrypto
---
This module provides native support for cryptographic algorithms. It's loosely based on PyCrypto.
## Classes
* [class AES](../pycom/aes.md) - Advanced Encryption Standard
* [class AES](/pycom/aes) - Advanced Encryption Standard
## **Methods**
#### crypto.getrandbits\(bits\)
#### crypto.getrandbits(bits)
Returns a bytes object filled with random bits obtained from the hardware random number generator.
@@ -16,7 +21,7 @@ According to the **ESP32 Technical Reference Manual**, such bits "... can be use
The parameter `bits` is rounded upwards to the nearest multiple of 32 bits.
{% hint style="danger" %}
{{{% hint style="danger" %}}}
Cryptography is not a trivial business. Doing things the wrong way could quickly result in decreased or no security. Please document yourself in the subject if you are depending on encryption to secure important information.
{% endhint %}
{{< /hint >}}

View File

@@ -1,10 +1,15 @@
# uctypes
---
title: "uctypes"
aliases:
- firmwareapi/micropython/uctypes.html
- firmwareapi/micropython/uctypes.md
- chapter/firmwareapi/micropython/uctypes
---
This module implements "foreign data interface" for MicroPython. The idea behind it is similar to CPython's `ctypes` modules, but the actual API is different, streamlined and optimised for small size. The basic idea of the module is to define data structure layout with about the same power as the C language allows, and the access it using familiar dot-syntax to reference sub-fields.
This module implements "foreign data interface" for MicroPython. The idea behind it is similar to CPythons `ctypes` modules, but the actual API is different, streamlined and optimised for small size. The basic idea of the module is to define data structure layout with about the same power as the C language allows, and the access it using familiar dot-syntax to reference sub-fields.
{% hint style="info" %}
Module ustruct Standard Python way to access binary data structures \(doesnt scale well to large and complex structures\).
{% endhint %}
{{{% hint style="info" %}}}
Module ustruct Standard Python way to access binary data structures (doesn't scale well to large and complex structures).
{{< /hint >}}
## Defining Structure Layout
@@ -18,7 +23,7 @@ Following are encoding examples for various field types:
"field_name": uctypes.UINT32 | 0
```
In other words, value is scalar type identifier OR-ed with field offset \(in bytes\) from the start of the structure.
In other words, value is scalar type identifier OR-ed with field offset (in bytes) from the start of the structure.
* Recursive structures:
@@ -29,7 +34,7 @@ In other words, value is scalar type identifier OR-ed with field offset \(in byt
})
```
I.e. value is a 2-tuple, first element of which is offset, and second is a structure descriptor dictionary \(note: offsets in recursive descriptors are relative to a structure it defines\).
I.e. value is a 2-tuple, first element of which is offset, and second is a structure descriptor dictionary (note: offsets in recursive descriptors are relative to a structure it defines).
* Arrays of Primitive Types:
@@ -69,21 +74,21 @@ I.e. value is a 2-tuple, first element of which is PTR flag OR-ed with offset, s
"bitf0": uctypes.BFUINT16 | 0 | 0 << uctypes.BF_POS | 8 << uctypes.BF_LEN,
```
I.e. value is type of scalar value containing given bitfield \(typenames are similar to scalar types, but prefixes with "BF"\), OR-ed with offset for scalar value containing the bitfield, and further OR-ed with values for bit offset and bit length of the bitfield within scalar value, shifted by BF\_POS and BF\_LEN positions, respectively. Bitfield position is counted from the least significant bit, and is the number of right-most bit of a field \(in other words, its a number of bits a scalar needs to be shifted right to extra the bitfield\).
I.e. value is type of scalar value containing given bitfield (typenames are similar to scalar types, but prefixes with "BF"), OR-ed with offset for scalar value containing the bitfield, and further OR-ed with values for bit offset and bit length of the bitfield within scalar value, shifted by BF\_POS and BF\_LEN positions, respectively. Bitfield position is counted from the least significant bit, and is the number of right-most bit of a field (in other words, it's a number of bits a scalar needs to be shifted right to extra the bitfield).
In the example above, first `UINT16` value will be extracted at offset 0 \(this detail may be important when accessing hardware registers, where particular access size and alignment are required\), and then bitfield whose rightmost bit is least-significant bit of this `UINT16`, and length is 8 bits, will be extracted - effectively, this will access least-significant byte of `UINT16`.
In the example above, first `UINT16` value will be extracted at offset 0 (this detail may be important when accessing hardware registers, where particular access size and alignment are required), and then bitfield whose rightmost bit is least-significant bit of this `UINT16`, and length is 8 bits, will be extracted - effectively, this will access least-significant byte of `UINT16`.
Note that bitfield operations are independent of target byte endianness, in particular, example above will access least-significant byte of `UINT16` in both little- and big-endian structures. But it depends on the least significant bit being numbered 0. Some targets may use different numbering in their native ABI, but `uctypes` always uses normalised numbering described above.
## Module Contents
#### class uctypes.struct\(addr, descriptor, layout\_type=NATIVE\)
#### class uctypes.struct(addr, descriptor, layout\_type=NATIVE)
Instantiate a "foreign data structure" object based on structure address in memory, descriptor \(encoded as a dictionary\), and layout type \(see below\).
Instantiate a "foreign data structure" object based on structure address in memory, descriptor (encoded as a dictionary), and layout type (see below).
#### uctypes.LITTLE\_ENDIAN
Layout type for a little-endian packed structure. \(Packed means that every field occupies exactly as many bytes as defined in the descriptor, i.e. the alignment is 1\).
Layout type for a little-endian packed structure. (Packed means that every field occupies exactly as many bytes as defined in the descriptor, i.e. the alignment is 1).
#### uctypes.BIG\_ENDIAN
@@ -93,46 +98,46 @@ Layout type for a big-endian packed structure.
Layout type for a native structure - with data endianness and alignment conforming to the ABI of the system on which MicroPython runs.
#### uctypes.sizeof\(struct\)
#### uctypes.sizeof(struct)
Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object \(or its aggregate field\).
Return size of data structure in bytes. Argument can be either structure class or specific instantiated structure object (or its aggregate field).
#### uctypes.addressof\(obj\)
#### uctypes.addressof(obj)
Return address of an object. Argument should be bytes, `bytearray` or other object supporting buffer protocol \(and address of this buffer is what actually returned\).
Return address of an object. Argument should be bytes, `bytearray` or other object supporting buffer protocol (and address of this buffer is what actually returned).
#### uctypes.bytes\_at\(addr, size\)
#### uctypes.bytes\_at(addr, size)
Capture memory at the given address and size as bytes object. As bytes object is immutable, memory is actually duplicated and copied into bytes object, so if memory contents change later, created object retains original value.
#### uctypes.bytearray\_at\(addr, size\)
#### uctypes.bytearray\_at(addr, size)
Capture memory at the given address and size as `bytearray` object. Unlike `bytes_at()` function above, memory is captured by reference, so it can be both written too, and you will access current value at the given memory address.
## Structure Descriptors and Instantiating Structure Objects
Given a structure descriptor dictionary and its layout type, you can instantiate a specific structure instance at a given memory address using uctypes.struct\(\) constructor. Memory address usually comes from following sources:
Given a structure descriptor dictionary and its layout type, you can instantiate a specific structure instance at a given memory address using uctypes.struct() constructor. Memory address usually comes from following sources:
* Predefined address, when accessing hardware registers on a baremetal system. Lookup these addresses in datasheet for a particular MCU/SoC.
* As a return value from a call to some FFI \(Foreign Function Interface\) function.
* From uctypes.addressof\(\), when you want to pass arguments to an FFI function, or alternatively, to access some data for I/O \(for example, data read from a file or network socket\).
* As a return value from a call to some FFI (Foreign Function Interface) function.
* From uctypes.addressof(), when you want to pass arguments to an FFI function, or alternatively, to access some data for I/O (for example, data read from a file or network socket).
## Structure objects
Structure objects allow accessing individual fields using standard dot notation: `my_struct.substruct1.field1`. If a field is of scalar type, getting it will produce a primitive value \(Python integer or float\) corresponding to the value contained in a field. A scalar field can also be assigned to.
Structure objects allow accessing individual fields using standard dot notation: `my_struct.substruct1.field1`. If a field is of scalar type, getting it will produce a primitive value (Python integer or float) corresponding to the value contained in a field. A scalar field can also be assigned to.
If a field is an array, its individual elements can be accessed with the standard subscript operator `[]` - both read and assigned to.
If a field is a pointer, it can be dereferenced using `[0]` syntax \(corresponding to C `*` operator, though `[0]` works in C too\). Subscripting a pointer with other integer values but 0 are supported too, with the same semantics as in C.
If a field is a pointer, it can be dereferenced using `[0]` syntax (corresponding to C `*` operator, though `[0]` works in C too). Subscripting a pointer with other integer values but 0 are supported too, with the same semantics as in C.
Summing up, accessing structure fields generally follows C syntax, except for pointer dereference, when you need to use `[0]` operator instead of `*`.
## Limitations
Accessing non-scalar fields leads to allocation of intermediate objects to represent them. This means that special care should be taken to layout a structure which needs to be accessed when memory allocation is disabled \(e.g. from an interrupt\). The recommendations are:
Accessing non-scalar fields leads to allocation of intermediate objects to represent them. This means that special care should be taken to layout a structure which needs to be accessed when memory allocation is disabled (e.g. from an interrupt). The recommendations are:
* Avoid nested structures. For example, instead of `mcu_registers.peripheral_a.register1`, define separate layout descriptors for each peripheral, to be accessed as `peripheral_a.register1`.
* Avoid other non-scalar data, like array. For example, instead of `peripheral_a.register[0]` use `peripheral_a.register0`.
Note that these recommendations will lead to decreased readability and conciseness of layouts, so they should be used only if the need to access structure fields without allocation is anticipated \(its even possible to define 2 parallel layouts - one for normal usage, and a restricted one to use when memory allocation is prohibited\).
Note that these recommendations will lead to decreased readability and conciseness of layouts, so they should be used only if the need to access structure fields without allocation is anticipated (it's even possible to define 2 parallel layouts - one for normal usage, and a restricted one to use when memory allocation is prohibited).

View File

@@ -1,44 +1,49 @@
# uhashlib
---
title: "uhashlib"
aliases:
- firmwareapi/micropython/uhashlib.html
- firmwareapi/micropython/uhashlib.md
- chapter/firmwareapi/micropython/uhashlib
---
This module implements binary data hashing algorithms. MD5 and SHA are supported. By limitations in the hardware, only one active hashing operation is supported at a time.
## Constructors
#### class uhashlib.md5\(\[data\]\)
#### class uhashlib.md5(\[data\])
Create a MD5 hasher object and optionally feed data into it.
#### class uhashlib.sha1\(\[data\]\)
#### class uhashlib.sha1(\[data\])
Create a SHA-1 hasher object and optionally feed data into it.
#### class uhashlib.sha224\(\[data\]\)
#### class uhashlib.sha224(\[data\])
Create a SHA-224 hasher object and optionally feed data into it.
#### class uhashlib.sha256\(\[data\]\)
#### class uhashlib.sha256(\[data\])
Create a SHA-256 hasher object and optionally feed data into it.
#### class uhashlib.sha384\(\[data\]\)
#### class uhashlib.sha384(\[data\])
Create a SHA-384 hasher object and optionally feed data into it.
#### class uhashlib.sha512\(\[data\]\)
#### class uhashlib.sha512(\[data\])
Create a SHA-512 hasher object and optionally feed data into it.
## Methods
#### hash.update\(data\)
#### hash.update(data)
Feed more binary data into hash.
#### hash.digest\(\)
#### hash.digest()
Return hash for all data passed through hash, as a bytes object. After this method is called, more data cannot be fed into hash any longer.
#### hash.hexdigest\(\)
#### hash.hexdigest()
This method is NOT implemented. Use `ubinascii.hexlify(hash.digest())` to achieve a similar effect.

View File

@@ -0,0 +1,23 @@
---
title: "ujson"
aliases:
- firmwareapi/micropython/ujson.html
- firmwareapi/micropython/ujson.md
- chapter/firmwareapi/micropython/ujson
---
This modules allows to convert between Python objects and the JSON data format.
## Methods
#### ujson.dumps(obj)
Return `obj` represented as a JSON string.
#### ujson.loads(str)
Parse the JSON `str` and return an object. Raises `ValueError` if the string is not correctly formed.
#### ujson.load(fp)
Parse contents of `fp` (a `.read()`-supporting file-like object containing a JSON document). Raises `ValueError` if the content is not correctly formed.

View File

@@ -1,5 +1,10 @@
# uos
---
title: "uos"
aliases:
- firmwareapi/micropython/uos.html
- firmwareapi/micropython/uos.md
- chapter/firmwareapi/micropython/uos
---
The `uos` module contains functions for filesystem access and `urandom` function.
## Port Specifics
@@ -7,78 +12,78 @@ The `uos` module contains functions for filesystem access and `urandom` function
The filesystem has `/` as the root directory and the available physical drives are accessible from here. They are currently:
* `/flash` the internal flash filesystem
* `/sd` the SD card \(if it exists\)
* `/sd` the SD card (if it exists)
## Methods
#### uos.uname\(\)
#### uos.uname()
Return information about the system, firmware release version, and MicroPython interpreter version.
#### uos.chdir\(path\)
#### uos.chdir(path)
Change current directory.
#### uos.getcwd\(\)
#### uos.getcwd()
Get the current directory.
#### uos.listdir\(\[dir\]\)
#### uos.listdir(\[dir\])
With no argument, list the current directory. Otherwise list the given directory.
#### uos.mkdir\(path\)
#### uos.mkdir(path)
Create a new directory.
#### uos.remove\(path\)
#### uos.remove(path)
Remove a file.
#### uos.rmdir\(path\)
#### uos.rmdir(path)
Remove a directory.
#### uos.rename\(old\_path, new\_path\)
#### uos.rename(old\_path, new\_path)
Rename a file.
#### uos.stat\(path\)
#### uos.stat(path)
Get the status of a file or directory.
The return value is a tuple with the following 10 values, in order:
* `st_mode`: protection bits.
* `st_ino`: `inode` number. \(not implemented, returns 0\)
* `st_dev`: device. \(not implemented, returns 0\)
* `st_nlink`: number of hard links. \(not implemented, returns 0\)
* `st_uid`: user id of owner. \(not implemented, returns 0\)
* `st_gid`: group id of owner. \(not implemented, returns 0\)
* `st_ino`: `inode` number. (not implemented, returns 0)
* `st_dev`: device. (not implemented, returns 0)
* `st_nlink`: number of hard links. (not implemented, returns 0)
* `st_uid`: user id of owner. (not implemented, returns 0)
* `st_gid`: group id of owner. (not implemented, returns 0)
* `st_size`: size of file in bytes.
* `st_atime`: time of most recent access.
* `st_mtime`: time of most recent content modification.
* `st_ctime`: time of most recent metadata change.
#### uos.getfree\(path\)
#### uos.getfree(path)
Returns the free space \(in KiB\) in the drive specified by path.
Returns the free space (in KiB) in the drive specified by path.
#### uos.sync\(\)
#### uos.sync()
Sync all filesystems.
#### uos.urandom\(n\)
#### uos.urandom(n)
Return a bytes object with n random bytes.
#### uos.unlink\(path\)
#### uos.unlink(path)
Alias for the `remove()` method.
#### uos.mount\(block\_device, mount\_point, \* , readonly=False\)
#### uos.mount(block\_device, mount\_point, \* , readonly=False)
Mounts a block device \(like an SD object\) in the specified mount point. Example:
Mounts a block device (like an SD object) in the specified mount point. Example:
```python
os.mount(sd, '/sd')
@@ -87,9 +92,9 @@ uos.unmount(path)
Unmounts a previously mounted block device from the given path.
#### uos.mkfat\(block\_device\)
#### uos.mkfat(block\_device)
Instantiate a VFS \(Virtual File System\) object with underlying FAT file system.
Instantiate a VFS (Virtual File System) object with underlying FAT file system.
Example:
@@ -103,13 +108,13 @@ vfs.mkfs(sd) # Formating the SD card
os.mount(vfs, '/sd')
```
#### uos.fsformat\(path\)
#### uos.fsformat(path)
Formats the block device mounted under the input path, must be either `/flash` or `/sd`
#### uos.dupterm\(stream\_object\)
#### uos.dupterm(stream\_object)
Duplicate the terminal \(the REPL\) on the passed stream-like object. The given object must at least implement the `read()` and `write()` methods.
Duplicate the terminal (the REPL) on the passed stream-like object. The given object must at least implement the `read()` and `write()` methods.
## Constants

View File

@@ -1,6 +1,11 @@
# ure
This module implements regular expression operations. Regular expression syntax supported is a subset of CPython re module \(and actually is a subset of POSIX extended regular expressions\).
---
title: "ure"
aliases:
- firmwareapi/micropython/ure.html
- firmwareapi/micropython/ure.md
- chapter/firmwareapi/micropython/ure
---
This module implements regular expression operations. Regular expression syntax supported is a subset of CPython re module (and actually is a subset of POSIX extended regular expressions).
Supported operators are:
@@ -21,17 +26,17 @@ Counted repetitions `({m,n})`, more advanced assertions, named groups, etc. are
## Methods
#### ure.compile\(regex\)
#### ure.compile(regex)
Compile regular expression, return `regex object`.
#### ure.match\(regex, string\)
#### ure.match(regex, string)
Match regex against `string`. Match always happens from starting position in a string.
#### ure.search\(regex, string\)
#### ure.search(regex, string)
Search regex in a string. Unlike match, this will search string for first position which matches regex \(which still may be 0 if regex is anchored\).
Search regex in a string. Unlike match, this will search string for first position which matches regex (which still may be 0 if regex is anchored).
#### ure.DEBUG
@@ -41,17 +46,17 @@ Flag value, display debug information about compiled expression.
Compiled regular expression. Instances of this class are created using `ure.compile()`.
#### regex.match\(string\)
#### regex.match(string)
#### regex.search\(string\)
#### regex.search(string)
#### regex.split\(string, max\_split=-1\)
#### regex.split(string, max\_split=-1)
## Match objects
Match objects as returned by `match()` and `search()` methods.
#### match.group\(\[index\]\)
#### match.group(\[index\])
Only numeric groups are supported.

View File

@@ -1,20 +1,25 @@
# usocket
---
title: "usocket"
aliases:
- firmwareapi/micropython/usocket.html
- firmwareapi/micropython/usocket.md
- chapter/firmwareapi/micropython/usocket
---
This module provides access to the BSD socket interface.
See corresponding CPython module for comparison.
## Socket Address Format\(s\)
## Socket Address Format(s)
Functions below which expect a network address, accept it in the format of `(ipv4_address, port)`, where `ipv4_address` is a string with dot-notation numeric IPv4 address, e.g. `8.8.8.8`, and port is integer port number in the range 1-65535. Note the domain names are not accepted as `ipv4_address`, they should be resolved first using `socket.getaddrinfo()`.
## Methods
#### socket.socket\(socket.AF\_INET, socket.SOCK\_STREAM, socket.IPPROTO\_TCP\)
#### socket.socket(socket.AF\_INET, socket.SOCK\_STREAM, socket.IPPROTO\_TCP)
Create a new socket using the given address family, socket type and protocol number.
#### socket.getaddrinfo\(host, port\)
#### socket.getaddrinfo(host, port)
Translate the host/port argument into a sequence of 5-tuples that contain all the necessary arguments for creating a socket connected to that service. The list of 5-tuples has following structure:
@@ -43,61 +48,61 @@ s.connect(socket.getaddrinfo('www.micropython.org', 80)[0][-1])
### Methods
#### socket.close\(\)
#### socket.close()
Mark the socket closed. Once that happens, all future operations on the socket object will fail. The remote end will receive no more data \(after queued data is flushed\).
Mark the socket closed. Once that happens, all future operations on the socket object will fail. The remote end will receive no more data (after queued data is flushed).
Sockets are automatically closed when they are garbage-collected, but it is recommended to `close()` them explicitly, or to use a with statement around them.
#### socket.bind\(address\)
#### socket.bind(address)
Bind the `socket` to `address`. The socket must not already be bound. The `address` parameter must be a tuple containing the IP address and the port.
{% hint style="info" %}
{{{% hint style="info" %}}}
In the case of LoRa sockets, the address parameter is simply an integer with the port number, for instance: `s.bind(1)`
{% endhint %}
{{< /hint >}}
#### socket.listen\(\[backlog\]\)
#### socket.listen(\[backlog\])
Enable a server to accept connections. If backlog is specified, it must be at least 0 \(if its lower, it will be set to 0\); and specifies the number of unaccepted connections that the system will allow before refusing new connections. If not specified, a default reasonable value is chosen.
Enable a server to accept connections. If backlog is specified, it must be at least 0 (if it's lower, it will be set to 0); and specifies the number of unaccepted connections that the system will allow before refusing new connections. If not specified, a default reasonable value is chosen.
#### socket.accept\(\)
#### socket.accept()
Accept a connection. The socket must be bound to an address and listening for connections. The return value is a pair `(conn, address)` where `conn` is a new socket object usable to send and receive data on the connection, and `address` is the address bound to the socket on the other end of the connection.
#### socket.connect\(address\)
#### socket.connect(address)
Connect to a remote socket at `address`.
#### socket.send\(bytes\)
#### socket.send(bytes)
Send data to the socket. The socket must be connected to a remote socket.
#### socket.sendall\(bytes\)
#### socket.sendall(bytes)
Alias of `socket.send(bytes)`.
#### socket.recv\(bufsize\)
#### socket.recv(bufsize)
Receive data from the socket. The return value is a bytes object representing the data received. The maximum amount of data to be received at once is specified by `bufsize`.
#### socket.sendto\(bytes, address\)
#### socket.sendto(bytes, address)
Send data to the socket. The socket should not be connected to a remote socket, since the destination socket is specified by address.
#### socket.recvfrom\(bufsize\)
#### socket.recvfrom(bufsize)
Receive data from the socket. The return value is a pair `(bytes, address)` where `bytes` is a bytes object representing the data received and `address` is the address of the socket sending the data.
#### socket.setsockopt\(level, optname, value\)
#### socket.setsockopt(level, optname, value)
Set the value of the given socket option. The needed symbolic constants are defined in the socket module \(`SO_*` etc.\). The value can be an integer or a bytes-like object representing a buffer.
Set the value of the given socket option. The needed symbolic constants are defined in the socket module (`SO_*` etc.). The value can be an integer or a bytes-like object representing a buffer.
#### socket.settimeout\(value\)
#### socket.settimeout(value)
Set a timeout on blocking socket operations. The value argument can be a nonnegative floating point number expressing seconds, or `None`. If a non-zero value is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. If zero is given, the socket is put in non-blocking mode. If None is given, the socket is put in blocking mode.
#### socket.setblocking\(flag\)
#### socket.setblocking(flag)
Set blocking or non-blocking mode of the socket: if flag is false, the socket is set to non-blocking, else to blocking mode.
@@ -108,45 +113,45 @@ sock.setblocking(True) is equivalent to sock.settimeout(None)
sock.setblocking(False) is equivalent to sock.settimeout(0.0)
```
#### socket.makefile\(mode='rb'\)
#### socket.makefile(mode='rb')
Return a file object associated with the socket. The exact returned type depends on the arguments given to makefile\(\). The support is limited to binary modes only \(`rb` and `wb`\). CPythons arguments: `encoding`, `errors`, and `newline` are not supported.
Return a file object associated with the socket. The exact returned type depends on the arguments given to makefile(). The support is limited to binary modes only (`rb` and `wb`). CPython's arguments: `encoding`, `errors`, and `newline` are not supported.
The socket must be in blocking mode; it can have a timeout, but the file objects internal buffer may end up in a inconsistent state if a timeout occurs.
The socket must be in blocking mode; it can have a timeout, but the file object's internal buffer may end up in a inconsistent state if a timeout occurs.
{% hint style="info" %}
{{{% hint style="info" %}}}
**Difference to CPython**
Closing the file object returned by `makefile()` **WILL** close the original socket as well.
{% endhint %}
{{< /hint >}}
#### socket.read\(size\)
#### socket.read(size)
Read up to size bytes from the socket. Return a bytes object. If `size` is not given, it behaves just like [`socket.readall()`](usocket.md#socket-readall), see below.
#### socket.readall\(\)
#### socket.readall()
Read all data available from the socket until EOF. This function will not return until the socket is closed.
#### socket.readinto\(buf\[, nbytes\]\)
#### socket.readinto(buf\[, nbytes\])
Read bytes into the `buf`. If `nbytes` is specified then read at most that many bytes. Otherwise, read at most `len(buf)` bytes.
Return value: number of bytes read and stored into `buf`.
#### socket.readline\(\)
#### socket.readline()
Read a line, ending in a newline character.
Return value: the line read.
#### socket.write\(buf\)
#### socket.write(buf)
Write the buffer of bytes to the socket.
Return value: number of bytes written.
#### socket.do_handshake\(\)
#### socket.do_handshake()
Perform the SSL handshake on the previously "wrapped" socket with ssl.wrap_socket().
COuld be used when the socket is non-blocking and the SSL handshake is not performed during connect().

View File

@@ -1,10 +1,15 @@
# ussl
This module provides access to Transport Layer Security \(often known as "Secure Sockets Layer"\) encryption and peer authentication facilities for network sockets, both client-side and server-side.
---
title: "ussl"
aliases:
- firmwareapi/micropython/ussl.html
- firmwareapi/micropython/ussl.md
- chapter/firmwareapi/micropython/ussl
---
This module provides access to Transport Layer Security (often known as "Secure Sockets Layer") encryption and peer authentication facilities for network sockets, both client-side and server-side.
## Methods
#### ssl.wrap\_socket\(sock, keyfile=None, certfile=None, server\_side=False, cert\_reqs=CERT\_NONE, ca\_certs=None\)
#### ssl.wrap\_socket(sock, keyfile=None, certfile=None, server\_side=False, cert\_reqs=CERT\_NONE, ca\_certs=None)
Takes an instance `sock` of `socket.socket`, and returns an instance of ssl.SSLSocket, a subtype of `socket.socket`, which wraps the underlying socket in an SSL context. Example:

View File

@@ -1,30 +1,35 @@
# ustruct
---
title: "ustruct"
aliases:
- firmwareapi/micropython/ustruct.html
- firmwareapi/micropython/ustruct.md
- chapter/firmwareapi/micropython/ustruct
---
See Python [struct](https://docs.python.org/3/library/struct.html) for more information.
Supported size/byte order prefixes: `@, <, >, !`.
Supported format codes: `b, B, h, H, i, I, l, L, q, Q, s, P, f, d` \(the latter 2 depending on the floating-point support\).
Supported format codes: `b, B, h, H, i, I, l, L, q, Q, s, P, f, d` (the latter 2 depending on the floating-point support).
## Methods
#### ustruct.calcsize\(fmt\)
#### ustruct.calcsize(fmt)
Return the number of bytes needed to store the given `fmt`.
#### ustruct.pack\(fmt, v1, v2, ...\)
#### ustruct.pack(fmt, v1, v2, ...)
Pack the values `v1, v2, ...` according to the format string `fmt`. The return value is a bytes object encoding the values.
#### ustruct.pack\_into\(fmt, buffer, offset, v1, v2, ...\)
#### ustruct.pack\_into(fmt, buffer, offset, v1, v2, ...)
Pack the values `v1, v2, ...` according to the format string `fmt` into a buffer starting at `offset`. `offset` may be negative to count from the end of buffer.
#### ustruct.unpack\(fmt, data\)
#### ustruct.unpack(fmt, data)
Unpack from the `data` according to the format string `fmt`. The return value is a tuple of the unpacked values.
#### ustruct.unpack\_from\(fmt, data, offset=0\)
#### ustruct.unpack\_from(fmt, data, offset=0)
Unpack from the `data` starting at `offset` according to the format string `fmt`. `offset` may be negative to count from the end of buffer. The return value is a tuple of the unpacked values.

View File

@@ -0,0 +1,92 @@
---
title: "utime"
aliases:
- firmwareapi/micropython/utime.html
- firmwareapi/micropython/utime.md
- chapter/firmwareapi/micropython/utime
---
The `utime` module provides functions for getting the current time and date, measuring time intervals, and for delays.
**Time Epoch**: Pycom's ESP32 port uses standard for POSIX systems epoch of `1970-01-01 00:00:00 UTC`.
## Maintaining actual calendar date/time
This requires a Real Time Clock (RTC). On systems with underlying OS (including some RTOS), an RTC may be implicit. Setting and maintaining actual calendar time is responsibility of OS/RTOS and is done outside of MicroPython, it just uses OS API to query date/time. On baremetal ports however system time depends on `machine.RTC()` object. The current calendar time may be set using `machine.RTC().datetime(tuple)` function, and maintained by following means:
* By a backup battery (which may be an additional, optional component for a particular board).
* Using networked time protocol (requires setup by a port/user).
* Set manually by a user on each power-up (many boards then maintain RTC time across hard resets, though some may require setting it again in such case).
If actual calendar time is not maintained with a system/MicroPython RTC, functions below which require reference to current absolute time may behave not as expected.
## Methods
#### utime.gmtime(\[secs\])
Convert a time expressed in seconds since the Epoch (see above) into an 8-tuple which contains: `(year, month, mday, hour, minute, second, weekday, yearday)` If `secs` is not provided or `None`, then the current time from the RTC is used.
* `year` includes the century (for example 2014).
* `month` is 1-12
* `mday` is 1-31
* `hour` is 0-23
* `minute` is 0-59
* `second` is 0-59
* `weekday` is 0-6 for Mon-Sun
* `yearday` is 1-366
#### utime.localtime(\[secs\])
Like `gmtime()` but converts to local time. If `secs` is not provided or `None`, the current time from the RTC is used.
#### utime.mktime()
This is inverse function of `localtime`. It's argument is a full 8-tuple which expresses a time as per `localtime`. It returns an integer which is the number of seconds since `Jan 1, 2000`.
#### utime.sleep(seconds)
Sleep for the given number of `seconds`. `seconds` can be a floating-point number to sleep for a fractional number of seconds. Note that other MicroPython ports may not accept floating-point argument, for compatibility with them use `sleep_ms()` and `sleep_us()` functions.
#### utime.sleep\_ms(ms)
Delay for given number of milliseconds, should be positive or 0.
#### utime.sleep\_us(us)
Delay for given number of microseconds, should be positive or 0
#### utime.ticks\_ms()
Returns uptime, in milliseconds.
#### utime.ticks\_us()
Just like `ticks_ms` above, but in microseconds.
#### utime.ticks\_cpu()
Same as `ticks_us`, but faster.
#### utime.ticks\_diff(end, start)
Measure period between consecutive calls to `ticks_ms()`, `ticks_us()`, or `ticks_cpu()`. The value returned by these functions may wrap around at any time, so directly subtracting them is not supported. `ticks_diff()` should be used instead. "start" value should actually precede "end" value in time, or result is undefined. This function should not be used to measure arbitrarily long periods of time (because `ticks_*()` functions wrap around and usually would have short period). The expected usage pattern is implementing event polling with timeout:
```python
# Wait for GPIO pin to be asserted, but at most 500us
start = time.ticks_us()
while pin.value() == 0:
if time.ticks_diff(time.ticks_us(), start) > 500:
raise TimeoutError
```
#### utime.time()
Returns the number of seconds, as an integer, since the Epoch, assuming that underlying RTC is set. If an RTC is not set, this function returns number of seconds since power up or reset). If you want to develop portable MicroPython application, you should not rely on this function to provide higher than second precision. If you need higher precision, use `ticks_ms()` and `ticks_us()` functions, if you need calendar time, `localtime()` without an argument is a better choice.
#### utime.timezone(\[secs\])
Set or get the timezone offset, in seconds. If `secs` is not provided, it returns the current value.
{{{% hint style="info" %}}}
In MicroPython, `time.timezone` works the opposite way to Python. In [Python](https://docs.python.org/3/library/time.html#time.timezone), to get the local time, you write `local_time = utc - timezone`, while in MicroPython it is `local_time = utc + timezone`.
{{< /hint >}}

View File

@@ -0,0 +1,27 @@
---
title: ""
aliases:
- firmwareapi/micropython/uzlib.html
- firmwareapi/micropython/uzlib.md
- chapter/firmwareapi/micropython/uzlib
---
_This module implements a subset of the corresponding_ `CPython` _module, as described below. For more information, refer to the original CPython documentation:_ `zlib`.
This module allows to decompress binary data compressed with [DEFLATE algorithm](https://en.wikipedia.org/wiki/DEFLATE) (commonly used in zlib library and gzip archiver). Compression is not yet implemented.
## **Methods**
**uzlib.decompress(data, wbits=0, bufsize=0)**
Return decompressed data as bytes. wbits is DEFLATE dictionary window size used during compression (8-15, the dictionary size is power of 2 of that value). Additionally, if value is positive, data is assumed to be zlib stream (with zlib header). Otherwise, if it's negative, it's assumed to be raw DEFLATE stream. bufsize parameter is for compatibility with CPython and is ignored.
**class uzlib.DecompIO(stream, wbits=0)**
Create a `stream` wrapper which allows transparent decompression of compressed data in another stream. This allows to process compressed streams with data larger than available heap size. In addition to values described in `decompress()`, wbits may take values 24..31 (16 + 8..15), meaning that input stream has gzip header.
{{{% hint style="info" %}}}
**Difference to CPython**
This class is MicroPython extension. It's included on provisional basis and may be changed considerably or removed in later versions.
{{< /hint >}}

View File

@@ -1,16 +1,21 @@
# Notes
---
title: "Notes"
aliases:
- firmwareapi/notes.html
- firmwareapi/notes.md
- chapter/firmwareapi/notes
---
## Interrupt Handling
In Pycoms ESP32 MicroPython port there are no restrictions on what can be done within an interrupt handler. For example, other ports do not allow allocating memory inside the handler or the use of sockets.
In Pycom's ESP32 MicroPython port there are no restrictions on what can be done within an interrupt handler. For example, other ports do not allow allocating memory inside the handler or the use of sockets.
These limitations were raised by handling the interrupt events differently. When an interrupt happens, a message is posted into a queue, notifying a separate thread that the appropriate callback handler should be called. Such handler would receive an argument. By default it is the object associated with the event.
The user can do whatever is required inside of the callback, such as creating new variables, or even sending network packets. Bear in mind that interrupts are processed sequentially and thus it is ideal to keep the handlers as short as possible in order to attend all of them in the minimum time.
Currently, there are 2 classes that support interrupts; the [`Alarm`](pycom/machine/timer.md#class-timer-alarm-handler-none-s-ms-us-arg-none-periodic-false) and [`Pin`](pycom/machine/pin.md) classes. Both classes provide the `.callback()` method that enables the interrupt and registers the given handler. For more details about interrupt usage along with examples, please visit their respective sections.
Currently, there are 2 classes that support interrupts; the [`Alarm`](pycom/machine/timer.md#class-timer-alarm-handler-none-s-ms-us-arg-none-periodic-false) and [`Pin`](pycom/machine/pin) classes. Both classes provide the `.callback()` method that enables the interrupt and registers the given handler. For more details about interrupt usage along with examples, please visit their respective sections.
{% hint style="info" %}
{{{% hint style="info" %}}}
Currently the interrupt system can queue up to **16 interrupts**.
{% endhint %}
{{< /hint >}}

View File

@@ -0,0 +1,7 @@
---
title: "Pycom Modules"
aliases:
- chapter/firmwareapi/pycom
---
These modules are specific to the Pycom devices and may have slightly different implementations to other variations of MicroPython (i.e. for Non-Pycom devices). Modules include those which support access to underlying hardware, e.g. I2C, SPI, WLAN, Bluetooth, etc.

View File

@@ -0,0 +1,6 @@
---
title: "Pycom Modules"
aliases:
---
These modules are specific to the Pycom devices and may have slightly different implementations to other variations of MicroPython (i.e. for Non-Pycom devices). Modules include those which support access to underlying hardware, e.g. I2C, SPI, WLAN, Bluetooth, etc.

View File

@@ -1,10 +1,15 @@
# AES
---
title: "AES"
aliases:
- firmwareapi/pycom/aes.html
- firmwareapi/pycom/aes.md
- chapter/firmwareapi/pycom/aes
---
AES (Advanced Encryption Standard) is a symmetric block cipher standardised by NIST. It has a fixed data block size of 16 bytes. Its keys can be 128, 192, or 256 bits long.
AES \(Advanced Encryption Standard\) is a symmetric block cipher standardised by NIST. It has a fixed data block size of 16 bytes. Its keys can be 128, 192, or 256 bits long.
{% hint style="info" %}
{{{% hint style="info" %}}}
AES is implemented using the ESP32 hardware module.
{% endhint %}
{{< /hint >}}
## Quick Usage Example
@@ -26,37 +31,37 @@ print(original)
## Constructors
#### class ucrypto.AES\(key, mode, IV, \* , counter, segment\_size\)
#### class ucrypto.AES(key, mode, IV, \* , counter, segment\_size)
Create an AES object that will let you encrypt and decrypt messages.
The arguments are:
* `key` \(byte string\) is the secret key to use. It must be 16 \(AES-128\), 24 \(AES-192\), or 32 \(AES-256\) bytes long.
* `key` (byte string) is the secret key to use. It must be 16 (AES-128), 24 (AES-192), or 32 (AES-256) bytes long.
* `mode` is the chaining mode to use for encryption and decryption. Default is `AES.MODE_ECB`.
* `IV` \(byte string\) initialisation vector. Should be 16 bytes long. It is ignored in modes `AES.MODE_ECB` and `AES.MODE_CRT`.
* `counter` \(byte string\) used only for `AES.MODE_CTR`. Should be 16 bytes long. Should not be reused.
* `IV` (byte string) initialisation vector. Should be 16 bytes long. It is ignored in modes `AES.MODE_ECB` and `AES.MODE_CRT`.
* `counter` (byte string) used only for `AES.MODE_CTR`. Should be 16 bytes long. Should not be reused.
* `segment_size` is the number of bits `plaintext` and `ciphertext` are segmented in. Is only used in `AES.MODE_CFB`. Supported values are `AES.SEGMENT_8` and `AES.SEGMENT_128`
## Methods
#### ucrypto.encrypt\(\)
#### ucrypto.encrypt()
Encrypt data with the key and the parameters set at initialisation.
#### ucrypto.decrypt\(\)
#### ucrypto.decrypt()
Decrypt data with the key and the parameters set at initialisation.
## Constants
* `AES.MODE_ECB`: Electronic Code Book. Simplest encryption mode. It does not hide data patterns well \(see this article for more info\)
* `AES.MODE_CBC`: Cipher-Block Chaining. An Initialisation Vector \(IV\) is required.
* `AES.MODE_ECB`: Electronic Code Book. Simplest encryption mode. It does not hide data patterns well (see this article for more info)
* `AES.MODE_CBC`: Cipher-Block Chaining. An Initialisation Vector (IV) is required.
* `AES.MODE_CFB`: Cipher feedback. `plaintext` and `ciphertext` are processed in segments of `segment_size` bits. Works a stream cipher.
* `AES.MODE_CTR`: Counter mode. Each message block is associated to a counter which must be unique across all messages that get encrypted with the same key.
* `AES.SEGMENT_8`, `AES.SEGMENT_128`: Length of the segment for `AES.MODE_CFB`
{% hint style="danger" %}
{{{% hint style="danger" %}}}
To avoid security issues, IV should always be a random number and should never be reused to encrypt two different messages. The same applies to the counter in CTR mode. You can use `crypto.getrandbits()` for this purpose.
{% endhint %}
{{< /hint >}}

View File

@@ -0,0 +1,120 @@
---
title: "machine"
aliases:
- chapter/firmwareapi/pycom/machine
---
The `machine` module contains specific functions related to the board.
### Quick Usage Example
```python
import machine
help(machine) # display all members from the machine module
machine.freq() # get the CPU frequency
machine.unique_id() # return the 6-byte unique id of the board (the LoPy's WiFi MAC address)
```
## Reset Functions
#### machine.reset()
Resets the device in a manner similar to pushing the external RESET button.
#### machine.reset\_cause()
Get the reset cause. See constants for the possible return values.
## Interrupt Functions
#### machine.disable\_irq()
Disable interrupt requests. Returns and integer representing the previous IRQ state. This return value can be passed to `enable_irq` to restore the IRQ to its original state.
#### machine.enable\_irq(\[state\])
Enable interrupt requests. The most common use of this function is to pass the value returned by `disable_irq` to exit a critical section. Another options is to enable all interrupts which can be achieved by calling the function with no parameters.
## Power Functions
#### machine.freq()
Returns CPU frequency in hertz.
#### machine.idle()
Gates the clock to the CPU, useful to reduce power consumption at any time during short or long periods. Peripherals continue working and execution resumes as soon as any interrupt is triggered (on many ports this includes system timer interrupt occurring at regular intervals on the order of millisecond).
#### machine.sleep(\[time\_ms\], resume\_wifi\_ble)
Sets the device in to light sleep mode , where in this mode digital peripherals, most of the RAM, and CPUs are clock-gated, and supply voltage is reduced. Upon exit from light sleep, peripherals and CPUs resume operation, their internal state is preserved.
* `time_ms` is the time in milliseconds that the device should wakeup after, if no time is given the device will sleep until the next reset cycle unless another wakeup source is configured.
* `resume_wifi_ble` is a boolean value that enables or disable restoring after wakeup any WiFi or BLE connection that was interrupted by light sleep.
* `True` Enable WiFi/BLE connections restoration
* `False` Disable Wifi/BLE connections restoration, default option is Disabled
_Note: in light sleep mode LoRa/Lte modems are stopped and have to be re-initialized after wakeup._
#### machine.deepsleep(\[time\_ms\])
Stops the CPU and all peripherals, including the networking interfaces (except for LTE). Execution is resumed from the main script, just as with a reset. If a value in milliseconds is given then the device will wake up after that period of time, otherwise it will remain in deep sleep until the reset button is pressed.
The products with LTE connectivity (FiPy, GPy, G01), require the LTE radio to be disabled separately via the LTE class before entering deepsleep. 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).
#### machine.pin\_sleep\_wakeup(pins, mode, enable\_pull)
Configure pins to wake up from deep/light sleep mode. The pins which have this capability are: `P2, P3, P4, P6, P8 to P10 and P13 to P23`.
The arguments are:
* `pins` a list or tuple containing the `GPIO` to setup for deepsleep wakeup.
* `mode` selects the way the configure `GPIO`s can wake up the module. The possible values are: `machine.WAKEUP_ALL_LOW` and `machine.WAKEUP_ANY_HIGH`.
* `enable_pull` if set to `True` keeps the pull up or pull down resistors enabled during deep sleep. If this variable is set to `True`, then `ULP` or capacitive touch wakeup cannot be used in combination with `GPIO` wakeup.
#### machine.wake\_reason()
Get the wake reason. See constants for the possible return values. Returns a tuple of the form: `(wake_reason, gpio_list)`. When the wakeup reason is either GPIO or touch pad, then the second element of the tuple is a list with GPIOs that generated the wakeup.
#### machine.remaining\_sleep\_time()
Returns the remaining timer duration (in milliseconds) if the ESP32 is woken up from deep sleep by something other than the timer. For example, if you set the timer for 30 seconds (30000 ms) and it wakes up after 10 seconds then this function will return `20000`.
## Miscellaneous Functions
#### machine.main(filename)
Set the `filename` of the main script to run after `boot.py` is finished. If this function is not called then the default file `main.py` will be executed.
It only makes sense to call this function from within `boot.py`.
#### machine.rng()
Return a 24-bit software generated random number.
#### machine.unique\_id()
Returns a byte string with a unique identifier of a board/SoC. It will vary from a board/SoC instance to another, if underlying hardware allows. Length varies by hardware (so use substring of a full value if you expect a short ID). In some MicroPython ports, ID corresponds to the network MAC address.
{{{% hint style="info" %}}}
Use `ubinascii.hexlify()` to convert the byte string to hexadecimal form for ease of manipulation and use elsewhere.
{{< /hint >}}
#### machine.info()
Returns the high water mark of the stack associated with various system tasks, in words (1 word = 4 bytes on the ESP32). If the value is zero then the task has likely overflowed its stack. If the value is close to zero then the task has come close to overflowing its stack.
## Constants
### Reset Causes
`machine.PWRON_RESET`, `machine.HARD_RESET`, `machine.WDT_RESET,` `machine.DEEPSLEEP_RESET`, `machine.SOFT_RESET`, `machine.BROWN_OUT_RESET`
### Wake Reasons
`machine.PWRON_WAKE`, `machine.PIN_WAKE`, `machine.RTC_WAKE`, `machine.ULP_WAKE`
### Pin Wakeup Modes
`machine.WAKEUP_ALL_LOW`, `machine.WAKEUP_ANY_HIGH`

View File

@@ -1,5 +1,7 @@
# machine
---
title: "machine"
aliases:
---
The `machine` module contains specific functions related to the board.
### Quick Usage Example
@@ -14,35 +16,35 @@ machine.unique_id() # return the 6-byte unique id of the board (the LoPy's WiFi
## Reset Functions
#### machine.reset\(\)
#### machine.reset()
Resets the device in a manner similar to pushing the external RESET button.
#### machine.reset\_cause\(\)
#### machine.reset\_cause()
Get the reset cause. See constants for the possible return values.
## Interrupt Functions
#### machine.disable\_irq\(\)
#### machine.disable\_irq()
Disable interrupt requests. Returns and integer representing the previous IRQ state. This return value can be passed to `enable_irq` to restore the IRQ to its original state.
#### machine.enable\_irq\(\[state\]\)
#### machine.enable\_irq(\[state\])
Enable interrupt requests. The most common use of this function is to pass the value returned by `disable_irq` to exit a critical section. Another options is to enable all interrupts which can be achieved by calling the function with no parameters.
## Power Functions
#### machine.freq\(\)
#### machine.freq()
Returns CPU frequency in hertz.
#### machine.idle\(\)
#### machine.idle()
Gates the clock to the CPU, useful to reduce power consumption at any time during short or long periods. Peripherals continue working and execution resumes as soon as any interrupt is triggered \(on many ports this includes system timer interrupt occurring at regular intervals on the order of millisecond\).
Gates the clock to the CPU, useful to reduce power consumption at any time during short or long periods. Peripherals continue working and execution resumes as soon as any interrupt is triggered (on many ports this includes system timer interrupt occurring at regular intervals on the order of millisecond).
#### machine.sleep\(\[time\_ms\], resume\_wifi\_ble\)
#### machine.sleep(\[time\_ms\], resume\_wifi\_ble)
Sets the device in to light sleep mode , where in this mode digital peripherals, most of the RAM, and CPUs are clock-gated, and supply voltage is reduced. Upon exit from light sleep, peripherals and CPUs resume operation, their internal state is preserved.
@@ -53,13 +55,13 @@ Sets the device in to light sleep mode , where in this mode digital peripherals,
_Note: in light sleep mode LoRa/Lte modems are stopped and have to be re-initialized after wakeup._
#### machine.deepsleep\(\[time\_ms\]\)
#### machine.deepsleep(\[time\_ms\])
Stops the CPU and all peripherals, including the networking interfaces \(except for LTE\). Execution is resumed from the main script, just as with a reset. If a value in milliseconds is given then the device will wake up after that period of time, otherwise it will remain in deep sleep until the reset button is pressed.
Stops the CPU and all peripherals, including the networking interfaces (except for LTE). Execution is resumed from the main script, just as with a reset. If a value in milliseconds is given then the device will wake up after that period of time, otherwise it will remain in deep sleep until the reset button is pressed.
The products with LTE connectivity \(FiPy, GPy, G01\), require the LTE radio to be disabled separately via the LTE class before entering deepsleep. 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\).
The products with LTE connectivity (FiPy, GPy, G01), require the LTE radio to be disabled separately via the LTE class before entering deepsleep. 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).
#### machine.pin\_sleep\_wakeup\(pins, mode, enable\_pull\)
#### machine.pin\_sleep\_wakeup(pins, mode, enable\_pull)
Configure pins to wake up from deep/light sleep mode. The pins which have this capability are: `P2, P3, P4, P6, P8 to P10 and P13 to P23`.
@@ -69,37 +71,37 @@ The arguments are:
* `mode` selects the way the configure `GPIO`s can wake up the module. The possible values are: `machine.WAKEUP_ALL_LOW` and `machine.WAKEUP_ANY_HIGH`.
* `enable_pull` if set to `True` keeps the pull up or pull down resistors enabled during deep sleep. If this variable is set to `True`, then `ULP` or capacitive touch wakeup cannot be used in combination with `GPIO` wakeup.
#### machine.wake\_reason\(\)
#### machine.wake\_reason()
Get the wake reason. See constants for the possible return values. Returns a tuple of the form: `(wake_reason, gpio_list)`. When the wakeup reason is either GPIO or touch pad, then the second element of the tuple is a list with GPIOs that generated the wakeup.
#### machine.remaining\_sleep\_time\(\)
#### machine.remaining\_sleep\_time()
Returns the remaining timer duration \(in milliseconds\) if the ESP32 is woken up from deep sleep by something other than the timer. For example, if you set the timer for 30 seconds \(30000 ms\) and it wakes up after 10 seconds then this function will return `20000`.
Returns the remaining timer duration (in milliseconds) if the ESP32 is woken up from deep sleep by something other than the timer. For example, if you set the timer for 30 seconds (30000 ms) and it wakes up after 10 seconds then this function will return `20000`.
## Miscellaneous Functions
#### machine.main\(filename\)
#### machine.main(filename)
Set the `filename` of the main script to run after `boot.py` is finished. If this function is not called then the default file `main.py` will be executed.
It only makes sense to call this function from within `boot.py`.
#### machine.rng\(\)
#### machine.rng()
Return a 24-bit software generated random number.
#### machine.unique\_id\(\)
#### machine.unique\_id()
Returns a byte string with a unique identifier of a board/SoC. It will vary from a board/SoC instance to another, if underlying hardware allows. Length varies by hardware \(so use substring of a full value if you expect a short ID\). In some MicroPython ports, ID corresponds to the network MAC address.
Returns a byte string with a unique identifier of a board/SoC. It will vary from a board/SoC instance to another, if underlying hardware allows. Length varies by hardware (so use substring of a full value if you expect a short ID). In some MicroPython ports, ID corresponds to the network MAC address.
{% hint style="info" %}
{{{% hint style="info" %}}}
Use `ubinascii.hexlify()` to convert the byte string to hexadecimal form for ease of manipulation and use elsewhere.
{% endhint %}
{{< /hint >}}
#### machine.info\(\)
#### machine.info()
Returns the high water mark of the stack associated with various system tasks, in words \(1 word = 4 bytes on the ESP32\). If the value is zero then the task has likely overflowed its stack. If the value is close to zero then the task has come close to overflowing its stack.
Returns the high water mark of the stack associated with various system tasks, in words (1 word = 4 bytes on the ESP32). If the value is zero then the task has likely overflowed its stack. If the value is close to zero then the task has come close to overflowing its stack.
## Constants

View File

@@ -1,5 +1,10 @@
---
search:
title: "ADC"
aliases:
- firmwareapi/pycom/machine/adc.html
- firmwareapi/pycom/machine/adc.md
- chapter/firmwareapi/pycom/machine/adc
---
keywords:
- ADC
- Analog
@@ -22,23 +27,23 @@ val = apin() # read an analog value
### Constructors
#### class machine.ADC\(id=0\)
#### class machine.ADC(id=0)
Create an ADC object; associate a channel with a pin. For more info check the hardware section.
### Methods
#### adc.init\( \* , bits=12\)
#### adc.init( \* , bits=12)
Enable the ADC block. This method is automatically called on object creation.
* `Bits` can take values between 9 and 12 and selects the number of bits of resolution of the ADC block.
#### adc.deinit\(\)
#### adc.deinit()
Disable the ADC block.
#### adc.channel\(\* , pin, attn=ADC.ATTN\_0DB\)
#### adc.channel(\* , pin, attn=ADC.ATTN\_0DB)
Create an analog pin.
@@ -52,11 +57,11 @@ Returns an instance of `ADCChannel`. Example:
apin = adc.channel(pin='P16')
```
#### adc.vref\(vref\)
#### adc.vref(vref)
If called without any arguments, this function returns the current calibrated voltage \(in millivolts\) of the `1.1v` reference. Otherwise it will update the calibrated value \(in millivolts\) of the internal `1.1v` reference.
If called without any arguments, this function returns the current calibrated voltage (in millivolts) of the `1.1v` reference. Otherwise it will update the calibrated value (in millivolts) of the internal `1.1v` reference.
#### adc.vref\_to\_pin\(pin\)
#### adc.vref\_to\_pin(pin)
Connects the internal `1.1v` to external `GPIO`. It can only be connected to `P22`, `P21` or `P6`. It is recommended to only use `P6` on the WiPy, on other modules this pin is connected to the radio.
@@ -70,31 +75,31 @@ Read analog values from internal/external sources. ADC channels can be connected
### Methods
#### adcchannel\(\)
#### adcchannel()
Fast method to read the channel value.
#### adcchannel.value\(\)
#### adcchannel.value()
Read the channel value.
#### adcchannel.init\(\)
#### adcchannel.init()
\(Re\)init and enable the ADC channel. This method is automatically called on object creation.
(Re)init and enable the ADC channel. This method is automatically called on object creation.
#### adcchannel.deinit\(\)
#### adcchannel.deinit()
Disable the ADC channel.
#### adcchannel.voltage\(\)
#### adcchannel.voltage()
Reads the channels value and converts it into a voltage \(in millivolts\)
Reads the channels value and converts it into a voltage (in millivolts)
#### adcchannel.value\_to\_voltage\(value\)
#### adcchannel.value\_to\_voltage(value)
Converts the provided value into a voltage \(in millivolts\) in the same way voltage does.
Converts the provided value into a voltage (in millivolts) in the same way voltage does.
{% hint style="danger" %}
{{{% hint style="danger" %}}}
ADC pin input range is `0-1.1V`. This maximum value can be increased up to `3.3V` using the highest attenuation of `11dB`. **Do not exceed the maximum of 3.3V**, to avoid damaging the device.
{% endhint %}
{{< /hint >}}

View File

@@ -1,5 +1,10 @@
# CAN
---
title: "CAN"
aliases:
- firmwareapi/pycom/machine/can.html
- firmwareapi/pycom/machine/can.md
- chapter/firmwareapi/pycom/machine/can
---
The CAN class supports the full CAN 2.0 specification with standard and extended frames, as well as acceptance filtering.
The ESP32 has a built-in CAN controller, but the transceiver needs to be added externally. A recommended device is the SN65HVD230.
@@ -16,7 +21,7 @@ can.recv()
## Constructors
#### class machine.CAN\(bus=0, ...\)
#### class machine.CAN(bus=0, ...)
Create an CAN object. See init for parameters of initialisation.:
@@ -27,28 +32,28 @@ can = CAN(0, mode=CAN.NORMAL, baudrate=500000, pins=('P22', 'P23')) # pin ord
## Methods
#### can.init\(mode=CAN.NORMAL, baudrate=500000, \*, frame\_format=CAN.FORMAT\_STD, rx\_queue\_len=128, pins=\('P22', 'P23'\)\)
#### can.init(mode=CAN.NORMAL, baudrate=500000, \*, frame\_format=CAN.FORMAT\_STD, rx\_queue\_len=128, pins=('P22', 'P23'))
Initialize the CAN controller. The arguments are:
* `mode` can take either CAN.NORMAL or CAN.SILENT. Silent mode is useful for sniffing the bus.
* `baudrate` sets up the bus speed. Acceptable values are between 1 and 1000000.
* `frame_format` defines the frame format to be accepted by the receiver. Useful for filtering frames based on the identifier length. Can tale either `CAN.FORMAT_STD`, `CAN.FORMAT_EXT`, `CAN.FORMAT_BOTH`. If `CAN.FORMAT_STD` is selected, extended frames won't be received and vice-versa.
* `rx_queue_len` defines the number of messages than can be queued by the receiver. Due to CAN being a high traffic bus, large values are recommended \(&gt;= 128\), otherwise messages will be dropped specially when no filtering is applied.
* `pins` selects the `Tx` and `Rx` pins \(in that order\).
* `rx_queue_len` defines the number of messages than can be queued by the receiver. Due to CAN being a high traffic bus, large values are recommended (&gt;= 128), otherwise messages will be dropped specially when no filtering is applied.
* `pins` selects the `Tx` and `Rx` pins (in that order).
#### can.deinit\(\)
#### can.deinit()
Disables the CAN bus.
#### can.send\(id, \* , data=None, rtr=False, extended=False\)
#### can.send(id, \* , data=None, rtr=False, extended=False)
Send a CAN frame on the bus
* `id` is the identifier of the message.
* `data` can take up to 8 bytes. It must be left empty is the message to be sent is a remote request \(rtr=True\).
* `data` can take up to 8 bytes. It must be left empty is the message to be sent is a remote request (rtr=True).
* `rtr` set it to false to send a remote request.
* `extnted` specifies if the message identifier width should be 11bit \(standard\) or 29bit \(extended\).
* `extnted` specifies if the message identifier width should be 11bit (standard) or 29bit (extended).
Can be used like:
@@ -60,9 +65,9 @@ can.send(id=0x010, data=bytes([0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08]))
can.send(id=0x012, rtr=True) # sends a remote request for message id=0x12
```
#### can.recv\(timeout=0\)
#### can.recv(timeout=0)
Get a message from the receive queue, and optionally specify a timeout value in **s** \(can be a floating point value e.g. `0.2`\). This function returns `None` if no messages available. If a message is present, it will be returned as a named tuple with the following form:
Get a message from the receive queue, and optionally specify a timeout value in **s** (can be a floating point value e.g. `0.2`). This function returns `None` if no messages available. If a message is present, it will be returned as a named tuple with the following form:
`(id, data, rtr, extended)`
@@ -71,7 +76,7 @@ Get a message from the receive queue, and optionally specify a timeout value in
(id=0x012, data=b'123', rtr=False, extended=False)
```
#### can.soft\_filter\(mode, filter\_list\)
#### can.soft\_filter(mode, filter\_list)
Specify a software filter accepting only the messages that pass the filter test.
@@ -95,7 +100,7 @@ can.soft_filter(CAN.FILTER_MASK, [(0x100, 0x7FF), (0x200, 0x7FC)]) # more of the
can.soft_filter(None) # disable soft filters, all messages are accepted
```
#### can.callback\(trigger, handler=None, arg=None\)
#### can.callback(trigger, handler=None, arg=None)
Set a callback to be triggered when any of this 3 events are present:
@@ -122,9 +127,9 @@ def can_cb(can_o):
can.callback(handler=can_cb, trigger=CAN.RX_FRAME)
```
#### can.events\(\)
#### can.events()
This method returns a value with bits sets \(if any\) indicating the events that have occurred in the bus. Please note that by calling this function the internal events registry is cleared automatically, therefore calling it immediately for a second time will most likely return a value of 0.
This method returns a value with bits sets (if any) indicating the events that have occurred in the bus. Please note that by calling this function the internal events registry is cleared automatically, therefore calling it immediately for a second time will most likely return a value of 0.
## Constants

View File

@@ -1,6 +1,11 @@
# DAC
The DAC is used to output analog values \(a specific voltage\) on pin `P22` or pin `P21`. The voltage will be between `0` and `3.3V`.
---
title: "DAC"
aliases:
- firmwareapi/pycom/machine/dac.html
- firmwareapi/pycom/machine/dac.md
- chapter/firmwareapi/pycom/machine/dac
---
The DAC is used to output analog values (a specific voltage) on pin `P22` or pin `P21`. The voltage will be between `0` and `3.3V`.
## Quick Usage Example
@@ -16,31 +21,31 @@ dac_tone.tone(1000, 0) # set tone output to 1kHz
## Constructors
#### class class machine.DAC\(pin\)
#### class class machine.DAC(pin)
Create a DAC object, that will let you associate a channel with a `pin`. `pin` can be a string argument.
## Methods
#### dac.init\(\)
#### dac.init()
Enable the DAC block. This method is automatically called on object creation.
#### dac.deinit\(\)
#### dac.deinit()
Disable the DAC block.
#### dac.write\(value\)
#### dac.write(value)
Set the DC level for a DAC pin. `value` is a float argument, with values between 0 and 1.
#### dac.tone\(frequency, amplitude\)
#### dac.tone(frequency, amplitude)
Sets up tone signal to the specified `frequency` at `amplitude` scale. `frequency` can be from `125Hz` to `20kHz` in steps of `122Hz`. `amplitude` is an integer specifying the tone amplitude to write the DAC pin. Amplitude value represents:
* `0` is 0dBV \(~ 3Vpp at 600 Ohm load\)
* `1` is -6dBV \(~1.5 Vpp\), `2` is -12dBV \(~0.8 Vpp\)
* `3` is -18dBV \(~0.4 Vpp\).
* `0` is 0dBV (~ 3Vpp at 600 Ohm load)
* `1` is -6dBV (~1.5 Vpp), `2` is -12dBV (~0.8 Vpp)
* `3` is -18dBV (~0.4 Vpp).
The generated signal is a sine wave with an DC offset of VDD/2.

View File

@@ -1,5 +1,10 @@
# I2C
---
title: "I2C"
aliases:
- firmwareapi/pycom/machine/i2c.html
- firmwareapi/pycom/machine/i2c.md
- chapter/firmwareapi/pycom/machine/i2c
---
I2C is a two-wire protocol for communicating between devices. At the physical level it consists of 2 wires: SCL and SDA, the clock and data lines respectively.
I2C objects are created attached to a specific bus. They can be initialised when created, or initialised later on.
@@ -28,7 +33,7 @@ i2c.deinit() # turn off the peripheral
Printing the `i2c` object gives you information about its configuration.
A master must specify the recipients address:
A master must specify the recipient's address:
```python
i2c.init(I2C.MASTER)
@@ -62,61 +67,61 @@ i2c.writeto_mem(0x42, 0x10, 'xy') # write 2 bytes to slave 0x42, slave memory 0x
## Constructors
#### class machine.I2C\(bus, ...\)
#### class machine.I2C(bus, ...)
Construct an I2C object on the given `bus`. `bus` can only be `0, 1, 2`. If the `bus` is not given, the default one will be selected \(`0`\). Buses `0` and `1` use the ESP32 I2C hardware peripheral while bus `2` is implemented with a bit-banged software driver.
Construct an I2C object on the given `bus`. `bus` can only be `0, 1, 2`. If the `bus` is not given, the default one will be selected (`0`). Buses `0` and `1` use the ESP32 I2C hardware peripheral while bus `2` is implemented with a bit-banged software driver.
## Methods
### General Methods
#### i2c.init\(mode, \* , baudrate=100000, pins=\(SDA, SCL\)\)
#### i2c.init(mode, \* , baudrate=100000, pins=(SDA, SCL))
Initialise the I2C bus with the given parameters:
* `mode` must be I2C.MASTER
* `baudrate` is the SCL clock rate
* pins is an optional tuple with the pins to assign to the I2C bus. The default I2C pins are `P9` \(SDA\) and `P10` \(SCL\)
* pins is an optional tuple with the pins to assign to the I2C bus. The default I2C pins are `P9` (SDA) and `P10` (SCL)
#### i2c.scan\(\)
#### i2c.scan()
Scan all I2C addresses between `0x08` and `0x77` inclusive and return a list of those that respond. A device responds if it pulls the SDA line low after its address \(including a read bit\) is sent on the bus.
Scan all I2C addresses between `0x08` and `0x77` inclusive and return a list of those that respond. A device responds if it pulls the SDA line low after its address (including a read bit) is sent on the bus.
### Standard Bus Operations
The following methods implement the standard I2C master read and write operations that target a given slave device.
#### i2c.readfrom\(addr, nbytes\)
#### i2c.readfrom(addr, nbytes)
Read `nbytes` from the slave specified by `addr`. Returns a bytes object with the data read.
#### i2c.readfrom\_into\(addr, buf\)
#### i2c.readfrom\_into(addr, buf)
Read into `buf` from the slave specified by `addr`. The number of bytes read will be the length of `buf`.
Return value is the number of bytes read.
#### i2c.writeto\(addr, buf, \* , stop=True\)
#### i2c.writeto(addr, buf, \* , stop=True)
Write the bytes from `buf` to the slave specified by `addr`. The argument `buf` can also be an integer which will be treated as a single byte. If `stop` is set to `False` then the stop condition wont be sent and the I2C operation may be continued \(typically with a read transaction\).
Write the bytes from `buf` to the slave specified by `addr`. The argument `buf` can also be an integer which will be treated as a single byte. If `stop` is set to `False` then the stop condition won't be sent and the I2C operation may be continued (typically with a read transaction).
Return value is the number of bytes written.
### Memory Operations
Some I2C devices act as a memory device \(or set of registers\) that can be read from and written to. In this case there are two addresses associated with an I2C transaction: the slave address and the memory address. The following methods are convenience functions to communicate with such devices.
Some I2C devices act as a memory device (or set of registers) that can be read from and written to. In this case there are two addresses associated with an I2C transaction: the slave address and the memory address. The following methods are convenience functions to communicate with such devices.
#### i2c.readfrom\_mem\(addr, memaddr, nbytes, \*, addrsize=8\)
#### i2c.readfrom\_mem(addr, memaddr, nbytes, \*, addrsize=8)
Read `nbytes` from the slave specified by `addr` starting from the memory address specified by `memaddr`. The `addrsize` argument is specified in bits and it can only take 8 or 16.
#### i2c.readfrom\_mem\_into\(addr, memaddr, buf, \*, addrsize=8\)
#### i2c.readfrom\_mem\_into(addr, memaddr, buf, \*, addrsize=8)
Read into `buf` from the slave specified by `addr` starting from the memory address specified by `memaddr`. The number of bytes read is the length of `buf`. The `addrsize` argument is specified in bits and it can only take 8 or 16.
The return value is the number of bytes read.
#### i2c.writeto\_mem\(addr, memaddr, buf \*, addrsize=8\)
#### i2c.writeto\_mem(addr, memaddr, buf \*, addrsize=8)
Write `buf` to the slave specified by `addr` starting from the memory address specified by `memaddr`. The argument `buf` can also be an integer which will be treated as a single byte. The `addrsize` argument is specified in bits and it can only take 8 or 16.

View File

@@ -1,6 +1,11 @@
# Pin
A pin is the basic object to control I/O pins \(also known as GPIO - general-purpose input/output\). It has methods to set the mode of the pin \(input, output, etc\) and methods to get and set the digital logic level. For analog control of a pin, see the ADC class.
---
title: "Pin"
aliases:
- firmwareapi/pycom/machine/pin.html
- firmwareapi/pycom/machine/pin.md
- chapter/firmwareapi/pycom/machine/pin
---
A pin is the basic object to control I/O pins (also known as GPIO - general-purpose input/output). It has methods to set the mode of the pin (input, output, etc) and methods to get and set the digital logic level. For analog control of a pin, see the ADC class.
## Quick Usage Example
@@ -21,9 +26,9 @@ p_in() # get value, 0 or 1
## Constructors
#### class machine.Pin\(id, ...\)
#### class machine.Pin(id, ...)
Create a new Pin object associated with the string `id`. If additional arguments are given, they are used to initialise the pin. [See pin.init\(\)](pin.md#pin-init-mode-pull-alt)
Create a new Pin object associated with the string `id`. If additional arguments are given, they are used to initialise the pin. [See pin.init()](pin.md#pin-init-mode-pull-alt)
```python
from machine import Pin
@@ -32,7 +37,7 @@ p = Pin('P10', mode=Pin.OUT, pull=None, alt=-1)
## Methods
#### pin.init\(mode, pull, \* , alt\)
#### pin.init(mode, pull, \* , alt)
Initialise the pin:
@@ -48,20 +53,20 @@ Initialise the pin:
Returns: `None`.
#### pin.id\(\)
#### pin.id()
Get the pin id.
#### pin.value\(\[value\]\)
#### pin.value(\[value\])
Get or set the digital logic level of the pin:
* With no argument, return 0 or 1 depending on the logic level of the pin.
* With value given, set the logic level of the pin. value can be anything that converts to a boolean. If it converts to True, the pin is set high, otherwise it is set low.
#### pin\(\[value\]\)
#### pin(\[value\])
Pin objects are callable. The call method provides a \(fast\) shortcut to set and get the value of the pin.
Pin objects are callable. The call method provides a (fast) shortcut to set and get the value of the pin.
Example:
@@ -73,25 +78,25 @@ pin() # fast method to get the value
See `pin.value()` for more details.
#### pin.toggle\(\)
#### pin.toggle()
Toggle the value of the pin.
#### pin.mode\(\[mode\]\)
#### pin.mode(\[mode\])
Get or set the pin mode.
#### pin.pull\(\[pull\]\)
#### pin.pull(\[pull\])
Get or set the pin pull.
#### pin.hold\(\[hold\]\)
#### pin.hold(\[hold\])
Get or set the pin hold. You can apply a hold to a pin by passing `True` \(or clear it by passing `False`\). When a pin is held, its value cannot be changed by using `Pin.value()` or `Pin.toggle()` until the hold is released. This Can be used to retain the pin state through a core reset and system reset triggered by watchdog time-out or Deep-sleep events. Only pins in the RTC power domain can retain their value through deep sleep or reset.
Get or set the pin hold. You can apply a hold to a pin by passing `True` (or clear it by passing `False`). When a pin is held, its value cannot be changed by using `Pin.value()` or `Pin.toggle()` until the hold is released. This Can be used to retain the pin state through a core reset and system reset triggered by watchdog time-out or Deep-sleep events. Only pins in the RTC power domain can retain their value through deep sleep or reset.
These are: `P2, P3, P4, P6, P8, P9, P10, P13, P14, P15, P16, P17, P18, P19, P20, P21, P22, P23`
#### pin.callback\(trigger, handler=None, arg=None\)
#### pin.callback(trigger, handler=None, arg=None)
Set a callback to be triggered when the input level at the pin changes.
@@ -118,9 +123,9 @@ p_in = Pin('P10', mode=Pin.IN, pull=Pin.PULL_UP)
p_in.callback(Pin.IRQ_FALLING | Pin.IRQ_RISING, pin_handler)
```
{% hint style="info" %}
For more information on how Pycoms products handle interrupts, see [here](../../notes.md#interrupt-handling).
{% endhint %}
{{{% hint style="info" %}}}
For more information on how Pycom's products handle interrupts, see [here](/../notes.md#interrupt-handling).
{{< /hint >}}
## Attributes

View File

@@ -1,5 +1,10 @@
# PWM
---
title: "PWM"
aliases:
- firmwareapi/pycom/machine/pwm.html
- firmwareapi/pycom/machine/pwm.md
- chapter/firmwareapi/pycom/machine/pwm
---
## class PWM Pulse Width Modulation
### Quick Usage Example
@@ -14,13 +19,13 @@ pwm_c.duty_cycle(0.3) # change the duty cycle to 30%
### Constructors
#### class machine.PWM\(timer, frequency\)
#### class machine.PWM(timer, frequency)
Create a PWM object. This sets up the `timer` to oscillate at the specified `frequency`. `timer` is an integer from 0 to 3. `frequency` is an integer from 1 Hz to 78 KHz \(this values can change in future upgrades\).
Create a PWM object. This sets up the `timer` to oscillate at the specified `frequency`. `timer` is an integer from 0 to 3. `frequency` is an integer from 1 Hz to 78 KHz (this values can change in future upgrades).
### Methods
#### pwm.channel\(id, pin \* , duty\_cycle=0.5\)
#### pwm.channel(id, pin \* , duty\_cycle=0.5)
Connect a PWM channel to a pin, setting the initial duty cycle. `id` is an integer from 0 to 7. `pin` is a string argument. `duty_cycle` is a keyword-only float argument, with values between 0 and 1. Returns an instance of `PWMChannel`.
@@ -28,7 +33,7 @@ Connect a PWM channel to a pin, setting the initial duty cycle. `id` is an integ
### Methods
#### pwmchannel.duty\_cycle\(value\)
#### pwmchannel.duty\_cycle(value)
Set the duty cycle for a PWM channel. `value` is a float argument, with values between 0 and 1.

View File

@@ -1,5 +1,10 @@
---
search:
title: "RMT"
aliases:
- firmwareapi/pycom/machine/rmt.html
- firmwareapi/pycom/machine/rmt.md
- chapter/firmwareapi/pycom/machine/rmt
---
keywords:
- RMT
- Remote
@@ -9,7 +14,7 @@ search:
# RMT
The RMT \(Remote Control\) module is primarily designed to send and receive infrared remote control signals that use on-off-keying of a carrier frequency, but due to its design it can be used to generate various types of signals.
The RMT (Remote Control) module is primarily designed to send and receive infrared remote control signals that use on-off-keying of a carrier frequency, but due to its design it can be used to generate various types of signals.
## Quick Usage Example: sending
@@ -40,7 +45,7 @@ data = rmt.recv_pulses()
## Constructors
#### class machine.RMT\(channel,...\)
#### class machine.RMT(channel,...)
Construct an RMT object on the given channel. `channel` can be 2-7. With no additional parameters, the RMT object is created but not initialised. If extra arguments are given, the RMT is initialised for transmission or reception. See `init` for parameters of initialisation. The resolution which a pulse can be sent/received depends on the selected channel:
@@ -57,13 +62,13 @@ Construct an RMT object on the given channel. `channel` can be 2-7. With no addi
## Methods
#### rmt.init\(gpio, rx\_idle\_threshold, rx\_filter\_threshold, tx\_idle\_level, tx\_carrier\)
#### rmt.init(gpio, rx\_idle\_threshold, rx\_filter\_threshold, tx\_idle\_level, tx\_carrier)
Initialise the RMT peripheral with the given parameters:
* `gpio` is the GPIO Pin to use.
* `rx_idle_threshold` is the maximum duration of a valid pulse. The represented time unit \(resolution\) depends on the selected channel, value can be 0-65535.
* `rx_filter_threshold` is the minimum duration of a valid pulse. The represented time unit \(resolution\) depends on the selected channel, value can be 0-31.
* `rx_idle_threshold` is the maximum duration of a valid pulse. The represented time unit (resolution) depends on the selected channel, value can be 0-65535.
* `rx_filter_threshold` is the minimum duration of a valid pulse. The represented time unit (resolution) depends on the selected channel, value can be 0-31.
* `tx_idle_level` is the output signal's level after the transmission is finished, can be RMT.HIGH or RMT.LOW.
* `tx_carrier` is the modulation of the pulses to send.
@@ -75,15 +80,15 @@ The `tx_carrier` parameter is a tuple with the following structure:
* `carrier_duty_percent` is the duty percent of the carrier's signal, can be 0%-100%.
* `carrier_level` is the level of the pulse to modulate, can be RMT.HIGH or RMT.LOW.
#### rmt.deinit\(\)
#### rmt.deinit()
Deinitialise the RMT object.
{% hint style="info" %}
{{{% hint style="info" %}}}
If an RMT object needs to be reconfigured from RX/TX to TX/RX, then either first `deinit()` must be called or the `init()` again with the desired configuration.
{% endhint %}
{{< /hint >}}
#### rmt.pulses\_get\(pulses, timeout\)
#### rmt.pulses\_get(pulses, timeout)
Reads in pulses from the GPIO pin.
@@ -104,19 +109,19 @@ Reads in pulses from the GPIO pin.
Return value: Tuple of items with the following structure: `(level, duration)`:
* `level` represents the level of the received bit/pulse, can be 0 or 1.
* `duration` represents the duration of the received pulse, the time unit \(resolution\) depends on the selected channel.
* `duration` represents the duration of the received pulse, the time unit (resolution) depends on the selected channel.
{% hint style="info" %}
{{{% hint style="info" %}}}
Maximum of 128 pulses can be received in a row without receiving "idle" signal. If the incoming pulse sequence contains more than 128 pulses the rest is dropped and the receiver waits for another sequence of pulses. The `pulses_get` function can be called to receive more than 128 pulses, however the above mentioned limitation should be kept in mind when evaluating the received data.
{% endhint %}
{{< /hint >}}
#### rmt.pulses\_send\(duration, data, start\_level, wait\_tx\_done\)
#### rmt.pulses\_send(duration, data, start\_level, wait\_tx\_done)
Generates pulses as defined by the parameters below
* `duration` represents the duration of the pulses to be sent, the time unit \(resolution\) depends on the selected channel.
* `duration` represents the duration of the pulses to be sent, the time unit (resolution) depends on the selected channel.
* `data` Tuple that represents the sequence of pulses to be sent, must be composed of 0 or 1 elements.
* `start_level` defines the state \(HIGH/LOW\) of the first pulse given by `duration` if `data` is not given.
* `start_level` defines the state (HIGH/LOW) of the first pulse given by `duration` if `data` is not given.
* `data` must be a tuple and `duration` can be a tuple or a single number, with `data` being optional. In the case that only `duration` is provided, it must be a tuple and you must also provide `start_level` which will dictate the level of the first duration, the signal level then toggles between each duration value.
* If `data` is provided and `duration` is a single number, each pulse in `data` will have have an equal length as set by `duration`.
* If `data` and `duration` are provided as tuples, they must be of the same number of elements, with each pulse lasting its matching duration.

View File

@@ -1,5 +1,10 @@
# RTC
---
title: "RTC"
aliases:
- firmwareapi/pycom/machine/rtc.html
- firmwareapi/pycom/machine/rtc.md
- chapter/firmwareapi/pycom/machine/rtc
---
The RTC is used to keep track of the date and time.
## Quick Usage Example
@@ -14,7 +19,7 @@ print(rtc.now())
## Constructors
#### class machine.RTC\(id=0, ...\)
#### class machine.RTC(id=0, ...)
Create an RTC object. See init for parameters of initialisation.
@@ -25,7 +30,7 @@ rtc = RTC(id=0)
## Methods
#### rtc.init\(datetime=None, source=RTC.INTERNAL\_RC\)
#### rtc.init(datetime=None, source=RTC.INTERNAL\_RC)
Initialise the RTC. The arguments are:
@@ -39,11 +44,11 @@ For example:
rtc.init((2017, 2, 28, 10, 30, 0, 0, 0))
```
{% hint style="info" %}
{{{% hint style="info" %}}}
`tzinfo` is ignored by this method. Use `time.timezone` to achieve similar results.
{% endhint %}
{{< /hint >}}
#### rtc.now\(\)
#### rtc.now()
Get get the current `datetime` tuple:
@@ -52,9 +57,9 @@ Get get the current `datetime` tuple:
rtc.now()
```
#### rtc.ntp\_sync\(server, \* , update\_period=3600\)
#### rtc.ntp\_sync(server, \* , update\_period=3600)
Set up automatic fetch and update the time using NTP \(SNTP\).
Set up automatic fetch and update the time using NTP (SNTP).
* `server` is the URL of the NTP server. Can be set to `None` to disable the periodic updates.
* `update_period` is the number of seconds between updates. Shortest period is 15 seconds.
@@ -65,7 +70,7 @@ Can be used like:
rtc.ntp_sync("pool.ntp.org") # this is an example. You can select a more specific server according to your geographical location
```
#### rtc.synced\(\)
#### rtc.synced()
Returns `True` if the last `ntp_sync` has been completed, `False` otherwise:
@@ -73,7 +78,7 @@ Returns `True` if the last `ntp_sync` has been completed, `False` otherwise:
rtc.synced()
```
#### rtc.memory\(\[data\]\)
#### rtc.memory(\[data\])
Reads RTC memory contents or write data in passed Buffer in to RTC memory

View File

@@ -1,14 +1,19 @@
# SD
---
title: "SD"
aliases:
- firmwareapi/pycom/machine/sd.html
- firmwareapi/pycom/machine/sd.md
- chapter/firmwareapi/pycom/machine/sd
---
The SD card class allows to configure and enable the memory card module of your Pycom module and automatically mount it as `/sd` as part of the file system. There is a single pin combination that can be used for the SD card, and the current implementation only works in 1-bit mode. The pin connections are as follows:
`P8: DAT0`, `P23: SCLK` and `P4: CMD` \(no external pull-up resistors are needed\)
`P8: DAT0`, `P23: SCLK` and `P4: CMD` (no external pull-up resistors are needed)
If you have one of the Pycom expansion boards, then simply insert the card into the micro SD socket and run your script.
{% hint style="info" %}
{{{% hint style="info" %}}}
Make sure your SD card is formatted either as FAT16 or FAT32.
{% endhint %}
{{< /hint >}}
## Quick Example Usage:
@@ -33,21 +38,21 @@ f.close()
## Constructors
#### class machine.SD\(id, ...\)
#### class machine.SD(id, ...)
Create a SD card object. See [`sd.init()`](sd.md#sd-init-id-0) for parameters if initialisation.
## Methods
#### sd.init\(id=0\)
#### sd.init(id=0)
Enable the SD card.
#### sd.deinit\(\)
#### sd.deinit()
Disable the SD card.
{% hint style="info" %}
{{{% hint style="info" %}}}
Please note that the SD card library currently supports FAT16/32 formatted SD cards up to 32 GB. Future firmware updates will increase compatibility with additional formats and sizes.
{% endhint %}
{{< /hint >}}

View File

@@ -1,5 +1,10 @@
# SPI
---
title: "SPI"
aliases:
- firmwareapi/pycom/machine/spi.html
- firmwareapi/pycom/machine/spi.md
- chapter/firmwareapi/pycom/machine/spi
---
SPI is a serial protocol that is driven by a master. At the physical level there are 3 lines: SCK, MOSI, MISO.
See usage model of I2C; SPI is very similar. Main difference is parameters to init the SPI bus:
@@ -41,13 +46,13 @@ spi.write_readinto(bytes([0x01, 0x02, 0x03, 0x04, 0x05]), rbuf) # send a receive
## Constructors
#### class machine.SPI\(id, ...\)
#### class machine.SPI(id, ...)
Construct an SPI object on the given bus. `id` can be only 0. With no additional parameters, the SPI object is created but not initialised \(it has the settings from the last initialisation of the bus, if any\). If extra arguments are given, the bus is initialised. See init for parameters of initialisation.
Construct an SPI object on the given bus. `id` can be only 0. With no additional parameters, the SPI object is created but not initialised (it has the settings from the last initialisation of the bus, if any). If extra arguments are given, the bus is initialised. See init for parameters of initialisation.
## Methods
#### spi.init\(mode, baudrate=1000000, \* , polarity=0, phase=0, bits=8, firstbit=SPI.MSB, pins=\(CLK, MOSI, MISO\)\)
#### spi.init(mode, baudrate=1000000, \* , polarity=0, phase=0, bits=8, firstbit=SPI.MSB, pins=(CLK, MOSI, MISO))
Initialise the SPI bus with the given parameters:
@@ -57,25 +62,25 @@ Initialise the SPI bus with the given parameters:
* `phase` can be 0 or 1 to sample data on the first or second clock edge respectively.
* `bits` is the width of each transfer, accepted values are 8, 16 and 32.
* `firstbit` can be SPI.MSB or SPI.LSB.
* `pins` is an optional tuple with the pins to assign to the SPI bus. If the pins argument is not given the default pins will be selected \(`P10` as CLK,`P11` as MOSI and `P14` as MISO\). If pins is passed as None then no pin assignment will be made.
* `pins` is an optional tuple with the pins to assign to the SPI bus. If the pins argument is not given the default pins will be selected (`P10` as CLK,`P11` as MOSI and `P14` as MISO). If pins is passed as None then no pin assignment will be made.
#### spi.deinit\(\)
#### spi.deinit()
Turn off the SPI bus.
#### spi.write\(buf\)
#### spi.write(buf)
Write the data contained in `buf`. Returns the number of bytes written.
#### spi.read\(nbytes, \* , write=0x00\)
#### spi.read(nbytes, \* , write=0x00)
Read the `nbytes` while writing the data specified by `write`. Returns the bytes read.
#### spi.readinto\(buf, \* , write=0x00\)
#### spi.readinto(buf, \* , write=0x00)
Read into the buffer specified by `buf` while writing the data specified by `write`. Return the number of bytes read.
#### spi.write\_readinto\(write\_buf, read\_buf\)
#### spi.write\_readinto(write\_buf, read\_buf)
Write from `write_buf` and read into `read_buf`. Both buffers must have the same length. Returns the number of bytes written

View File

@@ -1,5 +1,10 @@
# Timer
---
title: "Timer"
aliases:
- firmwareapi/pycom/machine/timer.html
- firmwareapi/pycom/machine/timer.md
- chapter/firmwareapi/pycom/machine/timer
---
## class Timer Measure Time and Set Alarms
Timers can be used for a great variety of tasks, like measuring time spans or being notified that a specific interval has elapsed.
@@ -8,30 +13,30 @@ These two concepts are grouped into two different subclasses:
`Chrono`: used to measure time spans. `Alarm`: to get interrupted after a specific interval.
{% hint style="info" %}
{{{% hint style="info" %}}}
You can create as many of these objects as needed.
{% endhint %}
{{< /hint >}}
### Constructors
#### class Timer.Chrono\(\)
#### class Timer.Chrono()
Create a chronometer object.
#### class Timer.Alarm\(handler=None, s, \* , ms, us, arg=None, periodic=False\)
#### class Timer.Alarm(handler=None, s, \* , ms, us, arg=None, periodic=False)
Create an Alarm object.
* `handler`: will be called after the interval has elapsed. If set to `None`, the alarm will be disabled after creation.
* `arg`: an optional argument can be passed to the callback handler function. If `None` is specified, the function will receive the object that triggered the alarm.
* `s, ms, us`: the interval can be specified in seconds \(float\), miliseconds \(integer\) or microseconds \(integer\). Only one at a time can be specified.
* `s, ms, us`: the interval can be specified in seconds (float), miliseconds (integer) or microseconds (integer). Only one at a time can be specified.
* `periodic`: an alarm can be set to trigger repeatedly by setting this parameter to `True`.
### Methods
#### Timer.sleep\_us\(\)
#### Timer.sleep\_us()
Delay for a given number of microseconds, should be positive or 0 \(for speed, the condition is not enforced\). Internally it uses the same timer as the other elements of the `Timer` class. It compensates for the calling overhead, so for example, 100us should be really close to 100us. For times bigger than 10,000us it releases the GIL to let other threads run, so exactitude is not guaranteed for delays longer than that.
Delay for a given number of microseconds, should be positive or 0 (for speed, the condition is not enforced). Internally it uses the same timer as the other elements of the `Timer` class. It compensates for the calling overhead, so for example, 100us should be really close to 100us. For times bigger than 10,000us it releases the GIL to let other threads run, so exactitude is not guaranteed for delays longer than that.
## class Chrono
@@ -39,27 +44,27 @@ Can be used to measure time spans.
### Methods
#### chrono.start\(\)
#### chrono.start()
Start the chronometer.
#### chrono.stop\(\)
#### chrono.stop()
Stop the chronometer.
#### chrono.reset\(\)
#### chrono.reset()
Reset the time count to 0.
#### chrono.read\(\)
#### chrono.read()
Get the elapsed time in seconds.
#### chrono.read\_ms\(\)
#### chrono.read\_ms()
Get the elapsed time in milliseconds.
#### chrono.read\_us\(\)
#### chrono.read\_us()
Get the elapsed time in microseconds.
@@ -91,13 +96,13 @@ Used to get interrupted after a specific interval.
### Methods
#### alarm.callback\(handler, \* , arg=None\)
#### alarm.callback(handler, \* , arg=None)
Specify a callback handler for the alarm. If set to `None`, the alarm will be disabled.
An optional argument `arg` can be passed to the callback handler function. If `None` is specified, the function will receive the object that triggered the alarm.
#### alarm.cancel\(\)
#### alarm.cancel()
Disables the alarm.
@@ -121,7 +126,7 @@ class Clock:
clock = Clock()
```
{% hint style="info" %}
For more information on how Pycoms products handle interrupts, see [notes](../../notes.md#interrupt-handling).
{% endhint %}
{{{% hint style="info" %}}}
For more information on how Pycom's products handle interrupts, see [notes](/../notes.md#interrupt-handling).
{{< /hint >}}

View File

@@ -1,6 +1,11 @@
# UART
UART implements the standard UART/USART duplex serial communications protocol. At the physical level it consists of 2 lines: RXD and TXD. The unit of communication is a character \(not to be confused with a string character\) which can be 5, 6, 7 or 8 bits wide.
---
title: "UART"
aliases:
- firmwareapi/pycom/machine/uart.html
- firmwareapi/pycom/machine/uart.md
- chapter/firmwareapi/pycom/machine/uart
---
UART implements the standard UART/USART duplex serial communications protocol. At the physical level it consists of 2 lines: RXD and TXD. The unit of communication is a character (not to be confused with a string character) which can be 5, 6, 7 or 8 bits wide.
UART objects can be created and initialised using:
@@ -39,7 +44,7 @@ uart.write('hello')
uart.read(5) # read up to 5 bytes
```
## Quick Usage Example using non-default pins \(TXD/RXD only\)
## Quick Usage Example using non-default pins (TXD/RXD only)
```python
from machine import UART
@@ -49,7 +54,7 @@ uart.write('hello')
uart.read(5) # read up to 5 bytes
```
## Quick Usage Example using non-default pins \(TXD/RXD and flow control\)
## Quick Usage Example using non-default pins (TXD/RXD and flow control)
```python
from machine import UART
@@ -61,17 +66,17 @@ uart.read(5) # read up to 5 bytes
## Constructors
#### class machine.UART\(bus, ...\)
#### class machine.UART(bus, ...)
Construct a UART object on the given `bus`. `bus` can be `0, 1 or 2`. If the `bus` is not given, the default one will be selected \(`0`\) or the selection will be made based on the given pins.
Construct a UART object on the given `bus`. `bus` can be `0, 1 or 2`. If the `bus` is not given, the default one will be selected (`0`) or the selection will be made based on the given pins.
{% hint style="danger" %}
{{{% hint style="danger" %}}}
On the GPy/FiPy UART2 is unavailable because it is used to communicate with the cellular radio.
{% endhint %}
{{< /hint >}}
## Methods
#### uart.init\(baudrate=9600, bits=8, parity=None, stop=1, \* , timeout\_chars=2, pins=\(TXD, RXD, RTS, CTS\)\)
#### uart.init(baudrate=9600, bits=8, parity=None, stop=1, \* , timeout\_chars=2, pins=(TXD, RXD, RTS, CTS))
Initialise the UART bus with the given parameters:
@@ -80,56 +85,56 @@ Initialise the UART bus with the given parameters:
* `parity` is the parity, `None`, UART.EVEN or UART.ODD.
* `stop` is the number of stop bits, `1 or 2`.
* `timeout_chars` Rx timeout defined in number of characters. The value given here will be multiplied by the time a characters takes to be transmitted at the configured `baudrate`.
* `pins` is a 4 or 2 item list indicating the TXD, RXD, RTS and CTS pins \(in that order\). Any of the pins can be `None` if one wants the UART to operate with limited functionality. If the RTS pin is given the the RX pin must be given as well. The same applies to CTS. When no pins are given, then the default set of TXD \(P1\) and RXD \(P0\) pins is taken, and hardware flow control will be disabled. If `pins=None`, no pin assignment will be made.
* `pins` is a 4 or 2 item list indicating the TXD, RXD, RTS and CTS pins (in that order). Any of the pins can be `None` if one wants the UART to operate with limited functionality. If the RTS pin is given the the RX pin must be given as well. The same applies to CTS. When no pins are given, then the default set of TXD (P1) and RXD (P0) pins is taken, and hardware flow control will be disabled. If `pins=None`, no pin assignment will be made.
#### uart.deinit\(\)
#### uart.deinit()
Turn off the UART bus.
#### uart.any\(\)
#### uart.any()
Return the number of characters available for reading.
#### uart.read\(\[nbytes\]\)
#### uart.read(\[nbytes\])
Read characters. If `nbytes` is specified then read at most that many bytes.
Return value: a bytes object containing the bytes read in. Returns `None` on timeout.
#### uart.readall\(\)
#### uart.readall()
Read as much data as possible.
Return value: a bytes object or `None` on timeout.
#### uart.readinto\(buf\[, nbytes\]\)
#### uart.readinto(buf\[, nbytes\])
Read bytes into the `buf`. If `nbytes` is specified then read at most that many bytes. Otherwise, read at most `len(buf)` bytes.
Return value: number of bytes read and stored into `buf` or `None` on timeout.
#### uart.readline\(\)
#### uart.readline()
Read a line, ending in a newline character. If such a line exists, return is immediate. If the timeout elapses, all available data is returned regardless of whether a newline exists.
Return value: the line read or `None` on timeout if no data is available.
#### uart.write\(buf\)
#### uart.write(buf)
Write the buffer of bytes to the bus.
Return value: number of bytes written or None on timeout.
#### uart.sendbreak\(\)
#### uart.sendbreak()
Send a break condition on the bus. This drives the bus low for a duration of 13 bits. Return value: `None`.
#### uart.wait\_tx\_done\(timeout\_ms\)
#### uart.wait\_tx\_done(timeout\_ms)
Waits at most `timeout_ms` for the last Tx transaction to complete. Returns `True` if all data has been sent and the TX buffer has no data in it, otherwise returns `False`.
## Constants
* Parity types \(along with `None`\): `UART.EVEN`, `UART.ODD`
* Parity types (along with `None`): `UART.EVEN`, `UART.ODD`
* IRQ trigger sources: `UART.RX_ANY`

View File

@@ -1,5 +1,10 @@
# WDT
---
title: "WDT"
aliases:
- firmwareapi/pycom/machine/wdt.html
- firmwareapi/pycom/machine/wdt.md
- chapter/firmwareapi/pycom/machine/wdt
---
The WDT is used to restart the system when the application crashes and ends up into a non recoverable state. After enabling, the application must "feed" the watchdog periodically to prevent it from expiring and resetting the system.
## Quick Usage Example
@@ -12,17 +17,17 @@ wdt.feed()
## Constructors
#### class machine.WDT\(id=0, timeout\)
#### class machine.WDT(id=0, timeout)
Create a WDT object and start it. The `id` can only be `0`. See the init method for the parameters of initialisation.
## Methods
#### wdt.init\(timeout\)
#### wdt.init(timeout)
Initialises the watchdog timer. The timeout must be given in milliseconds. Once it is running the WDT cannot be stopped but the timeout can be re-configured at any point in time.
#### wdt.feed\(\)
#### wdt.feed()
Feed the WDT to prevent it from resetting the system. The application should place this call in a sensible place ensuring that the WDT is only fed after verifying that everything is functioning correctly.

View File

@@ -0,0 +1,7 @@
---
title: "network"
aliases:
- chapter/firmwareapi/pycom/network
---
This module provides access to network drivers and routing configuration. Network drivers for specific hardware are available within this module and are used to configure specific hardware network interfaces.

View File

@@ -1,4 +1,6 @@
# network
---
title: "network"
aliases:
---
This module provides access to network drivers and routing configuration. Network drivers for specific hardware are available within this module and are used to configure specific hardware network interfaces.

View File

@@ -0,0 +1,257 @@
---
title: "Bluetooth"
aliases:
- chapter/firmwareapi/pycom/network/bluetooth
---
This class provides a driver for the Bluetooth radio in the module. Currently, only basic BLE functionality is available.
## Quick Usage Example
```python
from network import Bluetooth
import time
bt = Bluetooth()
bt.start_scan(-1)
while True:
adv = bt.get_adv()
if adv and bt.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL) == 'Heart Rate':
try:
conn = bt.connect(adv.mac)
services = conn.services()
for service in services:
time.sleep(0.050)
if type(service.uuid()) == bytes:
print('Reading chars from service = {}'.format(service.uuid()))
else:
print('Reading chars from service = %x' % service.uuid())
chars = service.characteristics()
for char in chars:
if (char.properties() & Bluetooth.PROP_READ):
print('char {} value = {}'.format(char.uuid(), char.read()))
conn.disconnect()
break
except:
print("Error while connecting or reading from the BLE device")
break
else:
time.sleep(0.050)
```
## Bluetooth Low Energy (BLE)
Bluetooth low energy (BLE) is a subset of classic Bluetooth, designed for easy connecting and communicating between devices (in particular mobile platforms). BLE uses a methodology known as Generic Access Profile (GAP) to control connections and advertising.
GAP allows for devices to take various roles but generic flow works with devices that are either a Server (low power, resource constrained, sending small payloads of data) or a Client device (commonly a mobile device, PC or Pycom Device with large resources and processing power). Pycom devices can act as both a Client and a Server.
## Constructors
#### class network.Bluetooth(id=0, ...)
Create a Bluetooth object, and optionally configure it. See init for params of configuration.
Example:
```python
from network import Bluetooth
bluetooth = Bluetooth()
```
## Methods
#### bluetooth.init(id=0, mode=Bluetooth.BLE, antenna=None)
* `id` Only one Bluetooth peripheral available so must always be 0
* `mode` currently the only supported mode is `Bluetooth.BLE`
* `antenna` selects between the internal and the external antenna. Can be either
`Bluetooth.INT_ANT`, `Bluetooth.EXT_ANT`.
With our development boards it defaults to using the internal antenna, but in
the case of an OEM module, the antenna pin (`P12`) is not used, so it's free to be
used for other things.
Initialises and enables the Bluetooth radio in BLE mode.
#### bluetooth.deinit()
Disables the Bluetooth radio.
#### bluetooth.start\_scan(timeout)
Starts performing a scan listening for BLE devices sending advertisements. This function always returns immediately, the scanning will be performed on the background. The return value is `None`. After starting the scan the function `get_adv()` can be used to retrieve the advertisements messages from the FIFO. The internal FIFO has space to cache 16 advertisements.
The arguments are:
* `timeout` specifies the amount of time in seconds to scan for advertisements, cannot be zero. If timeout is &gt; 0, then the BLE radio will listen for advertisements until the specified value in seconds elapses. If timeout &lt; 0, then there's no timeout at all, and stop\_scan() needs to be called to cancel the scanning process.
Examples:
```python
bluetooth.start_scan(10) # starts scanning and stop after 10 seconds
bluetooth.start_scan(-1) # starts scanning indefinitely until bluetooth.stop_scan() is called
```
#### bluetooth.stop\_scan()
Stops an ongoing scanning process. Returns `None`.
#### bluetooth.isscanning()
Returns `True` if a Bluetooth scan is in progress. `False` otherwise.
#### bluetooth.get\_adv()
Gets an named tuple with the advertisement data received during the scanning. The tuple has the following structure: `(mac, addr_type, adv_type, rssi, data)`
* `mac` is the 6-byte ling mac address of the device that sent the advertisement.
* `addr_type` is the address type. See the constants section below for more details.
* `adv_type` is the advertisement type received. See the constants section below fro more details.
* `rssi` is signed integer with the signal strength of the advertisement.
* `data` contains the complete 31 bytes of the advertisement message. In order to parse the data and get the specific types, the method `resolve_adv_data()` can be used.
Example for getting `mac` address of an advertiser:
```python
import ubinascii
bluetooth = Bluetooth()
bluetooth.start_scan(20) # scan for 20 seconds
adv = bluetooth.get_adv() #
ubinascii.hexlify(adv.mac) # convert hexadecimal to ascii
```
#### bluetooth.get\_advertisements()
Same as the `get_adv()` method, but this one returns a list with all the advertisements received.
#### bluetooth.resolve\_adv\_data(data, data\_type)
Parses the advertisement data and returns the requested `data_type` if present. If the data type is not present, the function returns `None`.
Arguments:
* `data` is the bytes object with the complete advertisement data.
* `data_type` is the data type to resolve from from the advertisement data. See constants section below for details.
Example:
```python
import ubinascii
from network import Bluetooth
bluetooth = Bluetooth()
bluetooth.start_scan(20)
while bluetooth.isscanning():
adv = bluetooth.get_adv()
if adv:
# try to get the complete name
print(bluetooth.resolve_adv_data(adv.data, Bluetooth.ADV_NAME_CMPL))
mfg_data = bluetooth.resolve_adv_data(adv.data, Bluetooth.ADV_MANUFACTURER_DATA)
if mfg_data:
# try to get the manufacturer data (Apple's iBeacon data is sent here)
print(ubinascii.hexlify(mfg_data))
```
#### bluetooth.connect(mac\_addr, timeout=None)
* `mac_addr` is the address of the remote device to connect
* `timeout` specifies the amount of time in milliseconds to wait for the connection process to finish. If not given then no timeout is applied The function blocks until the connection succeeds or fails (raises OSError) or the given `timeout` expires (raises `Bluetooth.timeout TimeoutError`). If the connections succeeds it returns a object of type `GATTCConnection`.
```python
bluetooth.connect('112233eeddff') # mac address is accepted as a string
```
#### bluetooth.callback(trigger=None, handler=None, arg=None)
Creates a callback that will be executed when any of the triggers occurs. The arguments are:
* `trigger` can be either `Bluetooth.NEW_ADV_EVENT`, `Bluetooth.CLIENT_CONNECTED`, or `Bluetooth.CLIENT_DISCONNECTED`
* `handler` is the function that will be executed when the callback is triggered.
* `arg` is the argument that gets passed to the callback. If nothing is given the bluetooth object itself is used.
An example of how this may be used can be seen in the [`bluetooth.events()`](./#bluetooth-events) method.
#### bluetooth.events()
Returns a value with bit flags identifying the events that have occurred since the last call. Calling this function clears the events.
Example of usage:
```python
from network import Bluetooth
bluetooth = Bluetooth()
bluetooth.set_advertisement(name='LoPy', service_uuid=b'1234567890123456')
def conn_cb (bt_o):
events = bt_o.events() # this method returns the flags and clears the internal registry
if events & Bluetooth.CLIENT_CONNECTED:
print("Client connected")
elif events & Bluetooth.CLIENT_DISCONNECTED:
print("Client disconnected")
bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)
bluetooth.advertise(True)
```
#### bluetooth.set\_advertisement(\* , name=None, manufacturer\_data=None, service\_data=None, service\_uuid=None)
Configure the data to be sent while advertising. If left with the default of `None` the data won't be part of the advertisement message.
The arguments are:
* `name` is the string name to be shown on advertisements.
* `manufacturer_data` manufacturer data to be advertised (hint: use it for iBeacons).
* `service_data` service data to be advertised.
* `service_uuid` uuid of the service to be advertised.
Example:
```python
bluetooth.set_advertisement(name="advert", manufacturer_data="lopy_v1")
```
#### bluetooth.advertise(\[Enable\])
Start or stop sending advertisements. The `set_advertisement()` method must have been called prior to this one.
#### bluetooth.service(uuid, \* , isprimary=True, nbr\_chars=1, start=True)
Create a new service on the internal GATT server. Returns a object of type `BluetoothServerService`.
The arguments are:
* `uuid` is the UUID of the service. Can take an integer or a 16 byte long string or bytes object.
* `isprimary` selects if the service is a primary one. Takes a `bool` value.
* `nbr_chars` specifies the number of characteristics that the service will contain.
* `start` if `True` the service is started immediately.
```python
bluetooth.service('abc123')
```
#### bluetooth.disconnect\_client()
Closes the BLE connection with the client.
## Constants
* Bluetooth mode: `Bluetooth.BLE`
* Advertisement type: `Bluetooth.CONN_ADV`, `Bluetooth.CONN_DIR_ADV`, `Bluetooth.DISC_ADV`, `Bluetooth.NON_CONN_ADV`, `Bluetooth.SCAN_RSP`
* Address type: `Bluetooth.PUBLIC_ADDR`, `Bluetooth.RANDOM_ADDR`, `Bluetooth.PUBLIC_RPA_ADDR`, `Bluetooth.RANDOM_RPA_ADDR`
* Advertisement data type: `Bluetooth.ADV_FLAG`, `Bluetooth.ADV_16SRV_PART`, `Bluetooth.ADV_T16SRV_CMPL`, `Bluetooth.ADV_32SRV_PART`, `Bluetooth.ADV_32SRV_CMPL`, `Bluetooth.ADV_128SRV_PART`, `Bluetooth.ADV_128SRV_CMPL`, `Bluetooth.ADV_NAME_SHORT`, `Bluetooth.ADV_NAME_CMPL`, `Bluetooth.ADV_TX_PWR`, `Bluetooth.ADV_DEV_CLASS`, `Bluetooth.ADV_SERVICE_DATA`, `Bluetooth.ADV_APPEARANCE`, `Bluetooth.ADV_ADV_INT`, `Bluetooth.ADV_32SERVICE_DATA`, `Bluetooth.ADV_128SERVICE_DATA`, `Bluetooth.ADV_MANUFACTURER_DATA`
* Characteristic properties (bit values that can be combined): `Bluetooth.PROP_BROADCAST`, `Bluetooth.PROP_READ`, `Bluetooth.PROP_WRITE_NR`, `Bluetooth.PROP_WRITE`, `Bluetooth.PROP_NOTIFY`, `Bluetooth.PROP_INDICATE`, `Bluetooth.PROP_AUTH`, `Bluetooth.PROP_EXT_PROP`
* Characteristic callback events: `Bluetooth.CHAR_READ_EVENT`, `Bluetooth.CHAR_WRITE_EVENT`, `Bluetooth.NEW_ADV_EVENT`, `Bluetooth.CLIENT_CONNECTED`, `Bluetooth.CLIENT_DISCONNECTED`, `Bluetooth.CHAR_NOTIFY_EVENT`
* Antenna type: `Bluetooth.INT_ANT`, `Bluetooth.EXT_ANT`
## Exceptions
* `Bluetooth.timeout`

View File

@@ -1,5 +1,7 @@
# Bluetooth
---
title: "Bluetooth"
aliases:
---
This class provides a driver for the Bluetooth radio in the module. Currently, only basic BLE functionality is available.
## Quick Usage Example
@@ -35,15 +37,15 @@ while True:
time.sleep(0.050)
```
## Bluetooth Low Energy \(BLE\)
## Bluetooth Low Energy (BLE)
Bluetooth low energy \(BLE\) is a subset of classic Bluetooth, designed for easy connecting and communicating between devices \(in particular mobile platforms\). BLE uses a methodology known as Generic Access Profile \(GAP\) to control connections and advertising.
Bluetooth low energy (BLE) is a subset of classic Bluetooth, designed for easy connecting and communicating between devices (in particular mobile platforms). BLE uses a methodology known as Generic Access Profile (GAP) to control connections and advertising.
GAP allows for devices to take various roles but generic flow works with devices that are either a Server \(low power, resource constrained, sending small payloads of data\) or a Client device \(commonly a mobile device, PC or Pycom Device with large resources and processing power\). Pycom devices can act as both a Client and a Server.
GAP allows for devices to take various roles but generic flow works with devices that are either a Server (low power, resource constrained, sending small payloads of data) or a Client device (commonly a mobile device, PC or Pycom Device with large resources and processing power). Pycom devices can act as both a Client and a Server.
## Constructors
#### class network.Bluetooth\(id=0, ...\)
#### class network.Bluetooth(id=0, ...)
Create a Bluetooth object, and optionally configure it. See init for params of configuration.
@@ -56,7 +58,7 @@ bluetooth = Bluetooth()
## Methods
#### bluetooth.init\(id=0, mode=Bluetooth.BLE, antenna=None\)
#### bluetooth.init(id=0, mode=Bluetooth.BLE, antenna=None)
* `id` Only one Bluetooth peripheral available so must always be 0
* `mode` currently the only supported mode is `Bluetooth.BLE`
@@ -66,23 +68,23 @@ bluetooth = Bluetooth()
With our development boards it defaults to using the internal antenna, but in
the case of an OEM module, the antenna pin \(`P12`\) is not used, so its free to be
the case of an OEM module, the antenna pin (`P12`) is not used, so it's free to be
used for other things.
Initialises and enables the Bluetooth radio in BLE mode.
#### bluetooth.deinit\(\)
#### bluetooth.deinit()
Disables the Bluetooth radio.
#### bluetooth.start\_scan\(timeout\)
#### bluetooth.start\_scan(timeout)
Starts performing a scan listening for BLE devices sending advertisements. This function always returns immediately, the scanning will be performed on the background. The return value is `None`. After starting the scan the function `get_adv()` can be used to retrieve the advertisements messages from the FIFO. The internal FIFO has space to cache 16 advertisements.
The arguments are:
* `timeout` specifies the amount of time in seconds to scan for advertisements, cannot be zero. If timeout is &gt; 0, then the BLE radio will listen for advertisements until the specified value in seconds elapses. If timeout &lt; 0, then theres no timeout at all, and stop\_scan\(\) needs to be called to cancel the scanning process.
* `timeout` specifies the amount of time in seconds to scan for advertisements, cannot be zero. If timeout is &gt; 0, then the BLE radio will listen for advertisements until the specified value in seconds elapses. If timeout &lt; 0, then there's no timeout at all, and stop\_scan() needs to be called to cancel the scanning process.
Examples:
@@ -91,15 +93,15 @@ bluetooth.start_scan(10) # starts scanning and stop after 10 seconds
bluetooth.start_scan(-1) # starts scanning indefinitely until bluetooth.stop_scan() is called
```
#### bluetooth.stop\_scan\(\)
#### bluetooth.stop\_scan()
Stops an ongoing scanning process. Returns `None`.
#### bluetooth.isscanning\(\)
#### bluetooth.isscanning()
Returns `True` if a Bluetooth scan is in progress. `False` otherwise.
#### bluetooth.get\_adv\(\)
#### bluetooth.get\_adv()
Gets an named tuple with the advertisement data received during the scanning. The tuple has the following structure: `(mac, addr_type, adv_type, rssi, data)`
@@ -121,11 +123,11 @@ adv = bluetooth.get_adv() #
ubinascii.hexlify(adv.mac) # convert hexadecimal to ascii
```
#### bluetooth.get\_advertisements\(\)
#### bluetooth.get\_advertisements()
Same as the `get_adv()` method, but this one returns a list with all the advertisements received.
#### bluetooth.resolve\_adv\_data\(data, data\_type\)
#### bluetooth.resolve\_adv\_data(data, data\_type)
Parses the advertisement data and returns the requested `data_type` if present. If the data type is not present, the function returns `None`.
@@ -155,16 +157,16 @@ while bluetooth.isscanning():
print(ubinascii.hexlify(mfg_data))
```
#### bluetooth.connect\(mac\_addr, timeout=None\)
#### bluetooth.connect(mac\_addr, timeout=None)
* `mac_addr` is the address of the remote device to connect
* `timeout` specifies the amount of time in milliseconds to wait for the connection process to finish. If not given then no timeout is applied The function blocks until the connection succeeds or fails \(raises OSError\) or the given `timeout` expires \(raises `Bluetooth.timeout TimeoutError`\). If the connections succeeds it returns a object of type `GATTCConnection`.
* `timeout` specifies the amount of time in milliseconds to wait for the connection process to finish. If not given then no timeout is applied The function blocks until the connection succeeds or fails (raises OSError) or the given `timeout` expires (raises `Bluetooth.timeout TimeoutError`). If the connections succeeds it returns a object of type `GATTCConnection`.
```python
bluetooth.connect('112233eeddff') # mac address is accepted as a string
```
#### bluetooth.callback\(trigger=None, handler=None, arg=None\)
#### bluetooth.callback(trigger=None, handler=None, arg=None)
Creates a callback that will be executed when any of the triggers occurs. The arguments are:
@@ -174,7 +176,7 @@ Creates a callback that will be executed when any of the triggers occurs. The ar
An example of how this may be used can be seen in the [`bluetooth.events()`](./#bluetooth-events) method.
#### bluetooth.events\(\)
#### bluetooth.events()
Returns a value with bit flags identifying the events that have occurred since the last call. Calling this function clears the events.
@@ -198,14 +200,14 @@ bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONN
bluetooth.advertise(True)
```
#### bluetooth.set\_advertisement\(\* , name=None, manufacturer\_data=None, service\_data=None, service\_uuid=None\)
#### bluetooth.set\_advertisement(\* , name=None, manufacturer\_data=None, service\_data=None, service\_uuid=None)
Configure the data to be sent while advertising. If left with the default of `None` the data wont be part of the advertisement message.
Configure the data to be sent while advertising. If left with the default of `None` the data won't be part of the advertisement message.
The arguments are:
* `name` is the string name to be shown on advertisements.
* `manufacturer_data` manufacturer data to be advertised \(hint: use it for iBeacons\).
* `manufacturer_data` manufacturer data to be advertised (hint: use it for iBeacons).
* `service_data` service data to be advertised.
* `service_uuid` uuid of the service to be advertised.
@@ -215,11 +217,11 @@ Example:
bluetooth.set_advertisement(name="advert", manufacturer_data="lopy_v1")
```
#### bluetooth.advertise\(\[Enable\]\)
#### bluetooth.advertise(\[Enable\])
Start or stop sending advertisements. The `set_advertisement()` method must have been called prior to this one.
#### bluetooth.service\(uuid, \* , isprimary=True, nbr\_chars=1, start=True\)
#### bluetooth.service(uuid, \* , isprimary=True, nbr\_chars=1, start=True)
Create a new service on the internal GATT server. Returns a object of type `BluetoothServerService`.
@@ -234,7 +236,7 @@ The arguments are:
bluetooth.service('abc123')
```
#### bluetooth.disconnect\_client\(\)
#### bluetooth.disconnect\_client()
Closes the BLE connection with the client.
@@ -244,7 +246,7 @@ Closes the BLE connection with the client.
* Advertisement type: `Bluetooth.CONN_ADV`, `Bluetooth.CONN_DIR_ADV`, `Bluetooth.DISC_ADV`, `Bluetooth.NON_CONN_ADV`, `Bluetooth.SCAN_RSP`
* Address type: `Bluetooth.PUBLIC_ADDR`, `Bluetooth.RANDOM_ADDR`, `Bluetooth.PUBLIC_RPA_ADDR`, `Bluetooth.RANDOM_RPA_ADDR`
* Advertisement data type: `Bluetooth.ADV_FLAG`, `Bluetooth.ADV_16SRV_PART`, `Bluetooth.ADV_T16SRV_CMPL`, `Bluetooth.ADV_32SRV_PART`, `Bluetooth.ADV_32SRV_CMPL`, `Bluetooth.ADV_128SRV_PART`, `Bluetooth.ADV_128SRV_CMPL`, `Bluetooth.ADV_NAME_SHORT`, `Bluetooth.ADV_NAME_CMPL`, `Bluetooth.ADV_TX_PWR`, `Bluetooth.ADV_DEV_CLASS`, `Bluetooth.ADV_SERVICE_DATA`, `Bluetooth.ADV_APPEARANCE`, `Bluetooth.ADV_ADV_INT`, `Bluetooth.ADV_32SERVICE_DATA`, `Bluetooth.ADV_128SERVICE_DATA`, `Bluetooth.ADV_MANUFACTURER_DATA`
* Characteristic properties \(bit values that can be combined\): `Bluetooth.PROP_BROADCAST`, `Bluetooth.PROP_READ`, `Bluetooth.PROP_WRITE_NR`, `Bluetooth.PROP_WRITE`, `Bluetooth.PROP_NOTIFY`, `Bluetooth.PROP_INDICATE`, `Bluetooth.PROP_AUTH`, `Bluetooth.PROP_EXT_PROP`
* Characteristic properties (bit values that can be combined): `Bluetooth.PROP_BROADCAST`, `Bluetooth.PROP_READ`, `Bluetooth.PROP_WRITE_NR`, `Bluetooth.PROP_WRITE`, `Bluetooth.PROP_NOTIFY`, `Bluetooth.PROP_INDICATE`, `Bluetooth.PROP_AUTH`, `Bluetooth.PROP_EXT_PROP`
* Characteristic callback events: `Bluetooth.CHAR_READ_EVENT`, `Bluetooth.CHAR_WRITE_EVENT`, `Bluetooth.NEW_ADV_EVENT`, `Bluetooth.CLIENT_CONNECTED`, `Bluetooth.CLIENT_DISCONNECTED`, `Bluetooth.CHAR_NOTIFY_EVENT`
* Antenna type: `Bluetooth.INT_ANT`, `Bluetooth.EXT_ANT`

View File

@@ -0,0 +1,13 @@
---
title: "GATT"
aliases:
- firmwareapi/pycom/network/bluetooth/gatt.html
- firmwareapi/pycom/network/bluetooth/gatt.md
- chapter/firmwareapi/pycom/network/bluetooth/gatt
---
GATT stands for the Generic Attribute Profile and it defines the way that two Bluetooth Low Energy devices communicate between each other using concepts called Services and Characteristics. GATT uses a data protocol known as the Attribute Protocol (ATT), which is used to store/manage Services, Characteristics and related data in a lookup table.
GATT comes into use once a connection is established between two devices, meaning that the device will have already gone through the advertising process managed by GAP. It's important to remember that this connection is exclusive; i.e. that only one client is connected to one server at a time. This means that the client will stop advertising once a connection has been made. This remains the case, until the connection is broken or disconnected.
The GATT Server, which holds the ATT lookup data and service and characteristic definitions, and the GATT Client (the phone/tablet), which sends requests to this server.

View File

@@ -1,32 +1,36 @@
# GATTCCharacteristic
The smallest concept in GATT is the Characteristic, which encapsulates a single data point \(though it may contain an array of related data, such as X/Y/Z values from a 3-axis accelerometer, longitude and latitude from a GPS, etc.\).
---
title: "GATTCCharacteristic"
aliases:
- firmwareapi/pycom/network/bluetooth/gattccharacteristic.html
- firmwareapi/pycom/network/bluetooth/gattccharacteristic.md
---
The smallest concept in GATT is the Characteristic, which encapsulates a single data point (though it may contain an array of related data, such as X/Y/Z values from a 3-axis accelerometer, longitude and latitude from a GPS, etc.).
The following class allows you to manage characteristics from a Client.
## Methods
#### characteristic.uuid\(\)
#### characteristic.uuid()
Returns the UUID of the service. In the case of 16-bit or 32-bit long UUIDs, the value returned is an integer, but for 128-bit long UUIDs the value returned is a bytes object.
#### characteristic.instance\(\)
#### characteristic.instance()
Returns the instance ID of the service.
#### characteristic.properties\(\)
#### characteristic.properties()
Returns an integer indicating the properties of the characteristic. Properties are represented by bit values that can be OR-ed together. See the constants section for more details.
#### characteristic.read\(\)
#### characteristic.read()
Read the value of the characteristic, sending a request to the GATT server. Returns a bytes object representing the characteristic value.
#### characteristic.value\(\)
#### characteristic.value()
Returns the locally stored value of the characteristic without sending a read request to the GATT server. If the characteristic value hasn't been read from the GATT server yet, the value returned will be 0.
#### characteristic.write\(value\)
#### characteristic.write(value)
Writes the given value on the characteristic. For now it only accepts bytes object representing the value to be written.
@@ -34,7 +38,7 @@ Writes the given value on the characteristic. For now it only accepts bytes obje
characteristic.write(b'x0f')
```
#### characteristic.callback\(trigger=None, handler=None, arg=None\)
#### characteristic.callback(trigger=None, handler=None, arg=None)
This method allows to register for notifications on the characteristic.
@@ -42,7 +46,7 @@ This method allows to register for notifications on the characteristic.
* `handler` is the function that will be executed when the callback is triggered.
* `arg` is the argument that gets passed to the callback. If nothing is given, the characteristic object that owns the callback will be used.
#### characteristic.read\_descriptor\(uuid\)
#### characteristic.read\_descriptor(uuid)
Returns the value of the descriptor specified by the `uuid` parameter. If no descriptor found for the characteristic returns None.

View File

@@ -1,14 +1,18 @@
# GATTCConnection
The GATT Client is the device that requests data from the server, otherwise known as the master device \(commonly this might be a phone/tablet/PC\). All transactions are initiated by the master, which receives a response from the slave.
---
title: "GATTCConnection"
aliases:
- firmwareapi/pycom/network/bluetooth/gattcconnection.html
- firmwareapi/pycom/network/bluetooth/gattcconnection.md
---
The GATT Client is the device that requests data from the server, otherwise known as the master device (commonly this might be a phone/tablet/PC). All transactions are initiated by the master, which receives a response from the slave.
## Methods
#### connection.disconnect\(\)
#### connection.disconnect()
Closes the BLE connection. Returns `None`.
#### connection.isconnected\(\)
#### connection.isconnected()
Returns `True` if the connection is still open. `False` otherwise.
@@ -35,9 +39,9 @@ while True:
print("Connected to device with addr = {}".format(ubinascii.hexlify(adv.mac)))
```
#### connection.services\(\)
#### connection.services()
Performs a service search on the connected BLE peripheral \(server\) a returns a list containing objects of the class GATTCService if the search succeeds.
Performs a service search on the connected BLE peripheral (server) a returns a list containing objects of the class GATTCService if the search succeeds.
Example:

View File

@@ -1,24 +1,28 @@
# GATTCService
---
title: "GATTCService"
aliases:
- firmwareapi/pycom/network/bluetooth/gattccservice.html
- firmwareapi/pycom/network/bluetooth/gattccservice.md
---
Services are used to categorise data up into specific chunks of data known as characteristics. A service may have multiple characteristics, and each service has a unique numeric ID called a UUID.
The following class allows control over Client services.
## Methods
#### service.isprimary\(\)
#### service.isprimary()
Returns `True` if the service is a primary one. `False` otherwise.
#### service.uuid\(\)
#### service.uuid()
Returns the UUID of the service. In the case of 16-bit or 32-bit long UUIDs, the value returned is an integer, but for 128-bit long UUIDs the value returned is a bytes object.
#### service.instance\(\)
#### service.instance()
Returns the instance ID of the service.
#### service.characteristics\(\)
#### service.characteristics()
Performs a get characteristics request on the connected BLE peripheral a returns a list containing objects of the class GATTCCharacteristic if the request succeeds.

Some files were not shown because too many files have changed in this diff Show More