Android_SDK Quick Start
Android_SDK quick start
Applicable Model
Routine download
Please download sample program
https://github.com/WITMOTION/WitStandardProtocol_JY901
Introduction to routines
Routine introduction
1. This example demonstrates how to use the Android Bluetooth 2.0 SDK developed by WITMOTION
2. This routine will demonstrate how to search and connect Bluetooth 2.0 sensors, and control the sensors
3. Please be familiar with the use of Wit-motion Bluetooth 2.0 before using the routine, and understand the protocol of the sensor
Routine directory
libs: Project dependencies
java: Project source code
MainActivity: On the main page of the project, the routine has only one activity, and all logic codes are in this activity

Routine dependency
This routine depends on the wit-sdk project. If you want to port it to your own app, please port the wit-sdk.aar under the lib folder in the routine to your app

build.gradle Add the following dependencies to

// This dependencies must be added
project permissions
This project needs to be connected to Bluetooth, so you need to obtain permission from the customer. If you need to port it to your app, please make sure that your app also applies for the following permissions
AndroidManifest.xml Main manifest file permission statement
Please declare the following permissions in your program's main manifest file
2.Code application permission
Before using Bluetooth, please call WitBluetoothManager.initInstance to initialize the Bluetooth manager. When initializing the Bluetooth manager, the Bluetooth manager will apply for permission from the user
Search device
After applying for permission, you can let the Bluetooth manager start searching for Bluetooth devices
Search bluetooth
The following is the code for searching Bluetooth. You need to get the Bluetooth manager, and then call the startDiscovery method. If you need to get the device found by the Bluetooth manager, you need to call registerObserver. After finding the device, you will be notified of the found Bluetooth device through the onFoundSPP method of register Observer
After starting the search, the onFoundDual method will be called when the device is found. Here, the device is connected immediately after the device is found.
Stop searching
After starting the search, the Bluetooth manager will not stop the search by itself, you need to call its stopDiscovery method to stop the search
Receive sensor data
Get data
The data of the sensor can be obtained through the getDeviceData method, getDeviceData needs to receive a key value, and this key value is stored in the WitSensorKey class
Record data
When the device is turned on, you can call the registerRecordObserver method of bwt901cl, and when the sensor data is updated, bwt901cl will call the onRecord method to notify you of the recorded data
Set sensor
Accelerometer Calibration
Accelerometer calibration can be done by calling AppliedCalibration of Bwt901cl. Remember to unlock the register before accumulator calibration
Magnetic Field Calibration
You can control the start and end of magnetic field calibration by calling the startFieldCalibration and endFieldCalibration methods of Bwt901cl. After starting the magnetic field calibration, please rotate 2-3 circles around each of the x y z axes of the sensor. If you don’t know the magnetic field calibration, you can consult our technical staff support.
Start Magnetic Field Calibration
End magnetic field calibration
Read sensor register
This time demonstrates how to read the 03 register of the sensor, use the sendProtocolData method to read the sensor data, and get the data of the register through getDeviceData after reading.
Last updated