def handleServerCall(self, payload):
self.logger.info("Handling server callback with payload {0}".format(payload))
payloadDict = json.loads(payload)
if "command" in payloadDict:
command = payloadDict["command"]
self.logger.info("Received command: {0}".format(command))
if command == "blink":
self.logger.info("BLINK!!!")
elif command == "reboot":
self.logger.info("REBOOT!!!")
elif command == "photo":
self.logger.info("PHOTO!!!")
photoFile = "/home/pi/puszcz.jpg"
with open(photoFile, mode='rb') as file:
photoData = file.read()
base64data = base64.b64encode(photoData)
self.service.sendMessage(json.dumps({'image':base64data, 'type':'jpg'}))
else:
self.logger.info("Command '{0}' unknown".format(command))
评论列表
文章目录