app2.py 文件源码

python
阅读 42 收藏 0 点赞 0 评论 0

项目:IotCenter 作者: panjanek 项目源码 文件源码
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))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号