예제 #1
0
    def onMessage(self, msg):
        msg = json.loads(msg)

        if msg['cmd'] == common_protocol.ServerCommands.DROP_TO_CONFIG:
            # wrong state, drop
            # flush IO
            io_clss = interface.get_interface_desc()
            for cls in io_clss['read']:
                cls.flush()
            for cls in io_clss['write']:
                cls.flush()
            self.protocol.pop_state()

            resp_msg = {'cmd': common_protocol.RPIClientCommands.DROP_TO_CONFIG_OK}
            self.sendJsonMessage(resp_msg)
            return

        elif msg['cmd'] == common_protocol.ServerCommands.ACK_DATA:
            server_ackcount = msg['ack_count']
            self.ackcount += server_ackcount
            if self.ackcount > -10:
                self.poll_and_send()

        elif msg['cmd'] == common_protocol.ServerCommands.RESUME_STREAMING:
            self.resume_streaming()

        elif msg['cmd'] == common_protocol.ServerCommands.PAUSE_STREAMING:
            self.pause_streaming()

        elif msg['cmd'] == common_protocol.ServerCommands.WRITE_DATA:
            key = msg['inter_face_port']
            value = msg['value']
            self.write_to_inter_face(key, value)
예제 #2
0
    def onMessage(self, msg):
        msg = json.loads(msg)

        if msg['cmd'] == common_protocol.ServerCommands.DROP_TO_CONFIG:
            # wrong state, drop
            # flush IO
            io_clss = interface.get_interface_desc()
            for cls in io_clss['read']:
                cls.flush()
            for cls in io_clss['write']:
                cls.flush()
            self.protocol.pop_state()

            resp_msg = {'cmd':common_protocol.RPIClientCommands.DROP_TO_CONFIG_OK}
            self.protocol.sendMessage(json.dumps(resp_msg))
            return

        elif msg['cmd'] == common_protocol.ServerCommands.ACK_DATA:
            server_ackcount = msg['ack_count']
            self.ackcount += server_ackcount
            if self.ackcount > -10:
                self.poll_and_send()

        elif msg['cmd'] == common_protocol.ServerCommands.RESUME_STREAMING:
            self.resume_streaming()

        elif msg['cmd'] == common_protocol.ServerCommands.PAUSE_STREAMING:
            self.pause_streaming()

        elif msg['cmd'] == common_protocol.ServerCommands.WRITE_DATA:
            key = msg['iface_port']
            value = msg['value']
            self.write_to_iface(key, value)
예제 #3
0
 def __init__(self):
     common_protocol.ProtocolState.__init__(self)
     self.mac = rpi_data.utility.get_mac()
     self.interfaces = interface.get_interface_desc()
예제 #4
0
 def __init__(self):
     common_protocol.ProtocolState.__init__(self)
     self.mac = rpi_data.utility.get_mac()
     self.interfaces = interface.get_interface_desc()