title: Synchronize the time between an android app and a server
body: <p>I use a raspberry pi with a Bluetooth dongle to simulate a beacon. I want to measure the time needed for a mobile app to detect the UUID of a beacon when I change it in the raspberry. With this code I found out the server used by the smartphone to synchronize the tile </p>
  
  <pre><code>final Resources res = this.getResources();
          final int id = Resources.getSystem().getIdentifier(
                  "config_ntpServer", "string","android");
          final String defaultServer = res.getString(id); 
  </code></pre>
  
  <p>Than I synchronized the time in the raspberry pi with </p>
  
  <pre><code>sudo ntpdate -u 2.android.pool.ntp.org
  </code></pre>
  
  <p>Before I change the id of the beacon I print the time</p>
  
  <pre><code>timestamp() {
    date +"%T,%3N"
  }
  
  
  timestamp # print timestamp
  
  sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1.....
  </code></pre>
  
  <p>Then I compare the time when I changed the UUID and the time in the logcat when the UUID was seen for the first time and the result is alwayse negative
  UUID changed at 15:33:03,276 and detected at 15:33:02.301.</p>
  
  <p>Is this a synchronization problem? Is there a better way to do this?</p>