コード例 #1
0
     print "Device %s reporting in"%idstr
     client.UID = idstr
 else:
     if client.UID:
         uid = client.UID
     else:
         uid = client.ip[0]
         
     if msgtype == sensor_packet.MT_RECORDSTORE_DATA:
         records = result[2]
     else:
         records = [msg]
     
     for idx in range(len(records)-1,-1,-1):
         last_rec = records[idx]
         tm = sensor_packet.read_packet_timestamp(last_rec)
         if tm:
             break;                    
     
     if tm:
         if abs(time.time() - tm) > MAX_TIMESTAMP_ERROR:
             offset = tm - time.time()
             for midx in range(len(records)):
                 tm2 = sensor_packet.read_packet_timestamp(records[midx])
                 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
コード例 #2
0
                if frame['id'] == 'rx_long_addr':
                    data = frame['rf_data']
                else:
                    tdata = frame['samples']
                    data = "DIGI/"
                    for delem in tdata:
                        print delem
                        for key,val in delem.iteritems():
                            data += str(key)+"/"+str(val)+"/"
                    print "Digi data: "+data
                    ts_noupdate.add(source_addr)
                
                #print "<"+source_addr+" : "+utils.hexify(data)
                children_cache.add(source_addr)
                
                rtime = sensor_packet.read_packet_timestamp(data)
                if rtime != None:
                    if time.time() - rtime <= MAX_TIMESTAMP_ERROR:
                        if source_addr not in ts_updated:
                            print "Device at "+source_addr+" synced."
                            ts_updated.add(source_addr)
                            if source_addr in ts_sent_update:
                                ts_sent_update.pop(source_addr)
                    else:
                        if source_addr in ts_updated:
                            print "Device at "+source_addr+" desynced."
                            ts_updated.remove(source_addr)

                if xbee_relay_IF.connected():
                    xbee_relay_IF.publish(source_addr,data)