def add2list(pkt): stre = -(256-ord(pkt.notdecoded[-4])) dev_found = False for dev in device_list: if pkt.addr2 == dev.mac_addr: dev.update(stre,get_current_minute(), get_current_time()) dev_found = True break if not dev_found: device_list.append(device(stre, get_current_minute(), get_current_time(), pkt.addr2))
def add2list(pkt): stre = -(256 - ord(pkt.notdecoded[-4])) dev_found = False for dev in device_list: if pkt.addr2 == dev.mac_addr: dev.update(stre, get_current_minute(), get_current_time()) dev_found = True break if not dev_found: device_list.append( device(stre, get_current_minute(), get_current_time(), pkt.addr2))
def del_outdated_device(): current_time = get_current_minute() for dev in device_list: if current_time - dev.last_detected_time > c.update_interval: device_list.remove(dev)