Want to change Major Minor ID with my app

Hello.

I am developer with estimote beacon and android studio application.

I want to change my beacon’s major, minor ID with my own app(Android studio)!!!

How can I do??

Are there sample android studio codes about that?

Hey @yeon,

first you have to connect to your beacon. After, you will be able to change the settings of your beacon (major & minor for example).

  1. initialize the connection to the Estimote cloud with EstimoteSDK.initialize() using your app’ ID and token,

  2. set a DiscoverableDevice listener on your BeaconManager instance,

  3. start the discovery with BeaconManager.startConfigurableDevicesDiscovery(),

  4. when having the scan result, choose the beacon you want to connect to,

  5. connect to this beacon with DeviceConnection.connect(),

  6. change the settings with DeviceConnection.edit(),

  7. disconnect from the beacon with DeviceConnection.close(),

Wow

Thanks for your detail answer.

But I can’t handle about that well because of my bad coding ability.

Could you teach me with some sample codes…?? Sorry.TT

Re,

So basically you will have an Android Activity in you app’ to connect to the beacon. Let’s name the activity ConnectActivity. Your app’s name will be MyApplication.

MyApplication.java
public class MyApplication extends Application {
    private final static String APP_ID = "my app' ID here as a string";
    private final static String APP_TOKEN = "my app' token here as a string";

    @Override
    public void onCreate() {
        super.onCreate();

        // This will initialize the connection with the Estimote cloud (1):
        EstimoteSDK.initialize(this.getApplicationContext(), APP_ID, APP_TOKEN);
    }
}

After, you will have to use the BeaconManager class.

ConnectActivity.java
public class ConnectActivity extends AppCompatActivity {
    private BeaconManager beaconManager;
    private ConfigurableDevice device;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Get an instance of the BeaconManager class (2.1):
        this.beaconManager = new BeaconManager(this);

        this.device = null;

        // Set a listener to the BeaconManager instance (2.2):
        this.beaconManager.setConfigurableDevicesListener(new BeaconManager.ConfigurableDevicesListener() {
            @Override
            public void onConfigurableDevicesFound(List<ConfigurableDevice> configurableDevices) {
                // Choose here which device on the list you want to connect to (4):
                device = [...]

                // Connect to the device to change settings (5):
                connectAndWriteToDevice(device);
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();

        if (this.device == null) {
            this.beaconManager.connect(BeaconManager.ServiceReadyCallback() {
                @Override
                public void onServiceReady() {
                    // Start the scanning after being connected to the BeaconService (3):
                    beaconManager.startConfigurableDevicesDiscovery();
                }
            });
        }
    }

    @Override
    protected void onPause() {
        this.beaconManager.stopConfigurableDevicesDiscovery();

        super.onPause();
    }
}

    @Override
    protected void onDestroy() {
        this.beaconManager.disconnect();

        super.onDestroy();
    }

    private void connectAndWriteToDevice(ConfigurableDevice device) {
        DeviceConnectionProvider deviceConnectionProvider = new DeviceConnectionProvider(this);

        deviceConnectionProvider.connectToService(new DeviceConnectionProvider.ConnectionProviderCallback() {
            @Override
            public void onConnectedToService() {
                DeviceConnection deviceConnection = connectionProvider.getConnection(device);

                deviceConnection.connect(new DeviceConnectionCallback() {
                    @Override
                    public void onConnected() {
                        // Change the settings in the device (6):
                        [...]

                        // Disconnect from the device (7):
                        deviceConnection.close();
                    }
                }

                deviceConnection.destroy();
            }
        });
    }

If you need more help, see the JavaDoc.

Hope it helps :slight_smile:

1 Like

What a kind man!

I envy you because you are so smart about this beacon and Android studio.

I just copy and paste your code in my application… But there are some problems about “beaconManager.setConfigurableDevicesListener”.

I will study with your sample codes.

Thank you for your good will.

1 Like