Okiff SDK
Project description
okiff-sdk
Python SDK for connecting to and communicating over MQTT brokers. Built as a compiled native extension for performance and ease of deployment.
Requirements
- Python 3.9 or later
- Linux x86-64 (glibc ≥ 2.39), with additional platforms coming
Installation
pip install okiff-sdk
No compilation required. The package ships as a pre-built binary wheel.
Quick Start
"""
Example:
Basic publish/subscribe usage of the okiff-sdk.
"""
# Imports
import time
from okiff_sdk import SDK
# Client setup
sdk = SDK()
# Callbacks
def on_connection(connected: bool, rc: int) -> None:
"""
Handle connection state changes.
Args:
connected: True if connected, False if disconnected.
rc: Paho return code. 0 = clean, -1 = unexpected loss.
"""
print(f"[on_connection] connected={connected}, rc={rc}")
def on_message(topic: str, payload: str) -> None:
"""
Handle incoming messages.
Args:
topic: Topic on which the message was received.
payload: Message body as a UTF-8 string.
"""
print(f"[on_message] topic={topic}, payload={payload}")
# Register callbacks
sdk.on_connection(on_connection)
sdk.on_message(on_message)
# Initialize and connect
sdk.init(
client_id = "my_client",
broker_host = "broker.example.com:1883",
protocol = "tcp",
username = "user",
password = "password",
)
# Connect
ok = sdk.connect()
# Publish and subscribe
if ok:
sdk.subscribe("my/topic")
sdk.publish("my/topic", "hello")
time.sleep(2)
# Cleanup
sdk.disconnect()
sdk.stop()
API Reference
SDK()
Creates a new SDK instance.
init(client_id, broker_host, protocol, username, password)
Initializes the client. Must be called before connect().
| Parameter | Type | Description |
|---|---|---|
client_id |
str |
Unique identifier for this client |
broker_host |
str |
Broker address including port, e.g. broker.example.com:1883 |
protocol |
str |
Transport protocol: "tcp" or "ssl" |
username |
str |
Authentication username |
password |
str |
Authentication password |
connect() -> bool
Connects to the broker. Returns True on success.
disconnect()
Gracefully disconnects from the broker.
publish(topic, payload, qos=0, retained=False)
Publishes a message to the given topic.
subscribe(topic, qos=0) -> bool
Subscribes to a topic. Returns True on success.
unsubscribe(topic)
Unsubscribes from a topic.
on_message(callback)
Registers a callback invoked when a message arrives.
Signature: callback(topic: str, payload: str) -> None
on_connection(callback)
Registers a callback invoked on connection state changes.
Signature: callback(connected: bool, rc: int) -> None
is_connected() -> bool
Returns the current connection state.
stop()
Stops all activity and releases resources. Call after disconnect().
License
Proprietary — all rights reserved.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
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 okiff_sdk-1.1.7-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: okiff_sdk-1.1.7-cp313-cp313-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.13, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf1e211d37676bf9c392b5bf4c501b827d51579477f0a4281d2ac84d430a553a
|
|
| MD5 |
5e6a215cfc28682fa7d92624387940dd
|
|
| BLAKE2b-256 |
5cc706821e22b7fab8004cfa32d94a802b4a8ecef471e90198e4ab1d275e13cd
|
File details
Details for the file okiff_sdk-1.1.7-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: okiff_sdk-1.1.7-cp312-cp312-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.12, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
97381fc0d4ae049b356d410f73571463a7885eeee7565f0f1824b0dfff4e78e6
|
|
| MD5 |
8fcbf0fdf6cd33d52a42bce2827ba003
|
|
| BLAKE2b-256 |
2bb81300b502299281c32bfe3227271b418b4be3c0c8d20d7640d0b592e9058f
|