Skip to main content

No project description provided

Project description

ipee-lemon

Python library for controlling IPEE Lemon devices over Bluetooth Low Energy (BLE) and serial (CLI).

Installation

Requires Python >= 3.12.

pip install ipee-lemon

Or with Poetry:

poetry add ipee-lemon

BLE

Connect to a Lemon device over BLE using the async API built on Bleak.

import asyncio
from ipee.lemon.ble.lemon_ble import LemonBleDevice

async def main():
    device = LemonBleDevice("AA:BB:CC:DD:EE:FF")
    await device.connect()

    # Send data via Nordic UART Service (NUS)
    await device.write("6E400002-B5A3-F393-E0A9-E50E24DCCA9E", b"hello")

    # Provision Wi-Fi credentials
    from ipee.lemon.ble.wifi_provision_service import WifiProvisioningService
    await device.write(WifiProvisioningService.SSID_UUID, b"MyNetwork")
    await device.write(WifiProvisioningService.PASSWORD_UUID, b"secret")

    # Trigger an OTA firmware update (requires Wi-Fi connection)
    from ipee.lemon.ble.ota_service import OtaService
    await device.write(OtaService.OTA_URL_UUID, b"https://example.com/firmware.bin")

    await device.disconnect()

asyncio.run(main())

LemonBleDevice comes with three services pre-registered:

Service Purpose
NUS (Nordic UART) Text-based communication with the device
Wi-Fi Provisioning Set SSID and password for network connection
OTA Trigger over-the-air firmware updates

Serial (CLI)

Control a Lemon device over a serial connection using command wrappers built on pySerial.

from serial import Serial
from ipee.lemon.cli.cli_wifi_service import CliWifiService
from ipee.lemon.cli.cli_ble_service import CliBleService
from ipee.lemon.cli.cli_sweep_service import CliSweepService, SweepMeasurementType

ser = Serial("/dev/ttyUSB0", baudrate=115200)

# Wi-Fi
wifi = CliWifiService()
wifi.set_ssid(ser, "MyNetwork")
wifi.set_password(ser, "secret")
wifi.connect(ser)
info = wifi.get_connection_info(ser)
print(info.ip, info.subnet, info.gateway)

# BLE
ble = CliBleService()
ble.enable(ser)
ble.send(ser, "hello from serial")

# Voltage sweep
sweep = CliSweepService()
sweep.start_voltage(ser, 0)
sweep.end_voltage(ser, 3_300_000)
sweep.set_step_size(ser, 1000)
sweep.set_step_duration(ser, 500)
sweep.set_measurement_type(ser, SweepMeasurementType.AMPLITUDE)

ser.close()

Available CLI services:

Service Tag Purpose
CliBleService ble Enable/disable BLE, send NUS data
CliWifiService wifi Configure and connect to Wi-Fi
CliOtaService ota_start Start OTA firmware update from a URL
CliLemonService lemon Set settle time and measurement frequency
CliSweepService sweep Configure and run voltage sweeps

Development

poetry install
make lint       # runs black, isort, flake8

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

ipee_lemon-0.5.0.tar.gz (11.7 kB view details)

Uploaded Source

Built Distribution

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

ipee_lemon-0.5.0-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file ipee_lemon-0.5.0.tar.gz.

File metadata

  • Download URL: ipee_lemon-0.5.0.tar.gz
  • Upload date:
  • Size: 11.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.18.35

File hashes

Hashes for ipee_lemon-0.5.0.tar.gz
Algorithm Hash digest
SHA256 d958f356446637019f69b7a5bb8eb306335dae8ca3582ea60c2c9b5e284f6801
MD5 ea268a74d773961960006dfd6df4ada6
BLAKE2b-256 b376c2f03465d9a6d21666aea358fe77260cd5cdf91214dd1a7c1017b1449575

See more details on using hashes here.

File details

Details for the file ipee_lemon-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ipee_lemon-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.4.1 CPython/3.12.3 Linux/6.18.35

File hashes

Hashes for ipee_lemon-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 110436d05c3b290d0c1460c0e3060560ce9f24f37f9a128afecb9a9605f16758
MD5 0300d5990c3f151b8a2f6c8bc2334fa5
BLAKE2b-256 70357de23a8e63ca2df52c540e0a2a31a2a2480b301936ad46bc4161f388e0ca

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