Ejemplo n.º 1
0
def command_sender():

    while True:
        try:
            kwargs = command_q.get()
            seq_num = get_seq_num()
            print("seq num", seq_num)

            ack = False
            for i in range(RETRIES):
                with send_lock:
                    sock.sendto(
                        tools.gen_packet(kwargs["hue"], kwargs["sat"],
                                         kwargs["bri"], kwargs["kel"],
                                         seq_num),
                        (kwargs["bulb_ip"], UDP_PORT))

                # wait...
                time.sleep(DELAY * (i * 1.5 + 1))

                # do we have ACK?
                if time.time() - ACKS[seq_num] < MAX_ACK_AGE:
                    ack = True
                    print("ACK confirmed, no more retries needed")
                    break
            if not ack:
                print("Unable to ACK packet with seq num", seq_num)

        except Exception as e:
            print("Unable to process command: {}".format(e))
Ejemplo n.º 2
0
def command_sender():

    while True:
        try:
            kwargs = command_q.get()
            seq_num = get_seq_num()
            print "seq num", seq_num

            ack = False
            for i in range(RETRIES):
                with send_lock:
                    sock.sendto(
                        tools.gen_packet(kwargs["hue"], kwargs["sat"], kwargs["bri"], kwargs["kel"], seq_num),
                        (kwargs["bulb_ip"], UDP_PORT),
                    )

                # wait...
                time.sleep(DELAY * (i * 1.5 + 1))

                # do we have ACK?
                if time.time() - ACKS[seq_num] < MAX_ACK_AGE:
                    ack = True
                    print "ACK confirmed, no more retries needed"
                    break
            if not ack:
                print "Unable to ACK packet with seq num", seq_num

        except Exception, e:
            print "Unable to process command: {}".format(e)
Ejemplo n.º 3
0
def set_HSBK(bulb_ip, hue, sat, bri, kel=3500):
    print(hue, sat, bri, kel)
    for _ in range(RETRIES):
        sock.sendto(gen_packet(hue, sat, bri, kel, SEQ_NUM),
                    (bulb_ip, UDP_PORT))
        time.sleep(DELAY)
Ejemplo n.º 4
0
def set_HSBK(bulb_ip, hue, sat, bri, kel=3500):
    print hue, sat, bri, kel
    for _ in range(RETRIES):
        sock.sendto(gen_packet(hue, sat, bri, kel, SEQ_NUM),
                    (bulb_ip, UDP_PORT))
        time.sleep(DELAY)