1

This Section illustrates the Client Side and Server side RPC (Remote Procedure C...

 1 year ago
source link: https://gist.github.com/shiyazt/ea9942d9705948df19d7d13aafab4f04
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
This Section illustrates the Client Side and Server side RPC (Remote Procedure Call) in ThingsBoard IoT Platform. Client_Side_RPC.py : This program will illustrates the Client side, RPC Server_Side_RPC.py : This Program will illustrates the Server side RPC and Temperature_Controller_Server_Side_RPC.py : This program illustrates Server side RPC u…

ghost commented on Sep 5, 2018

I am trying to acheive a simple task, however i am confused because its not working. After watching your tutorial, I am trying the code below but i am not getting desired results. I want to turn the knob (Knob widget in Thingsboard) and plot the value set by knob. For instance, rotate the knob and show the value of knob on chart/card etc. The script is below, can you help me to identify where i am doing wrong?

#!/usr/bin/env python
import os
import time
import smbus
import sys
import paho.mqtt.client as mqtt
import json

THINGSBOARD_HOST = 'ourdevice.tk'
ACCESS_TOKEN = 'iJqpMTIULqzlMgU2QpAw'

def on_connect(client, userdata, rc):
client.subscribe("v1/devices/me/rpc/request/+")

def on_message(client, userdata, msg):
data = json.loads(msg.payload)
data = int (data)
client.publish('v1/devices/me/telemetry', data)

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.username_pw_set(ACCESS_TOKEN)
client.connect(THINGSBOARD_HOST, 1883, 60)

try:
client.loop_forever()
except KeyboardInterrupt:
sys.exit()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK