def createExtendedMsg(adr, cmd1, cmd2, data, flags = 0x1f):
	msg = Msg.s_makeMessage("SendExtendedMessage")
	populateMsg(msg, adr, cmd1, cmd2, data)
	msg.setByte("messageFlags", flags | 0x10)
	checksum = (~(cmd1 + cmd2 + sum(data)) + 1) & 0xFF
	msg.setByte("userData14", checksum)
	return msg
示例#2
0
def createExtendedMsg(adr, cmd1, cmd2, data, flags=0x1f):
    msg = Msg.s_makeMessage("SendExtendedMessage")
    populateMsg(msg, adr, cmd1, cmd2, data)
    msg.setByte("messageFlags", flags | 0x10)
    checksum = (~(cmd1 + cmd2 + sum(data)) + 1) & 0xFF
    msg.setByte("userData14", checksum)
    return msg
示例#3
0
    def getid(self):
        """getid()
		get modem id data"""
        self.querier = Querier(InsteonAddress("00.00.00"))
        self.querier.setMsgHandler(IMInfoMsgHandler("getid"))
        msg = Msg.s_makeMessage("GetIMInfo")
        self.querier.sendMsg(msg)
	def getid(self):
		"""getid()
		get modem id data"""
		self.querier = Querier(InsteonAddress("00.00.00"))
		self.querier.setMsgHandler(IMInfoMsgHandler("getid"))
		msg = Msg.s_makeMessage("GetIMInfo")
		self.querier.sendMsg(msg)
示例#5
0
    def getIMConfig(self):
        """getIMConfig()
		get modem configuration flags byte"""
        self.querier = Querier(InsteonAddress("00.00.00"))
        self.querier.setMsgHandler(IMConfigMsgHandler("getIMConfig"))
        msg = Msg.s_makeMessage("GetIMConfig")
        self.querier.sendMsg(msg)
	def linkAsResponder(self, group):
		"""linkAsResponder(group)
		puts modem in link mode on group "group" """
		self.querier.setMsgHandler(DefaultMsgHandler("start linking"))
		msg = Msg.s_makeMessage("StartALLLinking")
		msg.setByte("LinkCode", 0x00)
		msg.setByte("ALLLinkGroup", group)
		self.querier.sendMsg(msg)
示例#7
0
    def linkAsResponder(self, group):
        """linkAsResponder(group)
		puts modem in link mode on group "group" """
        self.querier.setMsgHandler(DefaultMsgHandler("start linking"))
        msg = Msg.s_makeMessage("StartALLLinking")
        msg.setByte("LinkCode", 0x00)
        msg.setByte("ALLLinkGroup", group)
        self.querier.sendMsg(msg)
示例#8
0
    def unlinkAsController(self, group):
        """unlinkAsController(group)
		puts modem in unlink mode to unlink as controller on group "group" """
        self.querier.setMsgHandler(DefaultMsgHandler("unlink as controller"))
        msg = Msg.s_makeMessage("StartALLLinking")
        msg.setByte("LinkCode", 0xFF)
        msg.setByte("ALLLinkGroup", group)
        self.querier.sendMsg(msg)
	def unlinkAsController(self, group):
		"""unlinkAsController(group)
		puts modem in unlink mode to unlink as controller on group "group" """
		self.querier.setMsgHandler(DefaultMsgHandler("unlink as controller"))
		msg = Msg.s_makeMessage("StartALLLinking")
		msg.setByte("LinkCode", 0xFF)
		msg.setByte("ALLLinkGroup", group)
		self.querier.sendMsg(msg)
	def linkAsEither(self, group):
		"""linkAsEither(group)
		puts modem in link mode to link as controller or responder on group "group" """
		self.querier.setMsgHandler(
			DefaultMsgHandler("link/unlink as controller or responder"))
		msg = Msg.s_makeMessage("StartALLLinking")
		msg.setByte("LinkCode", 0x03)
		msg.setByte("ALLLinkGroup", group)
		self.querier.sendMsg(msg)
 def __bcast(self, group, cmd1, cmd2):
     msg = Msg.s_makeMessage("SendStandardMessage")
     flags = 0xcf
     adr = InsteonAddress(0x00, 0x00, group & 0xFF)
     msg.setAddress("toAddress", adr)
     msg.setByte("messageFlags", flags)
     msg.setByte("command1", cmd1)
     msg.setByte("command2", cmd2)
     iofun.writeMsg(msg)
	def __bcast(self, group, cmd1, cmd2):
		msg = Msg.s_makeMessage("SendStandardMessage")
		flags = 0xcf
		adr = InsteonAddress(0x00, 0x00, group & 0xFF)
		msg.setAddress("toAddress", adr)
		msg.setByte("messageFlags", flags)
		msg.setByte("command1", cmd1)
		msg.setByte("command2", cmd2)
		iofun.writeMsg(msg)
