Library for the iM282A radio transceiver module
Project description
iM282A WiMOD LR BASE+ HCI Python library
This library allows communicating with iM282A Radio (LoRa/FLRC/FSK) modules using vendor specific HCI messages and the WiMOD LR BASE+ proprietary firmware.
SensorApp endpoint is not supported (an in-firmware embedded sensor example application)! Feel free to open a PR if it's needed.
Most length limitations are not enforced or validated - make sure to read the corresponding vendor documentation of the firmware and module.
Install
python -m pip install im282a
Usage Example
from im282a import *
from threading import Thread
def receiver(radio: IM282A):
while True:
radio.handle()
with IM282A.from_serial("/dev/ttyUSB0", timeout=1) as radio1, IM282A.from_serial("/dev/ttyUSB1", timeout=1) as radio2:
t1 = Thread(target=receiver, args=(radio1,))
t2 = Thread(target=receiver, args=(radio2,))
t1.start()
t2.start()
radio1.send(SetRadioConfigReq(SetRadioModeReq.RadioControlNvmFlag_Ram))
radio2.send(SetRadioConfigReq(SetRadioModeReq.RadioControlNvmFlag_Ram))
radio1.send(SendConfirmedDataReq(0x10, 0x1234, b"Test message!"))
t1.join()
t2.join()
HciMessage:
Endpoint ID: 3 (radio_link)
Message ID: 10 (SendConfirmedDataRsp)
SendConfirmedDataRsp:
Status: 0 (ok)
HciMessage:
Endpoint ID: 3 (radio_link)
Message ID: 14 (ConfirmedDataTXInd)
ConfirmedDataTXInd:
Status: 0 (ok)
TXEventCounter: 21
RFMessageAirtime: 497 ms
HciMessage:
Endpoint ID: 3 (radio_link)
Message ID: 12 (ConfirmedDataRXInd)
ConfirmedDataRXInd:
Status:
Extended: True
Decrypted: False
DecryptionError: False
Encrypted: False
DstGroupAddress: 0x10
DstDeviceAddress: 0x1234
SrcGroupAddress: 0x10
SrcDeviceAddress: 0x1234
Payload: 54657374206d65737361676521 (Test message!)
Rssi: -64 dBm
Snr: 7 dB
RXTime: 2021-09-03 12:54:08
HciMessage:
Endpoint ID: 3 (radio_link)
Message ID: 20 (AckTXInd)
AckTXInd:
Status: 0 (ok)
TXEventCounter: 3
RFMessageAirtime: 346 ms
HciMessage:
Endpoint ID: 3 (radio_link)
Message ID: 16 (AckRXInd)
AckRXInd:
Status:
Extended: True
Decrypted: False
DecryptionError: False
Encrypted: False
DstGroupAddress: 0x10
DstDeviceAddress: 0x1234
SrcGroupAddress: 0x10
SrcDeviceAddress: 0x1234
Payload: ()
Rssi: -60 dBm
Snr: 7 dB
RXTime: 2021-09-03 03:54:09
How to use (rough overview)
IM282A(<serial_device>, [baud_rate], [timeout_s])will open a serial device using the SLIP protocol. Timeout will affect reading withinstance.handle()instance.send(<message>)is used to send messages derived from theHciMessageclass.instance.register_handler(<endpoint_id>, <message_id>, <function>)registers a callback function for a specific endpoint/message combination. Multiple functions can be registered per endpoint/message and are called duringinstance.receive()sequentially. The function receives adata: bytesargument which has the endpoint and message IDs already stripped and can be consumed by message classes likeping_response = PingRsp.from_bytes(data).instance.default_handlerwill handle all messages that are not handled by a callback function (default handler prints the hex bytes on stdout). The function receives two arguments:head: bytes, data: bytes.headcontains the endpoint and message IDs to be consumed byHciMessageand data the rest for the resulting message class. See the example above.
Contribution
Any help is appreciated, especially on documentation, tests or the API itself. Feel free to open issues or PRs.
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
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 im282a-3.0.1.tar.gz.
File metadata
- Download URL: im282a-3.0.1.tar.gz
- Upload date:
- Size: 15.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
77bcd99e34fa36d01b8ec3814a6f89b6a747d80cb3e8a745007573d8ca6280ed
|
|
| MD5 |
0e2509113cec157c4c30e0e7eef54a72
|
|
| BLAKE2b-256 |
5f830d2f0489ca2e44e6db35ffc3411a5b96ca18878940e5b1276ad15f9c35ac
|
File details
Details for the file im282a-3.0.1-py3-none-any.whl.
File metadata
- Download URL: im282a-3.0.1-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.8.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e24edf838bc8790f2d0c56390fd562be285b333d55aaed563ad160a03b15e6f
|
|
| MD5 |
1b4bfb3a285ca9762af5ca89aa67abf0
|
|
| BLAKE2b-256 |
7ac1bb25b3b26fd7c4b9707afbb20255c1ac71e5fc24b665a74ca19290162a72
|