The Pybytes library is positioned in the frozen section of the firmware.
It can be imported like regular modules:
from _pybytes import Pybytes from _pybytes_config import PybytesConfig conf = PybytesConfig().read_config() pybytes = Pybytes(conf) pybytes.start()
Or on boot
import pycom import machine pycom.pybytes_on_boot(True) machine.reset()
Provision the device to Pybytes. Use the
activationstring provided in Pybytes to activate the device.
Load the Pybytes configuration file. By default, this is found in
value of the default configuration file. additional options:
permanent: will call
pybytes.write_config(). If set
False, the new value will not be stored in the configuration file and only used this session.
Trueto not print to REPL.
Writes the updated configuration to the default configuration file. The parameters:
file: The file name and location
Trueto not print to REPL.
Print the configuration settings to the REPL.
Connect the device to Pybytes following the loaded configuration file. You will need to load a configuration file before calling this. If you are using the WiFi or LTE connection, and it is already available, Pybytes will use the existing connection.
pybytes.connect(), with the option to set
False will not start the connection immediately.
Enable the LTE connection to pybytes. Enter the paramters you would normally enter for a LTE connection.
Connect to Pybytes using LTE and the settings from the configuration file.
Connect to Pybytes using WiFi and the settings from the configuration file.
Connect to Pybytes using SigFox and the settings from the configuration file.
Connect to Pybytes using LoRa OTAA and the settings from the configuration file.
Connect to Pybytes using LoRa ABP and the settings from the configuration file.
Disconnect from Pybytes gracefully. Closes the MQTT connection and socket.
pybytes.disconnect() followed by
Returns the connection status to Pybytes, can be
Enable SSL on the Pybytes connection
Note that SSL might not be supported by your LTE connection
Write SSL certificate to file.
Send a signal to Pybytes. Arguments are:
signal_number: The signal number in Pybytes, can be any value between 0-254 (255 is reserved)
value: The value you want to send, this can be any type.
This will also work in Pymesh.
Sends a ping (is-alive) message to Pybytes.
Send an info message to Pybytes containing the device type and firmware version.
Sends the battery level to Pybytes. The argument
battery_level can be any integer.
See machine.deepsleep() for more details. Additionally, this method disconnects from Pybytes gracefully. The optional arguments operate machine.pin_sleep_wakeup()
Allows for the usage of
pycom.smart_config() for more information here
Enable debugging if you are having any issues. There are multiple debug levels, the lowest is 0 which is for warnings only and 99 is the highest used and will print more debugging messages
>> import pycom; >> pycom.nvs_set('pybytes_debug', debugLevel)
>> import pycom; >> pycom.nvs_set('pybytes_debug', 99)