Overview
Mist provides indoor blue dot navigation experience with 16 vBLE antenna array in Mist Access Point. This guide will provide detailed information on our Android SDK. It will help you configure application to integrate Mist SDK and initialize location services.
MistSDK DR uses dead reckoning approach to calculate user’s current position by using a previous position and advancing that position based on known and estimated speeds over elapsed time. Meaning DR is designed to take all location information available that a user had when connected and work the same as though the client is connected, even when experiencing a disconnect or blimp in the connection.
Mist android vBLE SDK supports the following features:
App Permissions
Mist SDK will require Bluetooth and Location services to function on your device. Declare the following permission(s) in your application manifest file. For example:
<manifest ... > <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_GPS" /> <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> ... </manifest>
Requirements
- Android Studio: 4.0 or later
- Minimum Android SDK: API 26
- Target Android SDK: API 29
- Mist AP wireless network infrastructure
- Bluetooth enabled Android device
- Access to Mist Account
Integrate MistSDK
MistSDK can be integrated by using one of the following ways in your android app project:
JCenter (Recommended)
Add the following in your app module build.gradle. This will take care of both Mist Core SDK and DR SDK.
implementation 'com.mist:core-sdk:2.1.29'
or
Manual Adding sdk_framework.aar
While manually setting up SDK, include both ‘Mist Core SDK’ and ‘DR SDK’ in your application project.
- Download ‘android-framework.aar’ and ‘mist-mobile.aar’ from SDK Releases
- Add the following to app/build.gradle in dependencies.
implementation(name:'android-framework', ext:'aar') implementation(name:'mist-mobile', ext:'aar') implementation fileTree(include: ['*.jar'], dir: 'libs')
In project/build.gradle, add following in repositories
flatDir { dirs 'libs'}
Other set up (required)
If your app is targeting API level 28 (Android 9.0) or above, you must include the following declaration within the element of AndroidManifest.xml.
<uses-library android:name="org.apache.http.legacy" android:required="false" />
Add the following in App/build.gradle, to implement the web socket dependencies:
implementation "org.java-websocket:Java-WebSocket:1.4.0"
For more details please refer to one of the Sample Apps
Initialize MistSDK
To initialize Mist SDK you need organization secret and organization id.
1. Obtain the invitation token from the Mist portal at the following path: Organization -> Mobile SDK. Use the token to obtain the org_id and secret via onReceivedSecret callback method from MSTOrgCredentialsManager:
MSTOrgCredentialsManager.enrollDeviceWithToken(mApp.get(), sdkToken, this);
@Override public void onReceivedSecret(String orgName, String orgID, String sdkSecret, String error, String envType) { if (!TextUtils.isEmpty(sdkSecret) && !TextUtils.isEmpty(orgID) && !TextUtils.isEmpty(sdkSecret)) { saveConfig(orgName, orgID, sdkSecret, envType); connect(indoorOnlyListener, this.advanceListener, appMode); } else { if (!Utils.isEmptyString(error)) { if (indoorOnlyListener != null) { indoorOnlyListener.onMistErrorReceived(error, new Date()); } } } }
2. Use the org_id and secret to initialize the MSTCentralManager. To use the location methods, implement the MSTCentralManagerIndoorOnlyListener and MistLocationAdvanceListener.
MSTCentralManagerIndoorOnlyListener is used to fetch x, y coordinates, map details, vBeacons list, zone, and vBeacon notifications.
MistLocationAdvanceListener provides advance callbacks to fetch the Lat/Lon, Speed, and direction along with relative x, y coordinate.
mstCentralManager = new MSTCentralManager(mApp.get(), orgData.getOrgId(), orgData.getSdkSecret()); mstCentralManager.setMSTCentralManagerIndoorOnlyListener(indoorOnlyListener); mstCentralManager.setMistLocationAdvanceListener(advanceListener);
3. Call start API of MSTCentralManager to start the SDK:
mstCentralManager.start();
4. Call stop on MSTCentralManager to stop receiving callbacks from Mist SDK:
mstCentralManager.stop();
Getting Location and Map Info:
Map Information: Map details such as mapId, mapName, mapImageURL, mapOrigin, width and height are received in onMapUpdated Callback. This method is called to load the new map or update the map while switching floors and sites.
void onMapUpdated(MSTMap map, Date dateUpdated)
MSTMap object contains following Mist map information:
- mapName
- mapId
- mapImageURL
- mapType
- mapOrigin
- mapScale
- mapWidth and mapHeight
- ppm (pixel per meter)
Location Information: Location response is used to know the position of the user in that particular floorplan. To get location information from Mist SDK implement MSTCentralManagerIndoorOnlyListener callbacks in your application. Following method returns updated location of the device as an MSTPoint object (X, Y) measured in meters from the map origin:
Relative coordinates based on top-left origin in meters (x,y)
void onRelativeLocationUpdated(MSTPoint var1, MSTMap[] var2, Date var3);
The current map can be retrieved by maps[0].
relativeLocation object contains the following user information:
- x, y: user location
- hasMotion: is the user in motion ,
- mstPointType: type Cloud,
- latency: latency in the network,
- heading: compass heading,
- headingFlag: availability of compass heading
Lat/Long coordinates
To get Lat/Lon information along with x/y from the SDK, you need to implement MistLocationAdvanceListener callbacks in your application. Following method returns the Lat/Lon.
void onDRRelativeLocationUpdated(JSONObject var1, MSTMap var2, Date var3);
The latitude and longitude coordinates can be found inside the JSONObject.
{ "Raw": { "Heading": -180, "Lat": 36.562600, "Lon": -118.957490, "Speed": 1.152899 }, "Snapped": { "Heading": -180, "Lat": 36.562600, "Lon": -118.957490, "Speed": 1.152899 } }
Sample Apps
For more detail, you can see the implementation in the sample app here
Documentation for MistSDK callbacks
For more callback related information refer Mist SDK callbacks page.
Release Notes
Check what’s new in the release notes