Преглед на файлове

Update documentation

master
陈福行 преди 5 години
родител
ревизия
34191204e3
променени са 2 файла, в които са добавени 145 реда и са изтрити 69 реда
  1. 65
    31
      README.md
  2. 80
    38
      README_CN.md

+ 65
- 31
README.md Целия файл

@@ -1,5 +1,5 @@

# Module documentation - Android
# AILink SDK Instructions-Android

[aar package download address](https://github.com/elinkthings/AILinkSdkDemoAndroid/releases)

@@ -7,15 +7,26 @@

[中文文档](README_CN.md)

This document is to guide Android developers to integrate AILink-SDK-Android in Android 4.4 and above systems, and it is mainly for some key usage examples.
## Contents
- Conditions of use:
- Import SDK
- Permission settings
- Start integration
- More commonly used interface introduction
- Matters needing attention
- AILinkBleParsingAndroid library overview
- Version History
- FQA
- Contact Us

## 1. Conditions of use:

## Conditions of use:
1. Android SDK minimum version android4.4 (API 19).
2. The Bluetooth version used by the device needs 4.0 and above.
3. Configure java1.8
4. The project depends on the androidx library

## 二, import SDK
## Import SDK


```
@@ -59,7 +70,7 @@ The download address is at the top of the document.

```

## 二、Permission settings
## Permission settings

```
<!--In most cases, you need to ensure that the device supports BLE.-->
@@ -80,7 +91,7 @@ The download address is at the top of the document.

> 6.0 and above systems must locate permissions, and need to obtain permissions manually

## 三, start integration
## Start integration

> Add below AndroidManifest.xml application tag
```
@@ -103,7 +114,7 @@ The download address is at the top of the document.
> You can use the BleBeseActivity class provided in the library,
and inherit the implementation method

### 1, Bind service:
- Bind service:
```
ps:Bind services where you need to handle Bluetooth, get Bluetooth device objects to handle, or comprehensively handle them in one place.
private void bindService() {
@@ -131,7 +142,7 @@ private void bindService() {
};

```
### 2, Set the mBluetoothService.setOnCallback ();
- Set the mBluetoothService.setOnCallback ();
```
Implement OnCallbackBle interface to get search, connect, disconnect status and data
/ **
@@ -175,7 +186,7 @@ public interface OnCallbackBle extends OnCallback {
    default void bleClose () {}
}
```
### 3, search for mBluetoothService.scanLeDevice (long timeOut);//timeOut milliseconds
- search for mBluetoothService.scanLeDevice (long timeOut);//timeOut milliseconds
```
/ **
      * Search device
@@ -196,20 +207,20 @@ public interface OnCallbackBle extends OnCallback {

The discovered device will be returned in onScanning (BleValueBean data) in the OnCallbackBle interface
```
### 4, connect mBluetoothService.connectDevice (String mAddress);
- connect mBluetoothService.connectDevice (String mAddress);
```
Note: It is recommended to stop searching for mBluetoothService.stopScan () before connecting,
so the connection process will be more stable After the connection is successful and the service is successfully obtained,
it will be returned in onServicesDiscovered (String mac) in the OnCallbackBle interface
```
### 5,Disconnect
- Disconnect
```
Disconnect all connections mBluetoothService.disconnectAll (),
since this library supports multiple connections, only the method of disconnecting the device is provided in the service

```

### 6, Get connected device object
- Get connected device object
```
Note:If no parsing package is added, you need to create a class to inherit BaseBleDeviceData.class, and then you can get the payload data of the device through this class onNotifyData interface
BleDevice bleDevice = mBluetoothService.getBleDevice (mAddress);
@@ -238,8 +249,8 @@ SendMcuBean is used to interact with MCU;
If there is a need for custom transparent data transmission, please inherit SendDataBean or send it using SendDataBean object.

```
## 四, more commonly used interface introduction
### 1, setOnBleVersionListener (OnBleVersionListener bleVersionListener) in BleDevice // device version number, unit interface
## More commonly used interface introduction
- setOnBleVersionListener (OnBleVersionListener bleVersionListener) in BleDevice // device version number, unit interface
```
  public interface OnBleVersionListener {
    / **
@@ -253,7 +264,7 @@ If there is a need for custom transparent data transmission, please inherit Send
    default void onSupportUnit (List <SupportUnitBean> list) {}
}
```
### 2, setOnMcuParameterListener (OnMcuParameterListener mcuParameterListener) in BleDevice // Power, time interface
- setOnMcuParameterListener (OnMcuParameterListener mcuParameterListener) in BleDevice // Power, time interface
```
public interface OnMcuParameterListener {
    / **
@@ -272,7 +283,7 @@ public interface OnMcuParameterListener {

}
```
### 3, setOnBleOtherDataListener (OnBleOtherDataListener onBleOtherDataListener) in BleDevice // Transparent data interface, if the data format does not conform to the protocol, this interface will return data
- setOnBleOtherDataListener (OnBleOtherDataListener onBleOtherDataListener) in BleDevice // Transparent data interface, if the data format does not conform to the protocol, this interface will return data
```
public interface OnBleOtherDataListener {

@@ -285,51 +296,51 @@ public interface OnBleOtherDataListener {
}
```

## 五, matters needing attention
## Matters needing attention

#### 1.The Bluetooth library only provides data, and analyzes some ble data. The data connected to the MCU module is not parsed.
#### 2, Please use the AILinkBleParsingAndroid library for module data analysis, which provides analysis templates for each module
#### 3, AILinkBleParsingAndroid library needs to rely on AILinkSDKRepositoryAndroid library, it is not recommended to use it alone
#### 4, The BaseBleDeviceData object is the base class object of the module device. It is recommended to inherit the implementation operation. For more details, please refer to the template in the AILinkBleParsingAndroid library.
#### 5, AILinkBleParsingAndroid library has source code provided, you can find start on github
#### 6, For more operations, please refer to the demo, you can clone this project
- The Bluetooth library only provides data, and analyzes some ble data. The data connected to the MCU module is not parsed.
- Please use the AILinkBleParsingAndroid library for module data analysis, which provides analysis templates for each module
- AILinkBleParsingAndroid library needs to rely on AILinkSDKRepositoryAndroid library, it is not recommended to use it alone
- The BaseBleDeviceData object is the base class object of the module device. It is recommended to inherit the implementation operation. For more details, please refer to the template in the AILinkBleParsingAndroid library.
- AILinkBleParsingAndroid library has source code provided, you can find start on github
- For more operations, please refer to the demo, you can clone this project


## 六, [AILinkBleParsingAndroid library overview](https://elinkthings.github.io/AILinkSDKAndroidDoc/)
## [AILinkBleParsingAndroid library overview](https://elinkthings.github.io/AILinkSDKAndroidDoc/)

#### 1, [baby scale](https://elinkthings.github.io/AILinkSDKAndroidDoc/babyscale/en/index.html)
- [baby scale](https://elinkthings.github.io/AILinkSDKAndroidDoc/babyscale/en/index.html)
```
BabyDeviceData parsing class
BabyBleConfig directive configuration class
```
#### 2, [height gauge](https://elinkthings.github.io/AILinkSDKAndroidDoc/height/en/index.html)
- [height gauge](https://elinkthings.github.io/AILinkSDKAndroidDoc/height/en/index.html)
```
HeightDeviceData Parsing Class
HeightBleConfig directive configuration class
```
#### 3, [sphygmomanometer](https://elinkthings.github.io/AILinkSDKAndroidDoc/sphygmomanometer/en/index.html)
- [sphygmomanometer](https://elinkthings.github.io/AILinkSDKAndroidDoc/sphygmomanometer/en/index.html)
```
SphyDeviceData parsing class
SphyBleConfig instruction configuration class
```
#### 4, [thermometer](https://elinkthings.github.io/AILinkSDKAndroidDoc/thermometer/en/index.html)
- [thermometer](https://elinkthings.github.io/AILinkSDKAndroidDoc/thermometer/en/index.html)
```
TempDeviceData parsing class
TempBleConfig instruction configuration class
```
#### 5, [forehead gun](https://elinkthings.github.io/AILinkSDKAndroidDoc/foreheadgun/en/index.html)
- [forehead gun](https://elinkthings.github.io/AILinkSDKAndroidDoc/foreheadgun/en/index.html)
```
TempGunDeviceData parsing class
TempGunBleConfig instruction configuration class
```
#### 6, [TPMS (Smart Tire Pressure)](https://elinkthings.github.io/AILinkSDKAndroidDoc/tpms/en/index.html)
- [TPMS (Smart Tire Pressure)](https://elinkthings.github.io/AILinkSDKAndroidDoc/tpms/en/index.html)
```
TPMS transfer board:
TpmsDeviceData Parsing Class
TpmsBleConfig directive configuration class
```

#### 7, [Body Fat Scale](https://elinkthings.github.io/AILinkSDKAndroidDoc/BodyFatScale/en/index.html)
- [Body Fat Scale](https://elinkthings.github.io/AILinkSDKAndroidDoc/BodyFatScale/en/index.html)
```
BodyFatBleUtilsData Body Fat Scale Object
BodyFatDataUtil Body fat scale analysis and instruction configuration class
@@ -338,3 +349,26 @@ McuHistoryRecordBean history object
User user information object
```

## Version History
| Version number | Update time | Author | Update information
|:----|:---|:-----|-----|
|1.2.9| 2020/4/10| xing| Modify SDK to gradle form dependency, fix known bugs

## FQA
- Can't scan the Bluetooth device?
1. Check whether the permissions of the App are normal. The 6.0 and above systems must locate the permissions and need to manually obtain the permissions;
2. Check whether the location service of the mobile phone is turned on, and some mobile phones may need to turn on GPS;
3. Whether ELinkBleServer is registered in AndroidManifest;
4. Whether the device is connected by other mobile phones;
5. Whether the search method is called too frequently, the scanLeDevice method needs to ensure that the total length of 5 scans exceeds 30s (different from different mobile phones, it is recommended to reduce the frequency as much as possible);
6. Restart the Bluetooth of the mobile phone and try again, some mobile phones need to restart the entire mobile phone;


## Contact Us
Shenzhen elink things Co., Ltd.

Phone: 0755-81773367

Official website: www.elinkthings.com

Email: app@elinkthings.com

+ 80
- 38
README_CN.md Целия файл

@@ -7,15 +7,23 @@

[English documentation](README.md)

该文档为指导Android开发人员在Android 4.4及以上系统中集成AILink-SDK-Android,主要为一些关键的使用示例
## 目录
- 使用条件
- 导入SDK
- 权限设置
- 开始集成
- 版本历史
- FQA
- 联系我们

## 一、使用条件:

## 使用条件
1. Android SDK最低版本android4.4(API 19)。
2. 设备所使用蓝牙版本需要4.0及以上。
3. 配置java1.8
4. 项目依赖androidx库

## 二、导入SDK
## 导入SDK


```
@@ -56,7 +64,7 @@ repositories {

```

## 二、权限设置
## 权限设置

```
<!--In most cases, you need to ensure that the device supports BLE.-->
@@ -77,7 +85,13 @@ repositories {

> 6.0及以上系统必须要定位权限,且需要手动获取权限

## 三、开始集成
## 开始集成

> 首先给SDK配置key和secret,[申请地址](http://sdk.aicare.net.cn)
```
//在主项目的application中初始化
AILinkSDK.getInstance().init(this, key, secret);
```

> 在AndroidManifest.xml application标签下面增加
```
@@ -89,17 +103,11 @@ repositories {
</application>

```
> 初始化 [key注册地址](http://sdk.aicare.net.cn)

```
//在application中调用
AILinkSDK.getInstance().init(this, key, secret);

```
- 绑定服务
> 注:可使用库中提供的BleBeseActivity类,继承实现方法,
里面有绑定服务判断权限等相关操作,详细可参考demo

### 1,绑定服务:
```
ps:在需要处理蓝牙的地方绑定服务,拿到蓝牙设备对象来处理,也可在一个地方综合处理.

@@ -127,7 +135,7 @@ private void bindService() {
}
};
```
### 2,绑定服务成功后设置监听mBluetoothService.setOnCallback();
- 绑定服务成功后设置监听mBluetoothService.setOnCallback();
```
实现OnCallbackBle接口可以获取搜索,连接,断开等状态和数据
/**
@@ -171,7 +179,7 @@ public interface OnCallbackBle extends OnCallback {
default void bleClose(){}
}
```
### 3,搜索 mBluetoothService.scanLeDevice(long timeOut);//timeOut毫秒
- 搜索 mBluetoothService.scanLeDevice(long timeOut);//timeOut毫秒
```
/**
* 搜索设备
@@ -192,20 +200,20 @@ public interface OnCallbackBle extends OnCallback {

搜索到的设备会在OnCallbackBle接口中的onScanning(BleValueBean data)返回
```
### 4,连接mBluetoothService.connectDevice(String mAddress);
- 连接mBluetoothService.connectDevice(String mAddress);
```
注:连接之前建议停止搜索mBluetoothService.stopScan(),这样连接过程会更稳定
连接成功并获取服务成功后会在OnCallbackBle接口中的onServicesDiscovered(String mac)返回
```
### 5,断开连接
- 断开连接
```
mBluetoothService.disconnectAll()断开所有连接,由于此库支持多连接,
所以service中只提供断开设备的方法,可在BleDevice.disconnect();断开连接
```

### 6,获取连接的设备对象
- 获取连接的设备对象
```
// 如果没有添加解析包的的话你需要创建一个类去继承BaseBleDeviceData.class,然后可以通过这个类 onNotifyData 接口获取到设备的Payload 数据
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress);
BleDevice对象拥有对此设备的所有操作,包括断开连接,发送指令,接收指令等操作
BleDevice.disconnect();//断开连接
@@ -230,12 +238,19 @@ BleDevice.sendData(SendDataBean sendDataBean)//发送指令,内容需要用SendD
由于发送数据存在发送队列,SendDataBean对象不建议复用,避免数据给覆盖;
SendBleBean用于与蓝牙模块交互;
SendMcuBean用于与mcu交互;
如果有自定义透传数据需求,请自行继承SendDataBean或者使用SendDataBean对象发送即可.
UUID不变的情况下,自定义透传数据使用SendMcuBean对象即可;
如果有自定义透传数据同时UUID也是特殊定义的,请参考SendMcuBean对象新建一个类继承SendDataBean即可;

```

## 四、较常用的接口介绍
### 1,BleDevice 中的setOnBleVersionListener(OnBleVersionListener bleVersionListener)//设备版本号,单位接口
- App与设备交互
- 依赖AILinkSDKParsingLibraryAndroid解析库,解析库中提供了各个模块的数据解析和控制指令,只需要实现各模块中的接口即可拿到数据.详细请参考demo和文档.也可以自行阅读源码

- 由于解析库提供了标准的数据解析,自由度相对较低,也可以继承对应的解析类进行扩展.如果这样还不能满足需求,你可以创建一个类去继承BaseBleDeviceData.class,然后实现相关方法通过 onNotifyData 接口获取到设备的Payload 数据,接下来可以自行解析数据;


## 较常用的接口介绍
- BleDevice 中的setOnBleVersionListener(OnBleVersionListener bleVersionListener)//设备版本号,单位接口
```
public interface OnBleVersionListener {
/**
@@ -249,7 +264,7 @@ SendMcuBean用于与mcu交互;
default void onSupportUnit(List<SupportUnitBean> list) {}
}
```
### 2,BleDevice 中的setOnMcuParameterListener(OnMcuParameterListener mcuParameterListener)//电量,时间接口
- BleDevice 中的setOnMcuParameterListener(OnMcuParameterListener mcuParameterListener)//电量,时间接口
```
public interface OnMcuParameterListener {
/**
@@ -268,7 +283,7 @@ public interface OnMcuParameterListener {

}
```
### 3,BleDevice 中的setOnBleOtherDataListener(OnBleOtherDataListener onBleOtherDataListener) //透传数据接口,数据格式不符合协议的才会走此接口返回数据
- BleDevice 中的setOnBleOtherDataListener(OnBleOtherDataListener onBleOtherDataListener) //透传数据接口,数据格式不符合协议的才会走此接口返回数据
```
public interface OnBleOtherDataListener {

@@ -281,50 +296,51 @@ public interface OnBleOtherDataListener {
}
```

## 五、注意事项
## 注意事项

#### 1,蓝牙库只提供数据,解析部分ble数据,mcu模块对接的数据不解析
#### 2,模块数据解析请使用AILinkBleParsingAndroid 库,里面有提供各模块的解析模板
#### 3,AILinkBleParsingAndroid库需要依赖AILinkSDKRepositoryAndroid库,不建议单独使用
#### 4,BaseBleDeviceData对象为模块设备的基类对象,建议继承实现操作,更多请参考AILinkBleParsingAndroid库中的模板
#### 5,AILinkBleParsingAndroid库有源码提供,可在github上查找start
#### 6,更多操作请参考demo,将此项目clone下来即可
- 蓝牙库只提供数据,通过继承BaseBleDeviceData对象实现onNotifyData方法可以接收数据
- 数据解析请使用AILinkBleParsingAndroid 库,里面有提供各模块的解析模板
- AILinkBleParsingAndroid库需要依赖AILinkSDKRepositoryAndroid库,不可单独使用
- BaseBleDeviceData对象为模块设备的基类对象,建议继承实现操作,更多请参考AILinkBleParsingAndroid库中的模板
- AILinkBleParsingAndroid库有源码提供,可在github上start
- 更多操作请参考demo,将此项目clone下来即可


## 六、[AILinkBleParsingAndroid库概述](https://elinkthings.github.io/AILinkSDKAndroidDoc/README_CN.html)

#### 1,[婴儿秤](https://elinkthings.github.io/AILinkSDKAndroidDoc/babyscale/zh/index.html)
## [AILinkBleParsingAndroid库概述](https://elinkthings.github.io/AILinkSDKAndroidDoc/README_CN.html)

- [婴儿秤](https://elinkthings.github.io/AILinkSDKAndroidDoc/babyscale/zh/index.html)
```
BabyDeviceData解析类
BabyBleConfig 指令配置类
```
#### 2,[身高仪](https://elinkthings.github.io/AILinkSDKAndroidDoc/height/zh/index.html)
- [身高仪](https://elinkthings.github.io/AILinkSDKAndroidDoc/height/zh/index.html)
```
HeightDeviceData解析类
HeightBleConfig指令配置类
```
#### 3,[血压计](https://elinkthings.github.io/AILinkSDKAndroidDoc/sphygmomanometer/zh/index.html)
- [血压计](https://elinkthings.github.io/AILinkSDKAndroidDoc/sphygmomanometer/zh/index.html)
```
SphyDeviceData解析类
SphyBleConfig指令配置类
```
#### 4,[体温计](https://elinkthings.github.io/AILinkSDKAndroidDoc/thermometer/zh/index.html)
- [体温计](https://elinkthings.github.io/AILinkSDKAndroidDoc/thermometer/zh/index.html)
```
TempDeviceData解析类
TempBleConfig指令配置类
```
#### 5,[额温枪](https://elinkthings.github.io/AILinkSDKAndroidDoc/foreheadgun/zh/index.html)
- [额温枪](https://elinkthings.github.io/AILinkSDKAndroidDoc/foreheadgun/zh/index.html)
```
TempGunDeviceData解析类
TempGunBleConfig指令配置类
```
#### 6,[TPMS(智能胎压)](https://elinkthings.github.io/AILinkSDKAndroidDoc/tpms/zh/index.html)
- [TPMS(智能胎压)](https://elinkthings.github.io/AILinkSDKAndroidDoc/tpms/zh/index.html)
```
TPMS转接板:
TpmsDeviceData解析类
TpmsBleConfig指令配置类
```
#### 7,[体脂秤](https://elinkthings.github.io/AILinkSDKAndroidDoc/BodyFatScale/zh/index.html)
- [体脂秤](https://elinkthings.github.io/AILinkSDKAndroidDoc/BodyFatScale/zh/index.html)
```
BodyFatBleUtilsData 体脂秤对象
BodyFatDataUtil 体脂秤解析和指令配置类
@@ -332,3 +348,29 @@ BodyFatRecord 体脂记录对象(测量返回)
McuHistoryRecordBean 历史记录对象
User 用户信息对象
```

## 版本历史
|版本号|更新时间|作者|更新信息|
|:----|:---|:-----|-----|
|1.2.9| 2020/4/10| xing| 修改SDK为gradle形式依赖,修复已知bug



## FQA
- 扫描不到蓝牙设备?
1.查看App权限是否正常,6.0及以上系统必须要定位权限,且需要手动获取权限;
2.查看手机的定位服务是否开启,部分手机可能需要打开GPS;
3.ELinkBleServer是否在在AndroidManifest中注册;
4.设备是否被其他手机连接;
5.是否调用搜索方法太频繁, scanLeDevice方法需要保证5次扫描总时长超过30s(各别手机有差异,建议尽量减少频率);
6.重启手机蓝牙再试试,部分手机需要整个手机重启;


## 联系我们
深圳市易连物联网有限公司

电话:0755-81773367

官网:www.elinkthings.com

邮箱:app@elinkthings.com

Loading…
Отказ
Запис