Add files via upload

This commit is contained in:
LukeSpad 2021-11-25 19:17:50 +00:00 committed by GitHub
parent cc056bca34
commit 82af7d348c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

24
main.py
View file

@ -24,16 +24,16 @@ if __name__ == '__main__':
if len(payload) + 9 < 73:
logging.info("\n\t----------------------------------------------------------------------------" +
"\n\t" + name + ": <--Data-received!-<< " +
datetime.now().strftime("on %D at %H:%M:%S") +
datetime.now().strftime("on %d/%m/%y at %H:%M:%S") +
"\n\t----------------------------------------------------------------------------" +
"\n\tHeader: " + header +
"\n\tPayload: " + payload +
"\n\t============================================================================" +
message)
elif len(payload) + 9 > 73 and len(payload) + 9 < 132:
elif 73 < len(payload) + 9 < 132:
logging.info("\n\t----------------------------------------------------------------------------" +
"\n\t" + name + ": <--Data-received!-<< " +
datetime.now().strftime("on %D at %H:%M:%S") +
datetime.now().strftime("on %d/%m/%y at %H:%M:%S") +
"\n\t----------------------------------------------------------------------------" +
"\n\tHeader: " + header +
"\n\tPayload: " + payload[:66] + "\n\t\t" + payload[66:132] +
@ -42,7 +42,7 @@ if __name__ == '__main__':
else:
logging.info("\n\t----------------------------------------------------------------------------" +
"\n\t" + name + ": <--Data-received!-<< " +
datetime.now().strftime("on %D at %H:%M:%S") +
datetime.now().strftime("on %d/%m/%y at %H:%M:%S") +
"\n\t----------------------------------------------------------------------------" +
"\n\tHeader: " + header +
"\n\tPayload: " + payload[:66] + "\n\t\t" + payload[66:132] + "\n\t\t" + payload[132:] +
@ -54,7 +54,7 @@ if __name__ == '__main__':
logging.debug(self.name + " Protocol Client last received " + str(last) + " seconds ago")
# Recconect if socket has disconnected, or if no response received to last ping
if not self.is_connected or last > 60:
logging.info("\t" + self.name + ": Reconnecting\n")
logging.info("\t" + self.name + ": Reconnecting!")
self.handle_close()
time.sleep(0.5)
self.client_connect()
@ -86,20 +86,26 @@ if __name__ == '__main__':
if mlcli.isBLGW:
logging.info('Creating BLGW Home Integration Protocol Client...')
blgw = BLHIP.BLHIPClient(host, port[1], user, pwd, 'BLGW Home Integration Protocol', cb)
mltn = None
else:
logging.info('Creating MLGW Home Integration Protocol Client...')
mltn = MLtn.MLtnClient(host, port[2], user, pwd, 'ML telnet client', cb)
blgw = None
# Main program loop
while True:
# Ping all connections every 10 minutes to prompt messages on the network
asyncore.loop(count=595, timeout=1)
if mlgw.is_connected: mlgw.ping()
if mlcli.is_connected: mlcli.ping()
if mlgw.is_connected:
mlgw.ping()
if mlcli.is_connected:
mlcli.ping()
if mlcli.isBLGW:
if blgw.is_connected: blgw.ping()
if blgw.is_connected:
blgw.ping()
else:
if mltn.is_connected: mltn.ping()
if mltn.is_connected:
mltn.ping()
# Check the connections approximately every 10 minutes to keep sockets open
asyncore.loop(count=5, timeout=1)