Skip to main content

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

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

okiff_sdk-1.1.7-cp313-cp313-manylinux_2_39_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.13manylinux: glibc 2.39+ x86-64

okiff_sdk-1.1.7-cp312-cp312-manylinux_2_39_x86_64.whl (2.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.39+ x86-64

File details

Details for the file okiff_sdk-1.1.7-cp313-cp313-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for okiff_sdk-1.1.7-cp313-cp313-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 bf1e211d37676bf9c392b5bf4c501b827d51579477f0a4281d2ac84d430a553a
MD5 5e6a215cfc28682fa7d92624387940dd
BLAKE2b-256 5cc706821e22b7fab8004cfa32d94a802b4a8ecef471e90198e4ab1d275e13cd

See more details on using hashes here.

File details

Details for the file okiff_sdk-1.1.7-cp312-cp312-manylinux_2_39_x86_64.whl.

File metadata

File hashes

Hashes for okiff_sdk-1.1.7-cp312-cp312-manylinux_2_39_x86_64.whl
Algorithm Hash digest
SHA256 97381fc0d4ae049b356d410f73571463a7885eeee7565f0f1824b0dfff4e78e6
MD5 8fcbf0fdf6cd33d52a42bce2827ba003
BLAKE2b-256 2bb81300b502299281c32bfe3227271b418b4be3c0c8d20d7640d0b592e9058f

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