2

I'm currently developing an Android app on Android Studio to detect and use iBeacons. The part where I have to detect the beacon and get his parameters is done but I'm facing issues to change the value of this parameters for a specific iBeacon with the APIs that are available on the Android system. I've seen that different functions like setId1 (UUID), setId2 (Major), setId3 (Minor) on the Beacon.Builder() class can be use to modify the values but I'm a little bit lost to know how to use this functions on an specific Beacon.

This is the definition of my class that I've created for the Beacon :

class IdBeacon {
    private String UUID;
    private String Major;
    private String Minor;
    private String Distance;
    private String RSSI;
    private String TxPower;

    public IdBeacon (String UUID, String Major, String Minor, String Distance, String RSSI, String TxPower){
        this.UUID = UUID;
        this.Major = Major;
        this.Minor = Minor;
        this.Distance = Distance;
        this.RSSI = RSSI;
        this.TxPower = TxPower;
    }

    public String getUUID() { return UUID; }
    public void setUUID(String UUID) { this.UUID = UUID; }

    public String getMajor() { return Major; }
    public void setMajor(String major) { Major = major; }

    public String getMinor() { return Minor; }
    public void setMinor(String minor) {  Minor = minor;  }

    public String getDistance() { return Distance;  }
    public void setDistance(String distance) { Distance = distance }

    public String getRSSI() { return RSSI; }
    public void setRSSI(String RSSI) { this.RSSI = RSSI; }

    public String getTxPower() { return TxPower; }
    public void setTxPower(String txPower) { this.TxPower = txPower; }
}

This is the code to get the different values of the iBeacon's parameters :

String distance =  String.valueOf(beacons.iterator().next().getDistance());
String Uuid = String.valueOf(beacons.iterator().next().getId1());
String major = String.valueOf(beacons.iterator().next().getId2());
String minor = String.valueOf(beacons.iterator().next().getId3());
String Rssi = String.valueOf(beacons.iterator().next().getRssi());
String TxPower = String.valueOf(beacons.iterator().next().getTxPower());

arrayIdBeacon.clear();
arrayIdBeacon.add(new IdBeacon(Uuid,major,minor,distance,Rssi,TxPower));

And this is the declaration of my ArrayAdapter to deal with the display of my iBeacon's parameters for my view :

public BeaconAdapter(Context context, ArrayList<IdBeacon> idBeacons){
    super(context, 0,idBeacons);
}

@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {

    IdBeacon beacon = getItem(position);

    if (convertView == null){
        convertView = LayoutInflater.from(getContext()).inflate(R.layout.mylist, parent, false);
    }

    TextView tvUuid = (TextView) convertView.findViewById(R.id.ValUUID);
    TextView tvMajor = (TextView) convertView.findViewById(R.id.ValMajor);
    TextView tvMinor = (TextView) convertView.findViewById(R.id.ValMinor);
    TextView tvDist = (TextView) convertView.findViewById(R.id.ValDist);
    TextView tvRSSI = (TextView) convertView.findViewById(R.id.ValRSSI);
    TextView tvTxPower = (TextView) convertView.findViewById(R.id.tvTxPower);

    if (beacon != null){
        tvUuid.setText(beacon.getUUID());
        tvMajor.setText(beacon.getMajor());
        tvMinor.setText(beacon.getMinor());
        tvDist.setText(beacon.getDistance());
        tvRSSI.setText(beacon.getRSSI());
        tvTxPower.setText(beacon.getTxPower());
    }

    return convertView;
}
Draken
  • 3,134
  • 13
  • 34
  • 54
P. Laine
  • 19
  • 1

1 Answers1

0

The Beacon.Builder() class in the Android Beacon Library is used to construct new beacon objects for the purpose of transmitting a beacon advertisement from the Android device itself.

There is no support in the library for changing external hardware beacon configurations, for example, changing the minor. This is true because there is no standard mechanism for doing so. Each beacon hardware manufacturer has its own system for changing the configuration, many of which are proprietary and undocumented.

Bottom line: to change hardware beacon configuration programmatically, you will need a specific SDK from your beacon vendor.

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
  • i am trying to change the uuid of an estimote beacon without using their SDK. is it not possible? any idea why? – zealvault May 29 '18 at 06:42
  • Estimote has a proprietary protocol for configuring their beacons. For this reason you must use their SDK to configure them or reverse engineer it yourself and write your own code. – davidgyoung May 29 '18 at 12:05