Search code examples
ibeacon-androidandroid-ibeaconeddystone

Broadcast different Eddystone packets in Android


I would like to broadcast multiple Eddystone packets in Android. I read that it cannot be done simultaneously however, we have to create a timer and broadcast multiple packets. I want to know if there are any restrictions like how many unique eddystone packets can we broadcast? Can I broadcast different and multiple packets in 1 second?


Solution

  • Some Android devices do allow sending multiple advertisements simultaneously. It all depends on the chipset on the phone. There is no way to know this in advance, but you can repeatedly attempt to start advertising with a different beacon identifier set until you get an error message. Here is the code with the Android Beacon Library:

    Beacon beacon = new Beacon.Builder()
        .setId1("2f234454-cf6d-4a0f-adf2-f4911ba9ffa6")
        .setId2("1")
        .setId3("2")
        .setManufacturer(0x0118)
        .setTxPower(-59)
        .setDataFields(Arrays.asList(new Long[] {0l}))
        .build();
    BeaconParser beaconParser = new BeaconParser()
        .setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25");
    BeaconTransmitter beaconTransmitter = new BeaconTransmitter(getApplicationContext(), beaconParser); 
    beaconTransmitter.startAdvertising(beacon beacon, new AdvertiseCallback() {
      public void onStartFailure(int errorCode) {
          // Called when failed
      }
      public void   onStartSuccess(AdvertiseSettings settingsInEffect) {
      }
    
    });
    

    It is also possible to use a timer to simulate multiple beacons by changing the identifiers every 100ms or so. Because the transmitter will have the same MAC address for each beacon identifier, different types of receivers will handle this differently. iOS will track them as multiple beacons, and devices using the Android Beacon Library will as well.