This section provides detailed documentation for all public classes and functions in unetpy.
Note: This documentation is auto-generated from source code docstrings. To regenerate, run:
python docs/generate_api_docs.py
The main high-level interface for communicating with UnetStack nodes. Provides a socket-like API for sending and receiving datagrams.
from unetpy import UnetSocket
with UnetSocket("localhost", 1100) as sock:
sock.bind(Protocol.USER)
sock.send([1, 2, 3], to=31, protocol=Protocol.USER)Protocol number assignments for different types of communication.
from unetpy import Protocol
Protocol.DATA # User application data (0)
Protocol.USER # User protocols start here (32)
Protocol.MAX # Maximum protocol number (63)Service identifiers for looking up agents.
from unetpy import Services
Services.PHYSICAL # Physical layer service
Services.DATAGRAM # Datagram service
Services.NODE_INFO # Node information serviceAddress constants.
from unetpy import Address
Address.BROADCAST # Broadcast address (0)All UnetStack message classes can be imported directly.
from unetpy import DatagramReq, DatagramNtf
req = DatagramReq()
req.to = 31
req.data = [1, 2, 3]DatagramReq- Request to send a datagramDatagramNtf- Notification of received datagramRxFrameNtf- Physical layer frame receivedTxFrameReq- Request to transmit a frame
Convert local coordinates to GPS coordinates.
from unetpy import to_gps
lat, lon = to_gps(origin=(1.34, 103.84), x=100, y=100)Convert GPS coordinates to local coordinates.
from unetpy import to_local
x, y = to_local(origin=(1.34, 103.84), lat=1.35, lon=103.85)The following classes are re-exported from fjagepy for convenience:
Gateway- Low-level connection to fjåge containerAgentID- Reference to an agentMessage- Base message classMessageClass- Factory for creating message typesPerformative- Message performatives (AGREE, REFUSE, etc.)ParameterReq- Request for a parameter valueParameterRsp- Response with a parameter valuePutFileReq- Request to upload a fileGetFileReq- Request to download a fileShellExecReq- Request to execute a shell commandGetFileRsp- Response with file contents