示例#13
0
    def linkAsEither(self, group):
        """linkAsEither(group)
		puts modem in link mode to link as controller or responder on group "group" """
        self.querier.setMsgHandler(
            DefaultMsgHandler("link/unlink as controller or responder"))
        msg = Msg.s_makeMessage("StartALLLinking")
        msg.setByte("LinkCode", 0x03)
        msg.setByte("ALLLinkGroup", group)
        self.querier.sendMsg(msg)
	def __makeModMsg(self, addr, group, controlCode, recordFlags, data, txt):
		msg = Msg.s_makeMessage("ManageALLLinkRecord");
		msg.setByte("controlCode", controlCode); # mod. first ctrl found or add
		msg.setByte("recordFlags", recordFlags);
		msg.setByte("ALLLinkGroup", group);
		msg.setAddress("linkAddress", InsteonAddress(addr));
		msg.setByte("linkData1", data[0] & 0xFF)
		msg.setByte("linkData2", data[1] & 0xFF)
		msg.setByte("linkData3", data[2] & 0xFF)
		return msg;
示例#15
0
def createExtendedMsg2(adr, cmd1, cmd2, data, flags=0x1f):
    msg = Msg.s_makeMessage("SendExtendedMessage")
    populateMsg(msg, adr, cmd1, cmd2, data)
    msg.setByte("messageFlags", flags | 0x10)
    crc = calcCRC(msg)
    crcLow = crc & 0xFF
    crcHigh = (crc >> 8) & 0xFF
    msg.setByte("userData13", int(crcHigh & 0xFF))
    msg.setByte("userData14", int(crcLow & 0xFF))
    return msg
示例#16
0
def createStdMsg(adr, flags, cmd1, cmd2, group):
    msg = Msg.s_makeMessage("SendStandardMessage")
    if group != -1:
        flags |= 0xc0
        adr = InsteonAddress(0x00, 0x00, group & 0xFF)
    msg.setAddress("toAddress", adr)
    msg.setByte("messageFlags", flags)
    msg.setByte("command1", cmd1)
    msg.setByte("command2", cmd2)
    return msg
def createExtendedMsg2(adr, cmd1, cmd2, data, flags = 0x1f):
	msg = Msg.s_makeMessage("SendExtendedMessage")
	populateMsg(msg, adr, cmd1, cmd2, data)
	msg.setByte("messageFlags", flags | 0x10)
	crc = calcCRC(msg)
	crcLow   = crc & 0xFF
	crcHigh  = (crc >> 8) & 0xFF
	msg.setByte("userData13", int(crcHigh & 0xFF))
	msg.setByte("userData14", int(crcLow & 0xFF))
	return msg
def createStdMsg(adr, flags, cmd1, cmd2, group):
	msg = Msg.s_makeMessage("SendStandardMessage")
	if group != -1:
		flags |= 0xc0
		adr = InsteonAddress(0x00, 0x00, group & 0xFF)
	msg.setAddress("toAddress", adr)
	msg.setByte("messageFlags", flags)
	msg.setByte("command1", cmd1)
	msg.setByte("command2", cmd2)
	return msg
示例#19
0
 def msgReceived(self, msg):
     if msg.isPureNack():
         return
     if msg.getByte("Cmd") == 0x69 or msg.getByte("Cmd") == 0x6a:
         if msg.getByte("ACK/NACK") == 0x15:
             self.done()
     elif msg.getByte("Cmd") == 0x57:
         self.dbMsg(msg)
         iofun.writeMsg(Msg.s_makeMessage("GetNextALLLinkRecord"))
     else:
         out("got unexpected msg: " + msg.toString())
示例#20
0
 def __makeModMsg(self, addr, group, controlCode, recordFlags, data, txt):
     msg = Msg.s_makeMessage("ManageALLLinkRecord")
     msg.setByte("controlCode", controlCode)
     # mod. first ctrl found or add
     msg.setByte("recordFlags", recordFlags)
     msg.setByte("ALLLinkGroup", group)
     msg.setAddress("linkAddress", InsteonAddress(addr))
     msg.setByte("linkData1", data[0] & 0xFF)
     msg.setByte("linkData2", data[1] & 0xFF)
     msg.setByte("linkData3", data[2] & 0xFF)
     return msg
