我试图在我的覆盆子pi上运行python脚本。而且我的设备也已经连接在bluemix上。起初,我可以运行脚本,但现在我得到了以下错误。运行超时连接到IBM iot服务
2016年11月14日06:46:30490 ibmiotf.application.Client警告无法因为TLSv1.2工作是不可用(MQTT SSL上至少需要的Python v2.7.9或3.4和OpenSSL V1来加密消息。 0.1) 2016-11-14 06:46:40,571 ibmiotf.application.Client CRITICAL连接到IBM物联网服务的操作超时:1tlj3z.messaging.internetof things.ibmcloud.com 操作超时连接到IBM物联网的服务网络:1tlj3z.mes saging.internetofthings.ibmcloud.com
PIO.setmode(GPIO.BCM)
GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(17, GPIO.OUT)
client = None
def myCommandCallback(cmd):
if cmd.event == "light":
有效载荷= json.loads( cmd.payload)
command = payload["command"]
print command
if command == "on":
GPIO.output(17, True)
elif的命令== “关”:
GPIO.output(17,假)
try:
options = ibmiotf.application.ParseConfigFile("/home/pi/device.cfg")
options["deviceId"] = options["id"]
options["id"] = "aaa" + options["id"]
client = ibmiotf.application.Client(options)
client.connect()
client.deviceEventCallback = myCommandCallback
client.subscribeToDeviceEvents(event="light")
while True:
GPIO.wait_for_edge(18, GPIO.FALLING)
print "Button Pushed"
myData = {'buttonPushed' : True}
client.publishEvent("raspberrypi", options["deviceId"], "input", "json", myData)
time.sleep(0.2)
除了ibmiotf.ConnectionException为e: 打印E
你可以添加你的代码和python版本吗?你是否检查过Pi的防火墙/互联网连接? – amadain
我能够ssh到我的pi。 –
ssh到pi只说pi在你的子网上。在pi上时,确保它可以ping 1tlj3z.messaging.internetofthings.ibmcloud.com。但瓦莱丽可能是正确的,你应该升级蟒蛇。 – amadain