예제 #1
0
signal.signal(signal.SIGINT, keyboardInterruptHandler)
print("threads ", threading.activeCount())
#if __name__ == "__main__":
#host="192.168.100.112"
#port=1883
#s_port=1885
#s_group="224.0.18.83"
r_port = 1884  #port gateway advertises on
r_group = "225.0.18.83"  #IP gateways advertises on
#r_port=1883 #port gateways advertises on
#r_group="225.1.1.1" #IP gateways advertises on
client = Client("linh")  #change so only needs name
print("threads ", threading.activeCount())
client.registerCallback(MyCallback())

client.find_gateway(r_port, r_group)
client.loop_start_gw()
while not client.GatewayFound:
    #while True:
    print("waiting for gateway threads ", threading.activeCount())
    time.sleep(10)

############

print("Gateway found")
gateway = gateways.pop(0)
host = gateway[0]
port = gateway[1]

#host="192.168.1.159"
#port=1885
예제 #2
0
    if delay != 0:
        time.sleep(delay)


########

#if __name__ == "__main__":
host = "192.168.1.159"
port = 1885
#m_port=1885 #port gateways advertises on
#m_group="225.0.18.83" #IP gateways advertises on

client = Client("linh")  #change so only needs name
client.message_arrived_flag = False
client.registerCallback(MyCallback())
"""
client.find_gateway(m_port,m_group)

while not client.GatewayFound:
  print("waiting for gateway")
  time.sleep(1)

############



"""
print("threads ", threading.activeCount())
print("connecting ", host)
client.connected_flag = False