def execute_command(data): logging.info("execute_command") logging.info(data) interface_configuration = None interface_type = InterfaceType(int(data["interface"])) if interface_type == InterfaceType.D7ASP: id_type = IdType[data["id_type"]] id = int(data["id"]) if id_type == IdType.NOID: id = None if id_type == IdType.NBID: id = CT() # TODO convert interface_configuration = Configuration( qos=QoS(resp_mod=ResponseMode[data["qos_response_mode"]]), addressee=Addressee(access_class=int(data["access_class"]), id_type=id_type, id=id)) cmd = Command.create_with_read_file_action( interface_type=interface_type, interface_configuration=interface_configuration, file_id=int(data["file_id"]), offset=int(data["offset"]), length=int(data["length"])) logging.info("executing cmd: {}".format(cmd)) modem.execute_command_async(cmd) return { 'tag_id': cmd.tag_id, 'interface': interface_type.name, 'command_description': cmd.describe_actions() }
def parse_forward_action(self, b7, b6, s): if b7: raise ParseError("bit 7 is RFU") interface_id = InterfaceType(int(s.read("uint:8"))) assert(interface_id == InterfaceType.D7ASP) interface_config = Configuration.parse(s) return ForwardAction(resp=b6, operation=Forward(operand=InterfaceConfiguration(interface_id=interface_id, interface_configuration=interface_config)))
def parse_forward_action(self, b7, b6, s): if b7: raise ParseError("bit 7 is RFU") interface_id = InterfaceType(int(s.read("uint:8"))) interface_config = None if (interface_id == InterfaceType.D7ASP): interface_config = Configuration.parse(s) elif (interface_id == InterfaceType.SERIAL): pass # no interface config else: assert (False) return ForwardAction(resp=b6, operation=Forward(operand=InterfaceConfiguration( interface_id=interface_id, interface_configuration=interface_config)))