A open-source Python client library for devices under the Borneo-IoT Project
Project description
borneo.py
A open-source Python client library for devices under the Borneo-IoT Project.
Features
- Basic device control (power on/off, reboot, factory reset, etc.)
- Device information queries
- Timezone settings
- Firmware upgrade checking
- CoAP OTA firmware updates
Installation
pip install -r requirements.txt
Usage Examples
Basic Device Control
import asyncio
from borneo.lyfi import LyfiCoapClient
async def main():
async with LyfiCoapClient("coap://192.168.1.100") as device:
# Get device information
info = await device.get_info()
print(f"Device info: {info}")
# Control device power
await device.set_on_off(True)
status = await device.get_on_off()
print(f"Device status: {status}")
if __name__ == "__main__":
asyncio.run(main())
CoAP OTA Firmware Update
import asyncio
from borneo.lyfi import LyfiCoapClient
async def update_firmware():
device_url = "coap://192.168.1.100"
firmware_path = "firmware.bin"
def progress_callback(current, total):
percent = int((current / total) * 100)
print(f"Upload progress: {percent}%")
def status_callback(message):
print(f"Status: {message}")
async with LyfiCoapClient(device_url) as device:
# Check OTA status
status = await device.check_ota_status()
if status['success']:
print(f"Current partition: {status['current_partition']}")
# Execute OTA update
result = await device.perform_ota_update(
firmware_path,
progress_callback=progress_callback,
status_callback=status_callback
)
if result['success']:
print("Firmware update successful!")
else:
print(f"Update failed: {result['error']}")
if __name__ == "__main__":
asyncio.run(update_firmware())
Command Line Tools
OTA Update Tool
# Execute OTA firmware update
python examples/ota_update.py coap://192.168.1.100 firmware.bin
# Check device OTA status only
python examples/ota_update.py coap://192.168.1.100
API Documentation
CoAP OTA Methods
check_ota_status()
Check device OTA status.
Returns:
{
'success': bool,
'current_partition': str, # Current running partition
'update_status': str, # Update status
'bytes_received': int # Bytes received
}
upload_firmware(firmware_path, progress_callback=None)
Upload firmware file to device.
Parameters:
firmware_path: Path to firmware fileprogress_callback: Optional progress callback functioncallback(current, total)
Returns:
{
'success': bool,
'message': str,
'next_boot': str, # Next boot partition
'checksum': str, # File checksum
'size': int # File size
}
perform_ota_update(firmware_path, progress_callback=None, status_callback=None)
Execute complete OTA update process.
Parameters:
firmware_path: Path to firmware fileprogress_callback: Optional progress callback functioncallback(current, total)status_callback: Optional status callback functioncallback(message)
Returns:
{
'success': bool,
'message': str,
'details': dict # Detailed result information
}
Dependencies
aiocoap>=0.4.12- CoAP protocol supportcbor2>=5.6.5- CBOR data format supportaiofiles- Async file operations
Packaging & development
This project uses a modern PEP 621 pyproject.toml (setuptools backend). Below are common development and packaging commands.
-
Build distributions:
python -m build(uses build backend frompyproject.toml)uv build(if you use Astral'suvtool)
-
Create and activate a local virtual environment (Windows):
python -m venv .venv.venv/Scripts/activate
-
Install dependencies for development:
pip install -e .- or
uv pip sync/uv venvwhen usinguv
-
Run an example:
python examples/hello_lyfi.py
-
Publish to PyPI:
uv publish- or
python -m twine upload dist/*
Notes:
- License:
GPL-3.0-or-later— please add or verify aLICENSEfile in the repository. - The project was migrated from
setup.pytopyproject.toml; builds produce bothsdistandwheelartifacts.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file borneoiot-0.4.13.tar.gz.
File metadata
- Download URL: borneoiot-0.4.13.tar.gz
- Upload date:
- Size: 22.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
111f133fa1c451be44fcb5203028263c4a5553dd2dfa9ad2a6cc12e97a64c908
|
|
| MD5 |
3176ea4d1a06ccd2adad1857c245aa73
|
|
| BLAKE2b-256 |
4528f8464482ef3d60a52130fb1ff0e7303551b57a6cbe322a65975c0eb7832e
|
File details
Details for the file borneoiot-0.4.13-py3-none-any.whl.
File metadata
- Download URL: borneoiot-0.4.13-py3-none-any.whl
- Upload date:
- Size: 22.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
75a87cfd421c1ffe9df2376e695dc6f866ef360cfc1a98f657c67c43351091db
|
|
| MD5 |
cdbd46e429ec6258d0f18f7cba672704
|
|
| BLAKE2b-256 |
f58f886cb34b77a60ed38d932efb2d63e8767cc6036168c1dd6085755885df21
|