def setDouble(self,name, value, ignoreCurrent=False): writer = RemoteMeDataWriter() writer.writeUInt16(remotemeStruct.VariableType.DOUBLE._value_) writer.writeString(name) writer.writeDouble(1 if value else 0) self.__remoteMe.send( remotemeMessages.getVariableChangeMessage(self.__remoteMe.getDeviceId(), ignoreCurrent, writer.getBytes()))
def setText2(self, name, value, value2, ignoreCurrent=False): writer = RemoteMeDataWriter() writer.writeUInt16(remotemeStruct.VariableType.TEXT_2._value_) writer.writeString(name) writer.writeString(value) writer.writeString(value2) self.__remoteMe.send( remotemeMessages.getVariableChangeMessage(self.__remoteMe.getDeviceId(), ignoreCurrent, writer.getBytes()))
def setIntegerBoolean(self,name, value, value2, ignoreCurrent=False): writer = RemoteMeDataWriter() writer.writeUInt16(remotemeStruct.VariableType.INTEGER_BOOLEAN._value_) writer.writeString(name) writer.writeInt32(value) writer.writeUInt8(1 if value2 else 0) self.__remoteMe.send( remotemeMessages.getVariableChangeMessage(self.__remoteMe.getDeviceId(), ignoreCurrent, writer.getBytes()))
def setSmallInteger3(self,name, value, value2, value3, ignoreCurrent=False): writer = RemoteMeDataWriter() writer.writeUInt16(remotemeStruct.VariableType.SMALL_INTEGER_3._value_) writer.writeString(name) writer.writeInt16(value) writer.writeInt16(value2) writer.writeInt16(value3) self.__remoteMe.send( remotemeMessages.getVariableChangeMessage(self.__remoteMe.getDeviceId(), ignoreCurrent, writer.getBytes()))
def getDecreaseGuestKeyCreditAndTimeMessage(senderDeviceId, sessionId, credit, time): writer = RemoteMeDataWriter() writer.writeUInt16( remotemeStruct.MessageType.DECREASE_GUEST_CREDIT_AND_TIME._value_) writer.writeUInt16(8) writer.writeUInt16(senderDeviceId) writer.writeUInt16(sessionId) writer.writeInt16(credit) writer.writeInt16(time) return writer.getBytes()
def getVariableChangeMessage(senderDeviceId, ignoreCurrent, data): size = 5 + len(data) if ignoreCurrent: size += 2 writer = RemoteMeDataWriter() writer.writeUInt16( remotemeStruct.MessageType.VARIABLE_CHANGE_MESSAGE._value_) writer.writeUInt16(size) writer.writeUInt16(senderDeviceId) if ignoreCurrent: writer.writeUInt8(1) writer.writeUInt16(senderDeviceId) else: writer.writeUInt8(0) writer.writeUInt16(1) writer.writeData(data) return writer.getBytes()
def getSubscribeMessage(types): writer = RemoteMeDataWriter() writer.writeUInt16(remotemeStruct.MessageType.EVENT_SUBSCRIBER._value_) writer.writeUInt16(2 * len(types)) for x in types: writer.writeUInt16(x._value_) return writer.getBytes()
def getPushNotificationMessage(webPageDeviceId, title, body, badge, icon, image, vibrate=None): if vibrate is None: vibrate = [] stringSize = 0 stringSize += len(getByteArray(title)) stringSize += len(getByteArray(body)) stringSize += len(getByteArray(badge)) stringSize += len(getByteArray(icon)) stringSize += len(getByteArray(image)) size = 2 + 5 + stringSize + 1 + len(vibrate) writer = RemoteMeDataWriter() writer.writeUInt16( remotemeStruct.MessageType.SEND_PUSH_NOTIFICATION._value_) writer.writeUInt16(size) writer.writeUInt16(webPageDeviceId) writer.writeString(title) writer.writeString(body) writer.writeString(badge) writer.writeString(icon) writer.writeString(image) writer.writeUInt16(len(vibrate)) for x in vibrate: writer.writeUInt8(x / 10) return writer.getBytes()