Skip to content

Commit 327889b

Browse files
committed
Updated README
1 parent b824679 commit 327889b

1 file changed

Lines changed: 46 additions & 32 deletions

File tree

README.md

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,38 @@
66

77
<a href="https://thingsboard.io"><img src="./logo.png?raw=true" width="100" height="100"></a>
88

9-
**💡 Make the notion that it is the early alpha of MQTT client MicroPython SDK special for controllers. So we appreciate any
10-
help in improving this project and getting it growing.**
9+
**💡 Make the notion that it is the early alpha of MQTT client MicroPython SDK special for controllers. So we
10+
appreciate any help in improving this project and getting it growing.**
1111

1212
ThingsBoard is an open-source IoT platform for data collection, processing, visualization, and device management.
1313
This project is a MicroPython library that provides convenient client SDK for Device API using MicroPython.
1414

15-
SDK supports:
15+
**SDK supports:**
1616
- Provided all supported feature of umqtt library
1717
- Unencrypted and encrypted (TLS v1.2) connection
1818
- QoS 0 and 1 (MQTT only)
1919
- Automatic reconnect
2020
- [Device MQTT](https://thingsboard.io/docs/reference/mqtt-api/) API provided by ThingsBoard
2121
- Firmware updates
22-
- Device Claiming are not supported yet
22+
- Device Claiming
23+
- Device provisioning
2324

24-
The [Device MQTT](https://thingsboard.io/docs/reference/mqtt-api/) API are based on uMQTT library.
25+
## Installation
2526

26-
**For now library support only local install (not from package manager relates to MicroPython)**
27+
To install using mip:
28+
29+
```bash
30+
import mip
31+
32+
mip.install('github:thingsboard/thingsboard-micropython-client-sdk')
33+
```
2734

2835
## Getting Started
2936

3037
Client initialization and telemetry publishing
31-
### MQTT
38+
3239
```python
33-
from tb_device_mqtt import TBDeviceMqttClient
40+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient
3441
telemetry = {"temperature": 41.9, "enabled": False, "currentFirmwareVersion": "v1.2.2"}
3542
client = TBDeviceMqttClient("127.0.0.1", "A1_TEST_TOKEN")
3643
# Connect to ThingsBoard
@@ -45,12 +52,15 @@ client.disconnect()
4552

4653
## Using Device APIs
4754

48-
**TBDeviceMqttClient** provides access to Device MQTT APIs of ThingsBoard platform. It allows to publish telemetry and attribute updates, subscribe to attribute changes, send and receive RPC commands, etc. Use **TBHTTPClient** for the Device HTTP API.
49-
#### Subscription to attributes
50-
##### MQTT
55+
**TBDeviceMqttClient** provides access to Device MQTT APIs of ThingsBoard platform. It allows to publish telemetry and
56+
attribute updates, subscribe to attribute changes, send and receive RPC commands, etc. Use **TBHTTPClient** for the
57+
Device HTTP API.
58+
59+
### Subscription to attributes
60+
5161
```python
5262
import time
53-
from tb_device_mqtt import TBDeviceMqttClient
63+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient
5464

5565
def on_attributes_change(client, result, exception):
5666
if exception is not None:
@@ -67,11 +77,11 @@ while True:
6777
time.sleep(1)
6878
```
6979

70-
#### Telemetry pack sending
71-
##### MQTT
80+
### Telemetry pack sending
81+
7282
```python
7383
import logging
74-
from tb_device_mqtt import TBDeviceMqttClient
84+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient
7585
import time
7686
telemetry_with_ts = {"ts": int(round(time.time() * 1000)), "values": {"temperature": 42.1, "humidity": 70}}
7787
client = TBDeviceMqttClient("127.0.0.1", "A1_TEST_TOKEN")
@@ -85,14 +95,14 @@ print("Result " + str(result))
8595
client.disconnect()
8696
```
8797

88-
#### Request attributes from server
89-
##### MQTT
98+
### Request attributes from server
99+
90100
```python
91101
import logging
92102
import time
93-
from tb_device_mqtt import TBDeviceMqttClient
103+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient
94104

95-
def on_attributes_change(client,result, exception:
105+
def on_attributes_change(client, result, exception):
96106
if exception is not None:
97107
print("Exception: " + str(exception))
98108
else:
@@ -105,13 +115,13 @@ while True:
105115
time.sleep(1)
106116
```
107117

108-
#### Respond to server RPC call
109-
##### MQTT
118+
### Respond to server RPC call
119+
110120
```python
111121
import psutil
112122
import time
113123
import logging
114-
from tb_device_mqtt import TBDeviceMqttClient
124+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient
115125

116126
# dependently of request method we send different data back
117127
def on_server_side_rpc_request(client, request_id, request_body):
@@ -127,12 +137,16 @@ client.connect()
127137
while True:
128138
time.sleep(1)
129139
```
130-
## Device provisioning
131-
**ProvisionManager** - class created to have ability to provision device to ThingsBoard, using device provisioning feature [Provisioning devices](https://thingsboard.io/docs/paas/user-guide/device-provisioning/)
132-
First, you need to set up and configure the `ProvisionManager`, which allows you to provision a device on the ThingsBoard server via MQTT. Below are the steps for using this class.
140+
141+
### Device provisioning
142+
143+
**ProvisionManager** - class created to have ability to provision device to ThingsBoard, using device provisioning
144+
feature [Provisioning devices](https://thingsboard.io/docs/paas/user-guide/device-provisioning/)
145+
First, you need to set up and configure the `ProvisionManager`, which allows you to provision a device on the
146+
ThingsBoard server via MQTT. Below are the steps for using this class.
133147

134148
```python
135-
from tb_device_mqtt import TBDeviceMqttClient, ProvisionManager
149+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient, ProvisionManager
136150

137151
THINGSBOARD_HOST = "YOUR_THINGSBOARD_HOST"
138152
THINGSBOARD_PORT = 1883
@@ -184,11 +198,14 @@ finally:
184198
print("Client was not connected; no need to disconnect.")
185199
```
186200

187-
# Claim device
188-
[**Claim device**](https://thingsboard.io/docs/pe/user-guide/claiming-devices/) is a function designed to handle the device claiming feature in ThingsBoard. It enables sending device claiming requests to the ThingsBoard MQTT broker, allowing dynamic assignment of devices to users or customers.
201+
### Device claiming
202+
203+
[**Claim device**](https://thingsboard.io/docs/pe/user-guide/claiming-devices/) is a function designed to handle the device claiming feature in ThingsBoard. It enables
204+
sending device claiming requests to the ThingsBoard MQTT broker, allowing dynamic assignment of devices to users or
205+
customers.
189206

190207
```python
191-
from tb_device_mqtt import TBDeviceMqttClient
208+
from thingsboard_sdk.tb_device_mqtt import TBDeviceMqttClient
192209

193210
THINGSBOARD_HOST = "YOUR_THINGSBOARD_HOST"
194211
THINGSBOARD_PORT = 1883
@@ -210,9 +227,6 @@ finally:
210227
client.disconnect()
211228
print("Disconnected from ThingsBoard.")
212229
```
213-
## Other Examples
214-
215-
There are more examples for both [device](https://github.com/thingsboard/thingsboard-python-client-sdk/tree/master/examples/device) and [gateway](https://github.com/thingsboard/thingsboard-python-client-sdk/tree/master/examples/gateway) in corresponding [folders](https://github.com/thingsboard/thingsboard-python-client-sdk/tree/master/examples).
216230

217231
## Support
218232

0 commit comments

Comments
 (0)