Retrieve Sensor information


#1

Hello,

I am trying to build an android application to gather sensor information from my estimote beacons. I am new to this technology but not new to android. Could someone help me in creating this application. I am also trying to claim a beacon which was given to me but I keep getting the “Claim failed due to server error. Please try after few minutes”. Also, what are the plugins required in android studio to create an app? Are there any templates already available which I could use?

Thanks.


#2

Hi @saurabhrao,

first, you have to know what kind of beacon you have: Proximity beacon, Location beacon or Sticker beacon? You can watch for the Estimote web-site. To be sure, note that the Sticker beacon is the small one, the Proximity beacon is the “basic” one and the Location beacon the stronger one. It will inform you with the data you can have from your beacon:

  • if you have a Proximity beacon, you can catch the Eddystone-TLM packets sent,
  • with a Location beacon, you can both recover the Eddystone-TLM and Estimote Telemetry packets that your beacon broadcasts,
  • the Sticker beacons have their own Nearable with Telemetry packet.

To build an Android app’ using the Estimote technology, you have to follow the instructions given in the Estimote Android SDK GitHub page:

Overview:
  • be sure that your Android device supports the Bluetooth Low Energy (minimum Android SDK version: 9),
  • create an Android Studio new project, add the following line to your build.gradle file: ``` dependencies { compile 'com.estimote:sdk:1.0.3:release@aar' } ``` and **synchronize** you project,
  • verify the **permissions** you need to use the Bluetooth features:
    • **Bluetooth** permissions: `android.permission.BLUETOOTH` and `android.permission.BLUETOOTH_ADMIN`,
    • **location services** activated and `android.permission.ACCES_COARSE_LOCATION` and `android.permission.ACCESS_FINE_LOCATION` for **Android M or later**,
  • take care on **Android N and later** because background BLE scanning is limited so you can't set a scan period under 6 seconds.

You have some templates in the GitHub (here), but it’s more convenient to follow the on-line guide. Follow the changelog file if you’re blocked with old classes/methods.


I can’t help you with the claim issue, need here an Estimote staff member.


#3

Hi @Ximun,

I have question regarding gathering telemetry information. I am getting an incompatible type error while following the tutorial online.

I have attached a snippet of the code. he startTelemetry function is type void and we are trying to put it in to a string. Could you please let me know what the solution could be?


#4

Hey,

looking at your code, I can’t see any listener put to the BeaconManager instance:

this.beaconManager.setTelemetryListener(new BeaconManager.TelemetryListener {
    public void onTelemetriesFound(List<EstimoteTelemetry> telemetries) {
        // Retrieve your sensor datas here.
    }
});

#5

Hey Sorry,

I hadn’t put the whole screenshot in. i shall do that now. Thanks for the prompt reply.


#6

Try not to check the return value (because it’s void):

@Override
public void onServiceReady() {
    this.beaconManager.startTelemetryDiscovery();
}

And to stop the discovery:

this.beaconManager.stopTelemetryDiscovery();

Also, why have you 2 onCreate() methods? I think there is only one onCreate() method overrided, this one:

protected void onCreate(Bundle savedInstanceState);

#7

The Oncreate function is a part of the previous tutorial for ranging of the beacons. Should i remove that? How will it still connect? Attaching a screenshot. Appreciate the help.


#8

I don’t understand why you have 2 onCreate() methods with:

  1. a ranging initialization,
  2. a telemetry discovery initialization.

#9

I was following this tutorial:-
http://developer.estimote.com/android/tutorial/part-3-ranging-beacons/

and now I’m continuing with this one:-
http://developer.estimote.com/sensors/estimote-telemetry/

Should both of them be on separate Java classes?


#10

OK ^^

Yes I think you should do 2 projects (2 applications). If you know how to code in Java Android, you can put an Activity for each process.

So your code should be like:
public class MyTelemetryListener extends AppCOmpatActivity {
    private BeaconManager beaconManager;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.id.activity_main);

        this.beaconManager = new BeaconManager(this);
        this.beaconManager.setTelemetryListener(new BeaconManager.TelemetryListener {
            @Override
            public void onTelemetriesFound(List<EstimoteTelemetry> telemetries) {
                for (EstimoteTelemetry t : telemetries) {
                    Log.d("TELEMETRY", "beaconID: " +  t.deviceId + "temperature: " + t.temperature + "°C.");
                }
            }
        });
    }

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

        this.beaconManager.connect(new BeaconManager.ServiceReadyCallback {
            @Override
            public void onServiceReady() {
                beaconManager.startTelemetryDiscovery();
            }
        }
    }

    @Override
    protected void onPause() {
        this.beaconManager.stopTelemetryDiscovery();
        
        super.onPause();
    }

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

        super.onDestroy();
    }
}

#11

Hi Thanks for the help. I keep getting this error:

even though I’ve already done this:


#12

Hey,

the initialize() method signature is:

public static void initialize(android.content.Context, java.lang.String, java.lang.String)

so we can’t verify…

  • Have you an active Internet connection ? It could be that.
  • Also, what Estimote Android SDK version are you using?
    Personnaly, it works well with the 1.0.1 version.

#13

Hi,
That’s not working,


#14

Hey,

are you calling initialize() in your application or activity onCreate() method?


#15

I’m calling it in the application class not the main_activity. Where do I need to call it?


#16

Calling it in the MyApplication.java class file is what you need to do:

public class MyApplication extends Application {
    private final static String APP_ID = <your app ID>;
    private final static String APP_TOKEN = <your app token>;
    @Override
    public void onCreate() {
        super.onCreate();

        EstimoteSDK.initialize(this, APP_ID, APP_TOKEN);
    }
}

#17

Hi,
I tried both with and without quotes. It doesn’t like it


#18

No, it’s like:

private final static String APP_ID = "beacon-app2-bn1";

#19

Hi,

I am now getting the following error,

I am using Estimote SDK 1.0.1 as you suggested.


#20

Did you write in your application’s onCreate() method:

EstimoteSDK.initialize(this.getApplicationContext(), APP_ID, APP_TOKEN);