gtmtg / python-app-sdk

The Things Network Application SDK for Python

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The Things Network Python SDK

Build Status

The Things Network

This is the Python Application SDK for The Things Network to receive messages from IoT devices via The Things Network and send messages as well.

Installation

$ pip install ttn

Documentation

Example

import time
import ttn

app_id = "foo"
access_key = "ttn-account.eiPq8mEeYRL_PNBZsOpPy-O3ABJXYWulODmQGR5PZzg"

def uplink_callback(msg, client):
  print("Received uplink from ", msg.dev_id)
  print(msg)

handler = ttn.HandlerClient(app_id, access_key)

# using mqtt client
mqtt_client = handler.data()
mqtt_client.set_uplink_callback(uplink_callback)
mqtt_client.connect()
time.sleep(60)
mqtt_client.close()

# using application manager client
app_client =  handler.application()
my_app = app_client.get()
print(my_app)
my_devices = app_client.devices()
print(my_devices)

License

Source code for The Things Network is released under the MIT License, which can be found in the LICENSE file. A list of authors can be found in the AUTHORS file.

About

The Things Network Application SDK for Python

License:MIT License


Languages

Language:Python 100.0%