示例#21
0
	def msgReceived(self, msg):
		if msg.isPureNack():
			return;
		if msg.getByte("Cmd") == 0x69 or msg.getByte("Cmd") == 0x6a :
			if msg.getByte("ACK/NACK") == 0x15:
				self.done()
		elif msg.getByte("Cmd") == 0x57:
			self.dbMsg(msg)
			iofun.writeMsg(Msg.s_makeMessage("GetNextALLLinkRecord"))
		else:
			out("got unexpected msg: " + msg.toString())
示例#22
0
	def makeMsg(self, offset, laddr, group, linkType, data):
		msg   = Msg.s_makeMessage("SendExtendedMessage")
		msg.setAddress("toAddress", InsteonAddress(self.getAddress()))
		msg.setByte("messageFlags", 0x1f)
		msg.setByte("command1", 0x2f)
		msg.setByte("command2", 0x00)
		msg.setByte("userData1", 0x00) # don't care info
		msg.setByte("userData2", 0x02) # set database
		msg.setByte("userData3", offset >> 8)  # high byte
		msg.setByte("userData4", offset & 0xff) # low byte
		msg.setByte("userData5", 8)  # number of bytes set:  1...8
		msg.setByte("userData6", linkType)
		msg.setByte("userData7", group)
		msg.setByte("userData8", laddr.getHighByte())
		msg.setByte("userData9", laddr.getMiddleByte())
		msg.setByte("userData10", laddr.getLowByte())
		# depends on mode: could be e.g. trigger point
		msg.setByte("userData11", data[0])
		msg.setByte("userData12", data[1]) # unused?
		msg.setByte("userData13", data[2]) # unused?
		rb = msg.getBytes("command1", 15);
		checksum = (~sum(rb) + 1) & 0xFF
		msg.setByte("userData14", checksum)
		return msg
	def makeMsg(self, offset, laddr, group, linkType, data):
		msg   = Msg.s_makeMessage("SendExtendedMessage")
		msg.setAddress("toAddress", InsteonAddress(self.getAddress()))
		msg.setByte("messageFlags", 0x1f)
		msg.setByte("command1", 0x2f)
		msg.setByte("command2", 0x00)
		msg.setByte("userData1", 0x00) # don't care info
		msg.setByte("userData2", 0x02) # set database
		msg.setByte("userData3", offset >> 8)  # high byte
		msg.setByte("userData4", offset & 0xff) # low byte
		msg.setByte("userData5", 8)  # number of bytes set:  1...8
		msg.setByte("userData6", linkType)
		msg.setByte("userData7", group)
		msg.setByte("userData8", laddr.getHighByte())
		msg.setByte("userData9", laddr.getMiddleByte())
		msg.setByte("userData10", laddr.getLowByte())
		# depends on mode: could be e.g. trigger point
		msg.setByte("userData11", data[0])
		msg.setByte("userData12", data[1]) # unused?
		msg.setByte("userData13", data[2]) # unused?
		rb = msg.getBytes("command1", 15);
		checksum = (~sum(rb) + 1) & 0xFF
		msg.setByte("userData14", checksum)
		return msg
示例#24
0
    def cancelLinking(self):
        """cancelLinking()
		takes modem out of linking or unlinking mode"""
        self.querier.setMsgHandler(DefaultMsgHandler("cancel linking"))
        msg = Msg.s_makeMessage("CancelALLLinking")
        self.querier.sendMsg(msg)
	def cancelLinking(self):
		"""cancelLinking()
		takes modem out of linking or unlinking mode"""
		self.querier.setMsgHandler(DefaultMsgHandler("cancel linking"))
		msg = Msg.s_makeMessage("CancelALLLinking")
		self.querier.sendMsg(msg)
示例#26
0
	def start(self):
		self.db.clear()
		self.keepRunning = True
		iofun.addListener(self)
		iofun.writeMsg(Msg.s_makeMessage("GetFirstALLLinkRecord"))
示例#27
0
 def start(self):
     self.db.clear()
     self.keepRunning = True
     iofun.addListener(self)
     iofun.writeMsg(Msg.s_makeMessage("GetFirstALLLinkRecord"))