diff --git a/config.toml b/config.toml index c5afaf5..097c9b3 100644 --- a/config.toml +++ b/config.toml @@ -627,6 +627,13 @@ theme = "doc-theme" identifier = "firmwareapi@pycom@network@bluetooth@gattscharacteristic" parent = "firmwareapi@pycom@network@bluetooth" weight = 60 +[[menu.main]] + name = "Pymesh BLE" + url = "/firmwareapi/pycom/network/bluetooth/BLE_Mesh/" + identifier = "firmwareapi@pycom@network@bluetooth@BLE_Mesh" + parent = "firmwareapi@pycom@network@bluetooth" + weight = 70 + # [Errno 2] No such file or directory: './content/firmwareapi/pycom/network/lora/README.md' [[menu.main]] diff --git a/content/firmwareapi/pycom/aes.md b/content/firmwareapi/pycom/aes.md index 543a18d..c430b9d 100644 --- a/content/firmwareapi/pycom/aes.md +++ b/content/firmwareapi/pycom/aes.md @@ -8,9 +8,8 @@ aliases: 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" %}} -AES is implemented using the ESP32 hardware module. -{{% /hint %}} +>AES is implemented using the ESP32 hardware module. + ## Quick Usage Example @@ -32,36 +31,40 @@ print(original) ## Constructors -#### class ucrypto.AES(key, mode, IV, \* , counter, segment\_size) +### class ucrypto.AES(key, mode=AES.MODE_ECB, 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. -* `mode` is the chaining mode to use for encryption and decryption. Default is `AES.MODE_ECB`. +* `mode` is the chaining mode to use for encryption and decryption. Can be the following values: + * `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. * `IV` (byte string) initialisation vector. Should be 16 bytes long. It is ignored in modes `AES.MODE_ECB` and `AES.MODE_CRT`. +> 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. * `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` +* `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` + * `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_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` +* `AES.MODE_ECB`, `AES.MODE_CBC`, `AES.MODE_CFB`, `AES.MODE_CTR` +* `AES.SEGMENT_8`, `AES.SEGMENT_128` + -{{% 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. -{{% /hint %}} diff --git a/content/firmwareapi/pycom/pycom.md b/content/firmwareapi/pycom/pycom.md index 667052b..25ccb09 100644 --- a/content/firmwareapi/pycom/pycom.md +++ b/content/firmwareapi/pycom/pycom.md @@ -19,117 +19,39 @@ pycom.heartbeat() # get the heartbeat state pycom.rgbled(0xff00) # make the LED light up in green color ``` -## Methods +## Miscelaneous Methods -#### pycom.heartbeat\(\[boolean\]\) +### pycom.heartbeat([boolean]) -Get or set the state (enabled or disabled) of the heartbeat LED. Accepts and returns boolean values (`True` or `False`). +Get or set the state (enabled or disabled) of the heartbeat LED. Accepts and returns boolean values. -#### pycom.heartbeat\_on\_boot\(\[boolean\]\) +### pycom.heartbeat_on_boot([boolean]) Allows you permanently disable or enable the heartbeat LED. Once this setting is set, it will persist between reboots. Note, this only comes into effect on the next boot, it does not stop the already running heartbeat. -#### pycom.rgbled(color) +### pycom.rgbled(color) -Set the colour of the RGB LED. The colour is specified as 24 bit value representing red, green and blue, where the red colour is represented by the 8 most significant bits. For instance, passing the value `0x00FF00` will light up the LED in a very bright green. +Set the colour of the RGB LED. The colour is specified as 24 bit value representing red, green and blue, in the following order `0xRRGGBB`. For instance, passing the value `0x00FF00` will light up the LED in a very bright green. -#### pycom.nvs\_set(key, value) +### pycom.nvs_set(key, value) Set the value of the specified key in the NVRAM memory area of the external flash. Data stored here is preserved across resets and power cycles. Value can only take 32-bit integers at the moment. Example: -```python -import pycom - -pycom.nvs_set('temp', 25) -pycom.nvs_set('count', 10) -``` - -#### pycom.nvs\_get(key) +### pycom.nvs_get(key) Get the value the specified key from the NVRAM memory area of the external flash. Example: -```python -import pycom - -pulses = pycom.nvs_get('count') -``` - If a non-existing key is given the returned value will be `None`. -#### pycom.nvs\_erase(key) +### pycom.nvs_erase(key) Erase the given key from the NVRAM memory area. -#### pycom.nvs\_erase\_all() +### pycom.nvs_erase_all() Erase the entire NVRAM memory area. -#### pycom.wifi\_on\_boot\(\[boolean\]\) - -Get or set the WiFi on boot flag. When this flag is set to `True`, The Wifi will be enabled according to the other wifi settings eg (ssid\_sta, pwd\_sta, ssid\_ap, pwd\_ap). when `False` the Wifi module will be disabled untill enabled directly via WLAN class. - -This setting is stored in non-volatile memory which preserves it across resets and power cycles. Example: - -```python -import pycom - -pycom.wifi_on_boot(True) # enable WiFi on boot -pycom.wifi_on_boot() # get the wifi on boot flag -``` - -#### pycom.wifi\_ssid\_sta\([ssid]\) - -Get or set the ssid of the Access point the device should connect to on startup. -This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.wifi\_ssid\_ap\([ssid]\) - -Get or set the ssid of the Access point that should be started by the device at startup, if not set and startup Wifi mode is AP the default AP name \(\-wlan-\\) will be used.This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.wifi\_pwd\_sta\([key]\) - -Get or set the Password of the Access point the device should connect to on startup, leave the password unset if the AP is open.This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.wifi\_pwd\_ap\([key]\) - -Get or set the Password of the Access point that should be started by the device at startup, leave unset if the AP should be open.This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.smart\_config\_on\_boot\([boolean]\) - -Read or (Enable/Disable) SmartConfig functionality on startup, this flag will be reset after successful completion of the smartConfig process after startup.This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.smart\_config\_on\_boot\([boolean]\) - -Read or (Enable/Disable) SmartConfig functionality on startup, this flag will be reset after successful completion of the smartConfig process after startup.This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.wifi\_mode\_on\_boot\(\[boolean\]\) - -Set or get the Wifi Mode at startup , `WLAN.STA`, `WLAN.AP` or `WLAN.APSTA`.This setting is stored in non-volatile memory which preserves it across resets and power cycles - -#### pycom.wdt\_on\_boot\_timeout(\[timeout\]) - -Sets or gets the WDT on boot timeout in milliseconds. The minimum value is 5000 ms. - -```python -import pycom - -pycom.wdt_on_boot_timeout(10000) # set the timeout to 5000ms -pycom.wdt_on_boot_timeout() # get the WDT timeout value -``` - -#### pycom.wdt\_on\_boot\(\[enable\]\) - -Enables the WDT at boot time with the timeout in ms set by the function `wdt_on_boot_timeout`. If this flag is set, the application needs to reconfigure the WDT with a new timeout and feed it regularly to avoid a reset - - -```python -import pycom - -pycom.wdt_on_boot(True) # enable WDT on boot -pycom.wdt_on_boot() # get the WDT on boot flag -``` - -#### pycom.pulses\_get\(pin, timeout\) +### pycom.pulses_get(pin, timeout) Return a list of pulses at `pin`. The methods scans for transitions at `pin` and returns a list of tuples, each telling the pin value and the duration in microseconds of that value. `pin` is a pin object, which must have set to `INP` or `OPEN_DRAIN` mode. The scan stops if not transitions occurs within `timeout` milliseconds. @@ -148,11 +70,68 @@ pin(1) data = pulses_get(pin, 100) ``` -#### pycom.ota\_start() +## Boot methods -#### pycom.ota\_write(buffer) +### pycom.wifi_on_boot([boolean]) -#### pycom.ota\_finish() +Get or set the WiFi on boot flag. When this flag is set to `True`, The WiFi will be enabled according to the other WiFi settings. when `False` the WiFi module will be disabled untill enabled directly via WLAN class. + +This setting is stored in non-volatile memory which preserves it across resets and power cycles. Example: + +### pycom.wifi_ssid_sta([ssid]) + +Get or set the ssid of the Access point the device should connect to on startup. +This setting is stored in non-volatile memory which preserves it across resets and power cycles + +### pycom.wifi_ssid_ap([ssid]) + +Get or set the ssid of the Access point that should be started by the device at startup, if not set and startup Wifi mode is AP the default AP name (`Board_Name>-wlan-