def ReadInfo_clicked(self): if not self._check_connection(): return try: self.log("\n" + self.tr("Read the card contained a base station state")) state = self.sportiduino.read_state_card() bs_state = BaseStation.State() bs_state.version = Sportiduino.Version(*state['version']) bs_state.config = BaseStation.Config.unpack(state['config']) bs_state.battery = BaseStation.Battery(state['battery']) bs_state.mode = state['mode'] bs_state.timestamp = state['timestamp'] bs_state.wakeuptime = state['wakeuptime'] self._show_base_station_state(bs_state) except Exception as err: self._process_error(err) raise err
def read_info_by_serial(cls, port, password): params = b'' params += int2byte(password[0]) params += int2byte(password[1]) params += int2byte(password[2]) resp_code, data = cls._send_command(port, cls.SERIAL_FUNC_READ_INFO, params, timeout=8) if resp_code == cls.SERIAL_RESP_INFO: state = cls.State() state.version = Sportiduino.Version(*data[0:3]) state.config = cls.Config.unpack(data[3:9]) state.battery = cls.Battery(byte2int(data[9])) state.mode = byte2int(data[10]) state.timestamp = datetime.fromtimestamp( Sportiduino._to_int(data[11:15])) state.wakeuptime = datetime.fromtimestamp( Sportiduino._to_int(data[15:19])) return state
def __init__(self): self.version = Sportiduino.Version(0) self.config = BaseStation.Config() self.mode = BaseStation.MODE_ACTIVE self.battery = BaseStation.Battery() self.timestamp = 0