Skip to main content

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 file
  • progress_callback: Optional progress callback function callback(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 file
  • progress_callback: Optional progress callback function callback(current, total)
  • status_callback: Optional status callback function callback(message)

Returns:

{
    'success': bool,
    'message': str,
    'details': dict                # Detailed result information
}

Dependencies

  • aiocoap>=0.4.12 - CoAP protocol support
  • cbor2>=5.6.5 - CBOR data format support
  • aiofiles - 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 from pyproject.toml)
    • uv build (if you use Astral's uv tool)
  • 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 venv when using uv
  • 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 a LICENSE file in the repository.
  • The project was migrated from setup.py to pyproject.toml; builds produce both sdist and wheel artifacts.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

borneoiot-0.4.12.tar.gz (22.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

borneoiot-0.4.12-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file borneoiot-0.4.12.tar.gz.

File metadata

  • Download URL: borneoiot-0.4.12.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.4

File hashes

Hashes for borneoiot-0.4.12.tar.gz
Algorithm Hash digest
SHA256 b04834d97c42e524ac90c681f151da6a794988f14ccea597d5a4542df6c02c0c
MD5 1df28c0c8d48931b531c6d107b38e7a3
BLAKE2b-256 a838120d1de4dc98ced08923b55f836e236585308e20c71a93aeb50bfec85c80

See more details on using hashes here.

File details

Details for the file borneoiot-0.4.12-py3-none-any.whl.

File metadata

  • Download URL: borneoiot-0.4.12-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

Hashes for borneoiot-0.4.12-py3-none-any.whl
Algorithm Hash digest
SHA256 b8a193d3417a05d442ba0b63fe8be45f20fe1bdf3731e5e98a5f985cf79d98cd
MD5 6a31c69b6f613129065db89c2518893c
BLAKE2b-256 89d4c2825463973090c9e3213211d8d3c76b95366f1e7db567410f2bdad00d40

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page