Skip to main content

Telenor NB-IoT client

Project description

nbiot-python

NBIoT-Python provides a Python client for the REST API for Telenor NB-IoT.

Configuration

The configuration file is located at ${HOME}/.telenor-nbiot. The file is a simple list of key/value pairs. Additional values are ignored. Comments must start with a #:

#
# This is the URL of the Telenor NB-IoT REST API. The default value is
# https://api.nbiot.telenor.io and can usually be omitted.
address=https://api.nbiot.telenor.io

#
# This is the API token. Create new token by logging in to the Telenor NB-IoT
# front-end at https://nbiot.engineering and create a new token there.
token=<your api token goes here>

The configuration file settings can be overridden by setting the environment variables TELENOR_NBIOT_ADDRESS and TELENOR_NBIOT_TOKEN. If you only use environment variables the configuration file can be ignored. Finally, there is a Client constructor that accepts the address and token directly.

Sample code

from nbiot import nbiot

client = nbiot.Client()
stream = await client.collection_output_stream('<YOUR_COLLECTION_ID>')
while True:
	try:
		msg = await stream.recv()
	except nbiot.OutputStreamClosed:
		break
	print(msg.payload)

Development

Development is done using Pipenv. Run pipenv install --dev to install all dependencies.

Because Python has not properly solved dependency management yet, dependencies must be be repeated in setup.py under the install_requires entry.

Testing

Tests are written using pytest. Run pipenv run pytest to run all the tests.

Deployment

To build and upload a new version to PyPI, make sure that you are using Python 3 and run

python setup.py sdist
python setup.py bdist_wheel
twine upload dist/*          # `pip install twine` to get this tool

Project details


Release history Release notifications

This version
History Node

0.2

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
telenor_nbiot-0.2-py3-none-any.whl (10.5 kB) Copy SHA256 hash SHA256 Wheel py3
telenor-nbiot-0.2.tar.gz (8.5 kB) Copy SHA256 hash SHA256 Source None

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page