public void addIBeacon(IBeacon iBeacon) {
   if (rangedIBeacons.containsKey(iBeacon)) {
     RangedIBeacon rangedIBeacon = rangedIBeacons.get(iBeacon);
     Log.d(
         TAG,
         "adding "
             + iBeacon.getProximityUuid()
             + " to existing range for: "
             + rangedIBeacon.getProximityUuid());
     rangedIBeacon.addRangeMeasurement(iBeacon.getRssi());
   } else {
     Log.d(TAG, "adding " + iBeacon.getProximityUuid() + " to new rangedIBeacon");
     rangedIBeacons.put(iBeacon, new RangedIBeacon(iBeacon));
   }
 }
  private JSONObject mapOfBeacon(IBeacon region) throws JSONException {
    JSONObject dict = new JSONObject();

    // beacon id
    dict.put("uuid", region.getProximityUuid());
    dict.put("major", region.getMajor());
    dict.put("minor", region.getMinor());

    // proximity
    dict.put("proximity", nameOfProximity(region.getProximity()));

    // signal strength and transmission power
    dict.put("rssi", region.getRssi());
    dict.put("tx", region.getTxPower());

    // accuracy = rough distance estimate limited to two decimal places (in metres)
    // NO NOT ASSUME THIS IS ACCURATE - it is effected by radio interference and obstacles
    dict.put("accuracy", Math.round(region.getAccuracy() * 100.0) / 100.0);

    return dict;
  }