|
пре 1 година | |
---|---|---|
.idea | пре 1 година | |
app | пре 1 година | |
gradle/wrapper | пре 1 година | |
moduleHealthRing | пре 1 година | |
.gitignore | пре 1 година | |
LICENSE | пре 1 година | |
README.md | пре 1 година | |
README_CN.md | пре 1 година | |
build.gradle | пре 1 година | |
gradle.properties | пре 1 година | |
gradlew | пре 1 година | |
gradlew.bat | пре 1 година | |
jitpack.yml | пре 1 година | |
settings.gradle | пре 1 година |
[TOC]
Latest version of AILinkSDKRepositoryAndroid: AILinkSDKRepositoryAndroid aar
Latest version of AILinkSDKOtaLibraryAndroid: AILinkSDKOtaLibraryAndroid aar
Latest version of AILinkSDKHealthRingLibraryAndroid: AILinkSDKHealthRingLibraryAndroid aar
Download the Android SDK demo from Git:
git clone http://git.elinkthings.com/elink/HealthRing-bleSDK-android-Demo.git
1.Add the JitPack repository to your build file
Add it to the end of the repositories in the root build.gradle:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
2.Add dependencies, refer to the latest version in the documentation header
dependencies {
implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:Tag'//Bluetooth library (required)
implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:Tag'//OTA library (required)
implementation 'com.github.elinkthings:AILinkSDKHealthRingLibraryAndroid:Tag'//Health ring library (required, depends on Bluetooth library and OTA library)
}
3.Configure Java 1.8 in Gradle
android {
...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
repositories {
flatDir {
dirs 'libs'
}
}
}
Alternatively, you can use aar package dependencies by downloading and placing them in the libs directory of your project. Download links are provided at the top of the document.
dependencies {
//implementation(name: 'aar包名', ext: 'aar')
}
<!-- For BLE compatibility on Android 6.0 and above -->
<uses-permission-sdk-23 android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission-sdk-23 android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- For Android 12, add maxSdkVersion -->
<uses-permission
android:name="android.permission.BLUETOOTH"
android:maxSdkVersion="30" />
<uses-permission
android:name="android.permission.BLUETOOTH_ADMIN"
android:maxSdkVersion="30" />
<!-- For Android 12, additional permissions are required and need to be dynamically requested -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"
android:usesPermissionFlags="neverForLocation"
tools:targetApi="s"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADVERTISE" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<!-- For Android 10 and 11, background scanning requires the following permission -->
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="false" />
<uses-feature
android:name="android.hardware.bluetooth"
android:required="false" />
Add the following code snippet inside the tag of your AndroidManifest.xml file:
<application>
...
<service android:name="com.pingwang.bluetoothlib.server.ELinkBleServer"/>
</application>
AILinkSDK.getInstance().init(mContextApplication);
AILinkBleManager.getInstance().init(mContext, new AILinkBleManager.onInitListener() {
@Override
public void onInitSuccess() {
// Initialization successful
}
@Override
public void onInitFailure() {
// Initialization failed
}
});
/**
* Bluetooth scan, connection, and other operation interface
*/
public interface OnCallbackBle extends OnCallback {
/**
* Start scanning for devices
*/
default void onStartScan(){}
/**
* Callback for each scanned device
*/
default void onScanning(BleValueBean data){}
/**
* Scan timeout (complete)
*/
default void onScanTimeOut(){}
/**
* Scan error
*
* @param time Time after which scanning can be performed again
* @param type 类型 {@link com.pingwang.bluetoothlib.config.BleConfig#SCAN_FAILED_SCANNING_TOO_FREQUENTLY} Too frequent
* {@link com.pingwang.bluetoothlib.config.BleConfig#SCAN_FAILED_TOO_THREE} Scanning failed more than 3 times
* {@link com.pingwang.bluetoothlib.config.BleConfig#SCAN_FAILED_OUT_OF_HARDWARE_RESOURCES} Hardware not supported (may also be a permission issue)
*/
default void onScanErr(int type, long time){}
/**
* Connecting
*/
default void onConnecting(String mac){}
/**
* Connection disconnected, in the UI thread
* @param mac Mac address
* @param code -1 Connection timeout, other error codes please refer to BLE protocol stack
*/
default void onDisConnected(String mac, int code){}
/**
* Connection successful (service discovered), in the UI thread
*/
default void onServicesDiscovered(String mac){}
/**
* Bluetooth is turned on, triggered on the thread
*/
default void bleOpen(){}
/**
* Bluetooth is not turned on, triggered on the thread
*/
default void bleClose(){}
}
/**
* Search for devices (no filtering)
* Scanning too frequently may cause scanning failure
* Ensure that the total scanning time of 5 scans exceeds 30s
* @param timeOut Timeout, in milliseconds (how long to search for data, 0 means continuous scanning)
*/
startScan(long timeOut)
/**
* Search for devices
* Scanning too frequently may cause scanning failure
* Ensure that the total scanning time of 5 scans exceeds 30s
* @param timeOut Timeout, in milliseconds (how long to search for data, 0 means continuous scanning)
* @param scanUUID UUID to filter (an empty array means no filtering)
*/
startScan(long timeOut, UUID scanUUID)
Example: Searching for AILink devices only
// BleConfig.UUID_SERVER_AILINK is the connection class device for AILink
// BleConfig.UUID_SERVER_BROADCAST_AILINK is the broadcast class device for AILink
startScan(30000, BleConfig.UUID_SERVER_AILINK,BleConfig.UUID_SERVER_BROADCAST_AILINK)
//OnCallbackBle interface
onScanning(BleValueBean data){
// Returns each scanned device, can be used to get broadcast data and refresh signal value
// Developers need to filter and deduplicate by themselves (can be deduplicated by MAC address)
}
// OnScanFilterListener interface
// It is recommended to implement this interface when you don't need to connect, which can reduce the number of interface implementations
onScanRecord(BleValueBean bleValueBean){
// Returns each scanned device, can be used to get broadcast data and refresh signal value
// Developers need to filter and deduplicate by themselves (can be deduplicated by MAC address)
}
/**
* Filter calculation -> can filter and select broadcast data
* @param bleValueBean Bluetooth broadcast data
* @return Whether it is valid, true for valid, false for invalid, discarded
*/
onFilter(BleValueBean bleValueBean){
}
// Note: It is recommended to stop scanning before connecting to make the connection process more stable
AILinkBleManager.getInstance().stopScan()
// Connection successful and service discovery will be called back in the OnCallbackBle interface
onServicesDiscovered(String mac){
// Connection successful, and service UUID is obtained successfully
// Data transmission and reception can be performed
}
// Disconnect all connections, AILink library supports connecting multiple Bluetooth devices.
AILinkBleManager.getInstance().disconnectAll();
// The AILinkBleManager object provides only the method to disconnect all devices. To disconnect a specific device, you can use the BleDevice.disconnect() method.
// You can get the BleDevice object in this way
AILinkBleManager.getInstance().getBleDevice(String mac);
// The BleDevice object has all operations on this device, including disconnecting, sending commands, and receiving commands.
val bleDevice = AILinkBleManager.getInstance().getBleDevice(mAddress);
val ringBleData: ElinkHealthRingBleData = ElinkHealthRingBleData(bleDevice)
//Query device status
ringBleData.getDeviceState()
//Get daily monitoring period
ringBleData.getCheckupDuration()
//Get sensor version
ringBleData.getSensorVersion()
//Get daily monitoring mode
ringBleData.getCheckupType()
//Get daily monitoring status
ringBleData.getAutoCheckState()
//Start daily monitoring
ringBleData.openAutoCheck()
//Stop daily monitoring
ringBleData.closeAutoCheck()
//Stop daily monitoring
ringBleData.setCheckupDuration(duration: Int) //Unit: Minutes
//Set daily monitoring mode
ringBleData.setCheckupType(type: ElinkCheckupType) //ElinkCheckupType.COMPLEX: Comprehensive monitoring, ElinkCheckupType.FAST: Quick monitoring
//Get history data
ringBleData.getHistory()
//Get the next page of history data
ringBleData.getNextHistory()
//End of history data
ringBleData.getHistoryOver()
//Delete history data
ringBleData.deleteHistory()
//Start health checkup
ringBleData.startCheckup()
//End health checkup
ringBleData.stopCheckup()
//Synchronize Unix time
ringBleData.syncUnixTime()
//Sensor OTA
ringBleData.startSensorOTA(fileData: ByteArray)
//Sensor OTA callback
ringBleData.setImplSensorOTA(object : ImplSensorOTA {
override fun onFailure(type: ElinkSensorOTAErrorType) {}
override fun onSuccess() {}
override fun onProgress(progress: Int) {}
})
//Bluetooth OTA
ringBleData.startBleOTA(filePath: String, object : OnBleOTAListener {
override fun onOtaSuccess() {}
override fun onOtaFailure(cmd: Int, err: String?) {}
override fun onOtaProgress(progress: Float, currentCount: Int, maxCount: Int,) {}
override fun onOtaStatus(status: Int) {}
override fun onReconnect(mac: String?) {}
})
//Disconnect the connection of the current device
BleDevice.disconnect();
ringBleData?.setImplHealthRingResult(object : ImplHealthRingResult {
/**
* Callback for starting health checkup
*
* @param success result
*/
override fun startCheckup(success: Boolean) {}
/**
* Callback for ending health checkup
*
* @param success result
*/
override fun stopCheckup(success: Boolean) {}
/**
* Callback for real-time health checkup data
*
* @param data ElinkCheckupRealtimeData
*/
override fun onGetRealtimeData(data: ElinkCheckupRealtimeData) {}
/**
* Health checkup packet callback
*
* @param data ByteArray
*/
override fun onGetCheckupPackets(data: ByteArray) {}
/**
* Callback for querying and setting daily monitoring period
*
* @param duration Unit (minutes)
*/
override fun onGetCheckupDuration(duration: Int) {}
/**
* Callback for obtaining history data, judge whether there is more history data based on total and sentCount
* If there is, call getNextHistory()
* If not, call getHistoryOver()
* After the end of history data acquisition, call deleteHistory() to delete history data
*
* @param histories List of historical data
* @param total Total
* @param sentCount Already acquired count
*/
override fun onGetHistory(
histories: List<ElinkRingHistoryData>,
total: Int,
sentCount: Int,
) {}
/**
* Callback for obtaining device status
*
* @param status
*/
override fun onGetDeviceStatus(status: ElinkRingDeviceStatus) {}
/**
* Callback for obtaining sensor version
*
* @param version
*/
override fun onGetSensorVersion(version: String) {}
/**
* Callback for querying, starting, and stopping daily monitoring status
*
* @param open
*/
override fun onGetAutoCheckupStatus(open: Boolean) {}
/**
* Callback for querying and setting daily monitoring mode
*
* @param type ElinkCheckupType.COMPLEX: Comprehensive monitoring, ElinkCheckupType.FAST: Quick monitoring
*/
override fun onGetCheckupType(type: ElinkCheckupType) {}
/**
* Notification callback for generating historical data on the device
*/
override fun onNotifyHistoryGenerated() {}
/**
* Callback for synchronizing UnixTime
*
* @param success
*/
override fun onSetUnixTimeResult(success: Boolean) {}
})
data class ElinkCheckupRealtimeData(
val heartRate: Int, //Heart rate
val bloodOxygen: Int, //Blood oxygen
val heartList: List<Int>, //Heart rhythm
val rr: Int,
val rri: List<Int>,
)
data class ElinkRingDeviceStatus(
val state: ElinkRingHistoryState, //Historical data status
val batteryLevel: Int, //Battery
val isCharging: Boolean, //Whether it is charging
val wearingStatus: ElinkWearingStatus, //wearing status
)
enum class ElinkRingHistoryState {
NOT_READY, //The historical time is not ready (unix time is not obtained)
PROCESSING, //Historical time is being processed (unix time has been obtained and historical data is being processed)
READY, //The historical time is ready (only in this state can the device history be obtained)
}
data class ElinkRingHistoryData(
val heartRate: Int, //Heart rate
val bloodOxygen: Int, //blood oxygen
val bk: Int, //Microcycle
val sbp: Int, //systolic blood pressure (high pressure)
val dbp: Int, //diastolic blood pressure (low pressure)
val rr: Int, //respiration rate
val sdann: Int,
val rmssd: Int,
val nn50: Int,
val pnn50: Int,
val time: Long, //time
val rri: List<Int>,
)
enum class ElinkCheckupType(val size: Byte) {
COMPLEX(72), //Comprehensive monitoring
FAST(30), //Quick monitoring
}
enum class ElinkSensorOTAErrorType {
START_OTA_FAIL,
CHECK_FAIL,
WRITE_ERROR,
ERASE_ERROR,
}
enum class ElinkWearingStatus {
UNSUPPORTED, //not supported
NOT_WEARING, //not wearing
WEARING, //Wearing
}
/**
*Set front-end service related parameters
* @param id id
* @param icon logo
* @param title title
* @param activityClass jump activity
*/
AILinkBleManager.getInstance().initForegroundService(int id, @DrawableRes int icon, String title, Class<?> activityClass)
//Start the foreground service,
AILinkBleManager.getInstance().startForeground();
//Stop the foreground service
AILinkBleManager.getInstance().stopForeground();
public interface OnBleVersionListener {
/**
*BM module software and hardware version number
*/
default void onBmVersion(String version){}
/**
* Units supported by mcu (all supported by default)
* @param list null or empty means all are supported
*/
default void onSupportUnit(List<SupportUnitBean> list) {}
}
Version number | Update time | Author | Update information |
---|---|---|---|
1.0.0 | 2024/03/14 | suzy | Initial version |
-keep class com.pinwang.ailinkble.**{*;}
-keep class com.pingwang.bluetoothlib.annotation.**{*;}
-keep class com.pingwang.bluetoothlib.bean.**{*;}
-keep class com.pingwang.bluetoothlib.config.**{*;}
-keep class com.pingwang.bluetoothlib.device.**{*;}
-keep class com.pingwang.bluetoothlib.listener.**{*;}
-keep public class com.pingwang.bluetoothlib.AILinkBleManager{*;}
-keep public class com.pingwang.bluetoothlib.AILinkSDK{*;}
-keep public class com.pingwang.bluetoothlib.utils.BleLog{*;}
-keep public class com.pingwang.bluetoothlib.utils.UuidUtils{*;}
-keep public class com.pingwang.bluetoothlib.utils.BleDataUtils{*;}
-keep public class com.pingwang.bluetoothlib.utils.BleCheckUtils{*;}
-keep class cn.net.aicare.algorithmutil.**{*;}
-keep class cn.net.aicare.**{*;}
-keep class com.besthealth.bhBodyComposition120.**{*;}
-keep class com.holtek.**{*;}
-keep class com.elinkthings.toothscore.**{*;}
-keep class cn.net.aicare.modulelibrary.module.**{*;}
-keep class com.elinkthings.healthring.**{*;}
Shenzhen ElinkThings Co., Ltd.
Tel: 0755-81773367
WeChat: ElinkThings08
Website: www.elinkthings.com
E-mail: app@elinkthings.com