def configure_sensor(serial_device, sensor_id, serial_enabled, channel, sleep_enabled): aci = AciUart.AciUart(port=serial_device, baudrate=115200) # Wait for serial connection to be ready time.sleep(2) cmd = sensei_cmd.SetConfig(sensor_id, serial_enabled, channel, sleep_enabled) data = cmd.serialize() aci.write_aci_cmd(AciCommand.AciAppCommand(data=data, length=len(data) + 1)) # Wait for flash to be written time.sleep(2) aci.write_aci_cmd(AciCommand.AciRadioReset()) aci.stop()
def set_time(serial_device): aci = AciUart.AciUart(port=serial_device, baudrate=115200) # Wait for serial connection to be ready time.sleep(2) cmd = sensei_cmd.SetTime() data = cmd.serialize() aci.write_aci_cmd(AciCommand.AciAppCommand(data=data, length=len(data) + 1)) aci.stop()
def FlagGet(self, Handle, FlagIndex): self.acidev.write_aci_cmd( AciCommand.AciFlagGet(handle=Handle, flag_index=FlagIndex))
def FlagSet(self, Handle, FlagIndex, FlagValue=True): self.acidev.write_aci_cmd( AciCommand.AciFlagSet(handle=Handle, flag_index=FlagIndex, flag_value=FlagValue))
def Stop(self): self.acidev.write_aci_cmd(AciCommand.AciStop())
def ValueGet(self, Handle): self.acidev.write_aci_cmd(AciCommand.AciValueGet(handle=Handle))
def MinIntervalGet(self): self.acidev.write_aci_cmd(AciCommand.AciIntervalMinMsGet())
def AccessAddressGet(self): self.acidev.write_aci_cmd(AciCommand.AciAccessAddressGet())
def RadioReset(self): self.acidev.write_aci_cmd(AciCommand.AciRadioReset())
def Echo(self, Data): self.acidev.write_aci_cmd( AciCommand.AciEcho(data=Data, length=(len(Data) + 1)))
def run_app_command(self, command): data = command.serialize() retval = self.aci.write_aci_cmd( AciCommand.AciAppCommand(data=data, length=len(data) + 1)) print("Events received: %s" % retval) return retval
def __repr__(self): return str.format( "I am %s and my Lenght is %d, OpCode is 0x%02x, CommandOpCode is %s, StatusCode is %s, and Data is %s" % (self.__class__.__name__, self.Len, self.OpCode, AciCommand.AciCommandLookUp(self.CommandOpCode), AciStatusLookUp(self.StatusCode), self.Data))
def __repr__(self): return "%s length:%d opcode:0x%02x command_opcode:%s status_code:%s data:%s" % ( self.__class__.__name__, self.Len, self.OpCode, AciCommand.AciCommandLookUp(self.CommandOpCode), AciStatusLookUp(self.StatusCode), self.Data)
def DFUData(self, Data): self.acidev.write_aci_cmd( AciCommand.AciDfuData(data=Data, length=(len(Data) + 1)))
def Init(self, AccessAddress=0x8E89BED6, MinInterval=100, Channel=39): self.acidev.write_aci_cmd( AciCommand.AciInit(access_address=AccessAddress, min_interval=MinInterval, channel=Channel))
def BuildVersionGet(self): self.acidev.write_aci_cmd(AciCommand.AciBuildVersionGet())
def ValueSet(self, Handle, Data): self.acidev.write_aci_cmd( AciCommand.AciValueSet(handle=Handle, data=Data, length=(len(Data) + 3)))
def ChannelGet(self): self.acidev.write_aci_cmd(AciCommand.AciChannelGet())
def ValueDisable(self, Handle): self.acidev.write_aci_cmd(AciCommand.AciValueDisable(handle=Handle))
def run_app_command(self, command): data = command.serialize() return self.aci.write_aci_cmd(AciCommand.AciAppCommand(data=data,length=len(data)+1))
def AppCommand(self, data=[]): self.acidev.write_aci_cmd(AciCommand.AciAppCommand(data=data,length=len(data)+1))