Skip to main content

No project description provided

Project description

Iotcore - Python MQTT Broker and IoT Features for Django and FastAPI

The project aims to give full support for mqtt broker and related apis. The internals of the mqtt server is written in
Rust using popular Tokio framework. Motive of the project is to avoid the GIL limitation of python and bring all the fun features offered by rust.

Features

  • Full-fledged configurable Tokio based MQTT broker
  • No python GIL limitation
  • All Standard MQTT broker features
  • Zero extra setup required to run mqtt broker in you Django and Fastapi project
  • MQTT client, with callback support for async or non-blocking applications
  • and more

Planned Features

  • Device support
  • Sensor support
  • Sensor data storage
  • Django based admin pages
  • Django rest framework based APIs for managing devices and sensors
  • SSL certificates and policy management

Installation

pip install iotcore

Create a new file called mqtt.toml in your root project directory and copy pase the sample mqtt.toml from https://github.com/tomvictor/iotcore

FastAPI setup

Broker only

from fastapi import FastAPI
from iotcore.fastapi import iotcore_broker

app = FastAPI(lifespan=iotcore_broker)


@app.get("/")
def read_root():
    return {"Hello": "World"}

Broker plus Mqtt client

from fastapi import FastAPI
from contextlib import asynccontextmanager
from iotcore import IotCore

iot = IotCore()


@asynccontextmanager
async def lifespan(app: FastAPI):
    iot.background_loop_forever()
    yield


app = FastAPI(lifespan=lifespan)


@app.get("/")
def read_root():
    return {"Hello": "World"}


def mqtt_callback(data):
    print(f"iot >: {data}")


@app.get("/sub")
def read_root():
    iot.subscribe("iot", mqtt_callback)
    return {"response": "subscribed"}


@app.get("/pub")
def read_root():
    iot.publish("iot", "test")
    return {"response": "published"}

Django Setup

Then add iotcore to the django apps as below in the settings.py file of your project

INSTALLED_APPS = [
    "Other Apps here",
    "iotcore.djangoiot"
]

Now Connect to mqtt broker on localhost
MQTT Port : 1883

Run Example project

Django

pip install iotcore
pip install django

python examples/django/manage.py runserver

FastAPI

pip install iotcore
pip install fastapi
pip install uvicorn

uvicorn examples.fastapi.main:app

Open you mqtt client and use below details to connect to the broker:
Host: 127.0.0.1 or localhost
Port: 1883

Contribute

  • Issue Tracker: github.com/tomvictor/iotcore/issues
  • Source Code: github.com/tomvictor/iotcore

Support

Star the project on GitHub :)

License

The project is licensed under the MIT license.

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

iotcore-0.0.14.tar.gz (26.8 kB view hashes)

Uploaded Source

Built Distributions

iotcore-0.0.14-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-pp310-pypy310_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

iotcore-0.0.14-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-pp39-pypy39_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-pp39-pypy39_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-pp39-pypy39_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

iotcore-0.0.14-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-pp38-pypy38_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-pp38-pypy38_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-pp38-pypy38_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

iotcore-0.0.14-pp37-pypy37_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-pp37-pypy37_pp73-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-pp37-pypy37_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded PyPy manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-pp37-pypy37_pp73-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded PyPy manylinux: glibc 2.12+ i686

iotcore-0.0.14-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-cp312-cp312-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded CPython 3.12 manylinux: glibc 2.12+ i686

iotcore-0.0.14-cp311-none-win_amd64.whl (3.1 MB view hashes)

Uploaded CPython 3.11 Windows x86-64

iotcore-0.0.14-cp311-none-win32.whl (2.9 MB view hashes)

Uploaded CPython 3.11 Windows x86

iotcore-0.0.14-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-cp311-cp311-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-cp311-cp311-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.12+ i686

iotcore-0.0.14-cp311-cp311-macosx_11_0_arm64.whl (3.6 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

iotcore-0.0.14-cp311-cp311-macosx_10_7_x86_64.whl (3.8 MB view hashes)

Uploaded CPython 3.11 macOS 10.7+ x86-64

iotcore-0.0.14-cp310-none-win_amd64.whl (3.1 MB view hashes)

Uploaded CPython 3.10 Windows x86-64

iotcore-0.0.14-cp310-none-win32.whl (2.9 MB view hashes)

Uploaded CPython 3.10 Windows x86

iotcore-0.0.14-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-cp310-cp310-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-cp310-cp310-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.12+ i686

iotcore-0.0.14-cp310-cp310-macosx_11_0_arm64.whl (3.6 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

iotcore-0.0.14-cp310-cp310-macosx_10_7_x86_64.whl (3.8 MB view hashes)

Uploaded CPython 3.10 macOS 10.7+ x86-64

iotcore-0.0.14-cp39-none-win_amd64.whl (3.1 MB view hashes)

Uploaded CPython 3.9 Windows x86-64

iotcore-0.0.14-cp39-none-win32.whl (2.9 MB view hashes)

Uploaded CPython 3.9 Windows x86

iotcore-0.0.14-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-cp39-cp39-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-cp39-cp39-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.12+ i686

iotcore-0.0.14-cp38-none-win_amd64.whl (3.1 MB view hashes)

Uploaded CPython 3.8 Windows x86-64

iotcore-0.0.14-cp38-none-win32.whl (2.9 MB view hashes)

Uploaded CPython 3.8 Windows x86

iotcore-0.0.14-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-cp38-cp38-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-cp38-cp38-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.12+ i686

iotcore-0.0.14-cp37-none-win_amd64.whl (3.1 MB view hashes)

Uploaded CPython 3.7 Windows x86-64

iotcore-0.0.14-cp37-none-win32.whl (2.9 MB view hashes)

Uploaded CPython 3.7 Windows x86

iotcore-0.0.14-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.4 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

iotcore-0.0.14-cp37-cp37m-manylinux_2_17_armv7l.manylinux2014_armv7l.whl (5.1 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARMv7l

iotcore-0.0.14-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (5.3 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

iotcore-0.0.14-cp37-cp37m-manylinux_2_12_i686.manylinux2010_i686.whl (5.7 MB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.12+ i686

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page