mirror of
https://github.com/LukeSpad/BeoGateway.git
synced 2024-12-23 21:51:51 +00:00
Add files via upload
This commit is contained in:
parent
cc056bca34
commit
82af7d348c
1 changed files with 33 additions and 27 deletions
24
main.py
24
main.py
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue