def ts_send(addr):
    global ts_sent_update, ts_updated, ts_noupdate
    if addr in ts_noupdate:
        return;
    print "Sending Timesync message to "+addr
    packet = sensor_packet.timesync_packet()
    send_to_xbee(addr, packet )
    ts_sent_update[addr] = time.time();
                            if tm2:
                                records[midx] = sensor_packet.set_packet_timestamp(records[midx],tm2 - offset);                            
                                
                        client.desynched = True
                    else:
                        if client.desynched:
                            print "Client at %s synchronized"%uid
                        client.desynched = False
                
                for m in records:
                    if sensor_packet.read_packet_type(m) == sensor_packet.MT_DEVICE_IDENTIFIER:
                        r = sensor_packet.read_packet(m)
                        uid = r[3]
                        
                print "%d records from %s"%(len(records),uid)
                
                for m in records:
                    if sensor_packet.read_packet_type(m) != sensor_packet.MT_DEVICE_IDENTIFIER:
                        sensor_packet.publish(uid,m)
        except:
            import traceback
            traceback.print_exc();
    
    for client in clients:
        if client.desynched:
            send_message(client, sensor_packet.timesync_packet())
            client.desynched = False
    
    time.sleep(0.01);