API – BLE Scan Callback Error

API – BLE Scan Callback Error

NAOSDK integrates a new callback, onBleError, to notify the application when the SDK is unable to scan BLE measurements.

Currently, this interface includes the error codes from the Android scanCallback API.”

 

This callback is integrated into the NAOSensorsListener interface like this

1**
2* Sensor state callbacks
3*/
4public interface NAOSensorsListener {/**
5* Receives notification that the client app needs to display calibration message to the user.
6*/
7void requiresCompassCalibration();
8 
9/**
10* Receives notification that the Wifi needs to be activated on the device
11*/
12void requiresWifiOn();
13 
14/**
15* Receives notification that the Bluetooth needs to be activated on the device
16*/
17void requiresBLEOn();
18 
19/**
20* Receives notification that the Localisation needs to be activated on the device
21*/
22void requiresLocationOn();
23 
24/**
25* Receives notification when BLE scan failed
26* @param err : the error code from Android API (ScanCallback.class)
27* SCAN_FAILED_ALREADY_STARTED = 1;
28* SCAN_FAILED_APPLICATION_REGISTRATION_FAILED = 2;
29* SCAN_FAILED_FEATURE_UNSUPPORTED = 4;
30* SCAN_FAILED_INTERNAL_ERROR = 3;
31* SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES = 5;
32* SCAN_FAILED_SCANNING_TOO_FREQUENTLY = 6;
33*/
34void onBleError(int err);
35}

Here is the list of errors codes that can be notified

 

err .Android code
1SCAN_FAILED_ALREADY_STARTED
2SCAN_FAILED_APPLICATION_REGISTRATION_FAILED
3SCAN_FAILED_FEATURE_UNSUPPORTED
4SCAN_FAILED_INTERNAL_ERROR
5SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES
6SCAN_FAILED_SCANNING_TOO_FREQUENTLY

Code implementation example when the scan error does not allow BLE sensor to be restarted

1@Override
2public void onBleError(int err) {
3// get error code from Ble Scanner
4if (err == ScanCallback.SCAN_FAILED_APPLICATION_REGISTRATION_FAILED) {
5// suggest the user to restart the phone
6}
7}
    • Related Articles

    • Monitoring API

      Overview The monitoring API can be used to receive monitoring information about all tags and gateways of a given site, it uses the MQTT protocol with a monitoring topic per site. Notifications by emails also are sent to Tracking managers of the ...
    • 6. Error Handling

      Here are the errors you might encounter when using the API. Every error is be returned with a HTTP Status Code (see below) and a JSON body with a root node errors with more details. Code Name Meaning 400 Bad Request The request cannot be processed ...
    • Oauth2 authentication

      NAO Cloud can act as an Oauth2 resource and authorization server. Overview The benefits of Oauth2 authentication is two-fold: Users log in once on NAO Cloud, and automatically get logged-in to your site Your site gets an access token to authenticate ...
    • Location API

      Overview Location API can be used to receive location information about all tags of a given site. Once subscribed to a topic, your application will receive MQTT messages. Each message contains a topic and a payload. Refer ot the “Connection and ...
    • Getting maps metadata

      Each NAO Cloud site has 1 or more buildings. Each building has 1 or more floors. The metadata of each site, building and floor can be retrieved via the REST API. Buildings To get information of all the buildings of the site, use the following API: ...