Selaa lähdekoodia

Update documentation

master
陈福行 4 vuotta sitten
vanhempi
commit
444646b08b
2 muutettua tiedostoa jossa 4 lisäystä ja 448 poistoa
  1. 4
    227
      README.md
  2. 0
    221
      README_CN.md

+ 4
- 227
README.md Näytä tiedosto

@@ -1,228 +1,5 @@
[TOC]

# TPMS SDK instructions-Android

[![](https://jitpack.io/v/elinkthings/TmpsSDKRepositoryAndroid.svg)](https://jitpack.io/#elinkthings/TmpsSDKRepositoryAndroid)

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

[key registered address](http://sdk.aicare.net.cn)




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

## Second, import the SDK


```
repositories {
    flatDir {
        dirs 'libs'
    }
}


1. Add the JitPack repository to your build file
Add it to the root build.gradle at the end of the repository:
allprojects {
repositories {
...
maven {url 'https://jitpack.io'}
}
}

2. Add dependencies
dependencies {
implementation 'com.github.elinkthings: TmpsSDKRepositoryAndroid: 1.2.2' // Bluetooth library

}

3. Configure java1.8 in gradle
    android {
        ...
        compileOptions {
            sourceCompatibility 1.8
            targetCompatibility 1.8
        }
    }

You can also use the aar package dependency, please download it yourself and put it in the project's libs, the download address is at the top of the document



```

## Second, permission settings

```
<!-In most cases, you need to ensure that the device supports BLE .-->
<uses-feature
    android: name = "android.hardware.bluetooth_le"
    android: required = "true" />

<uses-permission android: name = "android.permission.BLUETOOTH" />
<uses-permission android: name = "android.permission.BLUETOOTH_ADMIN" />

<!-Android 6.0 and above. Bluetooth scanning requires one of the following two permissions. You need to apply at run time .-->
<uses-permission android: name = "android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android: name = "android.permission.ACCESS_FINE_LOCATION" />

<!-Optional. If your app need dfu function .-->
<uses-permission android: name = "android.permission.INTERNET" />
```

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

## Three, start integration



- First configure the key and secret for the SDK, [application address](http://sdk.aicare.net.cn)

```
TpmsSDK.init(this, key, secret);
```

- Implement the TpmsScan.TpmsScanListener method

```
TpmsScan mTpmsScan = new TpmsScan (new TpmsScan.TpmsScanListener () {
            @Override
            public void onGetData (String mac, String deviceId, int rssi, float pressure, float battery, int temp, int status, float mcuVersion, int year, int month, int day, float bleVersion) {
                
            }
        });

```

### 3, search for TpmsScan.startScan (String [] deviceIdS);

```
    / **
     * Search device, search all devices by default and return through TpmsScanListener interface
     * /
     TpmsScan.startScan ()

   / **
     * Search for devices, search for devices in the incoming device id array and return through the TpmsScanListener interface
     *
     * /
     TpmsScan.startScan (String [] deviceIdS)

The found devices will be returned in onGetData (...) in the TpmsScan.TpmsScanListener interface

```

### 4, Data analysis returned by the TpmsScan.TpmsScanListener interface

```
public void onGetData (String mac, String deviceId, int rssi, float pressure, float battery, int temp, int status, float mcuVersion, int year, int month, int day, float bleVersion);

mac: device mac address
deviceId: device id
rssi: signal value
pressure: air pressure
battery: voltage
temp: temperature
status: status
    / **
     * device status
     * /
    public enum DeviceState {
        / **
         * Normal
         * /
        NORMAL,
        / **
         * Leakage
         * /
        LEAK,
        / **
         * Inflatable
         * /
        INFLATE,
        / **
         * start up
         * /
        START,
        / **
         * Power-on
         * /
        POWER_ON,
        / **
         * Wake up
         * /
        WEAK_UP,
        / **
         * Abnormal temperature
         * /
        TEMP_ERROR,
        / **
         * Abnormal battery
         * /
        BATTERY_ERROR,
        / **
         * Unknown
         * /
        UNKNOWN
    }
    
mcuVersion: mcu version number
year, month, day: date
bleVersion: Bluetooth version number


    / **
     * Equipment installation location
     * /
    public enum DevicePosition {
        / **
         * Front left
         * /
        LEFT_FRONT,
        / **
         * Rear left
         * /
        LEFT_REAR,
        / **
         * Front right
         * /
        RIGHT_FRONT,
        / **
         * right back
         * /
        RIGHT_REAR
    }

```

### 5, stop searching TpmsScan.stopScan ();



## FAQ

- 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, some mobile phones may need to turn on the GPS



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

Phone: 0755-81773367

Official website: www.elinkthings.com

Email: app@elinkthings.com


EN:
http://doc.elinkthings.com/web/#/15?page_id=73

CN:
http://doc.elinkthings.com/web/#/15?page_id=61

+ 0
- 221
README_CN.md Näytä tiedosto

@@ -1,221 +0,0 @@
[TOC]

# TPMS SDK使用说明 - Android
[![](https://jitpack.io/v/elinkthings/TmpsSDKRepositoryAndroid.svg)](https://jitpack.io/#elinkthings/TmpsSDKRepositoryAndroid)

[aar包下载地址](https://github.com/elinkthings/TmpsSDKRepositoryAndroid/releases)

[key注册地址](http://sdk.aicare.net.cn)



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

## 导入SDK


```
repositories {
flatDir {
dirs 'libs'
}
}


1.将JitPack存储库添加到您的构建文件中
将其添加到存储库末尾的root build.gradle中:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}

2.添加依赖项
dependencies {
implementation 'com.github.elinkthings:TmpsSDKRepositoryAndroid:1.2.2'//蓝牙库

}

3.在gradle中配置java1.8
android {
...
compileOptions {
sourceCompatibility 1.8
targetCompatibility 1.8
}
}

也可以使用aar包依赖,请自行下载放到项目的libs中,下载地址在文档顶部



```

## 权限设置

```
<!--In most cases, you need to ensure that the device supports BLE.-->
<uses-feature
android:name="android.hardware.bluetooth_le"
android:required="true"/>

<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>

<!--Android 6.0 and above. Bluetooth scanning requires one of the following two permissions. You need to apply at run time.-->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>

<!--Optional. If your app need dfu function.-->
<uses-permission android:name="android.permission.INTERNET"/>
```

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

## 开始集成



- 首先给SDK配置key和secret,[申请地址](http://sdk.aicare.net.cn)

```
booTpmsSDK.init(this,key,secret);
```

- 实现TpmsScan.TpmsScanListener方法

```
TpmsScan mTpmsScan = new TpmsScan(new TpmsScan.TpmsScanListener() {
@Override
public void onGetData(String mac, String deviceId, int rssi, float pressure, float battery,int temp, int status, float mcuVersion, int year, int month, int day,float bleVersion){

}
});
```
### 搜索 TpmsScan.startScan(String[] deviceIdS);
```
/**
* 搜索设备,默认搜索所有的设备并通过TpmsScanListener接口返回
*/
TpmsScan.startScan()

/**
* 搜索设备,搜索传入的设备id数组的设备并通过TpmsScanListener接口返回
*
*/
TpmsScan.startScan(String[] deviceIdS)

搜索到的设备会在TpmsScan.TpmsScanListener接口中的onGetData(...)返回

```


### TpmsScan.TpmsScanListener接口返回的数据解析

```
public void onGetData(String mac, String deviceId, int rssi, float pressure, float battery,int temp, int status, float mcuVersion, int year, int month, int day,float bleVersion);

mac:设备mac地址
deviceId:设备id
rssi:信号值
pressure:气压
battery:电压
temp:温度
status:状态
/**
* 设备状态
*/
public enum DeviceState {
/**
* 正常
*/
NORMAL,
/**
* 漏气
*/
LEAK,
/**
* 充气
*/
INFLATE,
/**
* 启动
*/
START,
/**
* 上电
*/
POWER_ON,
/**
* 唤醒
*/
WEAK_UP,
/**
* 温度异常
*/
TEMP_ERROR,
/**
* 电量异常
*/
BATTERY_ERROR,
/**
* 未知
*/
UNKNOWN
}

mcuVersion:mcu版本号
year,month,day :日期
bleVersion:蓝牙版本号


/**
* 设备安装位置
*/
public enum DevicePosition {
/**
* 左前
*/
LEFT_FRONT,
/**
* 左后
*/
LEFT_REAR,
/**
* 右前
*/
RIGHT_FRONT,
/**
* 右后
*/
RIGHT_REAR
}

```

### 停止搜索TpmsScan.stopScan();


## FAQ

- 扫描不到蓝牙设备?

1.查看App权限是否正常,6.0及以上系统必须要定位权限,且需要手动获取权限
2.查看手机的定位服务是否开启,部分手机可能需要打开GPS




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

电话:0755-81773367

官网:www.elinkthings.com

邮箱:app@elinkthings.com

Loading…
Peruuta
Tallenna