Okiff SDK
Project description
okiff-sdk
Python SDK for connecting to and communicating with MQTT brokers. Built as a compiled native extension for high performance and ease of deployment.
Requirements
- Python 3.9 or later
- Linux x86-64 (additional platforms coming soon)
Installation
pip install okiff-sdk
No compilation is required. The package is distributed as a pre-built binary wheel.
Quick Start
"""
Example:
Connect to an MQTT broker, subscribe to a topic,
publish a message, and receive messages using callbacks.
"""
import time
from okiff_sdk import SDK
# Create SDK instance
sdk = SDK()
# Connection callback
def on_connection(connected: bool, rc: int) -> None:
"""
Called whenever the connection state changes.
Args:
connected: True if connected, False otherwise.
rc: MQTT return code (0 = success, -1 = unexpected disconnect).
"""
print(f"[on_connection] connected={connected}, rc={rc}")
# Message callback
def on_message(topic: str, payload: str) -> None:
"""
Called when a message is received.
Args:
topic: MQTT topic.
payload: UTF-8 message payload.
"""
print(f"[on_message] topic={topic}, payload={payload}")
# Register callbacks
sdk.on_connection(on_connection)
sdk.on_message(on_message)
# Initialize SDK
sdk.init(
clientId="clientId",
brokerHost="ip:port",
protocol="tcp",
username="username",
password="YOUR_JWT_TOKEN",
cleanSession=True,
resumeSubs=True,
connectRetry=True,
autoReconnect=True,
connectRetryInterval=5,
maxReconnectInterval=30,
keepAlive=30,
pingTimeout=20,
writeTimeout=20,
orderMatters=False,
connectTimeout=5,
edition="Enterprise",
)
# Connect
if sdk.connect():
sdk.subscribe("okiff/sdk/test")
sdk.publish("okiff/sdk/test", "hello from okiff-sdk")
# Wait to receive messages
time.sleep(5)
# Disconnect
sdk.disconnect()
print("Disconnected")
API Reference
SDK()
Creates a new SDK instance.
init(...)
Initializes the MQTT client. L'option edition Enterprise permet à connecter l'IoT Thing to the Cloud Core. For Testing you can use edition Community and connect to Edge/Onpremise Broker core.
This method must be called before connect().
| Parameter | Type | Description |
|---|---|---|
clientId |
str |
Unique MQTT client identifier |
brokerHost |
str |
Broker address with port (host:port) |
protocol |
str |
Connection protocol ("tcp" or "ssl") |
username |
str |
MQTT username |
password |
str |
MQTT password or JWT token |
cleanSession |
bool |
Start a clean MQTT session |
resumeSubs |
bool |
Restore subscriptions after reconnect |
connectRetry |
bool |
Retry the initial connection if it fails |
autoReconnect |
bool |
Automatically reconnect after disconnect |
connectRetryInterval |
int |
Initial retry interval (seconds) |
maxReconnectInterval |
int |
Maximum reconnect interval (seconds) |
keepAlive |
int |
MQTT keep-alive interval (seconds) |
pingTimeout |
int |
Ping response timeout (seconds) |
writeTimeout |
int |
Socket write timeout (seconds) |
orderMatters |
bool |
Preserve message ordering |
connectTimeout |
int |
Connection timeout (seconds) |
edition |
str |
SDK edition (for example "Community" or "Enterprise") |
connect() -> bool
Connects to the configured MQTT broker.
Returns True if the connection succeeds.
disconnect()
Gracefully disconnects from the MQTT broker.
publish(topic, payload, qos=0, retained=False)
Publishes a message to the specified topic.
| Parameter | Type | Description |
|---|---|---|
topic |
str |
MQTT topic |
payload |
str |
Message payload |
qos |
int |
MQTT Quality of Service (0, 1 or 2) |
retained |
bool |
Publish as a retained message |
subscribe(topic, qos=0) -> bool
Subscribes to an MQTT topic.
Returns True if the subscription succeeds.
unsubscribe(topic)
Removes an existing topic subscription.
on_message(callback)
Registers a callback invoked whenever a message is received.
Callback signature:
callback(topic: str, payload: str) -> None
on_connection(callback)
Registers a callback invoked whenever the connection state changes.
Callback signature:
callback(connected: bool, rc: int) -> None
Where:
connected=Trueindicates the client is connected.connected=Falseindicates the client has disconnected.rcis the MQTT/Paho return code.
is_connected() -> bool
Returns the current connection status.
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.2.0-cp314-cp314-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: okiff_sdk-1.2.0-cp314-cp314-manylinux_2_39_x86_64.whl
- Upload date:
- Size: 2.2 MB
- Tags: CPython 3.14, manylinux: glibc 2.39+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b781b8ea6e7a2c685d3f4ff9a0bcb39ed331654c8a59742eea75cdc2aa1591aa
|
|
| MD5 |
d919819c53c3d70b0799a9fb67052472
|
|
| BLAKE2b-256 |
6cb4a0c1da0e9e7e3bb6ac6ebd10dfaed388b76d96a53c40f46a20b17de3c5a2
|
File details
Details for the file okiff_sdk-1.2.0-cp313-cp313-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: okiff_sdk-1.2.0-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.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f3259f594776532f84396e71536cb2f64c1514a21995029903a4e894d5432ab1
|
|
| MD5 |
23151eb260e0c7665f48f47fe65d7a60
|
|
| BLAKE2b-256 |
3cb106664ce566d04b432db77792d7ff6c80bd97fde9fead671a259e7995d142
|
File details
Details for the file okiff_sdk-1.2.0-cp312-cp312-manylinux_2_39_x86_64.whl.
File metadata
- Download URL: okiff_sdk-1.2.0-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.14.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
50da30d80746fc396ea75f881b801d3c3d333a6a6fb384dbec845c39270832b0
|
|
| MD5 |
10eaea8226ab371a5f55b1b8f124c463
|
|
| BLAKE2b-256 |
2fe8d18c0eaacb2c6dba7aee072d7724f5da228311fd8f70cff31487236f7c88
|