sourceCompatibility 1.8 | sourceCompatibility 1.8 | ||||
targetCompatibility 1.8 | targetCompatibility 1.8 | ||||
} | } | ||||
sourceSets { | |||||
main { | |||||
jniLibs.srcDirs = ['libs'] | |||||
} | |||||
} | |||||
} | } | ||||
implementation 'androidx.appcompat:appcompat:1.1.0' | implementation 'androidx.appcompat:appcompat:1.1.0' | ||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | implementation 'androidx.constraintlayout:constraintlayout:1.1.3' | ||||
testImplementation 'junit:junit:4.12' | testImplementation 'junit:junit:4.12' | ||||
implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.7.4' | |||||
implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.0.0' | |||||
implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.5.4' | |||||
implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.7.4'//蓝牙核心库 | |||||
implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.0.0'//OTA库,需要依赖核心库 | |||||
implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.5.4'//解析库,需要依赖核心库 | |||||
implementation 'androidx.recyclerview:recyclerview:1.1.0' | implementation 'androidx.recyclerview:recyclerview:1.1.0' | ||||
implementation 'com.jakewharton:butterknife:10.2.0' | implementation 'com.jakewharton:butterknife:10.2.0' | ||||
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0' | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.0' |
import com.pingwang.bluetoothlib.utils.BleDensityUtil; | import com.pingwang.bluetoothlib.utils.BleDensityUtil; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.ADWeight.ADWeightScaleBleConfig; | import cn.net.aicare.modulelibrary.module.ADWeight.ADWeightScaleBleConfig; | ||||
import cn.net.aicare.modulelibrary.module.ADWeight.ADWeightScaleUserData; | import cn.net.aicare.modulelibrary.module.ADWeight.ADWeightScaleUserData; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/7/12<br> | * 2019/7/12<br> | ||||
* 显示数据 | |||||
* 艾地体脂秤 | |||||
*/ | */ | ||||
public class ADWeightScaleCmdActivity extends BleBaseActivity implements OnCallbackBle, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, OnBleSettingListener, | public class ADWeightScaleCmdActivity extends BleBaseActivity implements OnCallbackBle, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, OnBleSettingListener, | ||||
ADWeightScaleDeviceData.onNotifyData, View.OnClickListener, RadioGroup.OnCheckedChangeListener { | ADWeightScaleDeviceData.onNotifyData, View.OnClickListener, RadioGroup.OnCheckedChangeListener { |
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/11/14<br> | * 2019/11/14<br> | ||||
* java类作用描述 | |||||
* 艾地体脂秤用户管理界面 | |||||
*/ | */ | ||||
public class ADWeightScaleUserActivity extends AppCompatActivity implements View.OnClickListener { | public class ADWeightScaleUserActivity extends AppCompatActivity implements View.OnClickListener { | ||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import android.widget.RadioButton; | import android.widget.RadioButton; | ||||
import android.widget.RadioGroup; | import android.widget.RadioGroup; | ||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | import com.pingwang.bluetoothlib.BleBaseActivity; | ||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | import com.pingwang.bluetoothlib.bean.BleValueBean; | ||||
import com.pingwang.bluetoothlib.utils.BleDensityUtil; | import com.pingwang.bluetoothlib.utils.BleDensityUtil; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.babyBodyFat.BabyBodyFatBleConfig; | import cn.net.aicare.modulelibrary.module.babyBodyFat.BabyBodyFatBleConfig; | ||||
private int heightUnit = 0; | private int heightUnit = 0; | ||||
private RadioButton mRadioButtonKg, mRadioButtonLb, mRadioButtonLbLb, mRadioButtonG, mRadioButtonOz, mRadioButtonStLb, mRadioButtonJin; | private RadioButton mRadioButtonKg, mRadioButtonLb, mRadioButtonLbLb, mRadioButtonG, mRadioButtonOz, mRadioButtonStLb, mRadioButtonJin; | ||||
private RadioButton mRadioButtonCm, mRadioButtonInch, mRadioButtonFoot; | private RadioButton mRadioButtonCm, mRadioButtonInch, mRadioButtonFoot; | ||||
private TextView tv_baby_body_fat_weight,tv_baby_body_fat_height,tv_baby_body_fat_adc; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | private Handler mHandler = new Handler(Looper.getMainLooper()) { | ||||
@Override | @Override | ||||
mRadioButtonFoot = findViewById(R.id.radio_height_foot); | mRadioButtonFoot = findViewById(R.id.radio_height_foot); | ||||
tv_baby_body_fat_weight = findViewById(R.id.tv_baby_body_fat_weight); | |||||
tv_baby_body_fat_height = findViewById(R.id.tv_baby_body_fat_height); | |||||
tv_baby_body_fat_adc = findViewById(R.id.tv_baby_body_fat_adc); | |||||
} | } | ||||
weightUnit = unit; | weightUnit = unit; | ||||
showWeightUnit(weightUnit); | showWeightUnit(weightUnit); | ||||
} | } | ||||
tv_baby_body_fat_weight.setText(weightStr+unitStr); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
heightUnit = unit; | heightUnit = unit; | ||||
showHeightUnit(heightUnit); | showHeightUnit(heightUnit); | ||||
} | } | ||||
tv_baby_body_fat_height.setText(heightStr+unitStr); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
public void onImpedanceSuccess(boolean appAlgorithm,int adc, int algorithmId) { | public void onImpedanceSuccess(boolean appAlgorithm,int adc, int algorithmId) { | ||||
BleLog.i(TAG, "测阻抗成功"); | BleLog.i(TAG, "测阻抗成功"); | ||||
mList.add(TimeUtils.getTime() + "测阻抗成功,阻抗值:" + adc + " ,算法ID:" + algorithmId+" ;"+(appAlgorithm?"使用app算法":"使用秤算法")); | mList.add(TimeUtils.getTime() + "测阻抗成功,阻抗值:" + adc + " ,算法ID:" + algorithmId+" ;"+(appAlgorithm?"使用app算法":"使用秤算法")); | ||||
tv_baby_body_fat_adc.setText(String.valueOf(adc)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
import com.pingwang.bluetoothlib.utils.BleDensityUtil; | import com.pingwang.bluetoothlib.utils.BleDensityUtil; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.babyscale.BabyBleConfig; | import cn.net.aicare.modulelibrary.module.babyscale.BabyBleConfig; | ||||
import cn.net.aicare.modulelibrary.module.babyscale.BabyDeviceData; | import cn.net.aicare.modulelibrary.module.babyscale.BabyDeviceData; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 显示数据 | |||||
* 婴儿秤 | |||||
*/ | */ | ||||
public class BabyCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener | public class BabyCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener | ||||
, OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener, | , OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener, | ||||
@Override | @Override | ||||
protected void onDestroy() { | protected void onDestroy() { | ||||
if (babyDevice!=null){ | |||||
babyDevice.disconnect(); | |||||
} | |||||
super.onDestroy(); | super.onDestroy(); | ||||
BleLog.i(TAG, "onDestroy"); | BleLog.i(TAG, "onDestroy"); | ||||
} | } |
import android.os.Handler; | import android.os.Handler; | ||||
import android.os.Looper; | import android.os.Looper; | ||||
import android.os.Message; | import android.os.Message; | ||||
import android.text.TextUtils; | |||||
import android.view.View; | import android.view.View; | ||||
import android.view.WindowManager; | import android.view.WindowManager; | ||||
import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
import com.pingwang.bluetoothlib.listener.OnBleInfoListener; | import com.pingwang.bluetoothlib.listener.OnBleInfoListener; | ||||
import com.pingwang.bluetoothlib.listener.OnBleOtherDataListener; | import com.pingwang.bluetoothlib.listener.OnBleOtherDataListener; | ||||
import com.pingwang.bluetoothlib.listener.OnBleParameterListener; | import com.pingwang.bluetoothlib.listener.OnBleParameterListener; | ||||
import com.pingwang.bluetoothlib.listener.OnBleRssiListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleSettingListener; | import com.pingwang.bluetoothlib.listener.OnBleSettingListener; | ||||
import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | ||||
import com.pingwang.bluetoothlib.listener.OnCallbackDis; | import com.pingwang.bluetoothlib.listener.OnCallbackDis; | ||||
import com.pingwang.bluetoothlib.utils.BleDataUtils; | import com.pingwang.bluetoothlib.utils.BleDataUtils; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Locale; | import java.util.Locale; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 基础指令信息数据显示 | * 基础指令信息数据显示 | ||||
*/ | */ | ||||
public class BleCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleDeviceDataListener, OnBleVersionListener, OnMcuParameterListener, OnBleErrListener, OnBleInfoListener, | |||||
OnBleParameterListener, OnBleCompanyListener, OnBleSettingListener, OnBleHandshakeListener, View.OnClickListener, OnBleOtherDataListener { | |||||
public class BleCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleDeviceDataListener, OnBleVersionListener, OnMcuParameterListener, OnBleErrListener, OnBleInfoListener, OnBleParameterListener, OnBleCompanyListener, OnBleSettingListener, OnBleHandshakeListener, View.OnClickListener, OnBleOtherDataListener, OnBleRssiListener { | |||||
private static String TAG = BleCmdActivity.class.getName(); | private static String TAG = BleCmdActivity.class.getName(); | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
private List<String> mList; | private List<String> mList; | ||||
private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
private EditText etName, etMacType, etDid, etBroadcastTime, etMcuType, etSleepTime; | |||||
private EditText etName, etMacType, etCid, etVid, etPid, etBroadcastTime, etMcuType, etSleepTime; | |||||
private Context mContext; | private Context mContext; | ||||
private String mAddress; | private String mAddress; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
/** | /** | ||||
* 是否暂停显示数据 | * 是否暂停显示数据 | ||||
*/ | */ | ||||
private boolean mPauseShowCmd=false; | |||||
private boolean mPauseShowCmd = false; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | private Handler mHandler = new Handler(Looper.getMainLooper()) { | ||||
@Override | @Override | ||||
public void handleMessage(Message msg) { | public void handleMessage(Message msg) { | ||||
findViewById(R.id.btnSleepTimeWrite).setOnClickListener(this); | findViewById(R.id.btnSleepTimeWrite).setOnClickListener(this); | ||||
findViewById(R.id.btnSleepTimeRead).setOnClickListener(this); | findViewById(R.id.btnSleepTimeRead).setOnClickListener(this); | ||||
findViewById(R.id.btn_start_ble).setOnClickListener(this); | findViewById(R.id.btn_start_ble).setOnClickListener(this); | ||||
findViewById(R.id.btnNameRssi).setOnClickListener(this); | |||||
etName = findViewById(R.id.etName); | etName = findViewById(R.id.etName); | ||||
etMacType = findViewById(R.id.etMacType); | etMacType = findViewById(R.id.etMacType); | ||||
etDid = findViewById(R.id.etDid); | |||||
etCid = findViewById(R.id.etCid); | |||||
etVid = findViewById(R.id.etVid); | |||||
etPid = findViewById(R.id.etPid); | |||||
etBroadcastTime = findViewById(R.id.etBroadcastTime); | etBroadcastTime = findViewById(R.id.etBroadcastTime); | ||||
etMcuType = findViewById(R.id.etMcuType); | etMcuType = findViewById(R.id.etMcuType); | ||||
etSleepTime = findViewById(R.id.etSleepTime); | etSleepTime = findViewById(R.id.etSleepTime); | ||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
break; | break; | ||||
case R.id.btnPause: | case R.id.btnPause: | ||||
mPauseShowCmd=!mPauseShowCmd; | |||||
mPauseShowCmd = !mPauseShowCmd; | |||||
break; | break; | ||||
case R.id.btnHandshake: | case R.id.btnHandshake: | ||||
if (mBleDevice != null) | |||||
mBleDevice.sendHandshake(); | |||||
if (mBleDevice != null) { | |||||
mBleDevice.setHandshakeStatus(true); | |||||
// mBleDevice.sendHandshake(); | |||||
mList.add(TimeUtils.getTime() + "发送握手"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
break; | break; | ||||
case R.id.btnVersion: | case R.id.btnVersion: | ||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getBleVersion()); | |||||
sendData(sendBleBean); | |||||
// sendBleBean = new SendBleBean(); | |||||
// sendBleBean.setHex(mBleSendCmdUtil.getBleVersion()); | |||||
// sendData(sendBleBean); | |||||
if (mBleDevice != null) { | |||||
String version = mBleDevice.getVersion(); | |||||
mList.add(TimeUtils.getTime() + "版本号:" + version); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
break; | break; | ||||
case R.id.btnBattery: | case R.id.btnBattery: | ||||
sendBleBean = new SendBleBean(); | sendBleBean = new SendBleBean(); | ||||
sendData(sendBleBean); | sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btnDidWrite: | case R.id.btnDidWrite: | ||||
String didStr = etDid.getText().toString().trim().toLowerCase(Locale.US); | |||||
if (didStr.contains(",")) { | |||||
String[] didStrS = didStr.split(","); | |||||
if (didStrS.length > 5) { | |||||
int cidS = Integer.parseInt(didStrS[0]); | |||||
int vidS = Integer.parseInt(didStrS[1]); | |||||
int pidS = Integer.parseInt(didStrS[2]); | |||||
int cid = Integer.parseInt(didStrS[3]); | |||||
int vid = Integer.parseInt(didStrS[4]); | |||||
int pid = Integer.parseInt(didStrS[5]); | |||||
byte[] did = bleDataUtils.getDid(cidS, vidS, pidS, cid, vid, pid); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setDid(did)); | |||||
sendData(sendBleBean); | |||||
try { | |||||
String cidS = etCid.getText().toString().trim().toLowerCase(Locale.US); | |||||
String vidS = etVid.getText().toString().trim().toLowerCase(Locale.US); | |||||
String pidS = etPid.getText().toString().trim().toLowerCase(Locale.US); | |||||
int cid = 0; | |||||
int vid = 0; | |||||
int pid = 0; | |||||
if (!TextUtils.isEmpty(cidS)) { | |||||
cid = Integer.parseInt(cidS); | |||||
} | |||||
if (!TextUtils.isEmpty(vidS)) { | |||||
vid = Integer.parseInt(vidS); | |||||
} | } | ||||
if (!TextUtils.isEmpty(pidS)) { | |||||
pid = Integer.parseInt(pidS); | |||||
} | |||||
byte[] did = bleDataUtils.getDid(1, 1, 1, cid, vid, pid); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setDid(did)); | |||||
sendData(sendBleBean); | |||||
} catch (NumberFormatException e) { | |||||
e.printStackTrace(); | |||||
} | } | ||||
break; | break; | ||||
case R.id.btnDidRead: | case R.id.btnDidRead: | ||||
sendBleBean.setHex(mBleSendCmdUtil.setToWake()); | sendBleBean.setHex(mBleSendCmdUtil.setToWake()); | ||||
sendData(sendBleBean); | sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btnNameRssi: | |||||
if (mBleDevice != null) { | |||||
mBleDevice.readRssi(); | |||||
} | |||||
break; | |||||
} | } | ||||
if (mBleDevice == null) { | if (mBleDevice == null) { | ||||
finish(); | finish(); | ||||
BleLog.i(TAG, "mBleDevice==null"); | BleLog.i(TAG, "mBleDevice==null"); | ||||
return; | |||||
} | } | ||||
mBleDevice.setOnBleVersionListener(this); | mBleDevice.setOnBleVersionListener(this); | ||||
// mBleDevice.setOnBleDeviceDataListener(this); | |||||
mBleDevice.setOnBleDeviceDataListener(this); | |||||
mBleDevice.setOnBleErrListener(this); | mBleDevice.setOnBleErrListener(this); | ||||
mBleDevice.setOnBleInfoListener(this); | mBleDevice.setOnBleInfoListener(this); | ||||
mBleDevice.setOnMcuParameterListener(this); | mBleDevice.setOnMcuParameterListener(this); | ||||
mBleDevice.setOnBleParameterListener(this); | mBleDevice.setOnBleParameterListener(this); | ||||
mBleDevice.setOnBleHandshakeListener(this); | mBleDevice.setOnBleHandshakeListener(this); | ||||
mBleDevice.setOnBleOtherDataListener(this); | mBleDevice.setOnBleOtherDataListener(this); | ||||
mBleDevice.setOnBleRssiListener(this); | |||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onNotifyOtherData(byte[] data) { | public void onNotifyOtherData(byte[] data) { | ||||
if (mPauseShowCmd){ | |||||
if (mPauseShowCmd) { | |||||
return; | return; | ||||
} | } | ||||
mList.add(TimeUtils.getTime() + "透传数据:" + BleStrUtils.byte2HexStr(data)); | mList.add(TimeUtils.getTime() + "透传数据:" + BleStrUtils.byte2HexStr(data)); | ||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
@Override | |||||
public void onNotifyDataA6(byte[] hex) { | |||||
} | |||||
@Override | @Override | ||||
public void onNotifyData(byte[] hex, int type) { | public void onNotifyData(byte[] hex, int type) { | ||||
if (mPauseShowCmd){ | |||||
if (mPauseShowCmd) { | |||||
return; | return; | ||||
} | } | ||||
String data = ""; | String data = ""; | ||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
@Override | |||||
public void OnRssi(int rssi) { | |||||
String name = ""; | |||||
if (mBleDevice != null) { | |||||
name = mBleDevice.getName(); | |||||
} | |||||
mList.add(TimeUtils.getTime() + "名称:" + name + " ,||信号:" + rssi); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | @Override | ||||
protected void onDestroy() { | protected void onDestroy() { | ||||
super.onDestroy(); | super.onDestroy(); |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.content.Context; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Looper; | |||||
import android.os.Message; | |||||
import android.view.View; | |||||
import android.view.WindowManager; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import android.widget.Toast; | |||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | |||||
import com.pingwang.bluetoothlib.device.SendBleBean; | |||||
import com.pingwang.bluetoothlib.listener.CallbackDisIm; | |||||
import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleDeviceDataListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleErrListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleHandshakeListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleInfoListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleOtherDataListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleParameterListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleSettingListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackDis; | |||||
import com.pingwang.bluetoothlib.listener.OnMcuParameterListener; | |||||
import com.pingwang.bluetoothlib.utils.BleDataUtils; | |||||
import com.pingwang.bluetoothlib.utils.BleLog; | |||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
/** | |||||
* xing<br> | |||||
* 2019/4/25<br> | |||||
* 基础指令信息数据显示 | |||||
*/ | |||||
public class BleCmdActivityDataData extends BleBaseActivity implements OnCallbackDis, OnBleDeviceDataListener, OnBleVersionListener, OnMcuParameterListener, OnBleErrListener, OnBleInfoListener, OnBleParameterListener, OnBleCompanyListener, OnBleSettingListener, OnBleHandshakeListener,View.OnClickListener , OnBleOtherDataListener { | |||||
private static String TAG = BleCmdActivityDataData.class.getName(); | |||||
private final int REFRESH_DATA = 3; | |||||
private List<String> mList; | |||||
private ArrayAdapter listAdapter; | |||||
private EditText etName, etMacType, etDid, etBroadcastTime, etMcuType; | |||||
private Context mContext; | |||||
private String mAddress; | |||||
private BleSendCmdUtil mBleSendCmdUtil; | |||||
private BleDataUtils bleDataUtils; | |||||
private BleDevice mBleDevice; | |||||
private int type; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | |||||
@Override | |||||
public void handleMessage(Message msg) { | |||||
switch (msg.what) { | |||||
case REFRESH_DATA: | |||||
if (listAdapter != null) | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
} | |||||
} | |||||
}; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_ble); | |||||
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); | |||||
mContext = this; | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
type = getIntent().getIntExtra("type", -1); | |||||
mBleSendCmdUtil = BleSendCmdUtil.getInstance(); | |||||
init(); | |||||
} | |||||
private void init() { | |||||
mList = new ArrayList<>(); | |||||
ListView listView = findViewById(R.id.listview); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
listView.setAdapter(listAdapter); | |||||
bleDataUtils = BleDataUtils.getInstance(); | |||||
findViewById(R.id.btnClear).setOnClickListener(this); | |||||
findViewById(R.id.btnHandshake).setOnClickListener(this); | |||||
findViewById(R.id.btnVersion).setOnClickListener(this); | |||||
findViewById(R.id.btnBattery).setOnClickListener(this); | |||||
findViewById(R.id.btnTimeRead).setOnClickListener(this); | |||||
findViewById(R.id.btnTimeWrite).setOnClickListener(this); | |||||
findViewById(R.id.btnNameRead).setOnClickListener(this); | |||||
findViewById(R.id.btnMacRead).setOnClickListener(this); | |||||
findViewById(R.id.btnMacTypeRead).setOnClickListener(this); | |||||
findViewById(R.id.btnNameWrite).setOnClickListener(this); | |||||
findViewById(R.id.btnMacTypeWrite).setOnClickListener(this); | |||||
findViewById(R.id.btnDidWrite).setOnClickListener(this); | |||||
findViewById(R.id.btnDidRead).setOnClickListener(this); | |||||
findViewById(R.id.btnBroadcastTimeWrite).setOnClickListener(this); | |||||
findViewById(R.id.btnBroadcastTimeRead).setOnClickListener(this); | |||||
findViewById(R.id.btnBmRestart).setOnClickListener(this); | |||||
findViewById(R.id.btnBmReset).setOnClickListener(this); | |||||
findViewById(R.id.btnMcuType).setOnClickListener(this); | |||||
findViewById(R.id.btnUnits).setOnClickListener(this); | |||||
etName = findViewById(R.id.etName); | |||||
etMacType = findViewById(R.id.etMacType); | |||||
etDid = findViewById(R.id.etDid); | |||||
etBroadcastTime = findViewById(R.id.etBroadcastTime); | |||||
etMcuType = findViewById(R.id.etMcuType); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
SendBleBean sendBleBean; | |||||
switch (v.getId()) { | |||||
case R.id.btnClear: | |||||
if (mList != null) | |||||
mList.clear(); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
break; | |||||
case R.id.btnHandshake: | |||||
if (mBleDevice != null) | |||||
mBleDevice.sendHandshake(); | |||||
break; | |||||
case R.id.btnVersion: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getBleVersion()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnBattery: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getMcuBatteryStatus()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnTimeRead: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getSysTime()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnTimeWrite: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setSysTime(bleDataUtils.getCurrentTime(),true)); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnNameRead: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getBleName()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnMacRead: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getBleMac()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnMacTypeRead: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getBroadcastDataType()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnMacTypeWrite: | |||||
byte macType = Byte.valueOf(etMacType.getText().toString().trim()); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setBroadcastDataType(macType)); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnNameWrite: | |||||
byte[] names = bleDataUtils.getBleName(etName.getText().toString().trim()); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setBleName(names)); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnBroadcastTimeRead: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getBleBroadcastTime()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnBroadcastTimeWrite: | |||||
int time = Integer.parseInt(etBroadcastTime.getText().toString().trim()); | |||||
byte[] broadcastTime = bleDataUtils.getBroadcastTime(time); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setBleBroadcastTime(broadcastTime)); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnDidWrite: | |||||
String didStr = etDid.getText().toString().trim().toLowerCase(Locale.US); | |||||
if (didStr.contains(",")) { | |||||
String[] didStrS = didStr.split(","); | |||||
if (didStrS.length > 5) { | |||||
int cidS = Integer.parseInt(didStrS[0]); | |||||
int vidS = Integer.parseInt(didStrS[1]); | |||||
int pidS = Integer.parseInt(didStrS[2]); | |||||
int cid = Integer.parseInt(didStrS[3]); | |||||
int vid = Integer.parseInt(didStrS[4]); | |||||
int pid = Integer.parseInt(didStrS[5]); | |||||
byte[] did = bleDataUtils.getDid(cidS, vidS, pidS, cid, vid, pid); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setDid(did)); | |||||
sendData(sendBleBean); | |||||
} | |||||
} | |||||
break; | |||||
case R.id.btnDidRead: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getDid()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnBmRestart: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setBleRestart()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnBmReset: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setBleReset()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnMcuType: | |||||
byte mode=(byte)Integer.parseInt(etMcuType.getText().toString().trim()); | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.setPortI2cSpiMode(mode)); | |||||
sendData(sendBleBean); | |||||
break; | |||||
case R.id.btnUnits: | |||||
sendBleBean = new SendBleBean(); | |||||
sendBleBean.setHex(mBleSendCmdUtil.getSupportUnit()); | |||||
sendData(sendBleBean); | |||||
break; | |||||
} | |||||
} | |||||
private void sendData(SendBleBean sendBleBean) { | |||||
if (mBleDevice != null) { | |||||
mBleDevice.sendData(sendBleBean); | |||||
} | |||||
} | |||||
//---------------------------------服务--------------------------------------------------- | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mList.add(TimeUtils.getTime() + "服务与界面建立连接成功"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
CallbackDisIm.getInstance().addListListener(this); | |||||
if (mBluetoothService != null) { | |||||
mBleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (mBleDevice == null) { | |||||
finish(); | |||||
BleLog.i(TAG, "mBleDevice==null"); | |||||
} | |||||
mBleDevice.setOnBleVersionListener(this); | |||||
// mBleDevice.setOnBleDeviceDataListener(this); | |||||
mBleDevice.setOnBleErrListener(this); | |||||
mBleDevice.setOnBleInfoListener(this); | |||||
mBleDevice.setOnMcuParameterListener(this); | |||||
mBleDevice.setOnBleSettingListener(this); | |||||
mBleDevice.setOnBleCompanyListener(this); | |||||
mBleDevice.setOnBleParameterListener(this); | |||||
mBleDevice.setOnBleHandshakeListener(this); | |||||
mBleDevice.setOnBleOtherDataListener(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
mList.add(TimeUtils.getTime() + "服务与界面连接断开"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
mHandler.postDelayed(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
finish(); | |||||
} | |||||
}, 3000); | |||||
//与服务断开连接 | |||||
mBluetoothService = null; | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
CallbackDisIm.getInstance().removeListener(this); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (bleDevice != null) { | |||||
BleLog.i(TAG, "unbindService,断开连接"); | |||||
bleDevice.disconnect(); | |||||
} | |||||
} | |||||
//-----------------状态------------------- | |||||
@Override | |||||
public void onConnecting(@NonNull String mac) { | |||||
//TODO 连接中 | |||||
BleLog.i(TAG, "连接中"); | |||||
} | |||||
@Override | |||||
public void onDisConnected(@NonNull String mac, int code) { | |||||
//TODO 连接断开 | |||||
BleLog.i(TAG, "连接断开"); | |||||
if (mAddress.equals(mac)) { | |||||
Toast.makeText(mContext, "连接断开:" + code, Toast.LENGTH_SHORT).show(); | |||||
finish(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServicesDiscovered(@NonNull String mac) { | |||||
//TODO 连接成功(获取服务成功) | |||||
BleLog.i(TAG, "连接成功(获取服务成功)"); | |||||
} | |||||
@Override | |||||
public void bleOpen() { | |||||
} | |||||
@Override | |||||
public void bleClose() { | |||||
BleLog.i(TAG, "蓝牙未开启,可请求开启"); | |||||
} | |||||
//--------------------------------- | |||||
@Override | |||||
public void onNotifyOtherData(byte[] data) { | |||||
mList.add(TimeUtils.getTime() + "透传数据:" + BleStrUtils.byte2HexStr(data)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onNotifyData(byte[] hex, int type) { | |||||
String data = ""; | |||||
if (hex != null) | |||||
data = BleStrUtils.byte2HexStr(hex); | |||||
if (type == 100) { | |||||
mList.add(TimeUtils.getTime() + "send->" + data); | |||||
} else { | |||||
mList.add(TimeUtils.getTime() + "notify->" + data); | |||||
} | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onHandshake(boolean status) { | |||||
mList.add(TimeUtils.getTime() + "握手:" + status); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBmVersion(String version) { | |||||
mList.add(TimeUtils.getTime() + "版本号:" + version); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onSupportUnit(List<SupportUnitBean> list) { | |||||
StringBuilder unitStr=new StringBuilder(); | |||||
unitStr.append(TimeUtils.getTime()); | |||||
for (SupportUnitBean supportUnitBean : list) { | |||||
unitStr.append("单位类型:").append(supportUnitBean.getType()); | |||||
StringBuilder units= new StringBuilder(); | |||||
units.append("["); | |||||
for (Integer integer1 : supportUnitBean.getSupportUnit()) { | |||||
units.append(integer1).append(","); | |||||
} | |||||
units.append("]"); | |||||
unitStr.append("单位列表:").append(units); | |||||
unitStr.append("\n"); | |||||
} | |||||
mList.add(unitStr.toString()); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onMcuBatteryStatus(int status, int battery) { | |||||
mList.add(TimeUtils.getTime() + "电量:" + battery + "%" + "||状态:" + status); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onSysTime(int status, int[] times) { | |||||
String timeStr = | |||||
times[0] + "-" + times[1] + "-" + times[2] + " " + times[3] + ":" + times[4] + | |||||
":" + times[5]; | |||||
mList.add(TimeUtils.getTime() + "时间:" + timeStr + "||是否有效:" + status); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onErr(int cmdType) { | |||||
mList.add(TimeUtils.getTime() + "错误:" + cmdType); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void OnSettingReturn(byte cmdType, byte cmdData) { | |||||
mList.add(TimeUtils.getTime() + "设置指令:" + cmdType + "||结果:" + cmdData); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBleName(String name) { | |||||
mList.add(TimeUtils.getTime() + "名称:" + name); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBleMac(String mac) { | |||||
mList.add(TimeUtils.getTime() + "Mac:" + mac); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onNoConnectSleep(int sleepSwitch, int sleepTime, int sleepBroadcastSwitch, | |||||
int sleepBroadcastTime) { | |||||
mList.add(TimeUtils.getTime() + "sleepSwitch:" + sleepSwitch + "||sleepTime:" + sleepTime + "||sleepBroadcastSwitch:" + sleepBroadcastSwitch + "||sleepBroadcastTime:" + sleepBroadcastTime); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void OnDID(int cid, int vid, int pid) { | |||||
mList.add(TimeUtils.getTime() + "cid:" + cid + "||vid:" + vid + "||pid:" + pid); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBleBroadcastTime(int time) { | |||||
mList.add(TimeUtils.getTime() + "广播间隔:" + time); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onConnectTime(int time, int status, int timeOut) { | |||||
mList.add(TimeUtils.getTime() + "连接:time:" + time + "||status:" + status + "||timeOut:" + timeOut); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBlePower(int power) { | |||||
mList.add(TimeUtils.getTime() + "功率:" + power); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onPortRate(int rate) { | |||||
mList.add(TimeUtils.getTime() + "串口波特率:" + rate); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBroadcastDataType(int type) { | |||||
mList.add(TimeUtils.getTime() + "广播大小端:" + type); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onModuleUUID(int length, String serverUUID, String featureUUID1, | |||||
String featureUUID2) { | |||||
mList.add(TimeUtils.getTime() + "UUID:length:" + length + "||serverUUID:" + serverUUID + | |||||
"||featureUUID1:" + featureUUID1 + "||featureUUID2" + featureUUID2); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBleMode(int mode) { | |||||
mList.add(TimeUtils.getTime() + "模式:" + mode); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
super.onDestroy(); | |||||
BleLog.i(TAG, "onDestroy"); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.os.Bundle; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ListView; | |||||
import android.widget.SeekBar; | |||||
import android.widget.TextView; | |||||
import android.widget.Toast; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import androidx.annotation.Nullable; | |||||
import androidx.appcompat.widget.AppCompatSeekBar; | |||||
import cn.net.aicare.modulelibrary.module.BloodOxygen.BleBloodOxygenBleConfig; | |||||
import cn.net.aicare.modulelibrary.module.BloodOxygen.BleBloodOxygenDeviceData; | |||||
/** | |||||
* 血氧仪 | |||||
*/ | |||||
public class BloodOxygenActivity extends BleBaseActivity implements OnCallbackBle, BleBloodOxygenDeviceData.DataCallback { | |||||
private TextView tv_sp_max, tv_sp_min, tv_pr_max, tv_pr_min, tv_pl_max, tv_pl_min, tv_version; | |||||
private AppCompatSeekBar sb_sp_max, sb_sp_min, sb_pr_max, sb_pr_min, sb_pl_max, sb_pl_min; | |||||
private ListView mListView; | |||||
private List<String> loglist; | |||||
private ArrayAdapter listAdapter; | |||||
private String mAddress; | |||||
private boolean mPauseRefresh = false; | |||||
private BleBloodOxygenDeviceData mBleBloodOxygenDeviceData; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_bloodoxygen); | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
tv_sp_max = findViewById(R.id.tv_sp_max); | |||||
tv_sp_min = findViewById(R.id.tv_sp_min); | |||||
tv_pr_max = findViewById(R.id.tv_pr_max); | |||||
tv_pr_min = findViewById(R.id.tv_pr_min); | |||||
tv_pl_max = findViewById(R.id.tv_pl_max); | |||||
tv_pl_min = findViewById(R.id.tv_pl_min); | |||||
tv_version = findViewById(R.id.tv_version); | |||||
sb_sp_max = findViewById(R.id.sb_sp_max); | |||||
sb_sp_min = findViewById(R.id.sb_sp_min); | |||||
sb_pr_max = findViewById(R.id.sb_pr_max); | |||||
sb_pr_min = findViewById(R.id.sb_pr_min); | |||||
sb_pl_max = findViewById(R.id.sb_pl_max); | |||||
sb_pl_min = findViewById(R.id.sb_pl_min); | |||||
sb_pl_min = findViewById(R.id.sb_pl_min); | |||||
mListView = findViewById(R.id.lv_log); | |||||
loglist = new ArrayList<>(); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, loglist); | |||||
mListView.setAdapter(listAdapter); | |||||
findViewById(R.id.bt_status).setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (mBleBloodOxygenDeviceData != null) | |||||
mBleBloodOxygenDeviceData.getDeviceStatus(); | |||||
} | |||||
}); | |||||
findViewById(R.id.bt_alarm).setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
int sp_max = sb_sp_max.getProgress(); | |||||
int sp_min = sb_sp_min.getProgress(); | |||||
int pl_max = sb_pl_max.getProgress(); | |||||
int pl_min = sb_pl_min.getProgress(); | |||||
int pr_max = sb_pr_max.getProgress(); | |||||
int pr_min = sb_pr_min.getProgress(); | |||||
if (mBleBloodOxygenDeviceData != null) | |||||
mBleBloodOxygenDeviceData.setAlarm(sp_max, sp_min, pr_max, pr_min, pl_max, pl_min); | |||||
} | |||||
}); | |||||
findViewById(R.id.bt_version).setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (mBleBloodOxygenDeviceData != null) | |||||
mBleBloodOxygenDeviceData.getVersion(); | |||||
} | |||||
}); | |||||
findViewById(R.id.bt_pause).setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
mPauseRefresh=!mPauseRefresh; | |||||
} | |||||
}); | |||||
findViewById(R.id.bt_clear).setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
mPauseRefresh=false; | |||||
loglist.clear(); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
}); | |||||
sb_sp_max.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_sp_max.setText(progress + ""); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
sb_sp_min.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_sp_min.setText(progress + ""); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
sb_pr_max.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_pr_max.setText(progress + ""); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
sb_pr_min.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_pr_min.setText(progress + ""); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
sb_pl_max.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_pl_max.setText(progress + ""); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
sb_pl_min.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_pl_min.setText(progress + ""); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
loglist.add(0, "连接设备成功"); | |||||
mBluetoothService.setOnCallback(this); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
BleBloodOxygenDeviceData.init(bleDevice, this); | |||||
mBleBloodOxygenDeviceData = BleBloodOxygenDeviceData.getInstance(); | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
protected void startScanBle(long timeOut) { | |||||
super.startScanBle(timeOut); | |||||
} | |||||
@Override | |||||
protected void stopScanBle() { | |||||
super.stopScanBle(); | |||||
} | |||||
@Override | |||||
protected void connectBle(BleValueBean bleValueBean) { | |||||
super.connectBle(bleValueBean); | |||||
} | |||||
@Override | |||||
protected void connectBle(String mac) { | |||||
super.connectBle(mac); | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
if (mAddress.equalsIgnoreCase(mac)) { | |||||
Toast.makeText(this, "设备断开连接", Toast.LENGTH_SHORT).show(); | |||||
finish(); | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
if (mBleBloodOxygenDeviceData != null) { | |||||
mBleBloodOxygenDeviceData.disconnect(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onData(byte[] data, int type) { | |||||
String dataStr = "收到的数据"; | |||||
if (type == 1) { | |||||
dataStr = "收到透传数据:"; | |||||
} | |||||
dataStr += BleStrUtils.byte2HexStr(data); | |||||
loglist.add(0, dataStr); | |||||
refreshData(); | |||||
} | |||||
@Override | |||||
public void onResult(int status, int spo2, int pr, float pi, int battery, float rr, int py, int pyTrough, int wearStatus) { | |||||
String statusStr = ""; | |||||
switch (status) { | |||||
case BleBloodOxygenBleConfig.Test_status_START: | |||||
statusStr = "开始测试"; | |||||
break; | |||||
case BleBloodOxygenBleConfig.Test_status_Finish: | |||||
statusStr = "正在测试"; | |||||
break; | |||||
case BleBloodOxygenBleConfig.Test_status_ERROR: | |||||
statusStr = "测试结束"; | |||||
break; | |||||
} | |||||
String wearStatusStr = wearStatus == 1 ? "已佩戴" : "未佩戴"; | |||||
String showData = | |||||
"测试状态:" + statusStr + "\n血氧饱和度:" + spo2 + "\n脉率:" + pr + "\n血流灌注指数:" + pi + "\n电池电量:" + battery + "\n呼吸频率(RR):" + rr + "\n脉率曲线值:" + py + "\n脉率曲线波谷:" + pyTrough + "\n佩戴状态:" + wearStatusStr; | |||||
loglist.add(0, showData); | |||||
refreshData(); | |||||
} | |||||
@Override | |||||
public void onSetResult(int result) { | |||||
String resultStr = ""; | |||||
switch (result) { | |||||
case BleBloodOxygenBleConfig.SET_RESULT_FAIL: | |||||
resultStr = "设置失败"; | |||||
break; | |||||
case BleBloodOxygenBleConfig.SET_RESULT_SUCCESS: | |||||
resultStr = "设置成功"; | |||||
break; | |||||
} | |||||
loglist.add(0, "设置结果" + resultStr); | |||||
refreshData(); | |||||
} | |||||
@Override | |||||
public void onErrorCode(int code) { | |||||
String errorStr = ""; | |||||
switch (code) { | |||||
case BleBloodOxygenBleConfig.ErrorCode_Saturation_Rate_Not_Stable: | |||||
errorStr = "血氧饱和率不稳定"; | |||||
break; | |||||
case BleBloodOxygenBleConfig.ErrorCode_Pulse_Rate_Unstable: | |||||
errorStr = "脉率不稳定"; | |||||
break; | |||||
case BleBloodOxygenBleConfig.ErrorCode_Test_Error: | |||||
errorStr = "测量出错"; | |||||
break; | |||||
case BleBloodOxygenBleConfig.ErrorCode_Low_Power: | |||||
errorStr = "设备低电"; | |||||
break; | |||||
} | |||||
loglist.add(0, "设置结果" + errorStr); | |||||
refreshData(); | |||||
} | |||||
private void refreshData() { | |||||
if (listAdapter != null && !mPauseRefresh) { | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onBmVersion(String version) { | |||||
tv_version.setText(version); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.os.Bundle; | |||||
import android.text.Editable; | |||||
import android.text.TextWatcher; | |||||
import android.util.Log; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import org.json.JSONArray; | |||||
import org.json.JSONException; | |||||
import org.json.JSONObject; | |||||
import java.io.ByteArrayOutputStream; | |||||
import java.io.IOException; | |||||
import java.io.InputStream; | |||||
import java.net.HttpURLConnection; | |||||
import java.net.URL; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.Nullable; | |||||
import androidx.appcompat.app.AppCompatActivity; | |||||
/** | |||||
* 4G血糖仪 | |||||
*/ | |||||
public class BloodSugar4GActivity extends AppCompatActivity implements View.OnClickListener { | |||||
private String TAG = BloodSugar4GActivity.class.getName(); | |||||
private String token; | |||||
private long appid; | |||||
private String imei; | |||||
private List<String> loglist; | |||||
private String myDeviceId; | |||||
private ArrayAdapter logAdapter; | |||||
private ListView listviw; | |||||
private EditText mEditText; | |||||
private Button btn_deviceId; | |||||
private Button btn_data; | |||||
private Button btn_clear; | |||||
private Button btn_login; | |||||
private List<Long> bodyIds; | |||||
private long maxId = 0l; | |||||
private Button btn_test; | |||||
private Button btn_produce; | |||||
private String url = "https://ailink.aicare.net.cn"; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_bloodsugar_4g); | |||||
listviw = findViewById(R.id.listviw); | |||||
mEditText = findViewById(R.id.ed_imei); | |||||
btn_deviceId = findViewById(R.id.btn_deviceId); | |||||
btn_data = findViewById(R.id.btn_data); | |||||
btn_clear = findViewById(R.id.btn_clear); | |||||
btn_login = findViewById(R.id.btn_login); | |||||
btn_test = findViewById(R.id.btn_test); | |||||
btn_produce = findViewById(R.id.btn_produce); | |||||
btn_deviceId.setOnClickListener(this); | |||||
btn_data.setOnClickListener(this); | |||||
btn_clear.setOnClickListener(this); | |||||
btn_login.setOnClickListener(this); | |||||
btn_test.setOnClickListener(this); | |||||
btn_produce.setOnClickListener(this); | |||||
loglist = new ArrayList<>(); | |||||
bodyIds = new ArrayList<>(); | |||||
logAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, loglist); | |||||
listviw.setAdapter(logAdapter); | |||||
new Thread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
login(); | |||||
} catch (Throwable throwable) { | |||||
throwable.printStackTrace(); | |||||
} | |||||
} | |||||
}).start(); | |||||
mEditText.addTextChangedListener(new TextWatcher() { | |||||
@Override | |||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |||||
} | |||||
@Override | |||||
public void onTextChanged(CharSequence s, int start, int before, int count) { | |||||
} | |||||
@Override | |||||
public void afterTextChanged(Editable s) { | |||||
myDeviceId = ""; | |||||
maxId = 0; | |||||
} | |||||
}); | |||||
} | |||||
public void login() throws Throwable { | |||||
String mUrl=url + "/api/user/login?key=inet_elink&username=dhls@qq.com&password=dc483e80a7a0bd9ef71d8cf973673924"; | |||||
URL uri = new URL(mUrl); | |||||
HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | |||||
// Post请求必须设置允许输出 | |||||
httpURLConnection.setDoOutput(true); | |||||
// Post请求不能使用缓存 | |||||
httpURLConnection.setUseCaches(false); | |||||
// 设置为Post请求 | |||||
httpURLConnection.setRequestMethod("POST"); | |||||
httpURLConnection.setInstanceFollowRedirects(true); | |||||
// 配置请求Content-Type | |||||
httpURLConnection.setRequestProperty("Content-Type", | |||||
"application/x-www-form-urlencode"); | |||||
// 设置连接超时时间 | |||||
httpURLConnection.setConnectTimeout(6 * 1000); | |||||
// 开始连接 | |||||
httpURLConnection.connect(); | |||||
// DataOutputStream dos = new DataOutputStream(httpURLConnection.getOutputStream()); | |||||
// dos.write(map.toString().getBytes()); | |||||
// dos.flush(); | |||||
// dos.close(); | |||||
// 判断请求是否成功 | |||||
if (httpURLConnection.getResponseCode() == 200) { | |||||
// 获取返回的数据 | |||||
byte[] data = readInputStream(httpURLConnection.getInputStream()); | |||||
String result = new String(data, "UTF-8"); | |||||
Log.i(TAG, result); | |||||
JSONObject jsonObject = new JSONObject(result); | |||||
JSONObject datajson = jsonObject.getJSONObject("data"); | |||||
runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
token = jsonObject.getString("token"); | |||||
appid = datajson.getLong("appUserId"); | |||||
loglist.add(0, "登录成功"); | |||||
logAdapter.notifyDataSetChanged(); | |||||
} catch (JSONException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
}); | |||||
} else { | |||||
Log.i(TAG, "Post方式请求失败"); | |||||
runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
loglist.add(0, "登录失败"); | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
public void getDeviceid() throws Throwable { | |||||
StringBuilder stringBuilder = new StringBuilder(); | |||||
stringBuilder.append(url); | |||||
stringBuilder.append("/api/device/getDeviceBySN?key=inet_elink&appUserId="); | |||||
stringBuilder.append(appid); | |||||
stringBuilder.append("&token="); | |||||
stringBuilder.append(token); | |||||
stringBuilder.append("&deviceSN="); | |||||
stringBuilder.append(imei); | |||||
Log.e(TAG, stringBuilder.toString()); | |||||
URL uri = new URL(stringBuilder.toString()); | |||||
HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | |||||
// Post请求必须设置允许输出 | |||||
httpURLConnection.setDoOutput(true); | |||||
// Post请求不能使用缓存 | |||||
httpURLConnection.setUseCaches(false); | |||||
// 设置为Post请求 | |||||
httpURLConnection.setRequestMethod("POST"); | |||||
httpURLConnection.setInstanceFollowRedirects(true); | |||||
// 配置请求Content-Type | |||||
httpURLConnection.setRequestProperty("Content-Type", | |||||
"application/x-www-form-urlencode"); | |||||
// 设置连接超时时间 | |||||
httpURLConnection.setConnectTimeout(6 * 1000); | |||||
// 开始连接 | |||||
httpURLConnection.connect(); | |||||
// DataOutputStream dos = new DataOutputStream(httpURLConnection.getOutputStream()); | |||||
// dos.write(map.toString().getBytes()); | |||||
// dos.flush(); | |||||
// dos.close(); | |||||
// 判断请求是否成功 | |||||
if (httpURLConnection.getResponseCode() == 200) { | |||||
// 获取返回的数据 | |||||
byte[] data = readInputStream(httpURLConnection.getInputStream()); | |||||
String result = new String(data, "UTF-8"); | |||||
Log.i(TAG, result); | |||||
JSONObject jsonObject = new JSONObject(result); | |||||
JSONArray datajson = jsonObject.getJSONArray("data"); | |||||
runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
if (datajson.length() > 0) | |||||
myDeviceId = datajson.getJSONObject(0).getString("deviceId"); | |||||
loglist.add(0, "设备信息" + result); | |||||
logAdapter.notifyDataSetChanged(); | |||||
} catch (JSONException e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
}); | |||||
} else { | |||||
Log.i(TAG, "Post方式请求失败"); | |||||
} | |||||
} | |||||
public void getData() throws Throwable { | |||||
if (myDeviceId.isEmpty()) { | |||||
runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
loglist.add(0, "请获取设备Id"); | |||||
logAdapter.notifyDataSetChanged(); | |||||
} | |||||
}); | |||||
return; | |||||
} | |||||
StringBuilder stringBuilder = new StringBuilder(); | |||||
stringBuilder.append(url); | |||||
stringBuilder.append("/api/deDataGlu/listByDeviceId?key=inet_elink&appUserId="); | |||||
stringBuilder.append(appid); | |||||
stringBuilder.append("&token="); | |||||
stringBuilder.append(token); | |||||
stringBuilder.append("&deviceId="); | |||||
stringBuilder.append(myDeviceId); | |||||
stringBuilder.append("&maxId="); | |||||
stringBuilder.append(maxId); | |||||
URL uri = new URL(stringBuilder.toString()); | |||||
HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | |||||
// // Post请求必须设置允许输出 | |||||
// httpURLConnection.setDoOutput(true); | |||||
// // Post请求不能使用缓存 | |||||
// httpURLConnection.setUseCaches(false); | |||||
// 设置为Post请求 | |||||
// httpURLConnection.setRequestMethod("GET"); | |||||
// httpURLConnection.setInstanceFollowRedirects(true); | |||||
// // 配置请求Content-Type | |||||
// httpURLConnection.setRequestProperty("Content-Type", | |||||
// "application/x-www-form-urlencode"); | |||||
// 设置连接超时时间 | |||||
httpURLConnection.setConnectTimeout(6 * 1000); | |||||
// 开始连接 | |||||
httpURLConnection.connect(); | |||||
// DataOutputStream dos = new DataOutputStream(httpURLConnection.getOutputStream()); | |||||
// dos.write(map.toString().getBytes()); | |||||
// dos.flush(); | |||||
// dos.close(); | |||||
// 判断请求是否成功 | |||||
if (httpURLConnection.getResponseCode() == 200) { | |||||
// 获取返回的数据 | |||||
byte[] data = readInputStream(httpURLConnection.getInputStream()); | |||||
String result = new String(data, "UTF-8"); | |||||
JSONObject jsonObject = new JSONObject(result); | |||||
JSONObject dataObject = jsonObject.getJSONObject("data"); | |||||
JSONArray datajson = dataObject.getJSONArray("list"); | |||||
bodyIds.clear(); | |||||
for (int i = 0; i < datajson.length(); i++) { | |||||
long id = datajson.getJSONObject(i).getLong("id"); | |||||
bodyIds.add(id); | |||||
StringBuffer stringBuffer = new StringBuffer(); | |||||
stringBuffer.append("id:"); | |||||
stringBuffer.append(id); | |||||
stringBuffer.append(" 创建时间:"); | |||||
stringBuffer.append(TimeUtils.getTime(datajson.getJSONObject(i).getLong("createTime"))); | |||||
stringBuffer.append("血糖值(原始值):"); | |||||
int value = datajson.getJSONObject(i).getInt("gluFasting"); | |||||
stringBuffer.append(value); | |||||
stringBuffer.append(" 小数位:"); | |||||
int point = datajson.getJSONObject(i).getInt("gluPoint"); | |||||
stringBuffer.append(point); | |||||
stringBuffer.append(" 单位:"); | |||||
int unit = datajson.getJSONObject(i).getInt("gluUnit"); | |||||
stringBuffer.append(unit); | |||||
stringBuffer.append("\n血糖(计算后)"); | |||||
stringBuffer.append(String.format(Locale.US, "%." + point + "f", (value * 1f) * Math.pow(10, 0 - point))); | |||||
stringBuffer.append(unit == 1 ? "mmol/L" : "mg/dL"); | |||||
loglist.add(0, stringBuffer.toString()); | |||||
} | |||||
if (maxId == 0) { | |||||
loglist.add(0, "总共有:" + bodyIds.size() + " 条"); | |||||
} else { | |||||
loglist.add(0, "新增了:" + bodyIds.size() + " 条"); | |||||
} | |||||
if (bodyIds.size() > 0) { | |||||
maxId = bodyIds.get(bodyIds.size() - 1); | |||||
} | |||||
Log.i(TAG, result); | |||||
runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
logAdapter.notifyDataSetChanged(); | |||||
} | |||||
}); | |||||
} else { | |||||
runOnUiThread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
loglist.add(0, "请求失败"); | |||||
logAdapter.notifyDataSetChanged(); | |||||
} | |||||
}); | |||||
} | |||||
} | |||||
public byte[] readInputStream(InputStream inputStream) throws IOException { | |||||
byte[] buffer = new byte[1024]; | |||||
int len = 0; | |||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |||||
while ((len = inputStream.read(buffer)) != -1) { | |||||
bos.write(buffer, 0, len); | |||||
} | |||||
bos.close(); | |||||
return bos.toByteArray(); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (v.getId() == R.id.btn_deviceId) { | |||||
imei = mEditText.getText().toString().trim(); | |||||
if (imei == null || imei.isEmpty()) { | |||||
loglist.add("请输入IMEI号"); | |||||
} else { | |||||
new Thread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
getDeviceid(); | |||||
} catch (Throwable throwable) { | |||||
throwable.printStackTrace(); | |||||
} | |||||
} | |||||
}).start(); | |||||
} | |||||
} else if (v.getId() == R.id.btn_data) { | |||||
new Thread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
getData(); | |||||
} catch (Throwable throwable) { | |||||
throwable.printStackTrace(); | |||||
} | |||||
} | |||||
}).start(); | |||||
} else if (v.getId() == R.id.btn_clear) { | |||||
loglist.clear(); | |||||
logAdapter.notifyDataSetChanged(); | |||||
} else if (v.getId() == R.id.btn_login) { | |||||
new Thread(new Runnable() { | |||||
@Override | |||||
public void run() { | |||||
try { | |||||
login(); | |||||
} catch (Throwable throwable) { | |||||
throwable.printStackTrace(); | |||||
} | |||||
} | |||||
}).start(); | |||||
} else if (v.getId() == R.id.btn_produce) { | |||||
url = "https://ailink.aicare.net.cn"; | |||||
} else if (v.getId() == R.id.btn_test) { | |||||
url = "http://test.ailink.app.aicare.net.cn"; | |||||
} | |||||
} | |||||
} |
import java.util.List; | import java.util.List; | ||||
import java.util.UUID; | import java.util.UUID; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.BroadcastScale.BroadcastScaleBleConfig; | import cn.net.aicare.modulelibrary.module.BroadcastScale.BroadcastScaleBleConfig; | ||||
import cn.net.aicare.modulelibrary.module.BroadcastScale.BroadcastScaleDeviceData; | import cn.net.aicare.modulelibrary.module.BroadcastScale.BroadcastScaleDeviceData; | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
private RadioButton mRadioButtonKg, mRadioButtonLb, mRadioButtonLbLb, mRadioButtonG, mRadioButtonOz, mRadioButtonStLb, mRadioButtonJin; | private RadioButton mRadioButtonKg, mRadioButtonLb, mRadioButtonLbLb, mRadioButtonG, mRadioButtonOz, mRadioButtonStLb, mRadioButtonJin; | ||||
private TextView tv_broadcast_temp, tv_broadcast_mac; | |||||
private TextView tv_broadcast_temp, tv_broadcast_mac,tv_broadcast_did; | |||||
private List<String> mList; | private List<String> mList; | ||||
private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
mRadioButtonLbLb = findViewById(R.id.radio_weight_lb_lb); | mRadioButtonLbLb = findViewById(R.id.radio_weight_lb_lb); | ||||
tv_broadcast_mac = findViewById(R.id.tv_broadcast_mac); | tv_broadcast_mac = findViewById(R.id.tv_broadcast_mac); | ||||
tv_broadcast_did = findViewById(R.id.tv_broadcast_did); | |||||
} | } | ||||
@Override | @Override | ||||
public void OnDID(int cid, int vid, int pid) { | public void OnDID(int cid, int vid, int pid) { | ||||
String didStr = "cid:" + cid + "||vid:" + vid + "||pid:" + pid; | String didStr = "cid:" + cid + "||vid:" + vid + "||pid:" + pid; | ||||
// if (tv_broadcast_did!=null){ | |||||
// tv_broadcast_did.setText(didStr); | |||||
// } | |||||
if (tv_broadcast_did!=null){ | |||||
tv_broadcast_did.setText(didStr); | |||||
} | |||||
} | } | ||||
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.content.Context; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Looper; | |||||
import android.os.Message; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | |||||
import com.pingwang.bluetoothlib.device.SendBleBean; | |||||
import com.pingwang.bluetoothlib.device.SendMcuBean; | |||||
import com.pingwang.bluetoothlib.listener.CallbackDisIm; | |||||
import com.pingwang.bluetoothlib.listener.OnBleDeviceDataListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleOtherDataListener; | |||||
import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackDis; | |||||
import com.pingwang.bluetoothlib.listener.OnMcuParameterListener; | |||||
import com.pingwang.bluetoothlib.utils.BleLog; | |||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.sphygmomanometer.SphyBleConfig; | |||||
/** | |||||
* xing<br> | |||||
* 2019/4/25<br> | |||||
* 验证不握手不加密模块 | |||||
*/ | |||||
public class ClearShakeHandsActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener, OnMcuParameterListener, | |||||
View.OnClickListener, OnBleOtherDataListener, OnBleDeviceDataListener { | |||||
private static String TAG = ClearShakeHandsActivity.class.getName(); | |||||
private final int REFRESH_DATA = 3; | |||||
private List<String> mList; | |||||
private ArrayAdapter listAdapter; | |||||
private Context mContext; | |||||
private EditText et_type; | |||||
private BleDevice mBleDevice; | |||||
private String mAddress; | |||||
private BleSendCmdUtil mBleSendCmdUtil; | |||||
private int type=0x01; | |||||
private byte unit = 0; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | |||||
@Override | |||||
public void handleMessage(Message msg) { | |||||
switch (msg.what) { | |||||
case REFRESH_DATA: | |||||
if (listAdapter != null) | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
} | |||||
} | |||||
}; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_clear_shake_hands); | |||||
mContext = this; | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
type = getIntent().getIntExtra("type", -1); | |||||
mBleSendCmdUtil = BleSendCmdUtil.getInstance(); | |||||
init(); | |||||
} | |||||
private void init() { | |||||
mList = new ArrayList<>(); | |||||
ListView listView = findViewById(R.id.listview); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
listView.setAdapter(listAdapter); | |||||
findViewById(R.id.btn_set_unit).setOnClickListener(this); | |||||
findViewById(R.id.btn1).setOnClickListener(this); | |||||
findViewById(R.id.clear).setOnClickListener(this); | |||||
et_type = findViewById(R.id.et_type); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
switch (v.getId()) { | |||||
case R.id.btn_set_unit: | |||||
if (unit == SphyBleConfig.SPHY_UNIT_MMHG) { | |||||
unit = SphyBleConfig.SPHY_UNIT_KPA; | |||||
setUnit(unit); | |||||
} else { | |||||
unit = SphyBleConfig.SPHY_UNIT_MMHG; | |||||
setUnit(unit); | |||||
} | |||||
break; | |||||
case R.id.btn1: | |||||
String cmd = et_type.getText().toString().trim(); | |||||
byte[] bytes=new byte[cmd.length()/2]; | |||||
for (int i=0;i<=cmd.length()-2;i+=2){ | |||||
int i1 = Integer.parseInt(cmd.substring(i, i + 2), 16); | |||||
bytes[i>>1]=(byte)i1; | |||||
} | |||||
SendMcuBean sendDataBean = new SendMcuBean(); | |||||
sendDataBean.setHex(type,bytes); | |||||
mBleDevice.sendData(sendDataBean); | |||||
mList.add(TimeUtils.getTime() + "发送->" + BleStrUtils.byte2HexStr(bytes)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
break; | |||||
case R.id.clear: | |||||
if (mList != null) | |||||
mList.clear(); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
break; | |||||
} | |||||
} | |||||
/** | |||||
* 设置单位(Set unit) | |||||
* | |||||
* @param unit | |||||
*/ | |||||
public void setUnit(byte unit) { | |||||
SendMcuBean sendMcuBean = new SendMcuBean(); | |||||
byte[] data = new byte[2]; | |||||
data[0] = SphyBleConfig.SET_UNIT; | |||||
data[1] = unit; | |||||
sendMcuBean.setHex(0x01, data); | |||||
mBleDevice.sendData(sendMcuBean); | |||||
mList.add(TimeUtils.getTime() + "发送->" + BleStrUtils.byte2HexStr(data)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
//---------------------------------服务--------------------------------------------------- | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
CallbackDisIm.getInstance().addListListener(this); | |||||
BleLog.i(TAG, "服务与界面建立连接成功"); | |||||
//与服务建立连接 | |||||
if (mBluetoothService != null) { | |||||
mBleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
mBleDevice.setA7Encryption(false); | |||||
mBleDevice.setOnBleDeviceDataListener(ClearShakeHandsActivity.this); | |||||
mBleDevice.setOnBleVersionListener(ClearShakeHandsActivity.this); | |||||
mBleDevice.setOnBleOtherDataListener(ClearShakeHandsActivity.this); | |||||
byte[] bytes = mBleSendCmdUtil.setClearShakeHands(); | |||||
SendBleBean sendBleBean=new SendBleBean(); | |||||
sendBleBean.setHex(bytes); | |||||
mBleDevice.sendData(sendBleBean); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
BleLog.i(TAG, "服务与界面连接断开"); | |||||
//与服务断开连接 | |||||
mBluetoothService = null; | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
CallbackDisIm.getInstance().removeListener(this); | |||||
if (mBleDevice != null) { | |||||
mBleDevice.disconnect(); | |||||
mBleDevice = null; | |||||
} | |||||
} | |||||
//-----------------状态------------------- | |||||
@Override | |||||
public void onConnecting(@NonNull String mac) { | |||||
//TODO 连接中 | |||||
if (mAddress.equals(mac)) | |||||
BleLog.i(TAG, "连接中"); | |||||
} | |||||
@Override | |||||
public void onDisConnected(@NonNull String mac, int code) { | |||||
//TODO 连接断开 | |||||
if (mAddress.equals(mac)) { | |||||
BleLog.i(TAG, "连接断开"); | |||||
finish(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServicesDiscovered(@NonNull String mac) { | |||||
//TODO 连接成功(获取服务成功) | |||||
if (mAddress.equals(mac)) | |||||
BleLog.i(TAG, "连接成功(获取服务成功)"); | |||||
} | |||||
@Override | |||||
public void bleOpen() { | |||||
} | |||||
@Override | |||||
public void bleClose() { | |||||
BleLog.i(TAG, "蓝牙未开启,可请求开启"); | |||||
finish(); | |||||
} | |||||
//-----------------通知------------------- | |||||
@Override | |||||
public void onNotifyData(byte[] hex, int type) { | |||||
mList.add(TimeUtils.getTime() + "notify->" + BleStrUtils.byte2HexStr(hex)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onNotifyDataA6(byte[] hex) { | |||||
mList.add(TimeUtils.getTime() + "notify->" + BleStrUtils.byte2HexStr(hex)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onNotifyOtherData(byte[] data) { | |||||
mList.add(TimeUtils.getTime() + "notify->" + BleStrUtils.byte2HexStr(data)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onBmVersion(String version) { | |||||
mList.add(TimeUtils.getTime() + "版本号:" + version); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
super.onDestroy(); | |||||
BleLog.i(TAG, "onDestroy"); | |||||
} | |||||
} |
import com.pingwang.bluetoothlib.server.ELinkBleServer; | import com.pingwang.bluetoothlib.server.ELinkBleServer; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.LoadingIosDialogFragment; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.LoadingIosDialogFragment; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.appcompat.app.AppCompatActivity; | import androidx.appcompat.app.AppCompatActivity; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/3/6<br> | * 2019/3/6<br> | ||||
* java类作用描述 | |||||
* 连接测试工具 | |||||
*/ | */ | ||||
public class ConnectBleTestActivity extends AppCompatActivity implements OnCallbackBle { | public class ConnectBleTestActivity extends AppCompatActivity implements OnCallbackBle { | ||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import android.widget.RadioButton; | import android.widget.RadioButton; | ||||
import com.holtek.libHTBodyfat.HTBodyBasicInfo; | |||||
import com.holtek.libHTBodyfat.HTBodyResultAllBody; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | import com.pingwang.bluetoothlib.BleBaseActivity; | ||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | import com.pingwang.bluetoothlib.bean.SupportUnitBean; | ||||
import com.pingwang.bluetoothlib.device.BleDevice; | import com.pingwang.bluetoothlib.device.BleDevice; | ||||
import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatBleDeviceData; | import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatBleDeviceData; | ||||
import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatUtil; | import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatUtil; | ||||
/** | |||||
* 八电极秤 | |||||
*/ | |||||
public class EightBodyfatActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, EightBodyFatBleDeviceData.EightBodyFatCallback { | public class EightBodyfatActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, EightBodyFatBleDeviceData.EightBodyFatCallback { | ||||
private List<String> loglist; | private List<String> loglist; | ||||
case EightBodyFatUtil.MEASUREMENT_END: | case EightBodyFatUtil.MEASUREMENT_END: | ||||
loglist.add(0, "测量完成"); | loglist.add(0, "测量完成"); | ||||
//测量完成 | //测量完成 | ||||
if (mEightBodyfatAdc!=null)kaimengJieMi(mEightBodyfatAdc); | |||||
break; | break; | ||||
case EightBodyFatUtil.MUC_CALL_BACK_RESULT: | case EightBodyFatUtil.MUC_CALL_BACK_RESULT: | ||||
switch (typeState) { | switch (typeState) { | ||||
@Override | @Override | ||||
public void onImpedance(int adc, int part, int arithmetic) { | public void onImpedance(int adc, int part, int arithmetic) { | ||||
loglist.add(0, "阻抗:" + adc + " 部位: " + part + " 算法" + arithmetic); | loglist.add(0, "阻抗:" + adc + " 部位: " + part + " 算法" + arithmetic); | ||||
kaimeng(part,adc); | |||||
} | } | ||||
@Override | @Override | ||||
public void showData(String data) { | public void showData(String data) { | ||||
// loglist.add(0, data); | // loglist.add(0, data); | ||||
} | } | ||||
private EightBodyfatAdc mEightBodyfatAdc; | |||||
private void kaimeng(int part, int adc) { | |||||
if (mEightBodyfatAdc == null) mEightBodyfatAdc = new EightBodyfatAdc(); | |||||
switch (part) { | |||||
case EightBodyFatUtil.IMPEDANCE_FOOT: | |||||
//双脚阻抗 | |||||
mEightBodyfatAdc.setAdcFoot(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_HAND: | |||||
//双手阻抗 | |||||
mEightBodyfatAdc.setAdcHand(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_BODY: | |||||
//躯干阻抗 | |||||
mEightBodyfatAdc.setAdcBody(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_L_HAND: | |||||
//"左手阻抗"; | |||||
mEightBodyfatAdc.setAdcLeftHand(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_R_HAND: | |||||
// adc = adc + "右手阻抗"; | |||||
mEightBodyfatAdc.setAdcRightHand(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_L_FOOT: | |||||
// adc = adc + "左脚阻抗"; | |||||
mEightBodyfatAdc.setAdcLeftFoot(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_R_FOOT: | |||||
// adc = adc + "右脚阻抗"; | |||||
mEightBodyfatAdc.setAdcRightFoot(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_L_BODY: | |||||
// adc = adc + "左驱干"; | |||||
mEightBodyfatAdc.setAdcLeftBody(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_R_BODY: | |||||
// adc = adc + "右躯干"; | |||||
mEightBodyfatAdc.setAdcRightBody(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_R_HAND_L_FOOT: | |||||
// adc = adc + "右手左脚"; | |||||
mEightBodyfatAdc.setAdcRightHandLeftFoot(adc); | |||||
break; | |||||
case EightBodyFatUtil.IMPEDANCE_L_HAND_R_FOOT: | |||||
// adc = adc + "左手右脚"; | |||||
mEightBodyfatAdc.setAdcLeftHandRightFoot(adc); | |||||
break; | |||||
default: | |||||
} | |||||
} | |||||
private void kaimengJieMi(EightBodyfatAdc mEightBodyfatAdc) { | |||||
loglist.add(0,mEightBodyfatAdc.toString()); | |||||
HTBodyBasicInfo basicInfo = new HTBodyBasicInfo(1, 170, 65, 25); | |||||
loglist.add(0, "默认传入用户: 性别:男,身高:170,体重 65kg 年龄25"); | |||||
basicInfo.htZAllBodyImpedance = mEightBodyfatAdc.getAdcRightBody(); | |||||
basicInfo.htZLeftLegImpedance = mEightBodyfatAdc.getAdcLeftFoot(); | |||||
basicInfo.htZRightLegImpedance = mEightBodyfatAdc.getAdcRightFoot(); | |||||
basicInfo.htZLeftArmImpedance = mEightBodyfatAdc.getAdcLeftHand(); | |||||
basicInfo.htZRightArmImpedance = mEightBodyfatAdc.getAdcRightHand(); | |||||
basicInfo.htTwoLegsImpedance = mEightBodyfatAdc.getAdcFoot(); | |||||
basicInfo.htTwoArmsImpedance = mEightBodyfatAdc.getAdcHand(); | |||||
HTBodyResultAllBody resultTwoLegs = new HTBodyResultAllBody(); | |||||
int errorType = resultTwoLegs.getBodyfatWithBasicInfo(basicInfo); | |||||
if (errorType == HTBodyBasicInfo.ErrorNone) { | |||||
String jiemi="加密阻抗:" + | |||||
" \n双脚=" + (resultTwoLegs.htZLeftLeg + resultTwoLegs.htZRightLeg) + | |||||
" \n双手=" + (resultTwoLegs.htZLeftArm + resultTwoLegs.htZRightArm) + | |||||
" \n左手=" + resultTwoLegs.htZLeftArm + | |||||
" \n右手=" + resultTwoLegs.htZRightArm + | |||||
" \n左脚=" + resultTwoLegs.htZLeftLeg + | |||||
" \n右脚=" + resultTwoLegs.htZRightLeg + | |||||
" \n左躯干=" + (resultTwoLegs.htZAllBody)+ | |||||
" \n右躯干=" + (resultTwoLegs.htZAllBody)+ | |||||
" \n右手左脚=" + (resultTwoLegs.htZRightArm + resultTwoLegs.htZLeftLeg) + | |||||
" \n左手右脚=" + (resultTwoLegs.htZLeftArm + resultTwoLegs.htZRightLeg) + | |||||
" \n全身=" + resultTwoLegs.htZAllBody; | |||||
loglist.add(0, jiemi); | |||||
} else { | |||||
loglist.add(0, "解析阻抗:错误码:" + errorType + "\n" | |||||
+ " ErrorAge = 1 ,ErrorWeight = 2, ErrorHeight = 4, ErrorSex = 8, ErrorImpedance = 16, ErrorImpedanceLeftLeg = 32, ErrorImpedanceRightLeg = 64,ErrorImpedanceLeftArm = 128, ErrorImpedanceRightArm = 256" | |||||
); | |||||
} | |||||
} | |||||
} | } |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
public class EightBodyfatAdc { | |||||
private int adcFoot; //双脚阻抗, | |||||
private int adcHand;//双手阻抗 | |||||
private int adcLeftHand; //左手阻抗 | |||||
private int adcRightHand; //右手阻抗 | |||||
private int adcLeftFoot; //左脚阻抗 | |||||
private int adcRightFoot; //右脚阻抗 | |||||
private int adcLeftBody; | |||||
private int adcRightBody; | |||||
private int adcRightHandLeftFoot; | |||||
private int adcLeftHandRightFoot; | |||||
private int adcBody; | |||||
public int getAdcFoot() { | |||||
return adcFoot; | |||||
} | |||||
public void setAdcFoot(int adcFoot) { | |||||
this.adcFoot = adcFoot; | |||||
} | |||||
public int getAdcHand() { | |||||
return adcHand; | |||||
} | |||||
public void setAdcHand(int adcHand) { | |||||
this.adcHand = adcHand; | |||||
} | |||||
public int getAdcLeftHand() { | |||||
return adcLeftHand; | |||||
} | |||||
public void setAdcLeftHand(int adcLeftHand) { | |||||
this.adcLeftHand = adcLeftHand; | |||||
} | |||||
public int getAdcRightHand() { | |||||
return adcRightHand; | |||||
} | |||||
public void setAdcRightHand(int adcRightHand) { | |||||
this.adcRightHand = adcRightHand; | |||||
} | |||||
public int getAdcLeftFoot() { | |||||
return adcLeftFoot; | |||||
} | |||||
public void setAdcLeftFoot(int adcLeftFoot) { | |||||
this.adcLeftFoot = adcLeftFoot; | |||||
} | |||||
public int getAdcRightFoot() { | |||||
return adcRightFoot; | |||||
} | |||||
public void setAdcRightFoot(int adcRightFoot) { | |||||
this.adcRightFoot = adcRightFoot; | |||||
} | |||||
public int getAdcLeftBody() { | |||||
return adcLeftBody; | |||||
} | |||||
public void setAdcLeftBody(int adcLeftBody) { | |||||
this.adcLeftBody = adcLeftBody; | |||||
} | |||||
public int getAdcRightBody() { | |||||
return adcRightBody; | |||||
} | |||||
public void setAdcRightBody(int adcRightBody) { | |||||
this.adcRightBody = adcRightBody; | |||||
} | |||||
public int getAdcRightHandLeftFoot() { | |||||
return adcRightHandLeftFoot; | |||||
} | |||||
public void setAdcRightHandLeftFoot(int adcRightHandLeftFoot) { | |||||
this.adcRightHandLeftFoot = adcRightHandLeftFoot; | |||||
} | |||||
public int getAdcLeftHandRightFoot() { | |||||
return adcLeftHandRightFoot; | |||||
} | |||||
public void setAdcLeftHandRightFoot(int adcLeftHandRightFoot) { | |||||
this.adcLeftHandRightFoot = adcLeftHandRightFoot; | |||||
} | |||||
public int getAdcBody() { | |||||
return adcBody; | |||||
} | |||||
public void setAdcBody(int adcBody) { | |||||
this.adcBody = adcBody; | |||||
} | |||||
@Override | |||||
public String toString() { | |||||
return "加密阻抗:" + | |||||
" \n双脚=" + adcFoot + | |||||
" \n双手=" + adcHand + | |||||
" \n左手=" + adcLeftHand + | |||||
" \n右手=" + adcRightHand + | |||||
" \n左脚=" + adcLeftFoot + | |||||
" \n右脚=" + adcRightFoot + | |||||
" \n左躯干=" + adcLeftBody + | |||||
" \n右躯干=" + adcRightBody + | |||||
" \n右手左脚=" + adcRightHandLeftFoot + | |||||
" \n左手右脚=" + adcLeftHandRightFoot + | |||||
" \n全身=" + adcBody ; | |||||
} | |||||
} |
import com.pingwang.bluetoothlib.utils.BleDensityUtil; | import com.pingwang.bluetoothlib.utils.BleDensityUtil; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.height.HeightDeviceData; | import cn.net.aicare.modulelibrary.module.height.HeightDeviceData; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 显示数据 | |||||
* 身高仪 | |||||
*/ | */ | ||||
public class HeightCmdActivity extends BleBaseActivity implements OnCallbackDis, | public class HeightCmdActivity extends BleBaseActivity implements OnCallbackDis, | ||||
HeightDeviceData.onNotifyData, OnBleVersionListener , OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | |||||
HeightDeviceData.onNotifyData, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | |||||
private static String TAG = HeightCmdActivity.class.getName(); | private static String TAG = HeightCmdActivity.class.getName(); | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
* 服务Intent | * 服务Intent | ||||
*/ | */ | ||||
private Context mContext; | private Context mContext; | ||||
private EditText et_type; | |||||
private HeightDeviceData mBleDevice; | private HeightDeviceData mBleDevice; | ||||
private String mAddress; | private String mAddress; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
findViewById(R.id.btnVersion).setOnClickListener(this); | findViewById(R.id.btnVersion).setOnClickListener(this); | ||||
findViewById(R.id.btnBattery).setOnClickListener(this); | findViewById(R.id.btnBattery).setOnClickListener(this); | ||||
findViewById(R.id.btn_get_did).setOnClickListener(this); | findViewById(R.id.btn_get_did).setOnClickListener(this); | ||||
et_type = findViewById(R.id.et_type); | |||||
cmdBtn(); | cmdBtn(); | ||||
} | } | ||||
sendBleBean.setHex(mBleSendCmdUtil.getDid()); | sendBleBean.setHex(mBleSendCmdUtil.getDid()); | ||||
mBleDevice.sendData(sendBleBean); | mBleDevice.sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btn1: | |||||
String cmd = et_type.getText().toString().trim(); | |||||
SendMcuBean sendDataBean = new SendMcuBean(); | |||||
sendDataBean.setHex(type,cmd.getBytes()); | |||||
mBleDevice.sendData(sendDataBean); | |||||
break; | |||||
case R.id.clear: | case R.id.clear: | ||||
if (mList != null) | if (mList != null) | ||||
mList.clear(); | mList.clear(); |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Message; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ListView; | |||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import java.lang.ref.WeakReference; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.HeightWeightScale.HeightBodyFatBleData; | |||||
import cn.net.aicare.modulelibrary.module.HeightWeightScale.HeightBodyFatBleUntils; | |||||
/** | |||||
* 身高体重秤 | |||||
*/ | |||||
public class HeightWeightScaleActivity extends BleBaseActivity implements OnCallbackBle, HeightBodyFatBleData.OnHeightBodyFatDataCallback, View.OnClickListener { | |||||
private String mAddress = ""; | |||||
private List<String> logList; | |||||
private ListView listView; | |||||
private ArrayAdapter listAdapter; | |||||
private int selectWUnit; | |||||
private int selectHUnit; | |||||
private int currentWUnit = 0; | |||||
private int currentHUnit = 0; | |||||
private int currentMode = 1; | |||||
private int selectMode = 1; | |||||
private final int SETUNIT = 0; | |||||
private final int SETUSER = 1; | |||||
private final int SETMODE = 2; | |||||
private final int ADC = 3; | |||||
private final int FINISH = 4; | |||||
private final int DEVICESTATUS = 5; | |||||
private final int VOICE = 6; | |||||
private final int VOICESTATUS = 7; | |||||
private MHandler mMHandler; | |||||
private TextView text; | |||||
private int currentVoice = 1; | |||||
private int selectVoice = 1; | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBluetoothService.setOnCallback(this); | |||||
logList.add(0, "绑定服务成功"); | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.setOnCallback(this); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (bleDevice != null) { | |||||
HeightBodyFatBleData.init(bleDevice); | |||||
HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | |||||
HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_height_bodyfat); | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
logList = new ArrayList<>(); | |||||
listView = findViewById(R.id.listView); | |||||
mMHandler = new WeakReference<>(new MHandler()).get(); | |||||
findViewById(R.id.kg).setOnClickListener(this); | |||||
findViewById(R.id.jin).setOnClickListener(this); | |||||
findViewById(R.id.st_lb).setOnClickListener(this); | |||||
findViewById(R.id.lb).setOnClickListener(this); | |||||
findViewById(R.id.girl).setOnClickListener(this); | |||||
findViewById(R.id.man).setOnClickListener(this); | |||||
findViewById(R.id.cm).setOnClickListener(this); | |||||
findViewById(R.id.inch).setOnClickListener(this); | |||||
findViewById(R.id.ft_in).setOnClickListener(this); | |||||
findViewById(R.id.bodyfat).setOnClickListener(this); | |||||
findViewById(R.id.weight).setOnClickListener(this); | |||||
findViewById(R.id.baby).setOnClickListener(this); | |||||
findViewById(R.id.deviceStatus).setOnClickListener(this); | |||||
findViewById(R.id.voice_open).setOnClickListener(this); | |||||
findViewById(R.id.voice_close).setOnClickListener(this); | |||||
findViewById(R.id.voice_status).setOnClickListener(this); | |||||
findViewById(R.id.finish).setOnClickListener(this); | |||||
findViewById(R.id.height_weight).setOnClickListener(this); | |||||
text = findViewById(R.id.text); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, logList); | |||||
listView.setAdapter(listAdapter); | |||||
} | |||||
@Override | |||||
public void onStartScan() { | |||||
} | |||||
@Override | |||||
public void onScanning(BleValueBean data) { | |||||
} | |||||
@Override | |||||
public void onScanTimeOut() { | |||||
} | |||||
@Override | |||||
public void onConnecting(String mac) { | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
if (mac.equals(mAddress)) { | |||||
logList.add(0, "连接已经断开"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onConnectionSuccess(String mac) { | |||||
} | |||||
@Override | |||||
public void onServicesDiscovered(String mac) { | |||||
} | |||||
@Override | |||||
public void bleOpen() { | |||||
} | |||||
@Override | |||||
public void bleClose() { | |||||
} | |||||
@Override | |||||
public void onVersion(String version) { | |||||
logList.add(0, "版本号:" + version); | |||||
} | |||||
@Override | |||||
public void onSupportUnitList(List<SupportUnitBean> list) { | |||||
} | |||||
@Override | |||||
public void onMcuResult(int type, int result) { | |||||
String resultStr = ""; | |||||
if (result == HeightBodyFatBleUntils.SET_SUCCESS) { | |||||
resultStr = "成功"; | |||||
} else if (result == HeightBodyFatBleUntils.SET_FAIL) { | |||||
resultStr = "失败"; | |||||
} else { | |||||
resultStr = "不支持"; | |||||
} | |||||
switch (type) { | |||||
case HeightBodyFatBleUntils.MCU_SET_USER_RESULT: | |||||
mMHandler.removeMessages(SETUSER); | |||||
logList.add(0, "下发用户结果:" + resultStr); | |||||
break; | |||||
case HeightBodyFatBleUntils.MCU_SET_UNIT_RESULT: | |||||
if (result == 0) { | |||||
currentHUnit = selectHUnit; | |||||
currentWUnit = selectWUnit; | |||||
if (currentHUnit == 0) { | |||||
} | |||||
text.setText("体重单位: " + currentWUnit + | |||||
"\n身高单位: " + currentHUnit + | |||||
"\n模式:" + currentMode + " 声音: " + currentVoice); | |||||
} | |||||
mMHandler.removeMessages(SETUNIT); | |||||
logList.add(0, "设置单位结果:" + resultStr); | |||||
break; | |||||
case HeightBodyFatBleUntils.MCU_SET_WORK_MODE_RESULT: | |||||
if (result == 0) { | |||||
currentMode = selectMode; | |||||
text.setText("体重单位: " + currentWUnit + | |||||
"\n身高单位: " + currentHUnit + | |||||
"\n模式:" + currentMode + " 声音: " + currentVoice); | |||||
} | |||||
mMHandler.removeMessages(SETMODE); | |||||
logList.add(0, "设置工作模式:" + resultStr); | |||||
break; | |||||
case HeightBodyFatBleUntils.MUC_REQUEST_VOICE_SET_RESULT: | |||||
if (result == 0) { | |||||
currentVoice = selectVoice; | |||||
text.setText("体重单位: " + currentWUnit + | |||||
"\n身高单位: " + currentHUnit + | |||||
"\n模式:" + currentMode + " 声音: " + currentVoice); | |||||
} | |||||
mMHandler.removeMessages(VOICE); | |||||
logList.add(0, "设置声音结果:" + resultStr); | |||||
break; | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onMcuRequestUser() { | |||||
logList.add(0, "请求下发用户,点击下发用户"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onDeviceStatus(int workMode, int battery, int batteryStatus, int weightUnit, int heightUnit, int voice) { | |||||
mMHandler.removeMessages(DEVICESTATUS); | |||||
currentMode = workMode; | |||||
currentWUnit = weightUnit; | |||||
currentHUnit = heightUnit; | |||||
currentVoice = voice; | |||||
text.setText("体重单位: " + currentWUnit + | |||||
"\n身高单位: " + currentHUnit + | |||||
"\n模式:" + currentMode + " 声音: " + currentVoice); | |||||
logList.add(0, "体重状态 模式:" + workMode + " 电池电量: " + battery + " 电池状态: " + batteryStatus | |||||
+ "\n 体重单位: " + weightUnit + " 身高单位: " + heightUnit + " 声音状态: " + voice); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onWeightBodyFat(int workMode, int weightMode, int weight, int decimals, int unit) { | |||||
logList.add(0, "体重体脂 模式:" + workMode + " 测量状态: " + weightMode + "\n 体重: " + weight | |||||
+ " 小数位: " + decimals + " 单位: " + unit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
if (weightMode == 2) { | |||||
mMHandler.removeMessages(ADC); | |||||
mMHandler.removeMessages(FINISH); | |||||
mMHandler.sendEmptyMessageDelayed(ADC, 30000); | |||||
mMHandler.sendEmptyMessageDelayed(FINISH, 40000); | |||||
} | |||||
} | |||||
@Override | |||||
public void onWeightBaby(int workMode, int weightMode, int adultWeight, int adultBabyWeight, int babyWeight, int decimals, int unit) { | |||||
logList.add(0, "抱婴体重 模式:" + workMode + " 测量状态:" + weightMode + " 成人体重:" + adultWeight + | |||||
"\n 抱婴体重:" + adultBabyWeight + " 婴儿体重:" + babyWeight + " 小数位:" + decimals + " 单位" + unit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
if (weightMode == 2) { | |||||
mMHandler.removeMessages(FINISH); | |||||
mMHandler.sendEmptyMessageDelayed(FINISH, 40000); | |||||
} | |||||
} | |||||
@Override | |||||
public void onWeight(int workMode, int weightMode, int weight, int decimals, int unit) { | |||||
logList.add(0, "体重 模式:" + workMode + " 测量状态: " + weightMode + "\n 体重: " + weight | |||||
+ " 小数位: " + decimals + " 单位: " + unit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
if (weightMode == 2) { | |||||
mMHandler.removeMessages(FINISH); | |||||
mMHandler.sendEmptyMessageDelayed(FINISH, 40000); | |||||
} | |||||
} | |||||
@Override | |||||
public void onAdc(int workMode, int status, int adcType, int adc, int arithmetic) { | |||||
mMHandler.removeMessages(ADC); | |||||
logList.add(0, "阻抗数据 模式:" + workMode + " 测量状态: " + status + "\n 阻抗类型: " + adcType | |||||
+ " 阻抗: " + adc + " 算法位: " + arithmetic); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onHeart(int workMode, int status, int heart) { | |||||
logList.add(0, "心率数据 模式:" + workMode + " 测量状态: " + status + " 心率: " + heart); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onTEMP(int workMode, int sign, int temp, int decimals, int unit) { | |||||
logList.add(0, "温度数据 模式:" + workMode + " 温度: " + temp + " 正负: " + sign + "小数 : " + decimals + " 单位 : " + unit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onHeight(int workMode, int height, int decimals, int unit) { | |||||
logList.add(0, "身高数据 模式:" + workMode + " 身高: " + height + " 小数位: " + decimals + "单位 : " + unit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onBodyfat1(int workMode, int bfr, int sfr, int vfr, int rom, int bmr, int age) { | |||||
logList.add(0, "体脂数据 模式:" + workMode + "\n 体脂率: " + bfr + " 皮下脂肪: " + sfr | |||||
+ "\n 内脏脂肪: " + vfr + " 肌肉路: " + rom + "\n 基础代谢率: " + bmr + " 年龄" + age); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onBodyfat2(int workMode, int bm, int water, int pp, int bmi, int heart, int obesityLevels) { | |||||
logList.add(0, "体脂数据 模式:" + workMode + " 骨量: " + bm + " 水分: " + water | |||||
+ "\n 蛋白率: " + pp + " bmi: " + bmi + " 心率: " + heart + " \n肥胖等级" + obesityLevels); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onVoice(int status) { | |||||
mMHandler.removeMessages(VOICESTATUS); | |||||
logList.add(0, "声音状态 模式:" + status); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onFinish(int workMode) { | |||||
logList.add(0, "测量完成 模式:" + workMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
mMHandler.removeMessages(FINISH); | |||||
} | |||||
@Override | |||||
public void onError(int error) { | |||||
logList.add(0, "错误码: " + error); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (HeightBodyFatBleData.getInstance() != null) { | |||||
switch (v.getId()) { | |||||
case R.id.kg: | |||||
selectWUnit = 0; | |||||
logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.jin: | |||||
selectWUnit = 1; | |||||
logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.st_lb: | |||||
selectWUnit = 4; | |||||
logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.lb: | |||||
selectWUnit = 6; | |||||
logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.girl: | |||||
logList.add(0, "下用户 女 18岁 165cm :" + selectWUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUser(0, 18, 165)); | |||||
mMHandler.removeMessages(SETUSER); | |||||
mMHandler.sendEmptyMessageDelayed(SETUSER, 3000); | |||||
break; | |||||
case R.id.man: | |||||
logList.add(0, "下用户 男 28岁 170cm :" + selectWUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUser(1, 28, 170)); | |||||
mMHandler.removeMessages(SETUSER); | |||||
mMHandler.sendEmptyMessageDelayed(SETUSER, 3000); | |||||
break; | |||||
case R.id.cm: | |||||
selectHUnit = 0; | |||||
logList.add(0, "下发身高单位 :" + selectHUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.inch: | |||||
selectHUnit = 1; | |||||
logList.add(0, "下发身高单位 :" + selectHUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.ft_in: | |||||
selectHUnit = 2; | |||||
logList.add(0, "下发身高单位 :" + selectHUnit); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | |||||
mMHandler.removeMessages(SETUNIT); | |||||
mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | |||||
break; | |||||
case R.id.baby: | |||||
selectMode = 2; | |||||
logList.add(0, "下发工作模式 :" + selectMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | |||||
mMHandler.removeMessages(SETMODE); | |||||
mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | |||||
break; | |||||
case R.id.bodyfat: | |||||
selectMode = 1; | |||||
logList.add(0, "下发工作模式 :" + selectMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | |||||
mMHandler.removeMessages(SETMODE); | |||||
mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | |||||
break; | |||||
case R.id.weight: | |||||
selectMode = 3; | |||||
logList.add(0, "下发工作模式 :" + selectMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | |||||
mMHandler.removeMessages(SETMODE); | |||||
mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | |||||
break; | |||||
case R.id.height_weight: | |||||
selectMode = 4; | |||||
logList.add(0, "下发工作模式 :" + selectMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | |||||
mMHandler.removeMessages(SETMODE); | |||||
mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | |||||
break; | |||||
case R.id.deviceStatus: | |||||
logList.add(0, "请求设备状态 :" ); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.getDeviceStatus()); | |||||
mMHandler.removeMessages(DEVICESTATUS); | |||||
mMHandler.sendEmptyMessageDelayed(DEVICESTATUS, 3000); | |||||
break; | |||||
case R.id.voice_open: | |||||
selectVoice = 1; | |||||
logList.add(0, "设置声音 :" + selectMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setVoiceStatus(selectVoice)); | |||||
mMHandler.removeMessages(VOICE); | |||||
mMHandler.sendEmptyMessageDelayed(VOICE, 3000); | |||||
break; | |||||
case R.id.voice_close: | |||||
selectVoice = 2; | |||||
logList.add(0, "设置声音 :" + selectMode); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setVoiceStatus(selectVoice)); | |||||
mMHandler.removeMessages(VOICE); | |||||
mMHandler.sendEmptyMessageDelayed(VOICE, 3000); | |||||
break; | |||||
case R.id.voice_status: | |||||
logList.add(0, "获取声音状态"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.getVoiceStatus()); | |||||
mMHandler.removeMessages(VOICESTATUS); | |||||
mMHandler.sendEmptyMessageDelayed(VOICESTATUS, 3000); | |||||
break; | |||||
case R.id.finish: | |||||
logList.add(0, "回复测量完成"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.replyTestFinish()); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
public class MHandler extends Handler { | |||||
@Override | |||||
public void handleMessage(@NonNull Message msg) { | |||||
super.handleMessage(msg); | |||||
switch (msg.what) { | |||||
case SETMODE: | |||||
logList.add(0, "下发模式没有回复"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case SETUNIT: | |||||
logList.add(0, "下发单位没有回复"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case SETUSER: | |||||
logList.add(0, "下发用户没有回复"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case FINISH: | |||||
logList.add(0, "没有回复测量完成指令(\n为了检测是否有回复。" + | |||||
"app会在接收到稳定体重的时候。开启定时器。去确认设备是否有回复测量完成。" + | |||||
"\n如果回复。此消息可以忽略)"+"\n 每次测量(母婴模式。的测量完成也只能发一次),测量完成的命令只能发一次!!!!。"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case ADC: | |||||
logList.add(0, "没有测量阻抗的指令(\n为了检测是否有回复。app会在接收到稳定体重的时候。开启定时器。去确认设备是否有回复测量阻抗的状态。\n如果回复。此消息可以忽略)"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case DEVICESTATUS: | |||||
logList.add(0, "没有接收到设备状态(\n为了检测是否有回复。app会在点击获取设备状态指令的时候。开启定时器。去确认设备是否有回复设备状态。\n如果回复。此消息可以忽略)"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case VOICE: | |||||
logList.add(0, "没有声音设置的回复(\n为了检测是否有回复。app会在点击设置声音的时候。开启定时器。去确认设备是否有回复设置声音。\n如果回复。此消息可以忽略)"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case VOICESTATUS: | |||||
logList.add(0, "没有声音状态的回复(\n为了检测是否有回复。app会在点击声音状态的时候。开启定时器。去确认设备是否有回复声音状态。\n如果回复。此消息可以忽略)"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.app.Dialog; | |||||
import android.content.DialogInterface; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Looper; | |||||
import android.os.Message; | |||||
import android.view.KeyEvent; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import androidx.fragment.app.DialogFragment; | |||||
import androidx.fragment.app.FragmentManager; | |||||
import androidx.fragment.app.FragmentTransaction; | |||||
/** | |||||
* elink-android<br> | |||||
* LoadingIosDialogFragment<br> | |||||
* xing<br> | |||||
* 2019/2/26 16:07<br> | |||||
* 加载提示框 | |||||
*/ | |||||
public class LoadingIosDialogFragment extends DialogFragment { | |||||
private static String TAG = LoadingIosDialogFragment.class.getName(); | |||||
private final static int DISMISS_OUT = 1; | |||||
/** | |||||
* 默认超时时间 | |||||
*/ | |||||
private int timeOut = 30; | |||||
private boolean show = false; | |||||
public boolean isShow() { | |||||
return show; | |||||
} | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | |||||
@Override | |||||
public void handleMessage(Message msg) { | |||||
switch (msg.what) { | |||||
case DISMISS_OUT: | |||||
LoadingIosDialogFragment.this.dismiss(); | |||||
break; | |||||
} | |||||
} | |||||
}; | |||||
@Override | |||||
public void dismiss() { | |||||
try { | |||||
mHandler.removeMessages(DISMISS_OUT); | |||||
if (getFragmentManager() != null) | |||||
super.dismiss(); | |||||
show = false; | |||||
} catch (Exception e) { | |||||
e.printStackTrace(); | |||||
} | |||||
} | |||||
public int getTimeOut() { | |||||
return timeOut; | |||||
} | |||||
public void setTimeOut(int timeOut) { | |||||
this.timeOut = timeOut; | |||||
} | |||||
public void show(@NonNull FragmentManager manager) { | |||||
this.show(manager, "LoadingIosDialogFragment"); | |||||
} | |||||
@Override | |||||
public void show(@NonNull FragmentManager manager, @Nullable String tag) { | |||||
try { | |||||
super.show(manager, tag); | |||||
show = true; | |||||
} catch (Exception e) { | |||||
show = false; | |||||
e.printStackTrace(); | |||||
} | |||||
mHandler.sendEmptyMessageDelayed(DISMISS_OUT, timeOut * 1000); | |||||
} | |||||
@Override | |||||
public int show(@NonNull FragmentTransaction transaction, @Nullable String tag) { | |||||
return super.show(transaction, tag); | |||||
} | |||||
@Override | |||||
public void onActivityCreated(@Nullable Bundle savedInstanceState) { | |||||
super.onActivityCreated(savedInstanceState); | |||||
if (getDialog() != null) { | |||||
getDialog().setOnShowListener(null); | |||||
getDialog().setOnCancelListener(null); | |||||
getDialog().setOnDismissListener(null); | |||||
} | |||||
} | |||||
@Nullable | |||||
@Override | |||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |||||
return super.onCreateView(inflater, container, savedInstanceState); | |||||
} | |||||
@NonNull | |||||
@Override | |||||
public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { | |||||
LayoutInflater inflater = LayoutInflater.from(requireContext()); | |||||
View v = inflater.inflate(R.layout.dialog_loading_ios, null);// 得到加载view | |||||
Dialog loadingDialog = new Dialog(requireContext(), R.style.MyDialog);// 创建自定义样式dialog | |||||
loadingDialog.setCancelable(false);//设置点击空白处是否可以取消 | |||||
//按返回键是否可以取消 | |||||
loadingDialog.setCanceledOnTouchOutside(false); | |||||
loadingDialog.setContentView(v);// 设置布局 | |||||
loadingDialog.setOnKeyListener(new DialogInterface.OnKeyListener() { | |||||
@Override | |||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) { | |||||
//返回不关闭 | |||||
return keyCode == KeyEvent.KEYCODE_BACK; | |||||
} | |||||
}); | |||||
return loadingDialog; | |||||
} | |||||
@Override | |||||
public void onDestroyView() { | |||||
super.onDestroyView(); | |||||
if (mHandler != null) { | |||||
mHandler.removeCallbacksAndMessages(null); | |||||
} | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | package aicare.net.cn.sdk.ailinksdkdemoandroid; | ||||
import android.Manifest; | |||||
import android.app.AlertDialog; | |||||
import android.content.DialogInterface; | |||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.content.pm.PackageManager; | |||||
import android.net.Uri; | |||||
import android.os.Build; | |||||
import android.os.Bundle; | |||||
import android.provider.Settings; | |||||
import android.os.Message; | |||||
import android.view.View; | import android.view.View; | ||||
import android.widget.Button; | |||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import com.pingwang.bluetoothlib.AILinkSDK; | import com.pingwang.bluetoothlib.AILinkSDK; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleAppBaseActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.config.AppConfig; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.find.FindDeviceNewActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_height.BroadcastHeightActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.SP; | import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.SP; | ||||
import androidx.annotation.NonNull; | |||||
import androidx.appcompat.app.AppCompatActivity; | |||||
import androidx.core.app.ActivityCompat; | |||||
public class MainActivity extends AppCompatActivity { | |||||
public class MainActivity extends BleAppBaseActivity { | |||||
private static String TAG = MainActivity.class.getName(); | private static String TAG = MainActivity.class.getName(); | ||||
private List<View> mList = new ArrayList<>(); | |||||
@Override | |||||
protected void uiHandlerMessage(Message msg) { | |||||
} | |||||
@Override | @Override | ||||
protected void onCreate(Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
AILinkSDK.getInstance().init(this); | |||||
setContentView(R.layout.activity_main); | |||||
protected int getLayoutId() { | |||||
return R.layout.activity_main; | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
protected void initListener() { | |||||
MyListener listener = new MyListener(); | |||||
// Button btn_shpy = findViewById(R.id.btn_sphy); | |||||
// Button btn_tempgun = findViewById(R.id.btn_tempgun); | |||||
// Button btn_temp = findViewById(R.id.btn_temp); | |||||
// Button btn_baby = findViewById(R.id.btn_baby); | |||||
// Button btn_height = findViewById(R.id.btn_height); | |||||
// Button btn_ble = findViewById(R.id.btn_ble); | |||||
// Button btn_weightScale = findViewById(R.id.btn_lock); | |||||
// Button btn_ble_test = findViewById(R.id.btn_ble_test); | |||||
// Button btnConnectTest = findViewById(R.id.btnConnectTest); | |||||
// Button btn_ad_weight = findViewById(R.id.btn_ad_weight); | |||||
// Button btn_ble_weight = findViewById(R.id.btn_ble_weight); | |||||
// Button btn_wifi_ble_tooth = findViewById(R.id.btn_wifi_ble_tooth); | |||||
// Button wifi_config = findViewById(R.id.wifi_config); | |||||
// Button eight_scale = findViewById(R.id.eight_scale); | |||||
// Button btn_ota = findViewById(R.id.btn_ota); | |||||
// Button btn_wristband = findViewById(R.id.btn_wristband); | |||||
// Button glucometer = findViewById(R.id.glucometer); | |||||
// Button btn_broadcast_scale = findViewById(R.id.btn_broadcast_scale); | |||||
// Button btn_broadcast_blood_oxygen = findViewById(R.id.btn_broadcast_blood_oxygen); | |||||
// Button btn_smart_mask = findViewById(R.id.btn_smart_mask); | |||||
// Button btn_bld = findViewById(R.id.btn_bld); | |||||
// Button btn_bleBo = findViewById(R.id.btn_bleBo); | |||||
// Button btn_coffeeScale = findViewById(R.id.btn_coffeeScale); | |||||
// Button btn_scooter = findViewById(R.id.btn_scooter); | |||||
// Button btn_shareCharger = findViewById(R.id.btn_shareCharger); | |||||
// Button btn_transmission = findViewById(R.id.btn_transmission); | |||||
// Button btn_wifi_ble_weight = findViewById(R.id.btn_wifi_ble_weight); | |||||
// Button btn_baby_body_fat = findViewById(R.id.btn_baby_body_fat); | |||||
mList.add(findViewById(R.id.btn_sphy)); | |||||
mList.add(findViewById(R.id.btn_tempgun)); | |||||
mList.add(findViewById(R.id.btn_temp)); | |||||
mList.add(findViewById(R.id.btn_baby)); | |||||
mList.add(findViewById(R.id.btn_height)); | |||||
mList.add(findViewById(R.id.btn_ble)); | |||||
mList.add(findViewById(R.id.btn_lock)); | |||||
mList.add(findViewById(R.id.btn_ble_test)); | |||||
mList.add(findViewById(R.id.btnConnectTest)); | |||||
mList.add(findViewById(R.id.btn_ad_weight)); | |||||
mList.add(findViewById(R.id.btn_ble_weight)); | |||||
mList.add(findViewById(R.id.btn_wifi_ble_tooth)); | |||||
mList.add(findViewById(R.id.wifi_config)); | |||||
mList.add(findViewById(R.id.eight_scale)); | |||||
mList.add(findViewById(R.id.btn_ota)); | |||||
mList.add(findViewById(R.id.glucometer)); | |||||
mList.add(findViewById(R.id.btn_broadcast_scale)); | |||||
mList.add(findViewById(R.id.btn_broadcast_blood_oxygen)); | |||||
mList.add(findViewById(R.id.btn_smart_mask)); | |||||
mList.add(findViewById(R.id.btn_bld)); | |||||
mList.add(findViewById(R.id.btn_bleBo)); | |||||
mList.add(findViewById(R.id.btn_coffeeScale)); | |||||
mList.add(findViewById(R.id.btn_scooter)); | |||||
mList.add(findViewById(R.id.btn_shareCharger)); | |||||
mList.add(findViewById(R.id.btn_share_socket)); | |||||
mList.add(findViewById(R.id.btn_transmission)); | |||||
mList.add(findViewById(R.id.btn_wifi_ble_weight)); | |||||
mList.add(findViewById(R.id.btn_baby_body_fat)); | |||||
mList.add(findViewById(R.id.btn_broadcast_height)); | |||||
mList.add(findViewById(R.id.btn_hbfs)); | |||||
mList.add(findViewById(R.id.btn_find)); | |||||
mList.add(findViewById(R.id.btn_4g_bs)); | |||||
mList.add(findViewById(R.id.btn_clear_shake_hands)); | |||||
mList.add(findViewById(R.id.btn_food_temp)); | |||||
mList.add(findViewById(R.id.btn_temp_humidity)); | |||||
mList.add(findViewById(R.id.btn_share_condom)); | |||||
for (View view : mList) { | |||||
view.setOnClickListener(listener); | |||||
} | |||||
List<Integer> showViewId = AppConfig.SHOW_VIEW_ID; | |||||
if (showViewId != null) { | |||||
for (View view : mList) { | |||||
view.setVisibility(View.GONE); | |||||
} | |||||
for (Integer integer : showViewId) { | |||||
findViewById(integer).setVisibility(View.VISIBLE); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
protected void initData() { | |||||
initPermissions(); | |||||
} | |||||
@Override | |||||
protected void initView() { | |||||
BleLog.init("", "", BuildConfig.DEBUG); | BleLog.init("", "", BuildConfig.DEBUG); | ||||
String version = getString(R.string.version) + ":" + BuildConfig.VERSION_NAME; | String version = getString(R.string.version) + ":" + BuildConfig.VERSION_NAME; | ||||
((TextView) findViewById(R.id.tv_app_version)).setText(version); | ((TextView) findViewById(R.id.tv_app_version)).setText(version); | ||||
init(); | |||||
initPermissions(); | |||||
AILinkSDK.getInstance().init(this);//sdk | |||||
SP.init(this); | SP.init(this); | ||||
} | } | ||||
private void init() { | |||||
MyListener listener = new MyListener(); | |||||
Button btn_shpy = findViewById(R.id.btn_sphy); | |||||
Button btn_tempgun = findViewById(R.id.btn_tempgun); | |||||
Button btn_temp = findViewById(R.id.btn_temp); | |||||
Button btn_baby = findViewById(R.id.btn_baby); | |||||
Button btn_height = findViewById(R.id.btn_height); | |||||
Button btn_ble = findViewById(R.id.btn_ble); | |||||
findViewById(R.id.btn_ble_weight).setOnClickListener(listener); | |||||
findViewById(R.id.btn_wifi_ble_tooth).setOnClickListener(listener); | |||||
findViewById(R.id.wifi_config).setOnClickListener(listener); | |||||
findViewById(R.id.eight_scale).setOnClickListener(listener); | |||||
findViewById(R.id.btn_ota).setOnClickListener(listener); | |||||
findViewById(R.id.glucometer).setOnClickListener(listener); | |||||
findViewById(R.id.btn_broadcast_scale).setOnClickListener(listener); | |||||
findViewById(R.id.btn_broadcast_blood_oxygen).setOnClickListener(listener); | |||||
findViewById(R.id.btn_smart_mask).setOnClickListener(listener); | |||||
findViewById(R.id.btn_transmission).setOnClickListener(listener); | |||||
btn_shpy.setOnClickListener(listener); | |||||
btn_tempgun.setOnClickListener(listener); | |||||
btn_temp.setOnClickListener(listener); | |||||
btn_baby.setOnClickListener(listener); | |||||
btn_height.setOnClickListener(listener); | |||||
btn_ble.setOnClickListener(listener); | |||||
findViewById(R.id.btn_wifi_ble_weight).setOnClickListener(listener); | |||||
findViewById(R.id.btn_baby_body_fat).setOnClickListener(listener); | |||||
} | |||||
private class MyListener implements View.OnClickListener { | private class MyListener implements View.OnClickListener { | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
// } | // } | ||||
int type = 0; | int type = 0; | ||||
switch (v.getId()) { | switch (v.getId()) { | ||||
case R.id.btn_clear_shake_hands: | |||||
type= BleDeviceConfig.CLEAR_SHAKE_HANDS; | |||||
break; | |||||
case R.id.btn_sphy: | case R.id.btn_sphy: | ||||
type = BleDeviceConfig.BLOOD_PRESSURE; | type = BleDeviceConfig.BLOOD_PRESSURE; | ||||
break; | break; | ||||
case R.id.btn_height: | case R.id.btn_height: | ||||
type = BleDeviceConfig.HEIGHT_METER; | type = BleDeviceConfig.HEIGHT_METER; | ||||
break; | break; | ||||
case R.id.btn_lock: | |||||
type = BleDeviceConfig.SMART_LOCK; | |||||
break; | |||||
case R.id.btn_ad_weight: | |||||
type = BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_AD; | |||||
break; | |||||
case R.id.btn_wifi_ble_weight: | case R.id.btn_wifi_ble_weight: | ||||
type = BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE; | type = BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE; | ||||
break; | break; | ||||
type = BleDeviceConfig.BABY_BODY_FAT; | type = BleDeviceConfig.BABY_BODY_FAT; | ||||
break; | break; | ||||
case R.id.btn_broadcast_scale: | case R.id.btn_broadcast_scale: | ||||
Intent intentBroadcast = new Intent(MainActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.BroadcastScaleActivity.class); | |||||
Intent intentBroadcast = new Intent(MainActivity.this, BroadcastScaleActivity.class); | |||||
startActivity(intentBroadcast); | startActivity(intentBroadcast); | ||||
return; | return; | ||||
case R.id.btn_broadcast_blood_oxygen: | case R.id.btn_broadcast_blood_oxygen: | ||||
Intent intentBloodOxygen = new Intent(MainActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.BroadcastBloodOxygenActivity.class); | |||||
Intent intentBloodOxygen = new Intent(MainActivity.this, BroadcastBloodOxygenActivity.class); | |||||
startActivity(intentBloodOxygen); | startActivity(intentBloodOxygen); | ||||
return; | return; | ||||
case R.id.btn_smart_mask: | case R.id.btn_smart_mask: | ||||
type = BleDeviceConfig.SMART_MASK; | type = BleDeviceConfig.SMART_MASK; | ||||
break; | break; | ||||
case R.id.btn_bleBo: | |||||
type = BleDeviceConfig.BLE_BOOLD_OXYGEN; | |||||
break; | |||||
// case R.id.btn_bld: | |||||
// type = BleDeviceConfig.BLD_WEIGHT; | |||||
// break; | |||||
case R.id.btn_ble: | case R.id.btn_ble: | ||||
type = -1; | type = -1; | ||||
break; | break; | ||||
case R.id.btn_ble_test: | |||||
type = -2; | |||||
break; | |||||
case R.id.btn_ota: | case R.id.btn_ota: | ||||
type = -3; | type = -3; | ||||
break; | break; | ||||
case R.id.btn_transmission: | case R.id.btn_transmission: | ||||
type = -4; | type = -4; | ||||
break; | break; | ||||
case R.id.eight_scale: | case R.id.eight_scale: | ||||
type = BleDeviceConfig.EIGHT_BODY_FAT_SCALE; | type = BleDeviceConfig.EIGHT_BODY_FAT_SCALE; | ||||
break; | break; | ||||
case R.id.btnConnectTest: | |||||
Intent intent = new Intent(MainActivity.this, ConnectBleTestActivity.class); | |||||
startActivity(intent); | |||||
return; | |||||
case R.id.wifi_config: | case R.id.wifi_config: | ||||
Intent intent1 = new Intent(MainActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.WifiConfigActivity.class); | |||||
Intent intent1 = new Intent(MainActivity.this, WifiConfigActivity.class); | |||||
startActivity(intent1); | startActivity(intent1); | ||||
return; | return; | ||||
case R.id.btn_coffeeScale: | |||||
// 咖啡秤 | |||||
type = BleDeviceConfig.COFFEE_SCALE; | |||||
break; | |||||
case R.id.btn_scooter: | |||||
type = BleDeviceConfig.SMART_SCOOTER; | |||||
break; | |||||
case R.id.btn_shareCharger: | |||||
// 共享充电器 | |||||
type = BleDeviceConfig.SHARE_CHARGER; | |||||
break; | |||||
case R.id.btn_share_socket: | |||||
// 共享插座 | |||||
type = BleDeviceConfig.SHARE_SOCKET; | |||||
break; | |||||
case R.id.btn_share_condom: | |||||
// 共享套套机 | |||||
type = BleDeviceConfig.SHARE_CONDOM; | |||||
break; | |||||
case R.id.btn_find: | |||||
// 寻物器 | |||||
Intent findDeviceActivity = new Intent(MainActivity.this, FindDeviceNewActivity.class); | |||||
startActivity(findDeviceActivity); | |||||
return; | |||||
case R.id.btn_broadcast_height: | |||||
// 广播身高仪 | |||||
Intent intentBroadcastHeight = new Intent(MainActivity.this, BroadcastHeightActivity.class); | |||||
startActivity(intentBroadcastHeight); | |||||
return; | |||||
case R.id.btn_4g_bs: | |||||
} | |||||
startActivity(type); | |||||
} | |||||
} | |||||
/** | |||||
* 初始化请求权限 | |||||
*/ | |||||
private void initPermissions() { | |||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |||||
ActivityCompat | |||||
.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.CHANGE_WIFI_MULTICAST_STATE, Manifest.permission.ACCESS_WIFI_STATE, | |||||
Manifest.permission.CHANGE_WIFI_STATE}, 1); | |||||
} | |||||
} | |||||
// 广播身高仪 | |||||
Intent bloodSugar4GIntent = new Intent(MainActivity.this, BloodSugar4GActivity.class); | |||||
startActivity(bloodSugar4GIntent); | |||||
return; | |||||
case R.id.btn_food_temp: | |||||
// 食品温度计 | |||||
type = BleDeviceConfig.FOOD_TEMP; | |||||
break; | |||||
case R.id.btn_hbfs: | |||||
type=BleDeviceConfig.HEIGHT_BODY_FAT; | |||||
break; | |||||
case R.id.btn_temp_humidity: | |||||
type= BleDeviceConfig.TEMP_Humidity; | |||||
break; | |||||
@Override | |||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |||||
if (requestCode != 1) { | |||||
return; | |||||
} | |||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { | |||||
} else { | |||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0])) { | |||||
//权限请求失败,但未选中“不再提示”选项 | |||||
new AlertDialog.Builder(this).setTitle("提示").setMessage("请求使用定位权限搜索蓝牙设备").setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
//引导用户至设置页手动授权 | |||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |||||
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null); | |||||
intent.setData(uri); | |||||
startActivity(intent); | |||||
} | |||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
if (dialog != null) { | |||||
dialog.cancel(); | |||||
} | |||||
} | |||||
}).show(); | |||||
} else { | |||||
//权限请求失败,选中“不再提示”选项 | |||||
// T.showShort(MainActivity.this, "获取权限失败"); | |||||
new AlertDialog.Builder(this).setTitle("提示").setMessage("请求使用定位权限搜索蓝牙设备").setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
//引导用户至设置页手动授权 | |||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |||||
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null); | |||||
intent.setData(uri); | |||||
startActivity(intent); | |||||
} | |||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
if (dialog != null) { | |||||
dialog.cancel(); | |||||
} | |||||
} | |||||
}).show(); | |||||
} | } | ||||
startActivity(type); | |||||
} | } | ||||
} | } | ||||
private void startActivity(int tyep) { | private void startActivity(int tyep) { | ||||
Intent intent = new Intent(this, aicare.net.cn.sdk.ailinksdkdemoandroid.ShowBleActivity.class); | |||||
Intent intent = new Intent(this, ShowBleActivity.class); | |||||
intent.putExtra("type", tyep); | intent.putExtra("type", tyep); | ||||
startActivity(intent); | startActivity(intent); | ||||
} | } |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | package aicare.net.cn.sdk.ailinksdkdemoandroid; | ||||
import android.Manifest; | |||||
import android.app.Activity; | |||||
import android.bluetooth.BluetoothAdapter; | |||||
import android.content.ComponentName; | import android.content.ComponentName; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.content.ServiceConnection; | import android.content.ServiceConnection; | ||||
import android.content.pm.PackageManager; | |||||
import android.location.LocationManager; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.os.Handler; | import android.os.Handler; | ||||
import android.os.IBinder; | import android.os.IBinder; | ||||
import android.os.Looper; | import android.os.Looper; | ||||
import android.os.Message; | import android.os.Message; | ||||
import android.provider.Settings; | |||||
import android.text.TextUtils; | |||||
import android.view.View; | import android.view.View; | ||||
import android.widget.AdapterView; | import android.widget.AdapterView; | ||||
import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
import android.widget.Button; | import android.widget.Button; | ||||
import android.widget.EditText; | |||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import android.widget.Toast; | import android.widget.Toast; | ||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | import com.pingwang.bluetoothlib.bean.BleValueBean; | ||||
import com.pingwang.bluetoothlib.config.BleConfig; | import com.pingwang.bluetoothlib.config.BleConfig; | ||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.CallbackDisIm; | import com.pingwang.bluetoothlib.listener.CallbackDisIm; | ||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | import com.pingwang.bluetoothlib.listener.OnCallbackBle; | ||||
import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.HashMap; | |||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | |||||
import java.util.UUID; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.LoadingIosDialogFragment; | import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.LoadingIosDialogFragment; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.find.FindDeviceNewActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.coffee_scale.CoffeeScaleActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.food_temp.FoodTempActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_charger.ShareChargerActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_condom.ShareCondomActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_socket.ShareSocketActivity; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.appcompat.app.AppCompatActivity; | import androidx.appcompat.app.AppCompatActivity; | ||||
import androidx.core.app.ActivityCompat; | |||||
import cn.net.aicare.modulelibrary.module.scooter.SkateboardBleConfig; | |||||
/** | /** | ||||
*/ | */ | ||||
public class ShowBleActivity extends AppCompatActivity implements OnCallbackBle, OnScanFilterListener { | public class ShowBleActivity extends AppCompatActivity implements OnCallbackBle, OnScanFilterListener { | ||||
public static final int REQUEST_PERMISSION_CODE = 1500; | |||||
private static String TAG = ShowBleActivity.class.getName(); | private static String TAG = ShowBleActivity.class.getName(); | ||||
private final int BIND_SERVER_OK = 1; | private final int BIND_SERVER_OK = 1; | ||||
private Intent bindIntent; | private Intent bindIntent; | ||||
private Context mContext; | private Context mContext; | ||||
private int mType; | private int mType; | ||||
private boolean mFilter = true; | |||||
private String mNoEncryptionMac = ""; | |||||
private String mFilterName = ""; | |||||
private String mFilterMac = ""; | |||||
private int mCid; | |||||
private int mVid; | |||||
private int mPid; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | private Handler mHandler = new Handler(Looper.getMainLooper()) { | ||||
@Override | @Override | ||||
public void handleMessage(Message msg) { | public void handleMessage(Message msg) { | ||||
} | } | ||||
init(); | init(); | ||||
initData(); | initData(); | ||||
} | } | ||||
private void initData() { | private void initData() { | ||||
Button btn = findViewById(R.id.btn); | Button btn = findViewById(R.id.btn); | ||||
Button btn1 = findViewById(R.id.btn1); | Button btn1 = findViewById(R.id.btn1); | ||||
Button clear = findViewById(R.id.clear); | Button clear = findViewById(R.id.clear); | ||||
final Button filter = findViewById(R.id.filter); | |||||
filter.setTag(true); | |||||
filter.setText(getString(R.string.filter)+"true"); | |||||
EditText et_filter_name = findViewById(R.id.et_filter_name); | |||||
EditText et_filter_mac = findViewById(R.id.et_filter_mac); | |||||
btn.setOnClickListener(new View.OnClickListener() { | btn.setOnClickListener(new View.OnClickListener() { | ||||
@Override | @Override | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
if (mBluetoothService != null) { | if (mBluetoothService != null) { | ||||
BleLog.i(TAG, "搜索设备"); | BleLog.i(TAG, "搜索设备"); | ||||
if (mType == -3) { | |||||
mBluetoothService.scanLeDevice(0); | |||||
mFilterName = et_filter_name.getText().toString().trim(); | |||||
mFilterMac = et_filter_mac.getText().toString().trim(); | |||||
if (mType == BleDeviceConfig.SMART_SCOOTER) { | |||||
Map<String, String> map = new HashMap<>(); | |||||
map.put(SkateboardBleConfig.UUID_BROADCAST.toString(), "37,3,1");//37=0x0025=电滑板的cid | |||||
mBluetoothService.scanLeDevice(0, map, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||||
} else { | } else { | ||||
if (mFilter) | |||||
mBluetoothService.scanLeDevice(0, BleConfig.UUID_SERVER_AILINK); | |||||
else | |||||
mBluetoothService.scanLeDevice(0); | |||||
//0000FEE7=手表 | |||||
mBluetoothService.scanLeDevice(0, BleConfig.UUID_SERVER_AILINK, UUID | |||||
.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||||
} | } | ||||
mList.clear(); | mList.clear(); | ||||
listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
} | } | ||||
}); | }); | ||||
filter.setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
boolean m = (Boolean) filter.getTag(); | |||||
filter.setTag(!m); | |||||
mFilter = !m; | |||||
filter.setText("过滤:" + mFilter); | |||||
} | |||||
}); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | ||||
listView.setAdapter(listAdapter); | listView.setAdapter(listAdapter); | ||||
listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { | ||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { | ||||
String itemStr = mList.get(position); | String itemStr = mList.get(position); | ||||
String mac = itemStr.split("=")[0]; | String mac = itemStr.split("=")[0]; | ||||
if (BleDeviceConfig.TOOTHBRUSH_WIFI_BLE==mType){ | |||||
Intent intent=new Intent(); | |||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.ToothBrushWifiBleActivity.class); | |||||
String cidVidPid = itemStr.split("=")[2]; | |||||
mCid = Integer.parseInt(cidVidPid.split(";")[0]); | |||||
mVid = Integer.parseInt(cidVidPid.split(";")[1]); | |||||
mPid = Integer.parseInt(cidVidPid.split(";")[2]); | |||||
if (mType == BleDeviceConfig.CLEAR_SHAKE_HANDS) { | |||||
//验证不握手,不加密的界面使用 | |||||
BleConfig.setHandshakeStatus(mac, false); | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.stopScan(); | |||||
mBluetoothService.connectDevice(mac); | |||||
showLoading(); | |||||
} | |||||
} else if (BleDeviceConfig.TOOTHBRUSH_WIFI_BLE == mType) { | |||||
Intent intent = new Intent(); | |||||
intent.setClass(ShowBleActivity.this, ToothBrushWifiBleActivity.class); | |||||
intent.putExtra("type", mType); | intent.putExtra("type", mType); | ||||
intent.putExtra("mac", mac); | intent.putExtra("mac", mac); | ||||
startActivity(intent); | startActivity(intent); | ||||
finish(); | finish(); | ||||
}else { | |||||
} else { | |||||
if (mCid == BleDeviceConfig.BLE_BOOLD_OXYGEN && mVid == 0x0012) { | |||||
//vid=12的不用握手校验,不加密 | |||||
mNoEncryptionMac = mac; | |||||
BleConfig.setHandshakeStatus(mac, false); | |||||
} else if (mCid == BleDeviceConfig.SMART_SCOOTER) { | |||||
if (mPid == 0x0001) { | |||||
//电滑板pid=01的不用握手校验,不加密 | |||||
BleConfig.setHandshakeStatus(mac, false); | |||||
} | |||||
mNoEncryptionMac = mac; | |||||
} else if (mCid == 0) { | |||||
//CID=0不需要握手 | |||||
BleConfig.setHandshakeStatus(mac, false); | |||||
} | |||||
if (mBluetoothService != null) { | if (mBluetoothService != null) { | ||||
mBluetoothService.stopScan(); | mBluetoothService.stopScan(); | ||||
mBluetoothService.connectDevice(mac); | mBluetoothService.connectDevice(mac); | ||||
}); | }); | ||||
// 延迟后请求权限 | |||||
btn.postDelayed(() -> { | |||||
if (isDestroyed()) { | |||||
return; | |||||
} | |||||
checkPermission(); | |||||
}, 500); | |||||
} | } | ||||
public void onScanning(@NonNull BleValueBean data) { | public void onScanning(@NonNull BleValueBean data) { | ||||
String mAddress = data.getMac(); | String mAddress = data.getMac(); | ||||
BleLog.i(TAG, "MAC=" + mAddress + "||CID=" + data.getCid() + "||VID=" + data.getVid() + "||PID=" + data.getPid()); | BleLog.i(TAG, "MAC=" + mAddress + "||CID=" + data.getCid() + "||VID=" + data.getVid() + "||PID=" + data.getPid()); | ||||
if (!mList.contains(mAddress + "=" + data.getName())) { | |||||
String dataStr = mAddress + "=" + data.getName() + "=" + data.getCid() + ";" + data.getVid() + ";" + data.getPid(); | |||||
if (!mList.contains(dataStr)) { | |||||
String data1 = BleStrUtils.byte2HexStr(data.getScanRecord()); | String data1 = BleStrUtils.byte2HexStr(data.getScanRecord()); | ||||
String data2 = BleStrUtils.byte2HexStr(data.getManufacturerData()); | String data2 = BleStrUtils.byte2HexStr(data.getManufacturerData()); | ||||
BleLog.i(TAG, "MAC=" + mAddress + " ||" + data1 + "||" + data2); | |||||
mList.add(mAddress + "=" + data.getName()); | |||||
BleLog.i(TAG, "设备地址+广播数据:" + mAddress + "||" + data1 + "||" + data2); | |||||
mList.add(dataStr); | |||||
listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
} | } | ||||
@Override | @Override | ||||
public void onDisConnected(@NonNull String mac, int code) { | public void onDisConnected(@NonNull String mac, int code) { | ||||
dismissLoading(); | dismissLoading(); | ||||
Toast.makeText(mContext, getString(R.string.disconnect) + code, Toast.LENGTH_SHORT).show(); | |||||
Toast.makeText(mContext, "连接断开:" + code, Toast.LENGTH_SHORT).show(); | |||||
} | } | ||||
@Override | @Override | ||||
public void onServicesDiscovered(@NonNull String mac) { | public void onServicesDiscovered(@NonNull String mac) { | ||||
if (mac.equalsIgnoreCase(mNoEncryptionMac)) { | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mac); | |||||
bleDevice.setA7Encryption(false); | |||||
mNoEncryptionMac = ""; | |||||
} | |||||
dismissLoading(); | dismissLoading(); | ||||
Intent intent = new Intent(); | Intent intent = new Intent(); | ||||
int type = mType;//默认婴儿秤 | int type = mType;//默认婴儿秤 | ||||
switch (type) { | switch (type) { | ||||
case BleDeviceConfig.BABY_SCALE: | case BleDeviceConfig.BABY_SCALE: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.BabyCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, BabyCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.INFRARED_THERMOMETER: | case BleDeviceConfig.INFRARED_THERMOMETER: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.TempGunCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, TempGunCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.BLOOD_PRESSURE: | case BleDeviceConfig.BLOOD_PRESSURE: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.SphyCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, SphyCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.THERMOMETER: | case BleDeviceConfig.THERMOMETER: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.TempCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, TempCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.HEIGHT_METER: | case BleDeviceConfig.HEIGHT_METER: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.HeightCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, HeightCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.WEIGHT_BODY_FAT_SCALE: | case BleDeviceConfig.WEIGHT_BODY_FAT_SCALE: | ||||
intent.setClass(ShowBleActivity.this, WeightScaleBleActivity.class); | intent.setClass(ShowBleActivity.this, WeightScaleBleActivity.class); | ||||
break; | break; | ||||
case BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_AD: | case BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_AD: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.ADWeightScaleCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, ADWeightScaleCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE: | case BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE: | ||||
intent.setClass(ShowBleActivity.this, WeightScaleWifiBleActivity.class); | intent.setClass(ShowBleActivity.this, WeightScaleWifiBleActivity.class); | ||||
break; | break; | ||||
case BleDeviceConfig.TOOTHBRUSH_WIFI_BLE: | case BleDeviceConfig.TOOTHBRUSH_WIFI_BLE: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.ToothBrushWifiBleActivity.class); | |||||
intent.setClass(ShowBleActivity.this, ToothBrushWifiBleActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.EIGHT_BODY_FAT_SCALE: | case BleDeviceConfig.EIGHT_BODY_FAT_SCALE: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.EightBodyfatActivity.class); | |||||
intent.setClass(ShowBleActivity.this, EightBodyfatActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.BLOOD_GLUCOSE: | case BleDeviceConfig.BLOOD_GLUCOSE: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.BloodGlucoseActivity.class); | |||||
intent.setClass(ShowBleActivity.this, BloodGlucoseActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.BABY_BODY_FAT: | case BleDeviceConfig.BABY_BODY_FAT: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.BabyBodyFatCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, BabyBodyFatCmdActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.SMART_MASK: | case BleDeviceConfig.SMART_MASK: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.SmartMaskActivity.class); | |||||
intent.setClass(ShowBleActivity.this, SmartMaskActivity.class); | |||||
break; | break; | ||||
case BleDeviceConfig.SMART_SCOOTER: | |||||
intent.setClass(ShowBleActivity.this, SkateboardDataActivity.class); | |||||
break; | |||||
case BleDeviceConfig.BLE_BOOLD_OXYGEN: | |||||
intent.setClass(ShowBleActivity.this, BloodOxygenActivity.class); | |||||
break; | |||||
case BleDeviceConfig.COFFEE_SCALE: | |||||
// 咖啡秤 | |||||
intent.setClass(ShowBleActivity.this, CoffeeScaleActivity.class); | |||||
break; | |||||
case BleDeviceConfig.SHARE_CHARGER: | |||||
// 共享充电器 | |||||
intent.setClass(ShowBleActivity.this, ShareChargerActivity.class); | |||||
break; | |||||
case BleDeviceConfig.SHARE_SOCKET: | |||||
// 共享插座 | |||||
intent.setClass(ShowBleActivity.this, ShareSocketActivity.class); | |||||
break; | |||||
case BleDeviceConfig.SHARE_CONDOM: | |||||
// 共享套套机 | |||||
intent.setClass(ShowBleActivity.this, ShareCondomActivity.class); | |||||
break; | |||||
case BleDeviceConfig.FIND_DEVICE: | |||||
// 寻物器 | |||||
// intent.setClass(ShowBleActivity.this, FindDeviceActivity.class); | |||||
intent.setClass(ShowBleActivity.this, FindDeviceNewActivity.class); | |||||
BleConfig.setHandshakeStatus(mac, false); | |||||
break; | |||||
case BleDeviceConfig.FOOD_TEMP: | |||||
// 食品温度计 | |||||
intent.setClass(ShowBleActivity.this, FoodTempActivity.class); | |||||
break; | |||||
case BleDeviceConfig.HEIGHT_BODY_FAT: | |||||
intent.setClass(ShowBleActivity.this, HeightWeightScaleActivity.class); | |||||
break; | |||||
case BleDeviceConfig.TEMP_Humidity: | |||||
intent.setClass(ShowBleActivity.this, TempHumidityActivity.class); | |||||
break; | |||||
// case BleDeviceConfig.BLD_WEIGHT: | |||||
// intent.setClass(ShowBleActivity.this, BLDWeightScaleBle.class); | |||||
// break; | |||||
case -1: | case -1: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.BleCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, BleCmdActivity.class); | |||||
break; | break; | ||||
case -2: | case -2: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.TestCmdActivity.class); | |||||
intent.setClass(ShowBleActivity.this, TestCmdActivity.class); | |||||
break; | break; | ||||
case -3: | case -3: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.TestOtaActivity.class); | |||||
intent.setClass(ShowBleActivity.this, TestOtaActivity.class); | |||||
break; | break; | ||||
case -4: | case -4: | ||||
intent.setClass(ShowBleActivity.this, aicare.net.cn.sdk.ailinksdkdemoandroid.TransmissionActivity.class); | |||||
intent.setClass(ShowBleActivity.this, TransmissionActivity.class); | |||||
break; | |||||
case 65536: | |||||
//验证不握手不加密的界面 | |||||
intent.setClass(ShowBleActivity.this, ClearShakeHandsActivity.class); | |||||
break; | break; | ||||
} | |||||
} | |||||
intent.putExtra("type", type); | intent.putExtra("type", type); | ||||
intent.putExtra("mac", mac); | intent.putExtra("mac", mac); | ||||
intent.putExtra("cid", mCid); | |||||
intent.putExtra("vid", mVid); | |||||
intent.putExtra("pid", mPid); | |||||
startActivity(intent); | startActivity(intent); | ||||
} | } | ||||
@Override | @Override | ||||
public void bleClose() { | public void bleClose() { | ||||
checkPermission(); | |||||
} | } | ||||
@Override | @Override | ||||
public boolean onFilter(BleValueBean bleValueBean) { | public boolean onFilter(BleValueBean bleValueBean) { | ||||
int cid = bleValueBean.getCid(); | int cid = bleValueBean.getCid(); | ||||
BleLog.i(TAG, "绑定设备广播类型:" + cid + "||添加的类型:" + mType); | BleLog.i(TAG, "绑定设备广播类型:" + cid + "||添加的类型:" + mType); | ||||
if (mType < 0 || mType > 0xFF) | |||||
return true; | |||||
else | |||||
if (mType < 0) { | |||||
if (TextUtils.isEmpty(mFilterName) && TextUtils.isEmpty(mFilterMac)) { | |||||
return true; | |||||
} | |||||
if (!TextUtils.isEmpty(mFilterName)) { | |||||
String name = bleValueBean.getName(); | |||||
if (name != null && name.toUpperCase().contains(mFilterName.toUpperCase())) { | |||||
return true; | |||||
} | |||||
} | |||||
if (!TextUtils.isEmpty(mFilterMac)) { | |||||
String mac = bleValueBean.getMac().replace(":", "").toUpperCase().trim(); | |||||
return mac.contains(mFilterMac.toUpperCase()); | |||||
} | |||||
return false; | |||||
} else { | |||||
return mType == cid; | return mType == cid; | ||||
} | |||||
} | } | ||||
@Override | @Override | ||||
//TODO 过滤后的设备 | //TODO 过滤后的设备 | ||||
} | } | ||||
@Override | |||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |||||
super.onActivityResult(requestCode, resultCode, data); | |||||
if (requestCode == REQUEST_PERMISSION_CODE) { | |||||
checkPermission(); | |||||
} | |||||
} | |||||
//--------------------------start Loading-------------------------- | //--------------------------start Loading-------------------------- | ||||
private LoadingIosDialogFragment mDialogFragment; | private LoadingIosDialogFragment mDialogFragment; | ||||
@Override | @Override | ||||
protected void onDestroy() { | protected void onDestroy() { | ||||
super.onDestroy(); | super.onDestroy(); | ||||
if (mBluetoothService != null) { | |||||
mBluetoothService.stopScan(); | |||||
} | |||||
unbindService(); | unbindService(); | ||||
} | } | ||||
// ------------------- 权限 ------------------ | |||||
/** | |||||
* 检查权限 | |||||
*/ | |||||
private void checkPermission() { | |||||
// 没有蓝牙权限就请求蓝牙权限 | |||||
if (!hasBluetooth()) { | |||||
requestBluetooth(); | |||||
return; | |||||
} | |||||
// 没有定位权限就请求定位权限 | |||||
if (!hasLocationPermission()) { | |||||
requestLocationPermission(this); | |||||
return; | |||||
} | |||||
// 没有定位服务就请求定位服务 | |||||
if (!hasLocationService()) { | |||||
requestLocationService(); | |||||
return; | |||||
} | |||||
// 都有了,OK | |||||
Toast.makeText(mContext, "权限都有,可以开始搜索", Toast.LENGTH_SHORT).show(); | |||||
} | |||||
/** | |||||
* 是否有定位权限 | |||||
* | |||||
* @return boolean | |||||
*/ | |||||
private boolean hasLocationPermission() { | |||||
return ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED; | |||||
} | |||||
/** | |||||
* 蓝牙是否打开 | |||||
* | |||||
* @return boolean | |||||
*/ | |||||
private boolean hasBluetooth() { | |||||
return BluetoothAdapter.getDefaultAdapter().isEnabled(); | |||||
} | |||||
/** | |||||
* 定位服务是否打开 | |||||
* | |||||
* @return boolean | |||||
*/ | |||||
private boolean hasLocationService() { | |||||
LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); | |||||
if (locationManager == null) { | |||||
return false; | |||||
} | |||||
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |||||
} | |||||
/** | |||||
* 申请定位权限 | |||||
*/ | |||||
private void requestLocationPermission(Activity activity) { | |||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_CODE); | |||||
} | |||||
/** | |||||
* 申请打开蓝牙 | |||||
*/ | |||||
private void requestBluetooth() { | |||||
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); | |||||
startActivityForResult(intent, REQUEST_PERMISSION_CODE); | |||||
} | |||||
/** | |||||
* 申请打开定位服务 | |||||
*/ | |||||
private void requestLocationService() { | |||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |||||
startActivityForResult(intent, REQUEST_PERMISSION_CODE); | |||||
} | |||||
} | } |
import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import butterknife.BindView; | import butterknife.BindView; | ||||
ListView mListview; | ListView mListview; | ||||
@BindView(R.id.get_version) | @BindView(R.id.get_version) | ||||
Button mGetVersion; | Button mGetVersion; | ||||
@BindView(R.id.get_AIQ) | |||||
Button mGetAIQ; | |||||
@BindView(R.id.close_power) | |||||
Button closePower; | |||||
@BindView(R.id.set_mode) | |||||
Button setMode; | |||||
@BindView(R.id.set_payload) | |||||
Button setPayload; | |||||
private List<String> mList; | private List<String> mList; | ||||
private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
private Context mContext; | private Context mContext; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
private int type = SmartMaskBleConfig.SMART_MASK; | private int type = SmartMaskBleConfig.SMART_MASK; | ||||
private int mFanStatus = 0; | private int mFanStatus = 0; | ||||
private boolean showPayload; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | private Handler mHandler = new Handler(Looper.getMainLooper()) { | ||||
@Override | @Override | ||||
mSetFan.setOnClickListener(this); | mSetFan.setOnClickListener(this); | ||||
mGetVersion.setOnClickListener(this); | mGetVersion.setOnClickListener(this); | ||||
setPayload.setOnClickListener(this); | |||||
setMode.setOnClickListener(this); | |||||
closePower.setOnClickListener(this); | |||||
mGetAIQ.setOnClickListener(this); | |||||
} | } | ||||
mDevice.setFanStatus(mFanStatus); | mDevice.setFanStatus(mFanStatus); | ||||
} | } | ||||
break; | break; | ||||
case R.id.get_AIQ: | |||||
if (mDevice != null) mDevice.getIAQData(); | |||||
break; | |||||
case R.id.set_mode: | |||||
if (mDevice != null) mDevice.setTestMode(); | |||||
break; | |||||
case R.id.close_power: | |||||
if (mDevice != null) mDevice.closePower(); | |||||
break; | |||||
case R.id.set_payload: | |||||
showPayload = true; | |||||
break; | |||||
} | } | ||||
} | } | ||||
//-----------------通知------------------- | //-----------------通知------------------- | ||||
@Override | |||||
public void onPayloadData(byte[] data) { | |||||
if (showPayload) { | |||||
mList.add(BleStrUtils.byte2HexStr(data)); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
} | |||||
@Override | |||||
public void onSetStatus(int type,int status) { | |||||
String data = ""; | |||||
if (type== SmartMaskBleConfig.GET_TEST_MODE){ | |||||
data="进入测试模式:"; | |||||
}else if (type== SmartMaskBleConfig.GET_POWER){ | |||||
data="关机:"; | |||||
} | |||||
switch (status) { | |||||
case 0: | |||||
data += "成功"; | |||||
break; | |||||
case 1: | |||||
data += "失败"; | |||||
break; | |||||
} | |||||
mList.add(TimeUtils.getTime() + data); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | @Override | ||||
public void onStatus(int airIndex, int fanStatus, int power, int powerStatus, int batteryRemaining, int breathRate, int breathState, int filterDuration) { | public void onStatus(int airIndex, int fanStatus, int power, int powerStatus, int batteryRemaining, int breathRate, int breathState, int filterDuration) { | ||||
} | } | ||||
@Override | |||||
public void onIAQData(int status, int eCo2, int TvOc, int hcho) { | |||||
String data = ""; | |||||
switch (status) { | |||||
case 0: | |||||
data = "OK"; | |||||
break; | |||||
case 1: | |||||
data = "Heating"; | |||||
break; | |||||
case 2: | |||||
data = "Error"; | |||||
break; | |||||
} | |||||
mList.add(TimeUtils.getTime() + data + "\n ECO2:" + eCo2 + "\n TVOC:" + TvOc + "\n HCHO:" + hcho); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | @Override | ||||
public void onBmVersion(String version) { | public void onBmVersion(String version) { | ||||
mList.add(TimeUtils.getTime() + "版本号:" + version); | mList.add(TimeUtils.getTime() + "版本号:" + version); |
import android.view.View; | import android.view.View; | ||||
import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
import android.widget.Button; | import android.widget.Button; | ||||
import android.widget.EditText; | |||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import com.pingwang.bluetoothlib.BleBaseActivity; | import com.pingwang.bluetoothlib.BleBaseActivity; | ||||
import com.pingwang.bluetoothlib.device.BleDevice; | import com.pingwang.bluetoothlib.device.BleDevice; | ||||
import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | ||||
import com.pingwang.bluetoothlib.device.SendBleBean; | import com.pingwang.bluetoothlib.device.SendBleBean; | ||||
import com.pingwang.bluetoothlib.device.SendMcuBean; | |||||
import com.pingwang.bluetoothlib.listener.CallbackDisIm; | import com.pingwang.bluetoothlib.listener.CallbackDisIm; | ||||
import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | ||||
import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | ||||
private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
private Context mContext; | private Context mContext; | ||||
private EditText et_type; | |||||
private SphyDeviceData mBleDevice; | private SphyDeviceData mBleDevice; | ||||
private String mAddress; | private String mAddress; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
}); | }); | ||||
findViewById(R.id.btn1).setOnClickListener(this); | |||||
findViewById(R.id.btnVersion).setOnClickListener(this); | findViewById(R.id.btnVersion).setOnClickListener(this); | ||||
findViewById(R.id.btnBattery).setOnClickListener(this); | findViewById(R.id.btnBattery).setOnClickListener(this); | ||||
findViewById(R.id.btn_get_did).setOnClickListener(this); | findViewById(R.id.btn_get_did).setOnClickListener(this); | ||||
findViewById(R.id.clear).setOnClickListener(this); | findViewById(R.id.clear).setOnClickListener(this); | ||||
et_type = findViewById(R.id.et_type); | |||||
cmdBtn(); | cmdBtn(); | ||||
} | } | ||||
sendBleBean.setHex(mBleSendCmdUtil.getDid()); | sendBleBean.setHex(mBleSendCmdUtil.getDid()); | ||||
mBleDevice.sendData(sendBleBean); | mBleDevice.sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btn1: | |||||
String cmd = et_type.getText().toString().trim(); | |||||
SendMcuBean sendDataBean = new SendMcuBean(); | |||||
sendDataBean.setHex(type,cmd.getBytes()); | |||||
mBleDevice.sendData(sendDataBean); | |||||
break; | |||||
case R.id.clear: | case R.id.clear: | ||||
if (mList != null) | if (mList != null) | ||||
mList.clear(); | mList.clear(); | ||||
@Override | @Override | ||||
public void getSphyCmd(byte cmd) { | public void getSphyCmd(byte cmd) { | ||||
mList.add(TimeUtils.getTime() + "cmd:" + cmd); | |||||
mList.add(TimeUtils.getTime() + "指令:" + cmd); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
public void sphyDataNow(int dia, int sys, int decimal, int pul, int unit) { | public void sphyDataNow(int dia, int sys, int decimal, int pul, int unit) { | ||||
String diaStr = BleDensityUtil.getInstance().holdDecimals(dia, decimal); | String diaStr = BleDensityUtil.getInstance().holdDecimals(dia, decimal); | ||||
String sysStr = BleDensityUtil.getInstance().holdDecimals(sys, decimal); | String sysStr = BleDensityUtil.getInstance().holdDecimals(sys, decimal); | ||||
mList.add(TimeUtils.getTime() + "current:dia=" + diaStr + " sys=" + sysStr + " pul=" + pul + " unit=" + unit); | |||||
mList.add(TimeUtils.getTime() + "实时:dia=" + diaStr + "sys=" + sysStr + "pul=" + pul + "unit" + "=" + unit); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
public void sphyData(int dia, int sys, int decimal, int pul, int unit) { | public void sphyData(int dia, int sys, int decimal, int pul, int unit) { | ||||
String diaStr = BleDensityUtil.getInstance().holdDecimals(dia, decimal); | String diaStr = BleDensityUtil.getInstance().holdDecimals(dia, decimal); | ||||
String sysStr = BleDensityUtil.getInstance().holdDecimals(sys, decimal); | String sysStr = BleDensityUtil.getInstance().holdDecimals(sys, decimal); | ||||
mList.add(TimeUtils.getTime() + "result:dia=" + diaStr + " sys=" + sysStr + " pul=" + pul + " unit=" + unit); | |||||
mList.add(TimeUtils.getTime() + "稳定:dia=" + diaStr + "sys=" + sysStr + "pul=" + pul + "unit" + "=" + unit); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
String showData = ""; | String showData = ""; | ||||
switch (unit) { | switch (unit) { | ||||
case CmdConfig.SETTING_SUCCESS: | case CmdConfig.SETTING_SUCCESS: | ||||
showData = getString(R.string.set_success); | |||||
showData = "设置单位成功"; | |||||
break; | break; | ||||
case CmdConfig.SETTING_FAILURE: | case CmdConfig.SETTING_FAILURE: | ||||
showData = getString(R.string.set_failure); | |||||
showData = "设置单位失败"; | |||||
break; | break; | ||||
case CmdConfig.SETTING_ERR: | case CmdConfig.SETTING_ERR: | ||||
showData = getString(R.string.set_err); | |||||
showData = "设置单位错误"; | |||||
break; | break; | ||||
} | } | ||||
mList.add(TimeUtils.getTime() + showData+" unit="+SphyCmdActivity.this.unit); | |||||
mList.add(TimeUtils.getTime() + showData); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
@Override | @Override | ||||
public void getErr(byte status) { | public void getErr(byte status) { | ||||
mList.add(TimeUtils.getTime() + "Err:" + status); | |||||
mList.add(TimeUtils.getTime() + "错误:" + status); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onBmVersion(String version) { | public void onBmVersion(String version) { | ||||
mList.add(TimeUtils.getTime() + "Version:" + version); | |||||
mList.add(TimeUtils.getTime() + "版本号:" + version); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
@Override | @Override | ||||
public void onMcuBatteryStatus(int status, int battery) { | public void onMcuBatteryStatus(int status, int battery) { | ||||
mList.add(TimeUtils.getTime() + getString(R.string.power) + battery + "%"); | |||||
mList.add(TimeUtils.getTime() + "电量:" + battery + "%"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
String time = | String time = | ||||
times[0] + "-" + times[1] + "-" + times[2] + " " + times[3] + ":" + times[4] + | times[0] + "-" + times[1] + "-" + times[2] + " " + times[3] + ":" + times[4] + | ||||
":" + times[5]; | ":" + times[5]; | ||||
mList.add(TimeUtils.getTime() + "system Time:" + time); | |||||
mList.add(TimeUtils.getTime() + "系统时间:" + time); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
} | } | ||||
import com.pingwang.bluetoothlib.utils.BleDensityUtil; | import com.pingwang.bluetoothlib.utils.BleDensityUtil; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.thermometer.TempDeviceData; | import cn.net.aicare.modulelibrary.module.thermometer.TempDeviceData; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 显示数据 | |||||
* 体温计 | |||||
*/ | */ | ||||
public class TempCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | public class TempCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | ||||
* 服务Intent | * 服务Intent | ||||
*/ | */ | ||||
private Context mContext; | private Context mContext; | ||||
private EditText et_type; | |||||
private TempDeviceData mBleDevice; | private TempDeviceData mBleDevice; | ||||
private String mAddress; | private String mAddress; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
findViewById(R.id.btnBattery).setOnClickListener(this); | findViewById(R.id.btnBattery).setOnClickListener(this); | ||||
findViewById(R.id.btn_get_did).setOnClickListener(this); | findViewById(R.id.btn_get_did).setOnClickListener(this); | ||||
findViewById(R.id.clear).setOnClickListener(this); | findViewById(R.id.clear).setOnClickListener(this); | ||||
et_type = findViewById(R.id.et_type); | |||||
cmdBtn(); | cmdBtn(); | ||||
} | } | ||||
sendBleBean.setHex(mBleSendCmdUtil.getDid()); | sendBleBean.setHex(mBleSendCmdUtil.getDid()); | ||||
mBleDevice.sendData(sendBleBean); | mBleDevice.sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btn1: | |||||
String cmd = et_type.getText().toString().trim(); | |||||
SendMcuBean sendDataBean = new SendMcuBean(); | |||||
sendDataBean.setHex(type,cmd.getBytes()); | |||||
mBleDevice.sendData(sendDataBean); | |||||
break; | |||||
case R.id.clear: | case R.id.clear: | ||||
if (mList != null) | if (mList != null) | ||||
mList.clear(); | mList.clear(); |
import com.pingwang.bluetoothlib.utils.BleDensityUtil; | import com.pingwang.bluetoothlib.utils.BleDensityUtil; | ||||
import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.foreheadgun.TempGunDeviceData; | import cn.net.aicare.modulelibrary.module.foreheadgun.TempGunDeviceData; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 显示数据 | |||||
* 额温枪 | |||||
*/ | */ | ||||
public class TempGunCmdActivity extends BleBaseActivity implements OnCallbackDis, | |||||
OnBleVersionListener, TempGunDeviceData.onNotifyData , OnBleCompanyListener, OnMcuParameterListener, View.OnClickListener { | |||||
public class TempGunCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleVersionListener, TempGunDeviceData.onNotifyData , OnBleCompanyListener, OnMcuParameterListener, View.OnClickListener { | |||||
private static String TAG = TempGunCmdActivity.class.getName(); | private static String TAG = TempGunCmdActivity.class.getName(); | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
* 服务Intent | * 服务Intent | ||||
*/ | */ | ||||
private Context mContext; | private Context mContext; | ||||
private EditText et_type; | |||||
private TempGunDeviceData mBleDevice; | private TempGunDeviceData mBleDevice; | ||||
private String mAddress; | private String mAddress; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
findViewById(R.id.btnBattery).setOnClickListener(this); | findViewById(R.id.btnBattery).setOnClickListener(this); | ||||
findViewById(R.id.btn_get_did).setOnClickListener(this); | findViewById(R.id.btn_get_did).setOnClickListener(this); | ||||
findViewById(R.id.clear).setOnClickListener(this); | findViewById(R.id.clear).setOnClickListener(this); | ||||
et_type = findViewById(R.id.et_type); | |||||
cmdBtn(); | cmdBtn(); | ||||
} | } | ||||
sendBleBean.setHex(mBleSendCmdUtil.getDid()); | sendBleBean.setHex(mBleSendCmdUtil.getDid()); | ||||
mBleDevice.sendData(sendBleBean); | mBleDevice.sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btn1: | |||||
String cmd = et_type.getText().toString().trim(); | |||||
SendMcuBean sendDataBean = new SendMcuBean(); | |||||
sendDataBean.setHex(type,cmd.getBytes()); | |||||
mBleDevice.sendData(sendDataBean); | |||||
break; | |||||
case R.id.clear: | case R.id.clear: | ||||
if (mList != null) | if (mList != null) | ||||
mList.clear(); | mList.clear(); |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Message; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import java.lang.ref.WeakReference; | |||||
import java.util.ArrayList; | |||||
import java.util.Collections; | |||||
import java.util.List; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.TempHumidity.TempHumidityBleUtils; | |||||
/** | |||||
* 温湿度计 | |||||
*/ | |||||
public class TempHumidityActivity extends BleBaseActivity implements OnCallbackBle, TempHumidityBleUtils.BleDataCallBack, View.OnClickListener { | |||||
private String mAddress = ""; | |||||
private List<String> logList; | |||||
private List<String> historyLogList; | |||||
private List<Long> historyLogListId; | |||||
private ListView listView; | |||||
private ListView list_view_history; | |||||
private ArrayAdapter listAdapter; | |||||
private ArrayAdapter historyListAdapter; | |||||
private MHandler mMHandler; | |||||
private EditText et_history; | |||||
private boolean isHeart; | |||||
private final int HEART = 1; | |||||
private TextView tv_result; | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBluetoothService.setOnCallback(this); | |||||
logList.add(0, "绑定服务成功"); | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.setOnCallback(this); | |||||
mBluetoothService.deviceConnectListener(mAddress, true); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (bleDevice != null) { | |||||
TempHumidityBleUtils.init(bleDevice); | |||||
TempHumidityBleUtils.getInstance().setBleDataCallBack(this); | |||||
} else { | |||||
mBluetoothService.disconnectAll(); | |||||
startScanBle(0); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_temp_humidity); | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
logList = new ArrayList<>(); | |||||
historyLogList = new ArrayList<>(); | |||||
historyLogListId = new ArrayList<>(); | |||||
listView = findViewById(R.id.listView); | |||||
list_view_history = findViewById(R.id.list_view_history); | |||||
tv_result = findViewById(R.id.tv_result); | |||||
et_history = findViewById(R.id.et_history); | |||||
mMHandler = new WeakReference<>(new MHandler()).get(); | |||||
findViewById(R.id.btn_slow).setOnClickListener(this); | |||||
findViewById(R.id.btn_fat).setOnClickListener(this); | |||||
findViewById(R.id.btn_history).setOnClickListener(this); | |||||
findViewById(R.id.btn_hear).setOnClickListener(this); | |||||
findViewById(R.id.btn_show_history).setOnClickListener(this); | |||||
findViewById(R.id.btn_clear).setOnClickListener(this); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, logList); | |||||
historyListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, historyLogList); | |||||
listView.setAdapter(listAdapter); | |||||
list_view_history.setAdapter(historyListAdapter); | |||||
} | |||||
@Override | |||||
public void onStartScan() { | |||||
} | |||||
@Override | |||||
public void onScanning(BleValueBean data) { | |||||
if (data.getMac().equalsIgnoreCase(mAddress)) { | |||||
stopScanBle(); | |||||
mBluetoothService.connectDevice(mAddress); | |||||
} | |||||
} | |||||
@Override | |||||
public void onScanTimeOut() { | |||||
} | |||||
@Override | |||||
public void onConnecting(String mac) { | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
if (mac.equals(mAddress)) { | |||||
logList.add(0, "连接已经断开"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onConnectionSuccess(String mac) { | |||||
stopScanBle(); | |||||
logList.add(0, "连接成功" + mac); | |||||
} | |||||
@Override | |||||
public void onServicesDiscovered(String mac) { | |||||
if (mac.equalsIgnoreCase(mAddress)) { | |||||
stopScanBle(); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (bleDevice != null) { | |||||
TempHumidityBleUtils.init(bleDevice); | |||||
TempHumidityBleUtils.getInstance().setBleDataCallBack(this); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void bleOpen() { | |||||
} | |||||
@Override | |||||
public void bleClose() { | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (TempHumidityBleUtils.getInstance() != null) { | |||||
switch (v.getId()) { | |||||
case R.id.btn_slow: | |||||
if (TempHumidityBleUtils.getInstance() != null) { | |||||
TempHumidityBleUtils.getInstance().sendSlowData(); | |||||
logList.add(0, "慢速保存数据"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
break; | |||||
case R.id.btn_fat: | |||||
if (TempHumidityBleUtils.getInstance() != null) { | |||||
TempHumidityBleUtils.getInstance().sendFatData(); | |||||
logList.add(0, "快速速保存数据"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
break; | |||||
case R.id.btn_history: | |||||
if (TempHumidityBleUtils.getInstance() != null) { | |||||
String s = et_history.getText().toString().trim(); | |||||
long maxId = 0; | |||||
if (!s.isEmpty()) { | |||||
maxId = Long.parseLong(s); | |||||
} | |||||
TempHumidityBleUtils.getInstance().getOffLineRecord(maxId); | |||||
logList.add(0, "获取历史记录 时间Id" + maxId); | |||||
tv_result.setText(""); | |||||
historyLogListId.clear(); | |||||
historyLogList.clear(); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
break; | |||||
case R.id.btn_show_history: | |||||
if (listView.getVisibility() == View.VISIBLE) { | |||||
historyListAdapter.notifyDataSetChanged(); | |||||
listView.setVisibility(View.GONE); | |||||
list_view_history.setVisibility(View.VISIBLE); | |||||
} else { | |||||
listView.setVisibility(View.VISIBLE); | |||||
list_view_history.setVisibility(View.GONE); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
case R.id.btn_hear: | |||||
if (!isHeart) { | |||||
isHeart = true; | |||||
mMHandler.sendEmptyMessage(HEART); | |||||
logList.add(0, "开启心跳"); | |||||
} else { | |||||
isHeart = false; | |||||
mMHandler.removeMessages(HEART); | |||||
logList.add(0, "关闭心跳"); | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
case R.id.btn_clear: | |||||
logList.clear(); | |||||
historyLogListId.clear(); | |||||
historyLogList.clear(); | |||||
listAdapter.notifyDataSetChanged(); | |||||
historyListAdapter.notifyDataSetChanged(); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onDeviceStatus(int battery, long time, float temp, float humidity) { | |||||
logList.add(0, "设备状态 电池电量:" + battery + "\n时间:" + time + " 温度: " + temp + " 湿度:" + humidity); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onOffLineRecordNum(long total, long sendNum) { | |||||
logList.add(0, "历史记录 总量:" + total + "发送量:" + sendNum); | |||||
if (total == sendNum) { | |||||
if (historyLogListId.size() > 0) { | |||||
Collections.sort(historyLogListId); | |||||
tv_result.setText("总:" + historyLogListId.size() + "开:" + historyLogListId.get(0) + "结:" + historyLogListId.get(historyLogList.size() - 1)); | |||||
} else { | |||||
tv_result.setText(""); | |||||
} | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onOffLineRecord(long time, float temp, float humidity) { | |||||
historyLogList.add(0, "时间:" + time + " 温度: " + temp + " 湿度:" + humidity); | |||||
historyLogListId.add(time); | |||||
} | |||||
public class MHandler extends Handler { | |||||
@Override | |||||
public void handleMessage(@NonNull Message msg) { | |||||
super.handleMessage(msg); | |||||
switch (msg.what) { | |||||
case HEART: | |||||
if (TempHumidityBleUtils.getInstance() != null) { | |||||
TempHumidityBleUtils.getInstance().getDeviceStatus(); | |||||
mMHandler.sendEmptyMessageDelayed(HEART, 5000); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
super.onDestroy(); | |||||
mMHandler.removeMessages(HEART); | |||||
if (mBluetoothService != null) | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
} |
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 显示数据 | |||||
* 测试指令界面 | |||||
*/ | */ | ||||
public class TestCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleDeviceDataListener, | |||||
View.OnClickListener { | |||||
public class TestCmdActivity extends BleBaseActivity implements OnCallbackDis, OnBleDeviceDataListener, View.OnClickListener { | |||||
private static String TAG = TestCmdActivity.class.getName(); | private static String TAG = TestCmdActivity.class.getName(); | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
case SEND_DATA: | case SEND_DATA: | ||||
if (sendUuid != null && sendUuidServer != null) { | if (sendUuid != null && sendUuidServer != null) { | ||||
SendDataBean sendDataBean = new SendDataBean(sendCmd.getBytes(), sendUuid | |||||
, BleConfig.WRITE_DATA, sendUuidServer); | |||||
SendDataBean sendDataBean = new SendDataBean(sendCmd.getBytes(), sendUuid, BleConfig.WRITE_DATA, sendUuidServer); | |||||
bleDevice.sendData(sendDataBean); | bleDevice.sendData(sendDataBean); | ||||
mHandler.sendEmptyMessageDelayed(SEND_DATA, sendTime); | mHandler.sendEmptyMessageDelayed(SEND_DATA, sendTime); | ||||
} | } | ||||
sendUuid = UUID.fromString(uuid); | sendUuid = UUID.fromString(uuid); | ||||
break; | break; | ||||
case R.id.btn_uuid_server: | case R.id.btn_uuid_server: | ||||
String uuidServer = | |||||
et_uuid_server.getText().toString().trim().toUpperCase(Locale.ENGLISH); | |||||
String uuidServer = et_uuid_server.getText().toString().trim().toUpperCase(Locale.ENGLISH); | |||||
if (uuidServer.length() == 8) { | if (uuidServer.length() == 8) { | ||||
uuidServer += uuidEnd; | uuidServer += uuidEnd; | ||||
} | } | ||||
UUID UUID_NOTIFY = UUID.fromString(notify); | UUID UUID_NOTIFY = UUID.fromString(notify); | ||||
if (bleDevice != null && sendUuidServer != null) { | if (bleDevice != null && sendUuidServer != null) { | ||||
// bleDevice.setNotify(notifyOpen); | // bleDevice.setNotify(notifyOpen); | ||||
bleDevice.setNotify(sendUuidServer,UUID_NOTIFY); | |||||
if (notifyOpen) { | |||||
bleDevice.setNotify(sendUuidServer, UUID_NOTIFY); | |||||
} else { | |||||
bleDevice.setCloseNotify(sendUuidServer, UUID_NOTIFY); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
protected void onDestroy() { | protected void onDestroy() { | ||||
super.onDestroy(); | super.onDestroy(); |
import android.text.TextUtils; | import android.text.TextUtils; | ||||
import android.view.View; | import android.view.View; | ||||
import android.widget.ArrayAdapter; | import android.widget.ArrayAdapter; | ||||
import android.widget.Button; | |||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import android.widget.Toast; | import android.widget.Toast; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/4/25<br> | * 2019/4/25<br> | ||||
* 显示数据 | |||||
* OTA测试界面 | |||||
*/ | */ | ||||
public class TestOtaActivity extends BleBaseActivity implements OnCallbackBle, | |||||
OnBleDeviceDataListener, View.OnClickListener, OnBleOTAListener, ShowListDialogFragment.onDialogListener { | |||||
public class TestOtaActivity extends BleBaseActivity implements OnCallbackBle, OnBleDeviceDataListener, View.OnClickListener, OnBleOTAListener, ShowListDialogFragment.onDialogListener { | |||||
private static String TAG = TestOtaActivity.class.getName(); | private static String TAG = TestOtaActivity.class.getName(); | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
private final int SEND_DATA = 4; | private final int SEND_DATA = 4; | ||||
private TextView mTvVersion; | private TextView mTvVersion; | ||||
private Button btn_shake_hands; | |||||
private List<String> mList; | private List<String> mList; | ||||
private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
private ArrayList<DialogStringImageAdapter.DialogStringImageBean> mDialogList; | private ArrayList<DialogStringImageAdapter.DialogStringImageBean> mDialogList; | ||||
private String mOTAFileName; | private String mOTAFileName; | ||||
private DialogOtaManager mDialogOtaManager; | |||||
private Handler mHandler = new Handler(Looper.getMainLooper()) { | private Handler mHandler = new Handler(Looper.getMainLooper()) { | ||||
@Override | @Override | ||||
public void handleMessage(Message msg) { | public void handleMessage(Message msg) { | ||||
ListView listView = findViewById(R.id.listview); | ListView listView = findViewById(R.id.listview); | ||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | ||||
listView.setAdapter(listAdapter); | listView.setAdapter(listAdapter); | ||||
mTvVersion = findViewById(R.id.tv_version); | |||||
btn_shake_hands = findViewById(R.id.btn_shake_hands); | |||||
btn_shake_hands.setTag(false); | |||||
findViewById(R.id.btn_ota_connect).setOnClickListener(this); | findViewById(R.id.btn_ota_connect).setOnClickListener(this); | ||||
findViewById(R.id.btn_ota_dis).setOnClickListener(this); | findViewById(R.id.btn_ota_dis).setOnClickListener(this); | ||||
findViewById(R.id.btn_ota_file).setOnClickListener(this); | findViewById(R.id.btn_ota_file).setOnClickListener(this); | ||||
findViewById(R.id.btn_ota_start).setOnClickListener(this); | |||||
mTvVersion=findViewById(R.id.tv_version); | |||||
findViewById(R.id.btn_ota_start_585).setOnClickListener(this); | |||||
findViewById(R.id.btn_ota_start_531).setOnClickListener(this); | |||||
findViewById(R.id.btn_ota_start_580).setOnClickListener(this); | |||||
btn_shake_hands.setOnClickListener(this); | |||||
mOTAFileName = SP.getInstance().getOtaFileName(); | mOTAFileName = SP.getInstance().getOtaFileName(); | ||||
if (mOTAFileName.isEmpty()) | if (mOTAFileName.isEmpty()) | ||||
mTvVersion.setText("xxxxxxxx"); | mTvVersion.setText("xxxxxxxx"); | ||||
else | else | ||||
mTvVersion.setText(mOTAFileName); | mTvVersion.setText(mOTAFileName); | ||||
mDialogList=new ArrayList<>(); | |||||
mDialogList = new ArrayList<>(); | |||||
} | } | ||||
@Override | @Override | ||||
public void onItemListener(int position) { | public void onItemListener(int position) { | ||||
if (mDialogList.size() > position) { | if (mDialogList.size() > position) { | ||||
DialogStringImageAdapter.DialogStringImageBean dialogStringImageBean = mDialogList | |||||
.get(position); | |||||
DialogStringImageAdapter.DialogStringImageBean dialogStringImageBean = mDialogList.get(position); | |||||
String name = dialogStringImageBean.getName(); | String name = dialogStringImageBean.getName(); | ||||
mOTAFileName = name; | mOTAFileName = name; | ||||
SP.getInstance().putOtaFileName(name); | SP.getInstance().putOtaFileName(name); | ||||
public void onClick(View v) { | public void onClick(View v) { | ||||
switch (v.getId()) { | switch (v.getId()) { | ||||
case R.id.btn_ota_connect: | case R.id.btn_ota_connect: | ||||
if (mBleDevice==null&&!TextUtils.isEmpty(mAddress)){ | |||||
if (mBleDevice == null && !TextUtils.isEmpty(mAddress)) { | |||||
connectBle(mAddress); | connectBle(mAddress); | ||||
} | } | ||||
break; | break; | ||||
case R.id.btn_ota_dis: | case R.id.btn_ota_dis: | ||||
if (mBleDevice!=null){ | |||||
if (mBleDevice != null) { | |||||
mBleDevice.disconnect(); | mBleDevice.disconnect(); | ||||
mBleDevice=null; | |||||
mBleDevice = null; | |||||
} | } | ||||
break; | break; | ||||
case R.id.btn_ota_file: | case R.id.btn_ota_file: | ||||
mDialogList.add(new DialogStringImageAdapter.DialogStringImageBean(s, 0)); | mDialogList.add(new DialogStringImageAdapter.DialogStringImageBean(s, 0)); | ||||
} | } | ||||
ShowListDialogFragment.newInstance().setTitle("").setCancel("",0).setCancelBlank(true) | |||||
.setBackground(true).setBottom(false).setList(mDialogList).setOnDialogListener(this) | |||||
ShowListDialogFragment.newInstance().setTitle("").setCancel("", 0).setCancelBlank(true).setBackground(true).setBottom(false).setList(mDialogList).setOnDialogListener(this) | |||||
.show(getSupportFragmentManager()); | .show(getSupportFragmentManager()); | ||||
break; | break; | ||||
case R.id.btn_ota_start: | |||||
if (mOTAFileName.isEmpty()) { | |||||
Toast.makeText(mContext, "请先选择文件", Toast.LENGTH_SHORT).show(); | |||||
return; | |||||
} | |||||
String byFileName = FileUtils.getByFileName()+mOTAFileName; | |||||
mList.add(TimeUtils.getTime() + "OTA已开始,请耐心等待"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
DialogOtaManager build = DialogOtaManager.newBuilder().setOnBleOTAListener(this).setFilePath(byFileName).build(mBleDevice); | |||||
build.startOta(); | |||||
case R.id.btn_ota_start_585: | |||||
startOta(DialogOtaManager.IC_TYPE_585); | |||||
break; | |||||
case R.id.btn_ota_start_531: | |||||
startOta(DialogOtaManager.IC_TYPE_531); | |||||
break; | |||||
case R.id.btn_ota_start_580: | |||||
startOta(DialogOtaManager.IC_TYPE_580); | |||||
break; | |||||
case R.id.btn_shake_hands: | |||||
boolean status = (boolean) btn_shake_hands.getTag(); | |||||
btn_shake_hands.setTag(!status); | |||||
btn_shake_hands.setText("握手:" + !status); | |||||
break; | break; | ||||
} | } | ||||
private void startOta(int icType){ | |||||
if (mOTAFileName.isEmpty()) { | |||||
Toast.makeText(mContext, "请先选择文件", Toast.LENGTH_SHORT).show(); | |||||
return; | |||||
} | |||||
String byFileName = FileUtils.getByFileName() + mOTAFileName; | |||||
mList.add(TimeUtils.getTime() + "OTA已开始,请耐心等待"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
mDialogOtaManager= DialogOtaManager.newBuilder().setOnBleOTAListener(this).setFilePath(byFileName).setIcType(icType).build(mBleDevice); | |||||
// mBleDevice.setOnDialogOTAListener(this); | |||||
// mBleDevice.startDialogOta(byFileName, icType,((Boolean) btn_shake_hands.getTag())); | |||||
} | |||||
/** | /** | ||||
* 初始化请求权限 | * 初始化请求权限 | ||||
*/ | */ | ||||
private void initPermissions() { | private void initPermissions() { | ||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | ||||
ActivityCompat | |||||
.requestPermissions(this, | |||||
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, | |||||
Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); | |||||
ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1); | |||||
} | } | ||||
} | } | ||||
@Override | @Override | ||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, | |||||
@NonNull int[] grantResults) { | |||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | super.onRequestPermissionsResult(requestCode, permissions, grantResults); | ||||
if (requestCode != 1) { | if (requestCode != 1) { | ||||
return; | return; | ||||
} else { | } else { | ||||
if (ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0])) { | if (ActivityCompat.shouldShowRequestPermissionRationale(this, permissions[0])) { | ||||
//权限请求失败,但未选中“不再提示”选项 | //权限请求失败,但未选中“不再提示”选项 | ||||
new AlertDialog.Builder(this).setTitle("提示").setMessage("请求使用定位权限搜索蓝牙设备") | |||||
.setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
//引导用户至设置页手动授权 | |||||
Intent intent = | |||||
new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |||||
Uri uri = Uri.fromParts("package", getApplicationContext() | |||||
.getPackageName(), null); | |||||
intent.setData(uri); | |||||
startActivity(intent); | |||||
} | |||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||||
new AlertDialog.Builder(this).setTitle("提示").setMessage("请求使用定位权限搜索蓝牙设备").setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
//引导用户至设置页手动授权 | |||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |||||
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null); | |||||
intent.setData(uri); | |||||
startActivity(intent); | |||||
} | |||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||||
@Override | @Override | ||||
public void onClick(DialogInterface dialog, int which) { | public void onClick(DialogInterface dialog, int which) { | ||||
if (dialog != null) { | if (dialog != null) { | ||||
} else { | } else { | ||||
//权限请求失败,选中“不再提示”选项 | //权限请求失败,选中“不再提示”选项 | ||||
// T.showShort(MainActivity.this, "获取权限失败"); | // T.showShort(MainActivity.this, "获取权限失败"); | ||||
new AlertDialog.Builder(this).setTitle("提示").setMessage("请求使用定位权限搜索蓝牙设备") | |||||
.setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
//引导用户至设置页手动授权 | |||||
Intent intent = | |||||
new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |||||
Uri uri = Uri.fromParts("package", getApplicationContext() | |||||
.getPackageName(), null); | |||||
intent.setData(uri); | |||||
startActivity(intent); | |||||
} | |||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||||
new AlertDialog.Builder(this).setTitle("提示").setMessage("请求使用定位权限搜索蓝牙设备").setPositiveButton("确定", new DialogInterface.OnClickListener() { | |||||
@Override | |||||
public void onClick(DialogInterface dialog, int which) { | |||||
//引导用户至设置页手动授权 | |||||
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | |||||
Uri uri = Uri.fromParts("package", getApplicationContext().getPackageName(), null); | |||||
intent.setData(uri); | |||||
startActivity(intent); | |||||
} | |||||
}).setNegativeButton("取消", new DialogInterface.OnClickListener() { | |||||
@Override | @Override | ||||
public void onClick(DialogInterface dialog, int which) { | public void onClick(DialogInterface dialog, int which) { | ||||
if (dialog != null) { | if (dialog != null) { | ||||
if (mBluetoothService != null) { | if (mBluetoothService != null) { | ||||
mBleDevice = mBluetoothService.getBleDevice(mAddress); | mBleDevice = mBluetoothService.getBleDevice(mAddress); | ||||
mBluetoothService.setOnCallback(this); | mBluetoothService.setOnCallback(this); | ||||
if (mDialogOtaManager != null) { | |||||
mDialogOtaManager.setOnBleOTAListener(this); | |||||
} | |||||
} | } | ||||
} | } | ||||
//-----------------通知------------------- | //-----------------通知------------------- | ||||
@Override | @Override | ||||
protected void onDestroy() { | protected void onDestroy() { | ||||
super.onDestroy(); | super.onDestroy(); | ||||
} | } | ||||
@Override | @Override | ||||
public void onOtaFailure(int cmd ,String err) { | |||||
public void onOtaFailure(int cmd, String err) { | |||||
mList.add(TimeUtils.getTime() + "OTA失败:" + err); | mList.add(TimeUtils.getTime() + "OTA失败:" + err); | ||||
mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
private int progressOld; | private int progressOld; | ||||
@Override | @Override | ||||
public void onOtaProgress(float progress, int currentCount, int maxCount) { | |||||
public void onOtaProgress(float progress,int currentCount,int maxCount) { | |||||
int progressInt = (int) progress; | int progressInt = (int) progress; | ||||
if (progressOld != progressInt) { | if (progressOld != progressInt) { | ||||
progressOld = progressInt; | progressOld = progressInt; |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.Locale; | |||||
/** | |||||
* xing<br> | |||||
* 2019/5/25<br> | |||||
* java类作用描述 | |||||
*/ | |||||
public class TimeUtils { | |||||
public static String getTime(){ | |||||
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
return format.format(System.currentTimeMillis())+":\n"; | |||||
} | |||||
} |
import java.util.HashMap; | import java.util.HashMap; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.WifiDialog; | |||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.ToothBrush.ToothBrushBleCmd; | import cn.net.aicare.modulelibrary.module.ToothBrush.ToothBrushBleCmd; | ||||
import cn.net.aicare.modulelibrary.module.ToothBrush.ToothBrushWiFiBleUtilsData; | import cn.net.aicare.modulelibrary.module.ToothBrush.ToothBrushWiFiBleUtilsData; | ||||
/** | |||||
* Wifi+ble 牙刷 | |||||
*/ | |||||
public class ToothBrushWifiBleActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, ToothBrushWiFiBleUtilsData.BleToothBrushWiFiCallback, ToothBrushWiFiBleUtilsData.BleToothBrushCallback { | public class ToothBrushWifiBleActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, ToothBrushWiFiBleUtilsData.BleToothBrushWiFiCallback, ToothBrushWiFiBleUtilsData.BleToothBrushCallback { | ||||
private String TAG = ToothBrushWifiBleActivity.class.getName(); | private String TAG = ToothBrushWifiBleActivity.class.getName(); | ||||
private String mAddress; | private String mAddress; | ||||
findViewById(R.id.default_try_out).setOnClickListener(this); | findViewById(R.id.default_try_out).setOnClickListener(this); | ||||
findViewById(R.id.default_time_mode).setOnClickListener(this); | findViewById(R.id.default_time_mode).setOnClickListener(this); | ||||
findViewById(R.id.default_mode).setOnClickListener(this); | findViewById(R.id.default_mode).setOnClickListener(this); | ||||
// findViewById(R.id.ota).setOnClickListener(this); | |||||
findViewById(R.id.ota).setOnClickListener(this); | |||||
mEditText = findViewById(R.id.select_wifi_et); | mEditText = findViewById(R.id.select_wifi_et); | ||||
select_gears_et = findViewById(R.id.select_gears_et); | select_gears_et = findViewById(R.id.select_gears_et); | ||||
mToothBrushWiFiBleUtilsData.getdefaultGearAndDuration(); | mToothBrushWiFiBleUtilsData.getdefaultGearAndDuration(); | ||||
break; | break; | ||||
// case R.id.ota: | |||||
// | |||||
// mToothBrushWiFiBleUtilsData.setOta(); | |||||
// | |||||
// break; | |||||
case R.id.ota: | |||||
mToothBrushWiFiBleUtilsData.setOta(); | |||||
break; | |||||
} | } | ||||
} | } |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | package aicare.net.cn.sdk.ailinksdkdemoandroid; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.content.pm.ActivityInfo; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.os.Handler; | import android.os.Handler; | ||||
import android.os.Looper; | import android.os.Looper; | ||||
import com.pingwang.bluetoothlib.device.BleDevice; | import com.pingwang.bluetoothlib.device.BleDevice; | ||||
import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | import com.pingwang.bluetoothlib.device.BleSendCmdUtil; | ||||
import com.pingwang.bluetoothlib.device.SendBleBean; | import com.pingwang.bluetoothlib.device.SendBleBean; | ||||
import com.pingwang.bluetoothlib.device.SendMcuBean; | |||||
import com.pingwang.bluetoothlib.listener.CallbackDisIm; | import com.pingwang.bluetoothlib.listener.CallbackDisIm; | ||||
import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | ||||
import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | import com.pingwang.bluetoothlib.listener.OnBleVersionListener; | ||||
import cn.net.aicare.modulelibrary.module.tpms.TpmsDeviceData; | import cn.net.aicare.modulelibrary.module.tpms.TpmsDeviceData; | ||||
/** | /** | ||||
* xing<br> | * xing<br> | ||||
* 2019/9/2<br> | * 2019/9/2<br> | ||||
* 显示数据 | |||||
* tpms连接版 | |||||
*/ | */ | ||||
public class TpmsConnectCmdActivity extends BleBaseActivity implements OnCallbackDis, | public class TpmsConnectCmdActivity extends BleBaseActivity implements OnCallbackDis, | ||||
TpmsDeviceData.onNotifyData, TpmsDeviceData.onTpmsSetting, TpmsDeviceData.onTpmsInfo, OnBleVersionListener, | |||||
OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | |||||
TpmsDeviceData.onNotifyData, TpmsDeviceData.onTpmsSetting, TpmsDeviceData.onTpmsInfo, OnBleVersionListener, OnMcuParameterListener, OnBleCompanyListener, View.OnClickListener { | |||||
private static String TAG = TpmsConnectCmdActivity.class.getName(); | private static String TAG = TpmsConnectCmdActivity.class.getName(); | ||||
private final int REFRESH_DATA = 3; | private final int REFRESH_DATA = 3; | ||||
* 服务Intent | * 服务Intent | ||||
*/ | */ | ||||
private Context mContext; | private Context mContext; | ||||
private EditText et_type; | |||||
private TpmsDeviceData mBleDevice; | private TpmsDeviceData mBleDevice; | ||||
private String mAddress; | private String mAddress; | ||||
private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
@Override | @Override | ||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//禁止横屏 | |||||
setContentView(R.layout.activity_height); | setContentView(R.layout.activity_height); | ||||
mContext = this; | mContext = this; | ||||
mAddress = getIntent().getStringExtra("mac"); | mAddress = getIntent().getStringExtra("mac"); | ||||
findViewById(R.id.btnVersion).setOnClickListener(this); | findViewById(R.id.btnVersion).setOnClickListener(this); | ||||
findViewById(R.id.btnBattery).setOnClickListener(this); | findViewById(R.id.btnBattery).setOnClickListener(this); | ||||
findViewById(R.id.btn_get_did).setOnClickListener(this); | findViewById(R.id.btn_get_did).setOnClickListener(this); | ||||
et_type = findViewById(R.id.et_type); | |||||
cmdBtn(); | cmdBtn(); | ||||
} | } | ||||
sendBleBean.setHex(mBleSendCmdUtil.getDid()); | sendBleBean.setHex(mBleSendCmdUtil.getDid()); | ||||
mBleDevice.sendData(sendBleBean); | mBleDevice.sendData(sendBleBean); | ||||
break; | break; | ||||
case R.id.btn1: | |||||
String cmd = et_type.getText().toString().trim(); | |||||
SendMcuBean sendDataBean = new SendMcuBean(); | |||||
sendDataBean.setHex(type,cmd.getBytes()); | |||||
mBleDevice.sendData(sendDataBean); | |||||
break; | |||||
case R.id.clear: | case R.id.clear: | ||||
if (mList != null) | if (mList != null) | ||||
mList.clear(); | mList.clear(); |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | package aicare.net.cn.sdk.ailinksdkdemoandroid; | ||||
import android.content.pm.ActivityInfo; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.os.Handler; | import android.os.Handler; | ||||
import android.os.Message; | import android.os.Message; | ||||
import android.widget.EditText; | import android.widget.EditText; | ||||
import android.widget.ListView; | import android.widget.ListView; | ||||
import androidx.annotation.Nullable; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | import com.pingwang.bluetoothlib.BleBaseActivity; | ||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | import com.pingwang.bluetoothlib.bean.SupportUnitBean; | ||||
import com.pingwang.bluetoothlib.device.BleDevice; | import com.pingwang.bluetoothlib.device.BleDevice; | ||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | import com.pingwang.bluetoothlib.listener.OnCallbackBle; | ||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | import com.pingwang.bluetoothlib.utils.BleStrUtils; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import java.lang.ref.WeakReference; | import java.lang.ref.WeakReference; | ||||
import java.util.ArrayList; | import java.util.ArrayList; | ||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.Transmission.TransmissionDeviceData; | import cn.net.aicare.modulelibrary.module.Transmission.TransmissionDeviceData; | ||||
/** | |||||
* 透传界面 | |||||
*/ | |||||
public class TransmissionActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, TransmissionDeviceData.MyBleCallback { | public class TransmissionActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, TransmissionDeviceData.MyBleCallback { | ||||
private EditText et, et_cid; | private EditText et, et_cid; | ||||
private Button send, bt_clear, bt_clear_log,bt_cid; | private Button send, bt_clear, bt_clear_log,bt_cid; | ||||
@Override | @Override | ||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//禁止横屏 | |||||
setContentView(R.layout.activity_transmission); | setContentView(R.layout.activity_transmission); | ||||
WeakReference weakReference = new WeakReference(new MHandler()); | WeakReference weakReference = new WeakReference(new MHandler()); | ||||
mMHandler = (MHandler) weakReference.get(); | mMHandler = (MHandler) weakReference.get(); | ||||
byte[] hexStr = BleStrUtils.stringToByte(hex); | byte[] hexStr = BleStrUtils.stringToByte(hex); | ||||
String cid = et_cid.getText().toString().toUpperCase().trim(); | String cid = et_cid.getText().toString().toUpperCase().trim(); | ||||
int hexStrCid = Integer.parseInt(cid, 16); | int hexStrCid = Integer.parseInt(cid, 16); | ||||
if (mTransmissionDeviceData != null) { | if (mTransmissionDeviceData != null) { | ||||
mTransmissionDeviceData.setSendData(hexStrCid, hexStr); | mTransmissionDeviceData.setSendData(hexStrCid, hexStr); | ||||
} | } | ||||
@Override | @Override | ||||
public void showdata(String data) { | public void showdata(String data) { | ||||
mlogList.add(0, "收 payload数据"+TimeUtils.getTime()+data); | |||||
mlogList.add(0, "收 payload数据"+ TimeUtils.getTime()+data); | |||||
mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
} | } | ||||
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
import android.content.Context; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.AdapterView; | |||||
import android.widget.SeekBar; | |||||
import android.widget.TextView; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.recyclerview.widget.RecyclerView; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.User; | |||||
public class UserAdapter extends RecyclerView.Adapter<UserAdapter.ViewHolder> { | |||||
private List<User> mUser; | |||||
private Context mContext; | |||||
public UserAdapter(Context context, List<User> mUser) { | |||||
this.mContext = context; | |||||
this.mUser = mUser; | |||||
} | |||||
@NonNull | |||||
@Override | |||||
public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |||||
return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.item_user_info,parent)); | |||||
} | |||||
@Override | |||||
public void onBindViewHolder(@NonNull ViewHolder holder, int position) { | |||||
} | |||||
@Override | |||||
public int getItemCount() { | |||||
return mUser.size(); | |||||
} | |||||
class ViewHolder extends RecyclerView.ViewHolder implements SeekBar.OnSeekBarChangeListener { | |||||
private TextView id; | |||||
private SeekBar agesb, heightsb, weightsb, adcsb; | |||||
public ViewHolder(@NonNull View itemView) { | |||||
super(itemView); | |||||
id = itemView.findViewById(R.id.id); | |||||
agesb = itemView.findViewById(R.id.adcsb); | |||||
agesb.setOnSeekBarChangeListener(this); | |||||
heightsb = itemView.findViewById(R.id.heightsb); | |||||
heightsb.setOnSeekBarChangeListener(this); | |||||
weightsb = itemView.findViewById(R.id.weightsb); | |||||
weightsb.setOnSeekBarChangeListener(this); | |||||
adcsb = itemView.findViewById(R.id.adcsb); | |||||
adcsb.setOnSeekBarChangeListener(this); | |||||
} | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
int id = seekBar.getId(); | |||||
User user = mUser.get(getLayoutPosition()); | |||||
if (id == R.id.weightsb) { | |||||
user.setWeight(progress); | |||||
} else if (id == R.id.adcsb) { | |||||
user.setAdc(progress); | |||||
} else if (id == R.id.heightsb) { | |||||
user.setHeight(progress); | |||||
} else if (id == R.id.age) { | |||||
user.setAge(progress); | |||||
} | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
} | |||||
} |
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.AddUserDialog; | |||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.AppHistoryRecordBean; | import cn.net.aicare.modulelibrary.module.BodyFatScale.AppHistoryRecordBean; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatBleUtilsData; | import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatBleUtilsData; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.McuHistoryRecordBean; | import cn.net.aicare.modulelibrary.module.BodyFatScale.McuHistoryRecordBean; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.User; | import cn.net.aicare.modulelibrary.module.BodyFatScale.User; | ||||
/** | |||||
* Ble体脂秤 | |||||
*/ | |||||
public class WeightScaleBleActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, BodyFatBleUtilsData.BleBodyFatCallback { | public class WeightScaleBleActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, BodyFatBleUtilsData.BleBodyFatCallback { | ||||
private String TAG = WeightScaleBleActivity.class.getName(); | private String TAG = WeightScaleBleActivity.class.getName(); | ||||
private String mAddress; | private String mAddress; |
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | import aicare.net.cn.sdk.ailinksdkdemoandroid.config.BleDeviceConfig; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.WifiDialog; | |||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.AppHistoryRecordBean; | import cn.net.aicare.modulelibrary.module.BodyFatScale.AppHistoryRecordBean; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatBleUtilsData; | import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatBleUtilsData; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatRecord; | import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatRecord; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.McuHistoryRecordBean; | import cn.net.aicare.modulelibrary.module.BodyFatScale.McuHistoryRecordBean; | ||||
/** | |||||
* wifi+ble体脂秤 | |||||
*/ | |||||
public class WeightScaleWifiBleActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, BodyFatBleUtilsData.BleBodyFatCallback, BodyFatBleUtilsData.BleBodyFatWiFiCallback { | public class WeightScaleWifiBleActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, BodyFatBleUtilsData.BleBodyFatCallback, BodyFatBleUtilsData.BleBodyFatWiFiCallback { | ||||
private String TAG = WeightScaleWifiBleActivity.class.getName(); | private String TAG = WeightScaleWifiBleActivity.class.getName(); | ||||
private String mAddress; | private String mAddress; | ||||
findViewById(R.id.setedname).setOnClickListener(this); | findViewById(R.id.setedname).setOnClickListener(this); | ||||
findViewById(R.id.setedpaw).setOnClickListener(this); | findViewById(R.id.setedpaw).setOnClickListener(this); | ||||
findViewById(R.id.setedmac).setOnClickListener(this); | findViewById(R.id.setedmac).setOnClickListener(this); | ||||
// findViewById(R.id.ota).setOnClickListener(this); | |||||
// findViewById(R.id.surroundings).setOnClickListener(this); | |||||
findViewById(R.id.ota).setOnClickListener(this); | |||||
findViewById(R.id.surroundings).setOnClickListener(this); | |||||
mEditText = findViewById(R.id.select_wifi_et); | mEditText = findViewById(R.id.select_wifi_et); | ||||
kg = findViewById(R.id.kg); | kg = findViewById(R.id.kg); | ||||
jing = findViewById(R.id.jin); | jing = findViewById(R.id.jin); | ||||
case R.id.disconnect: | case R.id.disconnect: | ||||
bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().disconnectWifi()); | bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().disconnectWifi()); | ||||
break; | break; | ||||
// case R.id.ota: | |||||
//// bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().ota()); | |||||
//// OtaUtil otaUtil=new OtaUtil(this,mBluetoothService.getBleDevice(mAddress)); | |||||
// showFileChooser(); | |||||
// break; | |||||
// case R.id.surroundings: | |||||
// if (isTest) { | |||||
// setIp(productIp); | |||||
// mList.add(0, "设置环境IP为生产环境"); | |||||
// | |||||
// } else { | |||||
// setIp(testIp); | |||||
// mList.add(0, "设置环境IP为测试环境"); | |||||
// | |||||
// | |||||
// } | |||||
// listAdapter.notifyDataSetChanged(); | |||||
// | |||||
// break; | |||||
case R.id.ota: | |||||
// bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().ota()); | |||||
// OtaUtil otaUtil=new OtaUtil(this,mBluetoothService.getBleDevice(mAddress)); | |||||
showFileChooser(); | |||||
break; | |||||
case R.id.surroundings: | |||||
if (isTest) { | |||||
setIp(productIp); | |||||
mList.add(0, "设置环境IP为生产环境"); | |||||
} else { | |||||
setIp(testIp); | |||||
mList.add(0, "设置环境IP为测试环境"); | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
break; | |||||
} | } |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | package aicare.net.cn.sdk.ailinksdkdemoandroid; | ||||
import android.annotation.SuppressLint; | |||||
import android.app.AlertDialog; | import android.app.AlertDialog; | ||||
import android.content.DialogInterface; | import android.content.DialogInterface; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.content.pm.ActivityInfo; | |||||
import android.content.pm.PackageManager; | import android.content.pm.PackageManager; | ||||
import android.location.LocationManager; | import android.location.LocationManager; | ||||
import android.os.Build; | import android.os.Build; | ||||
import cn.net.aicare.modulelibrary.module.wifi.WifiConfig; | import cn.net.aicare.modulelibrary.module.wifi.WifiConfig; | ||||
import cn.net.aicare.modulelibrary.module.wifi.WifiUtils; | import cn.net.aicare.modulelibrary.module.wifi.WifiUtils; | ||||
/** | |||||
* wifi配置界面 | |||||
*/ | |||||
public class WifiConfigActivity extends AppCompatActivity implements View.OnClickListener, WifiUtils.OnWifiEventListener { | public class WifiConfigActivity extends AppCompatActivity implements View.OnClickListener, WifiUtils.OnWifiEventListener { | ||||
private String TAG = WifiConfigActivity.class.getName(); | private String TAG = WifiConfigActivity.class.getName(); | ||||
private EditText ssid, paw, key, sn, devicename; | private EditText ssid, paw, key, sn, devicename; | ||||
private RadioButton kg, jing, stlb, lb; | private RadioButton kg, jing, stlb, lb; | ||||
private String mDeviceName; | private String mDeviceName; | ||||
@SuppressLint("SetTextI18n") | |||||
@Override | @Override | ||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
super.onCreate(savedInstanceState); | super.onCreate(savedInstanceState); | ||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//禁止横屏 | |||||
setContentView(R.layout.activity_wifi_config); | setContentView(R.layout.activity_wifi_config); | ||||
ssid = findViewById(R.id.ssid); | ssid = findViewById(R.id.ssid); | ||||
paw = findViewById(R.id.password); | paw = findViewById(R.id.password); |
package aicare.net.cn.sdk.ailinksdkdemoandroid.base; | package aicare.net.cn.sdk.ailinksdkdemoandroid.base; | ||||
import android.Manifest; | import android.Manifest; | ||||
import android.app.Activity; | |||||
import android.content.Context; | import android.content.Context; | ||||
import android.content.Intent; | import android.content.Intent; | ||||
import android.content.pm.ActivityInfo; | import android.content.pm.ActivityInfo; | ||||
import android.os.Message; | import android.os.Message; | ||||
import android.view.KeyEvent; | import android.view.KeyEvent; | ||||
import android.view.MenuItem; | import android.view.MenuItem; | ||||
import android.view.MotionEvent; | |||||
import android.view.View; | import android.view.View; | ||||
import android.view.inputmethod.InputMethodManager; | |||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import com.pingwang.bluetoothlib.BleBaseActivity; | import com.pingwang.bluetoothlib.BleBaseActivity; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.HintDataDialogFragment; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.AppStart; | |||||
import java.lang.ref.WeakReference; | import java.lang.ref.WeakReference; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.dialog.HintDataDialogFragment; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.AppStart; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.appcompat.widget.Toolbar; | import androidx.appcompat.widget.Toolbar; | ||||
/** | /** | ||||
* 需要申请的权限 | * 需要申请的权限 | ||||
*/ | */ | ||||
private String[] LOCATION_PERMISSION = new String[]{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION}; | |||||
private String[] LOCATION_PERMISSION = new String[]{Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION,Manifest.permission.WRITE_EXTERNAL_STORAGE}; | |||||
/** | /** | ||||
* 权限请求返回 | * 权限请求返回 |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
package aicare.net.cn.sdk.ailinksdkdemoandroid.base; | |||||
import android.content.ComponentName; | import android.content.ComponentName; | ||||
import android.content.Context; | import android.content.Context; |
package aicare.net.cn.sdk.ailinksdkdemoandroid.config; | |||||
import java.util.List; | |||||
/** | |||||
* xing<br> | |||||
* 2021/3/5<br> | |||||
* java类作用描述 | |||||
*/ | |||||
public class AppConfig { | |||||
/** | |||||
* 是否为客户专用OTA | |||||
*/ | |||||
public static boolean APP_TYPE_OTA=false; | |||||
/** | |||||
* 支持显示的ID,null表示所有的都显示,ID是按钮的ID不是CID | |||||
*/ | |||||
public static List<Integer> SHOW_VIEW_ID = null; | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
package aicare.net.cn.sdk.ailinksdkdemoandroid.dialog; | |||||
import android.app.Dialog; | import android.app.Dialog; | ||||
import android.content.DialogInterface; | import android.content.DialogInterface; | ||||
import android.content.IntentFilter; | |||||
import android.os.Bundle; | import android.os.Bundle; | ||||
import android.view.KeyEvent; | import android.view.KeyEvent; | ||||
import android.view.LayoutInflater; | import android.view.LayoutInflater; | ||||
import android.widget.SeekBar; | import android.widget.SeekBar; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.fragment.app.DialogFragment; | import androidx.fragment.app.DialogFragment; | ||||
import androidx.fragment.app.FragmentManager; | import androidx.fragment.app.FragmentManager; | ||||
import java.net.IDN; | |||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatDataUtil; | import cn.net.aicare.modulelibrary.module.BodyFatScale.BodyFatDataUtil; | ||||
import cn.net.aicare.modulelibrary.module.BodyFatScale.User; | import cn.net.aicare.modulelibrary.module.BodyFatScale.User; | ||||
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import java.util.List; | import java.util.List; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | ||||
import androidx.annotation.ColorInt; | import androidx.annotation.ColorInt; | ||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; |
import android.view.ViewGroup; | import android.view.ViewGroup; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | ||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.fragment.app.DialogFragment; | import androidx.fragment.app.DialogFragment; |
package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
package aicare.net.cn.sdk.ailinksdkdemoandroid.dialog; | |||||
import android.app.Dialog; | import android.app.Dialog; | ||||
import android.content.Context; | import android.content.Context; | ||||
import android.widget.EditText; | import android.widget.EditText; | ||||
import android.widget.TextView; | import android.widget.TextView; | ||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
import androidx.fragment.app.DialogFragment; | import androidx.fragment.app.DialogFragment; |
package aicare.net.cn.sdk.ailinksdkdemoandroid.find; | |||||
import android.content.Context; | |||||
import android.os.Bundle; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import android.widget.Toast; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Map; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.findDevice.FindConnectDeviceInfoBean; | |||||
import cn.net.aicare.modulelibrary.module.findDevice.FindDeviceData; | |||||
public class FindDeviceActivity extends BleBaseActivity implements View.OnClickListener, FindDeviceData.onNotifyData { | |||||
private Button btn_device_id_0, btn_device_id_1, btn_device_id_2, btn_device_id_3, btn_device_id_4, btn_device_id_5, btn_device_id_6; | |||||
private Button btn_clear, btn_get_connect_number, btn_connect_info_list,btn_scan_ble; | |||||
private EditText et_send_data; | |||||
private ListView list_view; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private Context mContext; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private FindDeviceData mFindDeviceData; | |||||
private Map<Integer, FindConnectDeviceInfoBean> mMap = new HashMap<>(); | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_find_device); | |||||
mContext = this; | |||||
btn_get_connect_number = findViewById(R.id.btn_get_connect_number); | |||||
btn_connect_info_list = findViewById(R.id.btn_connect_info_list); | |||||
btn_device_id_0 = findViewById(R.id.btn_device_id_0); | |||||
btn_device_id_1 = findViewById(R.id.btn_device_id_1); | |||||
btn_device_id_2 = findViewById(R.id.btn_device_id_2); | |||||
btn_device_id_3 = findViewById(R.id.btn_device_id_3); | |||||
btn_device_id_4 = findViewById(R.id.btn_device_id_4); | |||||
btn_device_id_5 = findViewById(R.id.btn_device_id_5); | |||||
btn_device_id_6 = findViewById(R.id.btn_device_id_6); | |||||
et_send_data = findViewById(R.id.et_send_data); | |||||
btn_clear = findViewById(R.id.btn_clear); | |||||
list_view = findViewById(R.id.list_view); | |||||
btn_scan_ble = findViewById(R.id.btn_scan_ble); | |||||
btn_device_id_0.setOnClickListener(this); | |||||
btn_device_id_1.setOnClickListener(this); | |||||
btn_device_id_2.setOnClickListener(this); | |||||
btn_device_id_3.setOnClickListener(this); | |||||
btn_device_id_4.setOnClickListener(this); | |||||
btn_device_id_5.setOnClickListener(this); | |||||
btn_device_id_6.setOnClickListener(this); | |||||
btn_clear.setOnClickListener(this); | |||||
btn_scan_ble.setOnClickListener(this); | |||||
btn_get_connect_number.setOnClickListener(this); | |||||
btn_connect_info_list.setOnClickListener(this); | |||||
// 获取Mac | |||||
mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
switch (v.getId()) { | |||||
case R.id.btn_connect_info_list: | |||||
if (mFindDeviceData!=null) { | |||||
mFindDeviceData.getConnectInfoList(); | |||||
} | |||||
break; | |||||
case R.id.btn_get_connect_number: | |||||
if (mFindDeviceData!=null) { | |||||
mFindDeviceData.getConnectDeviceNumber(); | |||||
} | |||||
break; | |||||
case R.id.btn_device_id_0: | |||||
sendCmd(0); | |||||
break; | |||||
case R.id.btn_device_id_1: | |||||
sendCmd(1); | |||||
break; | |||||
case R.id.btn_device_id_2: | |||||
sendCmd(2); | |||||
break; | |||||
case R.id.btn_device_id_3: | |||||
sendCmd(3); | |||||
break; | |||||
case R.id.btn_device_id_4: | |||||
sendCmd(4); | |||||
break; | |||||
case R.id.btn_device_id_5: | |||||
sendCmd(5); | |||||
break; | |||||
case R.id.btn_device_id_6: | |||||
sendCmd(6); | |||||
break; | |||||
case R.id.btn_clear: | |||||
mList.clear(); | |||||
if (mListAdapter != null) { | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
/** | |||||
* 发送指令 | |||||
*/ | |||||
private void sendCmd(int id) { | |||||
if (mMap != null) { | |||||
FindConnectDeviceInfoBean findConnectDeviceInfoBean = mMap.get(id); | |||||
if (findConnectDeviceInfoBean != null) { | |||||
String trim = et_send_data.getText().toString().trim(); | |||||
mFindDeviceData.setCmd(findConnectDeviceInfoBean.getDeviceId(), trim, findConnectDeviceInfoBean.getMac()); | |||||
} else { | |||||
Toast.makeText(mContext, "当前ID没有设备", Toast.LENGTH_SHORT).show(); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mBleDevice != null) { | |||||
mFindDeviceData = FindDeviceData.getInstance(mBleDevice); | |||||
mFindDeviceData.setOnNotifyData(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void onData(byte[] data, int type) { | |||||
} | |||||
@Override | |||||
public void onConnectNumber(int number) { | |||||
mList.add("当前连接的设备数量:" + number); | |||||
if (mListAdapter != null) { | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onConnectDeviceInfoList(List<FindConnectDeviceInfoBean> list) { | |||||
StringBuilder deviceInfo = new StringBuilder(); | |||||
for (FindConnectDeviceInfoBean findConnectDeviceInfoBean : list) { | |||||
mMap.put(findConnectDeviceInfoBean.getDeviceId(), findConnectDeviceInfoBean); | |||||
deviceInfo.append("设备ID").append(findConnectDeviceInfoBean.getDeviceId()).append(" || MAC地址:").append(findConnectDeviceInfoBean.getMac()).append("\n"); | |||||
} | |||||
mList.add(deviceInfo.toString()); | |||||
if (mListAdapter != null) { | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onConnectDeviceStatus(int id, int status) { | |||||
String statusStr = status == 0 ? "断开" : "连接"; | |||||
mList.add("设备ID:" + id + " || 状态:" + statusStr); | |||||
if (mListAdapter != null) { | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
//---------------新-------------- | |||||
@Override | |||||
public void onNearbyDeviceInfo(String mac, int rssi, byte[] broadcastData) { | |||||
} | |||||
@Override | |||||
public void onConnectDeviceStatus(String mac, int status) { | |||||
} | |||||
@Override | |||||
public void onConnectDeviceInfo(int status, String mac) { | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.find; | |||||
import android.content.Context; | |||||
import android.view.LayoutInflater; | |||||
import android.view.View; | |||||
import android.view.ViewGroup; | |||||
import android.widget.Button; | |||||
import java.util.List; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.recyclerview.widget.RecyclerView; | |||||
/** | |||||
* xing<br> | |||||
*/ | |||||
public class FindDeviceAdapter extends RecyclerView.Adapter<FindDeviceAdapter.KeyViewHolder> { | |||||
private List<FindDeviceBean> mList; | |||||
private OnItemClickListener listener; | |||||
private Context mContext; | |||||
public interface OnItemClickListener { | |||||
void onItemClick(int position); | |||||
} | |||||
public FindDeviceAdapter(Context context, List<FindDeviceBean> list, OnItemClickListener listener) { | |||||
mList = list; | |||||
this.listener = listener; | |||||
mContext = context; | |||||
} | |||||
@NonNull | |||||
@Override | |||||
public KeyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) { | |||||
View view = LayoutInflater.from(mContext).inflate(R.layout.item_find_device, parent, false); | |||||
return new KeyViewHolder(view, listener); | |||||
} | |||||
@Override | |||||
public void onBindViewHolder(@NonNull KeyViewHolder holder, int position) { | |||||
FindDeviceBean bean = mList.get(position); | |||||
holder.btn_find_device.setText("MAC="+bean.getMac()); | |||||
holder.btn_find_device.setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (listener != null) | |||||
listener.onItemClick(position); | |||||
} | |||||
}); | |||||
} | |||||
@Override | |||||
public int getItemCount() { | |||||
return mList.size(); | |||||
} | |||||
static class KeyViewHolder extends RecyclerView.ViewHolder { | |||||
private Button btn_find_device; | |||||
KeyViewHolder(@NonNull View itemView, final OnItemClickListener listener) { | |||||
super(itemView); | |||||
btn_find_device = itemView.findViewById(R.id.btn_find_device); | |||||
itemView.setOnClickListener(v -> { | |||||
if (listener != null) | |||||
listener.onItemClick(getLayoutPosition()); | |||||
}); | |||||
} | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.find; | |||||
import androidx.annotation.Nullable; | |||||
/** | |||||
* xing<br> | |||||
* 2021/4/12<br> | |||||
* java类作用描述 | |||||
*/ | |||||
public class FindDeviceBean { | |||||
private String mMac; | |||||
private String mName; | |||||
private int mRssi; | |||||
private byte[] mBroadcastData; | |||||
public FindDeviceBean(String mac, String name, int rssi, byte[] broadcastData) { | |||||
mMac = mac; | |||||
mName = name; | |||||
mRssi = rssi; | |||||
mBroadcastData = broadcastData; | |||||
} | |||||
public FindDeviceBean(String mac, String name, int rssi) { | |||||
mMac = mac; | |||||
mName = name; | |||||
mRssi = rssi; | |||||
} | |||||
public FindDeviceBean(String mac, int rssi) { | |||||
mMac = mac; | |||||
mRssi = rssi; | |||||
} | |||||
public FindDeviceBean(String mac, int rssi, byte[] broadcastData) { | |||||
mMac = mac; | |||||
mRssi = rssi; | |||||
mBroadcastData = broadcastData; | |||||
} | |||||
public String getMac() { | |||||
return mMac; | |||||
} | |||||
public void setMac(String mac) { | |||||
mMac = mac; | |||||
} | |||||
public String getName() { | |||||
return mName; | |||||
} | |||||
public void setName(String name) { | |||||
mName = name; | |||||
} | |||||
public int getRssi() { | |||||
return mRssi; | |||||
} | |||||
public void setRssi(int rssi) { | |||||
mRssi = rssi; | |||||
} | |||||
public byte[] getBroadcastData() { | |||||
return mBroadcastData; | |||||
} | |||||
public void setBroadcastData(byte[] broadcastData) { | |||||
mBroadcastData = broadcastData; | |||||
} | |||||
@Override | |||||
public boolean equals(@Nullable Object obj) { | |||||
if (obj instanceof String) { | |||||
return this.mMac.equalsIgnoreCase((String) obj); | |||||
} else if (obj instanceof FindDeviceBean) { | |||||
return this.mMac.equalsIgnoreCase(((FindDeviceBean) obj).getMac()); | |||||
} else { | |||||
return super.equals(obj); | |||||
} | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.find; | |||||
import android.os.Message; | |||||
import android.text.TextUtils; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.ListView; | |||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.AILinkSDK; | |||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
import com.pingwang.bluetoothlib.config.BleConfig; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | |||||
import com.pingwang.bluetoothlib.utils.BleLog; | |||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.BuildConfig; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleAppBaseActivity; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.SP; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.view.MyItemDecoration; | |||||
import androidx.recyclerview.widget.GridLayoutManager; | |||||
import androidx.recyclerview.widget.LinearLayoutManager; | |||||
import androidx.recyclerview.widget.RecyclerView; | |||||
import cn.net.aicare.modulelibrary.module.findDevice.FindDeviceData; | |||||
public class FindDeviceNewActivity extends BleAppBaseActivity implements View.OnClickListener, OnCallbackBle, FindDeviceData.onNotifyData, OnScanFilterListener, FindDeviceAdapter.OnItemClickListener { | |||||
private final int REFRESH_DATA = 2; | |||||
private final int START_SCAN_BLE =3; | |||||
private final static String BLE_NAME_START = "FiLink"; | |||||
private final static String BLE_UUID_1 = "74278bdab64445208f0c720eaf00001a"; | |||||
private final static String BLE_UUID_2 = "74278bdab64445208f0c720eaf00001b"; | |||||
private Button btn_clear, btn_scan_ble; | |||||
private TextView tv_status; | |||||
private ListView list_view; | |||||
private RecyclerView rv_device; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private FindDeviceData mFindDeviceData; | |||||
private volatile ArrayList<FindDeviceBean> mFindDeviceBeanList; | |||||
private FindDeviceAdapter mFindDeviceAdapter; | |||||
@Override | |||||
protected void uiHandlerMessage(Message msg) { | |||||
switch (msg.what) { | |||||
case REFRESH_DATA: | |||||
if (mListAdapter != null) { | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
break; | |||||
case START_SCAN_BLE: | |||||
bleOpen(); | |||||
break; | |||||
} | |||||
} | |||||
@Override | |||||
protected int getLayoutId() { | |||||
return R.layout.activity_find_device_new; | |||||
} | |||||
@Override | |||||
protected void initListener() { | |||||
btn_clear.setOnClickListener(this); | |||||
btn_scan_ble.setOnClickListener(this); | |||||
} | |||||
@Override | |||||
protected void initData() { | |||||
if (getSupportActionBar() != null) { | |||||
getSupportActionBar().setTitle(getString(R.string.app_name) + ":" + BuildConfig.VERSION_NAME); | |||||
} | |||||
SP.init(this); | |||||
// 获取Mac | |||||
// mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
mFindDeviceBeanList = new ArrayList<>(); | |||||
String findDeviceMacList = SP.getInstance().getFindDeviceMacList(); | |||||
if (!TextUtils.isEmpty(findDeviceMacList) && findDeviceMacList.contains(";")) { | |||||
String[] split = findDeviceMacList.split(";"); | |||||
for (int i = 0; i < split.length; i++) { | |||||
String mac = split[i]; | |||||
if (!TextUtils.isEmpty(mac)) { | |||||
mFindDeviceBeanList.add(new FindDeviceBean(mac, String.valueOf(i), -60)); | |||||
} | |||||
} | |||||
} | |||||
mFindDeviceAdapter = new FindDeviceAdapter(mContext, mFindDeviceBeanList, this); | |||||
rv_device.setAdapter(mFindDeviceAdapter); | |||||
} | |||||
@Override | |||||
protected void initView() { | |||||
AILinkSDK.getInstance().init(this);//sdk | |||||
btn_clear = findViewById(R.id.btn_clear); | |||||
tv_status = findViewById(R.id.tv_status); | |||||
list_view = findViewById(R.id.list_view); | |||||
btn_scan_ble = findViewById(R.id.btn_scan_ble); | |||||
rv_device = findViewById(R.id.rv_device); | |||||
rv_device.setLayoutManager(new GridLayoutManager(mContext, 2, LinearLayoutManager.VERTICAL, false)); | |||||
rv_device.addItemDecoration(new MyItemDecoration(mContext, LinearLayoutManager.VERTICAL, 1, mContext.getResources().getColor(R.color.public_white))); | |||||
// rv_device.setVisibility(View.INVISIBLE); | |||||
} | |||||
@Override | |||||
public void onItemClick(int position) { | |||||
if (mFindDeviceBeanList.size() > position) { | |||||
FindDeviceBean findDeviceBean = mFindDeviceBeanList.get(position); | |||||
if (mFindDeviceData != null) { | |||||
// mFindDeviceData.setDisconnectDevice(); | |||||
mFindDeviceData.setConnectDevice(findDeviceBean.getMac()); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
switch (v.getId()) { | |||||
case R.id.btn_scan_ble: | |||||
if (mFindDeviceData != null) { | |||||
// mFindDeviceData.setNearbyDevice(1, 10, new byte[]{}); | |||||
// if (rv_device.getVisibility() != View.VISIBLE) { | |||||
// rv_device.setVisibility(View.VISIBLE); | |||||
// } | |||||
mFindDeviceBeanList.clear(); | |||||
if (mFindDeviceAdapter != null) { | |||||
mFindDeviceAdapter.notifyDataSetChanged(); | |||||
} | |||||
mFindDeviceData.getConnectInfoList(); | |||||
mBluetoothService.scanLeDevice(30 * 1000); | |||||
} | |||||
break; | |||||
case R.id.btn_clear: | |||||
mList.clear(); | |||||
if (mListAdapter != null) { | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
StringBuilder mac = new StringBuilder(); | |||||
for (FindDeviceBean findDeviceBean : mFindDeviceBeanList) { | |||||
mac.append(findDeviceBean.getMac()).append(";"); | |||||
} | |||||
if (mac.length() > 0) { | |||||
mac.deleteCharAt(mac.length() - 1); | |||||
} | |||||
SP.getInstance().putFindDeviceMacList(mac.toString()); | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
protected void onResume() { | |||||
super.onResume(); | |||||
} | |||||
// ------------------- 权限 ------------------ | |||||
@Override | |||||
protected void onPermissionsOk() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.setOnCallback(this); | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
mBluetoothService.setOnScanFilterListener(this); | |||||
if (mBleDevice != null) { | |||||
mFindDeviceData = FindDeviceData.getInstance(mBleDevice); | |||||
mFindDeviceData.setOnNotifyData(this); | |||||
if (tv_status != null) | |||||
tv_status.setText("已连接:" + mMac); | |||||
mList.add("连接设备成功!"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} else { | |||||
mHandler.removeMessages(START_SCAN_BLE); | |||||
mHandler.sendEmptyMessage(START_SCAN_BLE); | |||||
} | |||||
} | |||||
} | |||||
//-------------------------- | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
if (mBluetoothService != null) { | |||||
initPermissions(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
if (mBluetoothService!=null){ | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
mFindDeviceData = null; | |||||
mBluetoothService=null; | |||||
} | |||||
@Override | |||||
public boolean onFilter(BleValueBean bleValueBean) { | |||||
if (bleValueBean.getName() != null && bleValueBean.getName().trim().toUpperCase().startsWith(BLE_NAME_START.toUpperCase())) { | |||||
return true; | |||||
} else { | |||||
byte[] data = bleValueBean.getManufacturerData(); | |||||
if (data != null && data.length > 20) { | |||||
byte[] uuidData = new byte[16]; | |||||
System.arraycopy(data, 4, uuidData, 0, uuidData.length); | |||||
String uuid = BleStrUtils.byte2HexStr_1(uuidData); | |||||
if (uuid.equalsIgnoreCase(BLE_UUID_1) || uuid.equalsIgnoreCase(BLE_UUID_2)) { | |||||
return true; | |||||
} | |||||
} | |||||
} | |||||
return false; | |||||
} | |||||
@Override | |||||
public void onScanning(BleValueBean bleValueBean) { | |||||
if (TextUtils.isEmpty(mMac) && bleValueBean.getName() != null && bleValueBean.getName().trim().toUpperCase().startsWith(BLE_NAME_START.toUpperCase())) { | |||||
mMac = bleValueBean.getMac(); | |||||
} else if (bleValueBean.getMac().equalsIgnoreCase(mMac) && mFindDeviceData == null) { | |||||
BleConfig.setHandshakeStatus(mMac, false); | |||||
mBluetoothService.stopScan(); | |||||
mBluetoothService.connectDevice(mMac); | |||||
mBluetoothService.setOnCallback(this); | |||||
} else if (bleValueBean.getName() == null || !bleValueBean.getName().trim().toUpperCase().startsWith(BLE_NAME_START.toUpperCase())) { | |||||
onNearbyDeviceInfo(bleValueBean.getMac(), bleValueBean.getRssi(), bleValueBean.getManufacturerData()); | |||||
} | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
if (mac.equalsIgnoreCase(mMac)) { | |||||
mFindDeviceData = null; | |||||
mList.add("连接断开:"+code); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
mHandler.removeMessages(START_SCAN_BLE); | |||||
mHandler.sendEmptyMessageDelayed(START_SCAN_BLE,2000); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServicesDiscovered(String mac) { | |||||
if (mac.equalsIgnoreCase(mMac)) { | |||||
mBluetoothService.stopScan(); | |||||
onServiceSuccess(); | |||||
} | |||||
} | |||||
@Override | |||||
public void bleOpen() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.stopScan(); | |||||
mList.add("正在扫描连接..."); | |||||
if (tv_status != null) | |||||
tv_status.setText("正在连接..."); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
mBluetoothService.scanLeDevice(0, BleConfig.UUID_SERVER_AILINK); | |||||
} | |||||
} | |||||
@Override | |||||
public void bleClose() { | |||||
mFindDeviceData = null; | |||||
mList.add("蓝牙已关闭!"); | |||||
if (tv_status != null) | |||||
tv_status.setText("蓝牙已关闭!"); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onData(byte[] data, int type) { | |||||
} | |||||
//---------------新-------------- | |||||
@Override | |||||
public void onNearbyDeviceInfo(String mac, int rssi, byte[] broadcastData) { | |||||
for (FindDeviceBean findDeviceBean : mFindDeviceBeanList) { | |||||
if (findDeviceBean.getMac().equalsIgnoreCase(mac)) { | |||||
return; | |||||
} | |||||
} | |||||
mFindDeviceBeanList.add(new FindDeviceBean(mac, rssi, broadcastData)); | |||||
if (mFindDeviceAdapter != null) { | |||||
mFindDeviceAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onConnectDeviceStatus(String mac, int status) { | |||||
String statusStr = ""; | |||||
switch (status) { | |||||
case 0: | |||||
statusStr = "连接成功"; | |||||
break; | |||||
case 1: | |||||
statusStr = "断开连接"; | |||||
break; | |||||
case 2: | |||||
statusStr = "响铃..."; | |||||
break; | |||||
case 3: | |||||
statusStr = "连接超时"; | |||||
break; | |||||
} | |||||
mList.add("设备:" + mac + " || 状态:" + statusStr); | |||||
mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
} | |||||
@Override | |||||
public void onConnectDeviceInfo(int status, String mac) { | |||||
BleLog.i(TAG, "当前连接的设备:" + mac + " || status=" + status); | |||||
if (status == 1) { | |||||
mFindDeviceBeanList.add(new FindDeviceBean(mac, -60, new byte[]{})); | |||||
if (mFindDeviceAdapter != null) { | |||||
mFindDeviceAdapter.notifyDataSetChanged(); | |||||
} | |||||
} | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_glucose; | |||||
import android.content.Intent; | |||||
import android.os.Bundle; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.CompoundButton; | |||||
import android.widget.ListView; | |||||
import android.widget.RadioButton; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.BloodGlucose.BloodGlucoseBleDeviceData; | |||||
import cn.net.aicare.modulelibrary.module.BloodGlucose.BloodGlucoseUtil; | |||||
/** | |||||
* 血糖仪 | |||||
*/ | |||||
public class BloodGlucoseActivity extends BleBaseActivity implements OnCallbackBle, BloodGlucoseBleDeviceData.BloodGlucoseCallback { | |||||
private Button support_unit, quest_status, showdata, test; | |||||
private RadioButton mmol, mg; | |||||
private ListView log_list; | |||||
private List<String> mLogList; | |||||
private ArrayAdapter listAdapter; | |||||
private String mAddress; | |||||
private boolean isShowData=false; | |||||
private BloodGlucoseBleDeviceData mBloodGlucoseBleDeviceData; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_blood_glucose); | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
support_unit = findViewById(R.id.support_unit); | |||||
quest_status = findViewById(R.id.quest_status); | |||||
showdata=findViewById(R.id.showdata); | |||||
test = findViewById(R.id.test); | |||||
mmol = findViewById(R.id.mmol); | |||||
mg = findViewById(R.id.mg); | |||||
log_list = findViewById(R.id.log_list); | |||||
mLogList = new ArrayList<>(); | |||||
listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mLogList); | |||||
log_list.setAdapter(listAdapter); | |||||
mmol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
@Override | |||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
if (isChecked) | |||||
if (mBloodGlucoseBleDeviceData != null) | |||||
mBloodGlucoseBleDeviceData.setUnit(BloodGlucoseUtil.UNIT_MMOL_L); | |||||
} | |||||
}); | |||||
mg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
@Override | |||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
if (isChecked) | |||||
if (mBloodGlucoseBleDeviceData != null) | |||||
mBloodGlucoseBleDeviceData.setUnit(BloodGlucoseUtil.UNIT_MG_DL); | |||||
} | |||||
}); | |||||
showdata.setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (!isShowData){ | |||||
showdata.setText("隐藏Data数据"); | |||||
isShowData=true; | |||||
}else { | |||||
showdata.setText("显示Data数据"); | |||||
isShowData=false; | |||||
} | |||||
} | |||||
}); | |||||
quest_status.setOnClickListener(new View.OnClickListener() { | |||||
@Override | |||||
public void onClick(View v) { | |||||
if (mBloodGlucoseBleDeviceData != null) | |||||
mBloodGlucoseBleDeviceData.queryStatus(); | |||||
} | |||||
}); | |||||
// 流程测试 | |||||
test.setOnClickListener(v -> { | |||||
Intent intent = new Intent(this, BloodGlucoseTestActivity.class); | |||||
intent.putExtra("mac", mAddress); | |||||
startActivity(intent); | |||||
}); | |||||
// 查询设备支持单位 | |||||
support_unit.setOnClickListener(v -> { | |||||
if (mBloodGlucoseBleDeviceData != null) { | |||||
mBloodGlucoseBleDeviceData.getSupportUnit(); | |||||
} | |||||
}); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mLogList.add(0, "绑定服务成功"); | |||||
listAdapter.notifyDataSetChanged(); | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.setOnCallback(this); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (bleDevice != null) { | |||||
mBloodGlucoseBleDeviceData = new BloodGlucoseBleDeviceData(bleDevice); | |||||
mBloodGlucoseBleDeviceData.setBloodGlucoseCallback(this); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
// 断开连接直接退出 | |||||
finish(); | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void onVersion(String version) { | |||||
mLogList.add(0, "版本号:"+version); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onSupportUnit(List<SupportUnitBean> list) { | |||||
mLogList.add(0, "支持单位:"); | |||||
for (SupportUnitBean supportUnitBean:list) { | |||||
mLogList.add(0, supportUnitBean.toString()); | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onDeviceStatus(int status) { | |||||
switch (status){ | |||||
case BloodGlucoseUtil.STATUS_STATELESS: | |||||
mLogList.add(0,status+" 无状态"); | |||||
break; | |||||
case BloodGlucoseUtil.STATUS_WAIT_TEST_PAPER: | |||||
mLogList.add(0,status+" 设备等待插入试纸"); | |||||
break; | |||||
case BloodGlucoseUtil.STATUS_WAIT_BLOOD_SAMPLES: | |||||
mLogList.add(0,status+" 设备已插入试纸,等待获取血样"); | |||||
break; | |||||
case BloodGlucoseUtil.STATUS_ANALYSIS_BLOOD_SAMPLES: | |||||
mLogList.add(0,status+" 血样已获取,分析血样中"); | |||||
break; | |||||
case BloodGlucoseUtil.STATUS_TEST_FINISH: | |||||
mLogList.add(0,status+" 上发数据完成,测量完成"); | |||||
break; | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onResult(int originalValue, float value, int unit, int decimal) { | |||||
mLogList.add(0,"原始数据:"+originalValue+" 值:"+value+" 单位:"+unit+" 小数点位:"+decimal); | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onErrorCode(int code) { | |||||
switch (code){ | |||||
case BloodGlucoseUtil.ERROR_CODE_NO_ELECTRICITY: | |||||
mLogList.add(0,code+" 电池没电"); | |||||
break; | |||||
case BloodGlucoseUtil.ERROR_CODE_USED_TEST_PAPER: | |||||
mLogList.add(0,code+" 已使用过的试纸"); | |||||
break; | |||||
case BloodGlucoseUtil.ERROR_CODE_TEMPERATURE_OUT_OF_RANGE: | |||||
mLogList.add(0,code+" 环境温度超出使用范围"); | |||||
break; | |||||
case BloodGlucoseUtil.ERROR_CODE_WITHDRAWN_TEST_PAPER: | |||||
mLogList.add(0,code+" 试纸施加血样后测试未完成,被退出试纸"); | |||||
break; | |||||
case BloodGlucoseUtil.ERROR_CODE_SELF_CHECK_FAIL: | |||||
mLogList.add(0,code+" 机器自检未通过"); | |||||
break; | |||||
case BloodGlucoseUtil.ERROR_CODE_RESULT_LOWER: | |||||
mLogList.add(0,code+" 测量结果过低,超出测量范围"); | |||||
break; | |||||
case BloodGlucoseUtil.ERROR_CODE_RESULT_OVERTOP: | |||||
mLogList.add(0,code+" 测量结果过高,超出测量范围"); | |||||
break; | |||||
default: | |||||
mLogList.add(0,"错误码:"+code); | |||||
break; | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onSetUnitResult(int result) { | |||||
switch (result){ | |||||
case BloodGlucoseUtil.SUCCESS: | |||||
mLogList.add(0,result+" 成功"); | |||||
break; | |||||
case BloodGlucoseUtil.FAILED: | |||||
mLogList.add(0,result+" 失败"); | |||||
break; | |||||
case BloodGlucoseUtil.NONSUPPORT: | |||||
mLogList.add(0,result+" 不支持"); | |||||
break; | |||||
} | |||||
listAdapter.notifyDataSetChanged(); | |||||
} | |||||
@Override | |||||
public void onData(String data) { | |||||
if (isShowData) | |||||
mLogList.add(0,data); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_glucose; | |||||
import android.os.Bundle; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ListView; | |||||
import android.widget.Toast; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.BloodGlucose.BloodGlucoseBleDeviceData; | |||||
import cn.net.aicare.modulelibrary.module.BloodGlucose.BloodGlucoseUtil; | |||||
public class BloodGlucoseTestActivity extends BleBaseActivity implements OnCallbackBle, BloodGlucoseBleDeviceData.BloodGlucoseCallback, OnBleCompanyListener { | |||||
private ListView list_view; | |||||
private ArrayAdapter mAdapter; | |||||
private List<String> mList; | |||||
private String mAddress; | |||||
private BloodGlucoseBleDeviceData mBleDevice; | |||||
private List<Integer> mSupportUnit;// 设备支持的单位列表 | |||||
private int mCurTestUnit = 0;// 当前在测试第几个单位 | |||||
private int mCurStep = 1;// 当前流程进行到第几步 | |||||
private static final int STEP_END_FAIL = -1;// 测试结束 失败 | |||||
private static final int STEP_END_SUCCESS = -2;// 测试结束 成功 | |||||
private static final int STEP_CID = 1;// 查询设备CID VID PID | |||||
private static final int STEP_UNIT = 2;// 查询设备支持的单位 | |||||
private static final int STEP_DEVICE_STATUS = 3;// 获取设备状态 | |||||
private static final int STEP_TEST_STATUS_1 = 4;// 测量状态1 插入试纸 | |||||
private static final int STEP_TEST_STATUS_2 = 5;// 测量状态2 获取血样 | |||||
private static final int STEP_TEST_STATUS_3 = 6;// 测量状态3 分析血样 | |||||
private static final int STEP_TEST_DATA = 7;// 测量数据 | |||||
private static final int STEP_TEST_STATUS_4 = 8;// 测量状态4 测量完成 | |||||
private static final int STEP_SET_UNIT = 9;// APP设置单位 需要设备支持该单位 | |||||
private static final int STEP_SET_UNIT_SUCCESS = 10;// APP设置单位 需要返回成功 | |||||
private static final int STEP_SET_UNIT_FAIL = 11;// APP设置单位 需要返回失败 | |||||
private static final int STEP_SET_UNIT_UNSUPPORT = 12;// APP设置单位 需要返回不支持 | |||||
private static final int STEP_ERROR_CODE_1 = 13;// 错误码 电池没电 | |||||
private static final int STEP_ERROR_CODE_2 = 14;// 错误码 已使用过的试纸 | |||||
private static final int STEP_ERROR_CODE_3 = 15;// 错误码 环境温度超出使用范围 | |||||
private static final int STEP_ERROR_CODE_4 = 16;// 错误码 试纸施加血样后测试未完成, 被退出试纸 | |||||
private static final int STEP_ERROR_CODE_5 = 17;// 错误码 机器自检未通过 | |||||
private static final int STEP_ERROR_CODE_6 = 18;// 错误码 测量结果过低, 超出测量范围 | |||||
private static final int STEP_ERROR_CODE_7 = 19;// 错误码 测量结果过高, 超出测量范围 | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_blood_glucose_test); | |||||
list_view = findViewById(R.id.list_view); | |||||
mAddress = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mAdapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mAdapter); | |||||
setTitle("流程测试"); | |||||
list_view.postDelayed(this::nextStep, 500); | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
showToast("设备断开连接"); | |||||
finish(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.setOnCallback(this); | |||||
BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
if (bleDevice != null) { | |||||
mBleDevice = new BloodGlucoseBleDeviceData(bleDevice); | |||||
mBleDevice.setBloodGlucoseCallback(this); | |||||
bleDevice.setOnBleCompanyListener(this); | |||||
} else { | |||||
// 无法获取到设备 | |||||
showToast("无法获取到设备信息"); | |||||
finish(); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void onVersion(String version) { | |||||
} | |||||
@Override | |||||
public void onSupportUnit(List<SupportUnitBean> list) { | |||||
// 获取到设备支持的单位 | |||||
if (mCurStep == STEP_UNIT) { | |||||
String supportUnitStr = "设备支持的单位:"; | |||||
if (list != null && list.size() > 0) { | |||||
boolean hasUnit = false; | |||||
for (SupportUnitBean bean : list) { | |||||
// 6 是血糖单位 | |||||
if (bean.getType().equals("6")) { | |||||
mSupportUnit = bean.getSupportUnit(); | |||||
hasUnit = true; | |||||
for (int unit : bean.getSupportUnit()) { | |||||
// if (unit == BloodGlucoseUtil.UNIT_MMOL_L) { | |||||
if (unit == 0) { | |||||
supportUnitStr += "mmol/L,"; | |||||
} | |||||
// if (unit == BloodGlucoseUtil.UNIT_MG_DL) { | |||||
if (unit == 1) { | |||||
supportUnitStr += "mg/DL,"; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
if (!hasUnit) { | |||||
supportUnitStr += "空"; | |||||
} | |||||
} else { | |||||
supportUnitStr += "空"; | |||||
} | |||||
if (supportUnitStr.contains(",")) { | |||||
supportUnitStr = supportUnitStr.substring(0, supportUnitStr.length() - 1); | |||||
} | |||||
addText(supportUnitStr); | |||||
addText("测试通过"); | |||||
mCurStep = STEP_DEVICE_STATUS; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onDeviceStatus(int status) { | |||||
if (mCurStep == STEP_DEVICE_STATUS) { | |||||
addText("获取到设备状态:" + status); | |||||
addText("测试通过"); | |||||
addText("下面进入血氧值测量流程测试"); | |||||
mCurStep = STEP_TEST_STATUS_1; | |||||
nextStep(); | |||||
} else { | |||||
switch (mCurStep) { | |||||
case STEP_TEST_STATUS_1: | |||||
// 插入试纸 | |||||
if (status == BloodGlucoseUtil.STATUS_WAIT_TEST_PAPER) { | |||||
addText("收到插入试纸,下一步"); | |||||
mCurStep = STEP_TEST_STATUS_2; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
case STEP_TEST_STATUS_2: | |||||
// 获取血样 | |||||
if (status == BloodGlucoseUtil.STATUS_WAIT_BLOOD_SAMPLES) { | |||||
addText("收到获取血样,下一步"); | |||||
mCurStep = STEP_TEST_STATUS_3; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
case STEP_TEST_STATUS_3: | |||||
// 分析血样 | |||||
if (status == BloodGlucoseUtil.STATUS_ANALYSIS_BLOOD_SAMPLES) { | |||||
addText("收到分析血样,下一步"); | |||||
mCurStep = STEP_TEST_DATA; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
case STEP_TEST_STATUS_4: | |||||
// 测量完成 | |||||
if (status == BloodGlucoseUtil.STATUS_TEST_FINISH) { | |||||
addText("收到测量完成"); | |||||
mCurStep = STEP_SET_UNIT; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
default: | |||||
stepError(); | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void onResult(int originalValue, float value, int unit, int decimal) { | |||||
if (mCurStep == STEP_TEST_DATA) { | |||||
addText("收到数据:originValue:" + originalValue + ",value:" + value + ",unit:" + unit + ",decimal:" + decimal); | |||||
mCurStep = STEP_TEST_STATUS_4; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onErrorCode(int code) { | |||||
if (mCurStep == STEP_ERROR_CODE_1) { | |||||
addText("收到错误码:" + code + ",下一步"); | |||||
mCurStep = STEP_END_SUCCESS; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
// switch (mCurStep) { | |||||
// case STEP_ERROR_CODE_1: | |||||
// if (code == 1) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_ERROR_CODE_2; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// case STEP_ERROR_CODE_2: | |||||
// if (code == 2) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_ERROR_CODE_3; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// case STEP_ERROR_CODE_3: | |||||
// if (code == 3) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_ERROR_CODE_4; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// case STEP_ERROR_CODE_4: | |||||
// if (code == 4) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_ERROR_CODE_5; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// case STEP_ERROR_CODE_5: | |||||
// if (code == 5) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_ERROR_CODE_6; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// case STEP_ERROR_CODE_6: | |||||
// if (code == 6) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_ERROR_CODE_7; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// case STEP_ERROR_CODE_7: | |||||
// if (code == 7) { | |||||
// addText("收到错误码:" + code + ",下一步"); | |||||
// mCurStep = STEP_END_SUCCESS; | |||||
// nextStep(); | |||||
// } else { | |||||
// stepError(); | |||||
// } | |||||
// break; | |||||
// } | |||||
} | |||||
@Override | |||||
public void onSetUnitResult(int result) { | |||||
switch (mCurStep) { | |||||
case STEP_SET_UNIT_SUCCESS: | |||||
// 设置单位成功 | |||||
// if (result == 0) { | |||||
if (result == 0 || result == 1 || result == 2) { | |||||
if (result == 0) { | |||||
addText("收到设置单位成功,下一步"); | |||||
} else if (result == 1) { | |||||
addText("收到设置单位失败,下一步"); | |||||
} else if (result == 2) { | |||||
addText("收到设置单位不支持,下一步"); | |||||
} | |||||
// mCurStep = STEP_SET_UNIT_FAIL; | |||||
mCurStep = STEP_SET_UNIT; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
case STEP_SET_UNIT_FAIL: | |||||
// if (result == 1) { | |||||
if (result == 0 || result == 1 || result == 2) { | |||||
// mCurStep = STEP_SET_UNIT_UNSUPPORT; | |||||
mCurStep = STEP_SET_UNIT; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
case STEP_SET_UNIT_UNSUPPORT: | |||||
// if (result == 2) { | |||||
if (result == 0 || result == 1 || result == 2) { | |||||
mCurStep = STEP_SET_UNIT; | |||||
nextStep(); | |||||
} else { | |||||
stepError(); | |||||
} | |||||
break; | |||||
default: | |||||
stepError(); | |||||
break; | |||||
} | |||||
} | |||||
@Override | |||||
public void onData(String data) { | |||||
} | |||||
@Override | |||||
public void OnDID(int cid, int vid, int pid) { | |||||
// 获取到设备的CID VID PID | |||||
if (cid < 0) { | |||||
cid = 0; | |||||
} | |||||
if (vid < 0) { | |||||
vid = 0; | |||||
} | |||||
if (pid < 0) { | |||||
pid = 0; | |||||
} | |||||
if (mCurStep == STEP_CID) { | |||||
addText("CID:" + cid + ",VID:" + vid + ",PID:" + pid); | |||||
if (cid > 0 && vid > 0 && pid > 0) { | |||||
addText("测试通过"); | |||||
mCurStep = STEP_UNIT; | |||||
nextStep(); | |||||
} else { | |||||
addText("测试不通过,CID VID PID不能小于等于0"); | |||||
mCurStep = STEP_END_FAIL; | |||||
nextStep(); | |||||
} | |||||
} else { | |||||
stepError(); | |||||
} | |||||
} | |||||
// 进行下一步 | |||||
private void nextStep() { | |||||
if (this.isDestroyed()) { | |||||
return; | |||||
} | |||||
String stepStr = "第" + mCurStep + "步:"; | |||||
switch (mCurStep) { | |||||
case STEP_CID: | |||||
// 查询CID VID PID | |||||
addText(stepStr + "查询设备CID VID PID"); | |||||
mBleDevice.getCidVidPid(); | |||||
break; | |||||
case STEP_UNIT: | |||||
// 查询设备支持单位 | |||||
addText(stepStr + "查询设备支持的单位"); | |||||
mBleDevice.getSupportUnit(); | |||||
break; | |||||
case STEP_DEVICE_STATUS: | |||||
// 获取设备状态 | |||||
addText(stepStr + "APP下发查询状态指令,MCU接收到指令需要回复设备当前状态"); | |||||
mBleDevice.queryStatus(); | |||||
break; | |||||
case STEP_TEST_STATUS_1: | |||||
// 测量状态1 | |||||
addText(stepStr + "请发送插入试纸"); | |||||
break; | |||||
case STEP_TEST_STATUS_2: | |||||
// 测量状态2 | |||||
addText(stepStr + "请发送获取血样"); | |||||
break; | |||||
case STEP_TEST_STATUS_3: | |||||
// 测量状态3 | |||||
addText(stepStr + "请发送分析血样中"); | |||||
break; | |||||
case STEP_TEST_DATA: | |||||
// 测量数据 | |||||
addText(stepStr + "请发送测量数据"); | |||||
break; | |||||
case STEP_TEST_STATUS_4: | |||||
// 测量状态4 | |||||
addText(stepStr + "请发送测量完成"); | |||||
break; | |||||
case STEP_SET_UNIT: | |||||
// APP设置单位 | |||||
if (mSupportUnit.size() > mCurTestUnit) { | |||||
// 还有单位没测,进行测试 | |||||
addText(stepStr + "APP下发单位:" + mSupportUnit.get(mCurTestUnit)); | |||||
mCurTestUnit++; | |||||
mCurStep = STEP_SET_UNIT_SUCCESS; | |||||
nextStep(); | |||||
} else { | |||||
// 单位都测试完了 | |||||
addText("单位设置测试完成"); | |||||
mCurStep = STEP_ERROR_CODE_1; | |||||
nextStep(); | |||||
} | |||||
break; | |||||
case STEP_SET_UNIT_SUCCESS: | |||||
// 单位设置成功 | |||||
// addText(stepStr + "请回复单位设置成功"); | |||||
addText(stepStr + "请回复单位设置结果"); | |||||
break; | |||||
case STEP_SET_UNIT_FAIL: | |||||
// 单位设置失败 | |||||
// addText(stepStr + "请回复单位设置失败"); | |||||
addText(stepStr + "请回复单位设置结果"); | |||||
break; | |||||
case STEP_SET_UNIT_UNSUPPORT: | |||||
// 单位设置不支持 | |||||
// addText(stepStr + "请回复单位设置不支持"); | |||||
addText(stepStr + "请回复单位设置结果"); | |||||
break; | |||||
case STEP_ERROR_CODE_1: | |||||
// 错误码 电池没电 | |||||
// addText(stepStr + "请发送错误码:电池没电"); | |||||
addText(stepStr + "目前血糖仪支持的错误码有:\n" + | |||||
"0x01:电池没电\n" + | |||||
"0x02:已使用过的试纸\n" + | |||||
"0x03:环境温度超出使用范围\n" + | |||||
"0x04:试纸施加血样后测试未完成,被退出试纸\n" + | |||||
"0x05:机器自检未通过\n" + | |||||
"0x06:测量结果过低,超出测量范围\n" + | |||||
"0x07:测量结果过高,超出测量范围\n\n" + | |||||
"请设备发送支持的其中一种错误码"); | |||||
break; | |||||
case STEP_ERROR_CODE_2: | |||||
// 错误码 已使用过的试纸 | |||||
addText(stepStr + "请发送错误码:已使用过的试纸"); | |||||
break; | |||||
case STEP_ERROR_CODE_3: | |||||
// 错误码 环境温度超出使用范围 | |||||
addText(stepStr + "请发送错误码:环境温度超出使用范围"); | |||||
break; | |||||
case STEP_ERROR_CODE_4: | |||||
// 错误码 试纸施加血样后测试未完成, 被退出试纸 | |||||
addText(stepStr + "请发送错误码:试纸施加血样后测试未完成, 被退出试纸"); | |||||
break; | |||||
case STEP_ERROR_CODE_5: | |||||
// 错误码 机器自检未通过 | |||||
addText(stepStr + "请发送错误码:机器自检未通过"); | |||||
break; | |||||
case STEP_ERROR_CODE_6: | |||||
// 错误码 测量结果过低, 超出测量范围 | |||||
addText(stepStr + "测量结果过低, 超出测量范围"); | |||||
break; | |||||
case STEP_ERROR_CODE_7: | |||||
// 错误码 测量结果过高, 超出测量范围 | |||||
addText(stepStr + "测量结果过高, 超出测量范围"); | |||||
break; | |||||
case STEP_END_FAIL: | |||||
// 测试结束 | |||||
addText("❌ 测试结束:失败"); | |||||
addText("❌ 请退出当前页面,重新进行流程测试"); | |||||
setTitle("❌ 测试结束:失败"); | |||||
break; | |||||
case STEP_END_SUCCESS: | |||||
// 测试结束 | |||||
addText("✔ 测试结束:成功"); | |||||
setTitle("✔ 测试结束:成功"); | |||||
break; | |||||
} | |||||
} | |||||
// 显示流程错误 | |||||
private void stepError() { | |||||
addText("❌ 第" + mCurStep + "步:" + "请严格按照流程进行测试!"); | |||||
} | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
mList.add(text); | |||||
mAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
} | |||||
// 弹出Toast | |||||
private void showToast(String text) { | |||||
Toast.makeText(this, text, Toast.LENGTH_SHORT).show(); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_height; | |||||
import android.Manifest; | |||||
import android.app.Activity; | |||||
import android.bluetooth.BluetoothAdapter; | |||||
import android.content.Context; | |||||
import android.content.Intent; | |||||
import android.content.pm.PackageManager; | |||||
import android.location.LocationManager; | |||||
import android.os.Bundle; | |||||
import android.provider.Settings; | |||||
import android.text.TextUtils; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.ListView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
import com.pingwang.bluetoothlib.config.BleConfig; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackDis; | |||||
import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | |||||
import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||||
import com.pinwang.ailinkble.AiLinkPwdUtil; | |||||
import java.math.BigDecimal; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import androidx.core.app.ActivityCompat; | |||||
import cn.net.aicare.modulelibrary.module.BroadcastScale.BroadcastScaleBleConfig; | |||||
/** | |||||
* 广播身高仪 | |||||
*/ | |||||
public class BroadcastHeightActivity extends BleBaseActivity implements OnCallbackDis, OnScanFilterListener { | |||||
private Context mContext; | |||||
private ListView list_view; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_broadcast_height); | |||||
mContext = this; | |||||
list_view = findViewById(R.id.list_view); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
// 绑定服务成功,检查权限 | |||||
checkPermission(); | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public boolean onFilter(BleValueBean bleValueBean) { | |||||
return true; | |||||
} | |||||
/** | |||||
* 请求权限的Code | |||||
*/ | |||||
public static final int REQUEST_PERMISSION_CODE = 1500; | |||||
@Override | |||||
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) { | |||||
super.onActivityResult(requestCode, resultCode, data); | |||||
if (requestCode == REQUEST_PERMISSION_CODE) { | |||||
checkPermission(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { | |||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults); | |||||
if (requestCode == REQUEST_PERMISSION_CODE) { | |||||
checkPermission(); | |||||
} | |||||
} | |||||
@Override | |||||
public void onScanRecord(BleValueBean bleValueBean) { | |||||
if (TextUtils.isEmpty(mMac) && bleValueBean.isBroadcastModule()) { | |||||
// 是广播模块 | |||||
if (bleValueBean.getCid() == 0x03) { | |||||
// 是身高仪,进行数据解析 | |||||
notifyData(bleValueBean.getManufacturerData(), bleValueBean.getCid(), bleValueBean.getVid(), bleValueBean.getPid(), bleValueBean.getMac()); | |||||
} | |||||
} | |||||
} | |||||
/** | |||||
* @param manufacturerData 自定义厂商数据0xFF后面的数据 | |||||
* @param cid cid 设备类型 | |||||
* @param vid vid | |||||
* @param pid pid | |||||
*/ | |||||
private void notifyData(byte[] manufacturerData, int cid, int vid, int pid, String mac) { | |||||
if (manufacturerData == null) { | |||||
addText("接收到的数据:null"); | |||||
return; | |||||
} | |||||
if (manufacturerData.length >= 20) { | |||||
byte sum = manufacturerData[9]; | |||||
byte[] data = new byte[10]; | |||||
System.arraycopy(manufacturerData, 10, data, 0, data.length); | |||||
byte newSum = cmdSum(data); | |||||
if (newSum == sum) { | |||||
// addText("接收到的数据:原始数据:" + BleStrUtils.byte2HexStr(data)); | |||||
byte[] bytes; | |||||
byte[] dataOriginal = data.clone(); | |||||
if (cid != 0 || vid != 0 || pid != 0) { | |||||
//数据需要解密 | |||||
if (cid == BroadcastScaleBleConfig.BROADCAST_SCALE_LING_YANG_CID) { | |||||
bytes = AiLinkPwdUtil.decryptLingYang(data); | |||||
} else { | |||||
bytes = AiLinkPwdUtil.decryptBroadcast(cid, vid, pid, data); | |||||
} | |||||
} else { | |||||
bytes = data; | |||||
} | |||||
// addText("接收到的数据:" + BleStrUtils.byte2HexStr(bytes)); | |||||
checkData(bytes, cid, vid, pid, mac); | |||||
} else { | |||||
addText("校验和错误"); | |||||
} | |||||
} | |||||
} | |||||
// 上一次的流水号 | |||||
private int mLastSerialNum = -1; | |||||
/** | |||||
* 解析数据 | |||||
* | |||||
* @param hex 解密后的数据 | |||||
* @param cid cid | |||||
* @param vid vid | |||||
* @param pid pid | |||||
*/ | |||||
private void checkData(byte[] hex, int cid, int vid, int pid, String mac) { | |||||
// 流水号 | |||||
int serialNum = hex[0]; | |||||
if (serialNum == mLastSerialNum) { | |||||
return; | |||||
} | |||||
mLastSerialNum = serialNum; | |||||
// 测量标识 | |||||
int flag = hex[1] & 0xff; | |||||
// 身高原始数据 | |||||
int heightOrigin = (hex[2] & 0xff) << 8 | (hex[3] & 0xff); | |||||
// 身高单位 0:cm;1:inch;2:ft-in | |||||
int heightUnit = (hex[4] & 0xff) & 0x0f; | |||||
// 身高小数点 | |||||
int heightDecimal = ((hex[4] & 0xff) & 0xf0) >> 4; | |||||
// 体重原始数据 | |||||
int weightOrigin = (hex[5] & 0xff) << 8 | (hex[6] & 0xff); | |||||
// 体重单位 0:kg;1:斤;2:lb:oz;3:oz;4:st:lb;5:g;6:lb | |||||
int weightUnit = (hex[7] & 0xff) & 0x0f; | |||||
// 体重正负号 | |||||
int weightSymbol = ((hex[7] & 0xff) & 0x10) >> 4; | |||||
// 体重小数点 | |||||
int weightDecimal = ((hex[7] & 0xff) & 0xe0) >> 5; | |||||
// 电量 | |||||
int battery = hex[8] & 0xff; | |||||
// 输出 | |||||
String text = ""; | |||||
text += "MAC地址:" + mac; | |||||
text += "\n数据解析:" + BleStrUtils.byte2HexStr(hex); | |||||
text += "\n测量标识:" + flag + ":" + getFlagStr(flag); | |||||
text += "\n身高原始数据:" + heightOrigin; | |||||
text += "\n身高单位:" + heightUnit; | |||||
text += "\n身高小数点:" + heightDecimal; | |||||
text += "\n身高最终值:" + getHeightStr(heightOrigin, heightUnit, heightDecimal); | |||||
if (weightOrigin != 0xffff) { | |||||
text += "\n体重原始数据:" + weightOrigin; | |||||
text += "\n体重单位:" + weightUnit; | |||||
text += "\n体重正负号:" + weightSymbol; | |||||
text += "\n体重小数点:" + weightDecimal; | |||||
text += "\n体重最终值:" + getWeightStr(weightOrigin, weightUnit, weightDecimal, weightSymbol); | |||||
} else { | |||||
text += "\n体重:" + "不支持"; | |||||
} | |||||
if (battery != 0xff) { | |||||
text += "\n电量:" + battery; | |||||
} else { | |||||
text += "\n电量:" + "不支持"; | |||||
} | |||||
addText(text); | |||||
} | |||||
private String getFlagStr(int flag) { | |||||
String str = ""; | |||||
switch (flag) { | |||||
case 0: | |||||
str = "正在测量"; | |||||
break; | |||||
case 1: | |||||
str = "稳定身高体重"; | |||||
break; | |||||
case 0xff: | |||||
str = "测量失败"; | |||||
break; | |||||
} | |||||
return str; | |||||
} | |||||
private String getHeightStr(int heightOrigin, int heightUnit, int heightDecimal) { | |||||
String str = ""; | |||||
str += getPreFloatStr((float) (heightOrigin * 1.0f / Math.pow(10, heightDecimal)), heightDecimal, 0); | |||||
switch (heightUnit) { | |||||
case 0: | |||||
str += "cm"; | |||||
break; | |||||
case 1: | |||||
str += "inch"; | |||||
break; | |||||
case 2: | |||||
try { | |||||
int ft = Integer.parseInt(str); | |||||
int f = ft / 12; | |||||
int i = ft - f * 12; | |||||
str = f + "'" + i + "\""; | |||||
} catch (Exception e) { | |||||
str = "解析异常,原始值不是int型"; | |||||
} | |||||
break; | |||||
} | |||||
return str; | |||||
} | |||||
private String getWeightStr(int weightOrigin, int weightUnit, int weightDecimal, int weightSymbol) { | |||||
String str = ""; | |||||
str += getPreFloatStr((float) (weightOrigin * 1.0f / Math.pow(10, weightDecimal)) * (weightSymbol == 1 ? -1 : 1), weightDecimal, 0); | |||||
switch (weightUnit) { | |||||
case 0: | |||||
str += "kg"; | |||||
break; | |||||
case 1: | |||||
str += "斤"; | |||||
break; | |||||
case 2: | |||||
str += "lb:oz"; | |||||
break; | |||||
case 3: | |||||
str += "oz"; | |||||
break; | |||||
case 4: | |||||
str += "st:lb"; | |||||
break; | |||||
case 5: | |||||
str += "g"; | |||||
break; | |||||
case 6: | |||||
str += "lb"; | |||||
break; | |||||
} | |||||
return str; | |||||
} | |||||
/** | |||||
* 四舍五入保留一位小数 | |||||
* | |||||
* @param f 原来小数 | |||||
* @return 保留后的小数 | |||||
*/ | |||||
public static float getPreFloat(float f) { | |||||
return getPreFloat(f, 1, 0); | |||||
} | |||||
/** | |||||
* 保留小数 | |||||
* | |||||
* @param f 原始小数 | |||||
* @param bit 保留多少位 | |||||
* @param type 0 四舍五入,1 去尾,2 银行家, 3 进一 | |||||
* @return 保留后的小数 | |||||
*/ | |||||
public static float getPreFloat(float f, int bit, int type) { | |||||
return Float.parseFloat(getPreFloatStr(f, bit, type)); | |||||
} | |||||
/** | |||||
* 保留小数,获取字符串 | |||||
* | |||||
* @param f 原始小数 | |||||
* @param bit 保留多少位 | |||||
* @param type 0 四舍五入,1 去尾,2 银行家, 3 进一 | |||||
* @return 保留后的小数 | |||||
*/ | |||||
public static String getPreFloatStr(float f, int bit, int type) { | |||||
BigDecimal dc = new BigDecimal(f); | |||||
switch (type) { | |||||
default: | |||||
case 0: | |||||
// 四舍五入 | |||||
return dc.setScale(bit, BigDecimal.ROUND_HALF_UP).toString(); | |||||
case 1: | |||||
// 去尾 | |||||
return dc.setScale(bit, BigDecimal.ROUND_DOWN).toString(); | |||||
case 2: | |||||
// 银行家 | |||||
return dc.setScale(bit, BigDecimal.ROUND_HALF_EVEN).toString(); | |||||
case 3: | |||||
// 进一 | |||||
return dc.setScale(bit, BigDecimal.ROUND_UP).toString(); | |||||
} | |||||
} | |||||
/** | |||||
* 校验累加,从1开始加 | |||||
*/ | |||||
private static byte cmdSum(byte[] data) { | |||||
byte sum = 0; | |||||
for (byte datum : data) { | |||||
sum += datum; | |||||
} | |||||
return sum; | |||||
} | |||||
/** | |||||
* 检查权限,并开始扫描 | |||||
*/ | |||||
private void checkPermission() { | |||||
// 没有打开蓝牙就请求打开蓝牙 | |||||
if (!hasBluetooth()) { | |||||
requestBluetooth(); | |||||
return; | |||||
} | |||||
// 没有定位权限就请求定位权限 | |||||
if (!hasLocationPermission()) { | |||||
requestLocationPermission(this); | |||||
return; | |||||
} | |||||
// 没有定位服务就请求定位服务 | |||||
if (!hasLocationService()) { | |||||
requestLocationService(); | |||||
return; | |||||
} | |||||
// 权限都有了,OK | |||||
addText("权限都有,开始接收广播数据"); | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.setOnScanFilterListener(this); | |||||
mBluetoothService.scanLeDevice(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
} | |||||
} | |||||
/** | |||||
* 是否有定位权限 | |||||
* | |||||
* @return boolean | |||||
*/ | |||||
private boolean hasLocationPermission() { | |||||
return ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED; | |||||
} | |||||
/** | |||||
* 蓝牙是否打开 | |||||
* | |||||
* @return boolean | |||||
*/ | |||||
private boolean hasBluetooth() { | |||||
return BluetoothAdapter.getDefaultAdapter().isEnabled(); | |||||
} | |||||
/** | |||||
* 定位服务是否打开 | |||||
* | |||||
* @return boolean | |||||
*/ | |||||
private boolean hasLocationService() { | |||||
LocationManager locationManager = (LocationManager) mContext.getSystemService(Context.LOCATION_SERVICE); | |||||
if (locationManager == null) { | |||||
return false; | |||||
} | |||||
return locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | |||||
} | |||||
/** | |||||
* 申请定位权限 | |||||
*/ | |||||
private void requestLocationPermission(Activity activity) { | |||||
ActivityCompat.requestPermissions(activity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, REQUEST_PERMISSION_CODE); | |||||
} | |||||
/** | |||||
* 申请打开蓝牙 | |||||
*/ | |||||
private void requestBluetooth() { | |||||
Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); | |||||
startActivityForResult(intent, REQUEST_PERMISSION_CODE); | |||||
} | |||||
/** | |||||
* 申请打开定位服务 | |||||
*/ | |||||
private void requestLocationService() { | |||||
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | |||||
startActivityForResult(intent, REQUEST_PERMISSION_CODE); | |||||
} | |||||
private SimpleDateFormat sdf; | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
if (sdf == null) { | |||||
sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
} | |||||
mList.add(sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.coffee_scale; | |||||
import android.os.Bundle; | |||||
import android.text.TextUtils; | |||||
import android.util.Log; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import android.widget.RadioButton; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.CoffeeScale.CoffeeScaleData; | |||||
/** | |||||
* 咖啡秤 | |||||
*/ | |||||
public class CoffeeScaleActivity extends BleBaseActivity implements View.OnClickListener, CoffeeScaleData.CoffeeScaleCallback { | |||||
private static final String TAG = "Tag1"; | |||||
private Button btn_clear; | |||||
private Button btn_zero; | |||||
private Button btn_set_weight_unit; | |||||
private Button btn_set_temp_unit; | |||||
private Button btn_set_auto_shutdown; | |||||
private Button btn_set_timing; | |||||
private Button btn_callback_timing; | |||||
private Button btn_set_alert; | |||||
private Button btn_stop_alert; | |||||
private Button btn_callback_alert; | |||||
private Button btn_callback_stop_alert; | |||||
private Button btn_brew_mode; | |||||
private RadioButton rb_kg; | |||||
private RadioButton rb_jin; | |||||
private RadioButton rb_lb_oz; | |||||
private RadioButton rb_oz; | |||||
private RadioButton rb_st_lb; | |||||
private RadioButton rb_g; | |||||
private RadioButton rb_lb; | |||||
private RadioButton rb_c; | |||||
private RadioButton rb_f; | |||||
private RadioButton rb_positive_timing; | |||||
private RadioButton rb_negative_timing; | |||||
private RadioButton rb_timing_start; | |||||
private RadioButton rb_timing_pause; | |||||
private RadioButton rb_timing_reset; | |||||
private RadioButton rb_callback_timing_success; | |||||
private RadioButton rb_callback_timing_fail; | |||||
private RadioButton rb_callback_timing_not_support; | |||||
private RadioButton rb_alert_close; | |||||
private RadioButton rb_alert_open; | |||||
private RadioButton rb_callback_alert_success; | |||||
private RadioButton rb_callback_alert_fail; | |||||
private RadioButton rb_callback_alert_not_support; | |||||
private RadioButton rb_callback_stop_alert_success; | |||||
private RadioButton rb_callback_stop_alert_fail; | |||||
private RadioButton rb_callback_stop_alert_not_support; | |||||
private RadioButton rb_brew_mode_enter; | |||||
private RadioButton rb_brew_mode_exit; | |||||
private EditText et_auto_shutdown; | |||||
private EditText et_timing; | |||||
private EditText et_alert; | |||||
private ListView list_view; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private CoffeeScaleData mCoffeeScaleData; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_coffee_scale); | |||||
btn_clear = findViewById(R.id.btn_clear); | |||||
btn_zero = findViewById(R.id.btn_zero); | |||||
btn_set_weight_unit = findViewById(R.id.btn_set_weight_unit); | |||||
btn_set_temp_unit = findViewById(R.id.btn_set_temp_unit); | |||||
btn_set_auto_shutdown = findViewById(R.id.btn_set_auto_shutdown); | |||||
btn_set_timing = findViewById(R.id.btn_set_timing); | |||||
btn_callback_timing = findViewById(R.id.btn_callback_timing); | |||||
btn_set_alert = findViewById(R.id.btn_set_alert); | |||||
btn_stop_alert = findViewById(R.id.btn_stop_alert); | |||||
btn_callback_alert = findViewById(R.id.btn_callback_alert); | |||||
btn_callback_stop_alert = findViewById(R.id.btn_callback_stop_alert); | |||||
btn_brew_mode = findViewById(R.id.btn_brew_mode); | |||||
rb_kg = findViewById(R.id.rb_kg); | |||||
rb_jin = findViewById(R.id.rb_jin); | |||||
rb_lb_oz = findViewById(R.id.rb_lb_oz); | |||||
rb_oz = findViewById(R.id.rb_oz); | |||||
rb_st_lb = findViewById(R.id.rb_st_lb); | |||||
rb_g = findViewById(R.id.rb_g); | |||||
rb_lb = findViewById(R.id.rb_lb); | |||||
rb_c = findViewById(R.id.rb_c); | |||||
rb_f = findViewById(R.id.rb_f); | |||||
rb_positive_timing = findViewById(R.id.rb_positive_timing); | |||||
rb_negative_timing = findViewById(R.id.rb_negative_timing); | |||||
rb_timing_start = findViewById(R.id.rb_timing_start); | |||||
rb_timing_pause = findViewById(R.id.rb_timing_pause); | |||||
rb_timing_reset = findViewById(R.id.rb_timing_reset); | |||||
rb_callback_timing_success = findViewById(R.id.rb_callback_timing_success); | |||||
rb_callback_timing_fail = findViewById(R.id.rb_callback_timing_fail); | |||||
rb_callback_timing_not_support = findViewById(R.id.rb_callback_timing_not_support); | |||||
rb_alert_close = findViewById(R.id.rb_alert_close); | |||||
rb_alert_open = findViewById(R.id.rb_alert_open); | |||||
rb_callback_alert_success = findViewById(R.id.rb_callback_alert_success); | |||||
rb_callback_alert_fail = findViewById(R.id.rb_callback_alert_fail); | |||||
rb_callback_alert_not_support = findViewById(R.id.rb_callback_alert_not_support); | |||||
rb_callback_stop_alert_success = findViewById(R.id.rb_callback_stop_alert_success); | |||||
rb_callback_stop_alert_fail = findViewById(R.id.rb_callback_stop_alert_fail); | |||||
rb_callback_stop_alert_not_support = findViewById(R.id.rb_callback_stop_alert_not_support); | |||||
rb_brew_mode_enter = findViewById(R.id.rb_brew_mode_enter); | |||||
rb_brew_mode_exit = findViewById(R.id.rb_brew_mode_exit); | |||||
et_auto_shutdown = findViewById(R.id.et_auto_shutdown); | |||||
et_timing = findViewById(R.id.et_timing); | |||||
et_alert = findViewById(R.id.et_alert); | |||||
list_view = findViewById(R.id.list_view); | |||||
btn_clear.setOnClickListener(this); | |||||
btn_zero.setOnClickListener(this); | |||||
btn_set_weight_unit.setOnClickListener(this); | |||||
btn_set_temp_unit.setOnClickListener(this); | |||||
btn_set_auto_shutdown.setOnClickListener(this); | |||||
btn_set_timing.setOnClickListener(this); | |||||
btn_callback_timing.setOnClickListener(this); | |||||
btn_set_alert.setOnClickListener(this); | |||||
btn_stop_alert.setOnClickListener(this); | |||||
btn_callback_alert.setOnClickListener(this); | |||||
btn_callback_stop_alert.setOnClickListener(this); | |||||
btn_brew_mode.setOnClickListener(this); | |||||
// 获取Mac | |||||
mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
switch (v.getId()) { | |||||
case R.id.btn_clear: | |||||
// 清空文本框 | |||||
clearText(); | |||||
break; | |||||
case R.id.btn_zero: | |||||
// APP下发去皮功能(归零功能) | |||||
appSetZero(); | |||||
break; | |||||
case R.id.btn_set_weight_unit: | |||||
// APP下发重量单位 | |||||
appSetWeightUnit(); | |||||
break; | |||||
case R.id.btn_set_temp_unit: | |||||
// APP下发温度单位 | |||||
appSetTempUnit(); | |||||
break; | |||||
case R.id.btn_set_auto_shutdown: | |||||
// APP下发自动关机 | |||||
appSetAutoShutdown(); | |||||
break; | |||||
case R.id.btn_set_timing: | |||||
// APP下发计时功能控制 | |||||
appSetTiming(); | |||||
break; | |||||
case R.id.btn_callback_timing: | |||||
// APP回复计时功能 | |||||
appCallbackTiming(); | |||||
break; | |||||
case R.id.btn_set_alert: | |||||
// APP下发报警设置 | |||||
appSetAlert(); | |||||
break; | |||||
case R.id.btn_stop_alert: | |||||
// APP停止报警指令 | |||||
appStopAlert(); | |||||
break; | |||||
case R.id.btn_callback_alert: | |||||
// APP回复报警设置 | |||||
appCallbackAlert(); | |||||
break; | |||||
case R.id.btn_callback_stop_alert: | |||||
// APP回复停止报警 | |||||
appCallbackStopAlert(); | |||||
break; | |||||
case R.id.btn_brew_mode: | |||||
// APP设置冲煮模式 | |||||
appBrewMode(); | |||||
break; | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mBleDevice != null) { | |||||
mCoffeeScaleData = new CoffeeScaleData(mBleDevice); | |||||
mCoffeeScaleData.setCoffeeScaleCallback(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void mcuResult(int weightType, int weightUnit, int weightDecimal, int weightSource, float weight, int tempUnit, int tempDecimal, int tempSource, float temp, int err) { | |||||
Log.i(TAG, "onResult"); | |||||
String text = "MCU上发重量:" + (weightType == 1 ? "稳定重量" : "实时重量"); | |||||
text += ";重量小数点:" + weightDecimal; | |||||
text += ";重量原始值:" + weightSource; | |||||
text += ";重量:" + (weightDecimal > 0 ? weight : (int) weight) + getWeightUnitStr(weightUnit); | |||||
if (tempUnit != 0xff) { | |||||
text += ";温度小数点:" + tempDecimal; | |||||
text += ";温度原始值:" + tempSource; | |||||
text += ";温度:" + (tempDecimal > 0 ? temp : (int) temp) + getTempUnitStr(tempUnit); | |||||
} else { | |||||
text += ";温度:不支持"; | |||||
} | |||||
if (err != 0xff) { | |||||
text += ";异常:" + getErrStr(err); | |||||
} else { | |||||
text += ";异常:不支持"; | |||||
} | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuPower(int status, int power) { | |||||
Log.i(TAG, "onPower:" + status + "," + power); | |||||
String text = "MCU上发充电状态:" + getPowerStatusStr(status); | |||||
text += ";电量:" + power + "%"; | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuTiming(int seconds, int type, int op) { | |||||
Log.i(TAG, "onTiming:" + seconds + ",type:" + type + ",op:" + op); | |||||
String text = "MCU上发计时:" + seconds + "秒"; | |||||
text += ";" + getTimingStr(type) + ";" + getTimingOpStr(op); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuAlert(int seconds, int op) { | |||||
Log.i(TAG, "onAlert:" + seconds + "," + op); | |||||
String text = "MCU上发报警:" + seconds + "秒;" + getAlertOpStr(op); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuStopAlert() { | |||||
Log.i(TAG, "onStopAlert"); | |||||
String text = "MCU停止报警"; | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackSetZero(int status) { | |||||
Log.i(TAG, "onSetZero:" + status); | |||||
String text = "MCU回复去皮(归零):" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackSetWeightUnit(int status) { | |||||
Log.i(TAG, "onSetWeightUnit:" + status); | |||||
String text = "MCU回复设置重量单位:" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackSetTempUnit(int status) { | |||||
Log.i(TAG, "onSetTempUnit:" + status); | |||||
String text = "MCU回复设置温度单位:" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackSetAutoShutdown(int status) { | |||||
Log.i(TAG, "onSetAutoShutdown:" + status); | |||||
String text = "MCU回复设置自动关机:" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackSetTiming(int status) { | |||||
Log.i(TAG, "onSetTiming:" + status); | |||||
String text = "MCU回复设置计时功能:" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackSetAlert(int status) { | |||||
Log.i(TAG, "onSetAlert:" + status); | |||||
String text = "MCU回复设置警报功能:" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuCallbackStopAlert(int status) { | |||||
Log.i(TAG, "onStopAlert:" + status); | |||||
String text = "MCU回复停止警报功能:" + getStatusStr(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuBrewMode(int status) { | |||||
Log.i(TAG, "onBrewMode:" + status); | |||||
String text = "MCU冲煮模式:" + getBrewMode(status); | |||||
addText(text); | |||||
} | |||||
@Override | |||||
public void mcuSupportUnit(List<SupportUnitBean> list) { | |||||
} | |||||
// APP下发去皮功能(归零功能) | |||||
private void appSetZero() { | |||||
Log.i(TAG, "去皮功能(归零功能)"); | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发归零"); | |||||
mCoffeeScaleData.setZero(); | |||||
} | |||||
} | |||||
// APP设置重量单位 | |||||
private void appSetWeightUnit() { | |||||
Log.i(TAG, "设置重量单位"); | |||||
int weightUnit = rb_kg.isChecked() ? 0 : rb_jin.isChecked() ? 1 : rb_lb_oz.isChecked() ? 2 : rb_oz.isChecked() ? 3 : rb_st_lb.isChecked() ? 4 : rb_g.isChecked() ? 5 : rb_lb.isChecked() ? 6 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发重量单位:" + weightUnit + ";" + getWeightUnitStr(weightUnit)); | |||||
mCoffeeScaleData.setWeightUnit(weightUnit); | |||||
} | |||||
} | |||||
// APP设置温度单位 | |||||
private void appSetTempUnit() { | |||||
Log.i(TAG, "设置温度单位"); | |||||
int tempUnit = rb_c.isChecked() ? 0 : rb_f.isChecked() ? 1 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发温度单位:" + tempUnit + ";" + getTempUnitStr(tempUnit)); | |||||
mCoffeeScaleData.setTempUnit(tempUnit); | |||||
} | |||||
} | |||||
// APP设置自动关机 | |||||
private void appSetAutoShutdown() { | |||||
Log.i(TAG, "设置自动关机"); | |||||
String str = et_auto_shutdown.getText().toString(); | |||||
if (!TextUtils.isEmpty(str)) { | |||||
int num = -1; | |||||
try { | |||||
num = Integer.parseInt(str); | |||||
} catch (Exception e) { | |||||
addText("APP下发自动关机:必须为整数"); | |||||
} | |||||
if (num >= 0xffff) { | |||||
addText("APP下发自动关机:不能≥65535"); | |||||
} else if (num < 0) { | |||||
addText("APP下发自动关机:必须为正整数"); | |||||
} else { | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发自动关机:" + num + "秒"); | |||||
mCoffeeScaleData.setAutoShutdown(num); | |||||
} | |||||
} | |||||
} else { | |||||
addText("APP下发自动关机:不能为空"); | |||||
} | |||||
} | |||||
// APP计时功能控制 | |||||
private void appSetTiming() { | |||||
Log.i(TAG, "计时功能控制"); | |||||
String str = et_timing.getText().toString(); | |||||
if (!TextUtils.isEmpty(str)) { | |||||
int num = -1; | |||||
try { | |||||
num = Integer.parseInt(str); | |||||
} catch (Exception e) { | |||||
addText("APP下发计时功能:必须为整数"); | |||||
} | |||||
if (num >= 0xffff) { | |||||
addText("APP下发计时功能:不能≥65535"); | |||||
} else if (num < 0) { | |||||
addText("APP下发计时功能:必须为正整数"); | |||||
} else { | |||||
int type = rb_positive_timing.isChecked() ? 0 : rb_negative_timing.isChecked() ? 1 : 0; | |||||
int op = rb_timing_start.isChecked() ? 1 : rb_timing_pause.isChecked() ? 2 : rb_timing_reset.isChecked() ? 3 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发计时功能:" + num + "秒;" + getTimingStr(type) + ";" + getTimingOpStr(op)); | |||||
mCoffeeScaleData.setTiming(num, type, op); | |||||
} | |||||
} | |||||
} else { | |||||
addText("APP下发计时功能:不能为空"); | |||||
} | |||||
} | |||||
// APP回复计时功能 | |||||
private void appCallbackTiming() { | |||||
Log.i(TAG, "回复计时功能"); | |||||
int status = rb_callback_timing_success.isChecked() ? 0 : rb_callback_timing_fail.isChecked() ? 1 : rb_callback_timing_not_support.isChecked() ? 2 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP回复计时功能:" + status + ";" + getStatusStr(status)); | |||||
mCoffeeScaleData.callbackTiming(status); | |||||
} | |||||
} | |||||
// APP报警设置指令 | |||||
private void appSetAlert() { | |||||
Log.i(TAG, "报警设置指令"); | |||||
String str = et_alert.getText().toString(); | |||||
if (!TextUtils.isEmpty(str)) { | |||||
int num = -1; | |||||
try { | |||||
num = Integer.parseInt(str); | |||||
} catch (Exception e) { | |||||
addText("APP下发报警设置:必须为整数"); | |||||
} | |||||
if (num >= 0xffff) { | |||||
addText("APP下发报警设置:不能≥65535"); | |||||
} else if (num < 0) { | |||||
addText("APP下发报警设置:必须为正整数"); | |||||
} else { | |||||
int op = rb_alert_close.isChecked() ? 0 : rb_alert_open.isChecked() ? 1 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发报警设置:" + num + "秒;" + getAlertOpStr(op)); | |||||
mCoffeeScaleData.setAlert(num, op); | |||||
} | |||||
} | |||||
} else { | |||||
addText("APP下发报警设置:不能为空"); | |||||
} | |||||
} | |||||
// APP停止报警指令 | |||||
private void appStopAlert() { | |||||
Log.i(TAG, "停止报警指令"); | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP下发停止报警"); | |||||
mCoffeeScaleData.stopAlert(); | |||||
} | |||||
} | |||||
// APP回复报警设置 | |||||
private void appCallbackAlert() { | |||||
Log.i(TAG, "回复报警设置"); | |||||
int status = rb_callback_alert_success.isChecked() ? 0 : rb_callback_alert_fail.isChecked() ? 1 : rb_callback_alert_not_support.isChecked() ? 2 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP回复报警设置:" + status + ";" + getStatusStr(status)); | |||||
mCoffeeScaleData.callbackAlert(status); | |||||
} | |||||
} | |||||
// APP回复停止报警 | |||||
private void appCallbackStopAlert() { | |||||
Log.i(TAG, "回复停止报警"); | |||||
int status = rb_callback_stop_alert_success.isChecked() ? 0 : rb_callback_stop_alert_fail.isChecked() ? 1 : rb_callback_stop_alert_not_support.isChecked() ? 2 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP回复停止报警:" + status + ";" + getStatusStr(status)); | |||||
mCoffeeScaleData.callbackStopAlert(status); | |||||
} | |||||
} | |||||
// APP设置冲煮模式 | |||||
private void appBrewMode() { | |||||
Log.i(TAG, "设置冲煮模式"); | |||||
int status = rb_brew_mode_enter.isChecked() ? 1 : 0; | |||||
if (mCoffeeScaleData != null) { | |||||
addText("APP设置冲煮模式:" + status + ";" + getBrewMode(status)); | |||||
mCoffeeScaleData.brewMode(status); | |||||
} | |||||
} | |||||
SimpleDateFormat sdf; | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
if (sdf == null) { | |||||
sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
} | |||||
mList.add(sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
} | |||||
// 清空文本 | |||||
private void clearText() { | |||||
mList.clear(); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
private String getWeightUnitStr(int weightUnit) { | |||||
switch (weightUnit) { | |||||
case 0: | |||||
return "kg"; | |||||
case 1: | |||||
return "斤"; | |||||
case 2: | |||||
return "lb:oz"; | |||||
case 3: | |||||
return "oz"; | |||||
case 4: | |||||
return "st:lb"; | |||||
case 5: | |||||
return "g"; | |||||
case 6: | |||||
return "lb"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getTempUnitStr(int tempUnit) { | |||||
switch (tempUnit) { | |||||
case 0: | |||||
return "℃"; | |||||
case 1: | |||||
return "℉"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getErrStr(int err) { | |||||
switch (err) { | |||||
case 0: | |||||
return "无异常"; | |||||
case 1: | |||||
return "超重"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getStatusStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "失败"; | |||||
case 2: | |||||
return "不支持"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getPowerStatusStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "没有充电"; | |||||
case 1: | |||||
return "充电中"; | |||||
case 2: | |||||
return "充满电"; | |||||
case 3: | |||||
return "充电异常"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getTimingStr(int type) { | |||||
switch (type) { | |||||
case 0: | |||||
return "正计时"; | |||||
case 1: | |||||
return "倒计时"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getTimingOpStr(int op) { | |||||
switch (op) { | |||||
case 1: | |||||
return "计时"; | |||||
case 2: | |||||
return "暂停"; | |||||
case 3: | |||||
return "重置"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getAlertOpStr(int op) { | |||||
switch (op) { | |||||
case 0: | |||||
return "关闭"; | |||||
case 1: | |||||
return "打开"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getBrewMode(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "退出"; | |||||
case 1: | |||||
return "进入"; | |||||
} | |||||
return ""; | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.food_temp; | |||||
import android.os.Bundle; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.EditText; | |||||
import android.widget.ListView; | |||||
import android.widget.RadioButton; | |||||
import android.widget.Spinner; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.Calendar; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.FoodTemp.FoodTempData; | |||||
/** | |||||
* 食品温度计界面 | |||||
*/ | |||||
public class FoodTempActivity extends BleBaseActivity implements View.OnClickListener, FoodTempData.FoodTempCallback { | |||||
private static final String TAG = "Tag1"; | |||||
private Button btn_clear; | |||||
private Button btn_get_device; | |||||
private Button btn_set_temp_unit; | |||||
private RadioButton rb_set_c; | |||||
private RadioButton rb_set_f; | |||||
private Button btn_stop_alert; | |||||
private Spinner sp_stop_alert; | |||||
private Button btn_set_target; | |||||
private Spinner sp_set_target; | |||||
private EditText et_set_target; | |||||
private RadioButton rb_set_target_c; | |||||
private RadioButton rb_set_target_f; | |||||
private Button btn_set_timing; | |||||
private Spinner sp_set_timing; | |||||
private EditText et_set_timing; | |||||
private Button btn_open_close; | |||||
private RadioButton rb_open; | |||||
private RadioButton rb_close; | |||||
private Button btn_sync_time; | |||||
private EditText et_year; | |||||
private EditText et_month; | |||||
private EditText et_day; | |||||
private EditText et_hour; | |||||
private EditText et_minute; | |||||
private EditText et_second; | |||||
private EditText et_week; | |||||
private Button btn_open_close_probe; | |||||
private Spinner sp_open_close_probe; | |||||
private RadioButton rb_open_probe; | |||||
private RadioButton rb_close_probe; | |||||
private ListView list_view; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private FoodTempData mFoodTempData; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_food_temp); | |||||
btn_clear = findViewById(R.id.btn_clear); | |||||
btn_get_device = findViewById(R.id.btn_get_device); | |||||
btn_set_temp_unit = findViewById(R.id.btn_set_temp_unit); | |||||
rb_set_c = findViewById(R.id.rb_set_c); | |||||
rb_set_f = findViewById(R.id.rb_set_f); | |||||
btn_stop_alert = findViewById(R.id.btn_stop_alert); | |||||
sp_stop_alert = findViewById(R.id.sp_stop_alert); | |||||
btn_set_target = findViewById(R.id.btn_set_target); | |||||
sp_set_target = findViewById(R.id.sp_set_target); | |||||
et_set_target = findViewById(R.id.et_set_target); | |||||
rb_set_target_c = findViewById(R.id.rb_set_target_c); | |||||
rb_set_target_f = findViewById(R.id.rb_set_target_f); | |||||
btn_set_timing = findViewById(R.id.btn_set_timing); | |||||
sp_set_timing = findViewById(R.id.sp_set_timing); | |||||
et_set_timing = findViewById(R.id.et_set_timing); | |||||
btn_open_close = findViewById(R.id.btn_open_close); | |||||
rb_open = findViewById(R.id.rb_open); | |||||
rb_close = findViewById(R.id.rb_close); | |||||
btn_sync_time = findViewById(R.id.btn_sync_time); | |||||
et_year = findViewById(R.id.et_year); | |||||
et_month = findViewById(R.id.et_month); | |||||
et_day = findViewById(R.id.et_day); | |||||
et_hour = findViewById(R.id.et_hour); | |||||
et_minute = findViewById(R.id.et_minute); | |||||
et_second = findViewById(R.id.et_second); | |||||
et_week = findViewById(R.id.et_week); | |||||
btn_open_close_probe = findViewById(R.id.btn_open_close_probe); | |||||
sp_open_close_probe = findViewById(R.id.sp_open_close_probe); | |||||
rb_open_probe = findViewById(R.id.rb_open_probe); | |||||
rb_close_probe = findViewById(R.id.rb_close_probe); | |||||
list_view = findViewById(R.id.list_view); | |||||
btn_clear.setOnClickListener(this); | |||||
btn_get_device.setOnClickListener(this); | |||||
btn_set_temp_unit.setOnClickListener(this); | |||||
btn_stop_alert.setOnClickListener(this); | |||||
btn_set_target.setOnClickListener(this); | |||||
btn_set_timing.setOnClickListener(this); | |||||
btn_open_close.setOnClickListener(this); | |||||
btn_sync_time.setOnClickListener(this); | |||||
btn_open_close_probe.setOnClickListener(this); | |||||
// 获取Mac | |||||
mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
// 默认时间 | |||||
Calendar calendar = Calendar.getInstance(); | |||||
calendar.setTimeInMillis(System.currentTimeMillis()); | |||||
et_year.setText("" + calendar.get(Calendar.YEAR)); | |||||
et_month.setText("" + (calendar.get(Calendar.MONTH) + 1)); | |||||
et_day.setText("" + calendar.get(Calendar.DAY_OF_MONTH)); | |||||
et_hour.setText("" + calendar.get(Calendar.HOUR_OF_DAY)); | |||||
et_minute.setText("" + calendar.get(Calendar.MINUTE)); | |||||
et_second.setText("" + calendar.get(Calendar.SECOND)); | |||||
int week = (calendar.get(Calendar.DAY_OF_WEEK) - 1); | |||||
if (week <= 0) { | |||||
week = 7; | |||||
} | |||||
et_week.setText("" + week); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
int id = v.getId(); | |||||
if (id == R.id.btn_clear) { | |||||
clearText(); | |||||
} else if (id == R.id.btn_get_device) { | |||||
appGetDevice(); | |||||
} else if (id == R.id.btn_set_temp_unit) { | |||||
appSetTempUnit(); | |||||
} else if (id == R.id.btn_stop_alert) { | |||||
appStopAlert(); | |||||
} else if (id == R.id.btn_set_target) { | |||||
appSetTargetTemp(); | |||||
} else if (id == R.id.btn_set_timing) { | |||||
appSetTiming(); | |||||
} else if (id == R.id.btn_open_close) { | |||||
appOpenClose(); | |||||
} else if (id == R.id.btn_sync_time) { | |||||
appSyncTime(); | |||||
} else if (id == R.id.btn_open_close_probe) { | |||||
appOpenCloseProbe(); | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mBleDevice != null) { | |||||
mFoodTempData = new FoodTempData(mBleDevice); | |||||
mFoodTempData.setFoodTempCallback(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void mcuDevice(int probeNum, int chargerState, int battery, int tempUnit, int alertType) { | |||||
addText("MCU上发设备信息:探针数量:" + probeNum + ",充电状态:" + chargerState + ",电量:" + battery + ",温度单位:" + tempUnit + ",警报类型:" + alertType); | |||||
} | |||||
@Override | |||||
public void mcuResult(int id, int inDevice, int curTemp, int curTempUnit, int ambienceTemp, int ambienceTempUnit, int targetTemp, int targetTempUnit, int inMeat, int enableAlert, int mode, int timing, int alertType) { | |||||
addText("MCU上发数据:探针编号:" + id + ",探针插入设备状态:" + inDevice + ",当前温度:" + curTemp + ",当前温度单位:" + curTempUnit + ",环境温度:" + ambienceTemp + ",环境温度单位:" + ambienceTempUnit + ",目标温度:" + targetTemp + ",目标温度单位:" + targetTempUnit + ",探针插入肉状态:" + inMeat + ",警报启动状态:" + enableAlert + ",模式:" + mode + ",定时:" + timing + ",警报类型:" + alertType); | |||||
} | |||||
@Override | |||||
public void mcuSetTempUnitResult(int result) { | |||||
addText("MCU回复设置温度单位结果:" + result); | |||||
} | |||||
@Override | |||||
public void mcuStopAlertResult(int result) { | |||||
addText("MCU回复停止警报结果:" + result); | |||||
} | |||||
@Override | |||||
public void mcuSetTargetTempResult(int result) { | |||||
addText("MCU回复设置目标温度结果:" + result); | |||||
} | |||||
@Override | |||||
public void mcuSetTimingResult(int result) { | |||||
addText("MCU回复设置定时结果:" + result); | |||||
} | |||||
@Override | |||||
public void mcuOpenCloseResult(int result) { | |||||
addText("MCU回复开关机结果:" + result); | |||||
} | |||||
@Override | |||||
public void mcuSyncTimeResult(int result) { | |||||
addText("MCU回复同步时间结果:" + result); | |||||
} | |||||
@Override | |||||
public void mcuOpenCloseProbeResult(int result) { | |||||
addText("MCU回复开关探针结果:" + result); | |||||
} | |||||
/** | |||||
* APP获取设备信息 | |||||
*/ | |||||
private void appGetDevice() { | |||||
mFoodTempData.appGetDevice(); | |||||
addText("APP请求获取设备信息"); | |||||
} | |||||
/** | |||||
* APP设置温度单位 | |||||
*/ | |||||
private void appSetTempUnit() { | |||||
int unit = rb_set_c.isChecked() ? 0 : 1; | |||||
mFoodTempData.appSetTempUnit(unit); | |||||
addText("APP设置温度单位:" + unit); | |||||
} | |||||
/** | |||||
* APP停止设备报警 | |||||
*/ | |||||
private void appStopAlert() { | |||||
int id = sp_stop_alert.getSelectedItemPosition(); | |||||
mFoodTempData.appStopAlert(id); | |||||
addText("APP停止设备报警:" + id); | |||||
} | |||||
/** | |||||
* APP设置目标温度 | |||||
*/ | |||||
private void appSetTargetTemp() { | |||||
int id = sp_set_target.getSelectedItemPosition(); | |||||
int temp = 0; | |||||
int tempUnit = rb_set_target_c.isChecked() ? 0 : 1; | |||||
try { | |||||
temp = Integer.parseInt(et_set_target.getText().toString()); | |||||
} catch (Exception ignored) { | |||||
addText("目标温度必须是整数"); | |||||
return; | |||||
} | |||||
mFoodTempData.appSetTargetTemp(id, temp, tempUnit); | |||||
addText("APP设置目标温度:编号:" + id + ",温度:" + temp + ",温度单位:" + tempUnit); | |||||
} | |||||
/** | |||||
* APP设置定时 | |||||
*/ | |||||
private void appSetTiming() { | |||||
int id = sp_set_timing.getSelectedItemPosition(); | |||||
int minute = 0; | |||||
try { | |||||
minute = Integer.parseInt(et_set_timing.getText().toString()); | |||||
} catch (Exception ignored) { | |||||
addText("定时必须是整数"); | |||||
return; | |||||
} | |||||
mFoodTempData.appSetTiming(id, minute); | |||||
addText("APP设置定时:编号:" + id + ",分钟:" + minute); | |||||
} | |||||
/** | |||||
* APP开关设备 | |||||
*/ | |||||
private void appOpenClose() { | |||||
boolean isOpen = rb_open.isChecked(); | |||||
mFoodTempData.appOpenClose(isOpen); | |||||
addText("APP开关设备:" + isOpen); | |||||
} | |||||
/** | |||||
* APP同步时间 | |||||
*/ | |||||
private void appSyncTime() { | |||||
int year = 0; | |||||
int month = 0; | |||||
int day = 0; | |||||
int hour = 0; | |||||
int minute = 0; | |||||
int second = 0; | |||||
int week = 0; | |||||
try { | |||||
year = Integer.parseInt(et_year.getText().toString()); | |||||
month = Integer.parseInt(et_month.getText().toString()); | |||||
day = Integer.parseInt(et_day.getText().toString()); | |||||
hour = Integer.parseInt(et_hour.getText().toString()); | |||||
minute = Integer.parseInt(et_minute.getText().toString()); | |||||
second = Integer.parseInt(et_second.getText().toString()); | |||||
week = Integer.parseInt(et_week.getText().toString()); | |||||
} catch (Exception ignored) { | |||||
addText("年月日时分秒必须是整数"); | |||||
return; | |||||
} | |||||
mFoodTempData.appSyncTime(year, month, day, hour, minute, second, week); | |||||
addText("APP同步时间:年:" + year + ",月:" + month + ",日:" + day + ",时:" + hour + ",分:" + minute + ",秒:" + second + ",一周第几天:" + week); | |||||
} | |||||
/** | |||||
* APP开关探针 | |||||
*/ | |||||
private void appOpenCloseProbe() { | |||||
int id = sp_open_close_probe.getSelectedItemPosition(); | |||||
boolean isOpen = rb_open_probe.isChecked(); | |||||
mFoodTempData.appOpenCloseProbe(id, isOpen); | |||||
addText("APP开关探针:编号:" + id + "," + isOpen); | |||||
} | |||||
SimpleDateFormat sdf; | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
if (sdf == null) { | |||||
sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
} | |||||
mList.add(sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
} | |||||
// 清空文本 | |||||
private void clearText() { | |||||
mList.clear(); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_charger; | |||||
import android.os.Bundle; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.ListView; | |||||
import android.widget.RadioButton; | |||||
import android.widget.SeekBar; | |||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.ShareCharger.ShareChargerData; | |||||
/** | |||||
* 共享充电器 | |||||
*/ | |||||
public class ShareChargerActivity extends BleBaseActivity implements View.OnClickListener, ShareChargerData.ShareChargerCallback { | |||||
private Button btn_set; | |||||
private SeekBar seek_hour; | |||||
private SeekBar seek_minute; | |||||
private SeekBar seek_second; | |||||
private TextView tv_hour; | |||||
private TextView tv_minute; | |||||
private TextView tv_second; | |||||
private Button btn_get; | |||||
private Button btn_switch; | |||||
private RadioButton rb_open; | |||||
private RadioButton rb_close; | |||||
private ListView list_view; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private ShareChargerData mShareChargerData; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_share_charger); | |||||
btn_set = findViewById(R.id.btn_set); | |||||
seek_hour = findViewById(R.id.seek_hour); | |||||
seek_minute = findViewById(R.id.seek_minute); | |||||
seek_second = findViewById(R.id.seek_second); | |||||
tv_hour = findViewById(R.id.tv_hour); | |||||
tv_minute = findViewById(R.id.tv_minute); | |||||
tv_second = findViewById(R.id.tv_second); | |||||
btn_get = findViewById(R.id.btn_get); | |||||
btn_switch = findViewById(R.id.btn_switch); | |||||
rb_open = findViewById(R.id.rb_open); | |||||
rb_close = findViewById(R.id.rb_close); | |||||
list_view = findViewById(R.id.list_view); | |||||
btn_set.setOnClickListener(this); | |||||
btn_get.setOnClickListener(this); | |||||
btn_switch.setOnClickListener(this); | |||||
// 滑动修改时间显示 | |||||
seek_hour.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_hour.setText(progress + "时"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
seek_minute.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_minute.setText(progress + "分"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
seek_second.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_second.setText((progress + 1) + "秒"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
// 获取Mac | |||||
mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
switch (v.getId()) { | |||||
case R.id.btn_set: | |||||
int hour = seek_hour.getProgress(); | |||||
int minute = seek_minute.getProgress(); | |||||
int second = seek_second.getProgress() + 1; | |||||
if (mShareChargerData != null) { | |||||
addText("APP设置充电时间:" + getTimeStr(hour, minute, second)); | |||||
mShareChargerData.appSetChargerTime(hour, minute, second); | |||||
} | |||||
break; | |||||
case R.id.btn_get: | |||||
if (mShareChargerData != null) { | |||||
addText("APP获取剩余充电时间"); | |||||
mShareChargerData.appGetChargerTime(); | |||||
} | |||||
break; | |||||
case R.id.btn_switch: | |||||
boolean isOpen = rb_open.isChecked(); | |||||
if (mShareChargerData != null) { | |||||
addText("APP切换开关:" + isOpen); | |||||
mShareChargerData.appSwitch(isOpen); | |||||
} | |||||
break; | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mBleDevice != null) { | |||||
mShareChargerData = new ShareChargerData(mBleDevice); | |||||
mShareChargerData.setShareChargerCallback(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void mcuSetChargerTime(int status) { | |||||
addText("MCU回复设置充电时间:" + getStatusStr(status)); | |||||
} | |||||
@Override | |||||
public void mcuGetChargerTime(int status, int hour, int minute, int second) { | |||||
addText("MCU回复查询剩余充电时间:" + getStatusStr(status) + ";" + getTimeStr(hour, minute, second)); | |||||
} | |||||
@Override | |||||
public void mcuSwitch(int status) { | |||||
addText("MCU回复开关:" + getStatusStr(status)); | |||||
} | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
mList.add(sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
} | |||||
private String getStatusStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "失败"; | |||||
case 2: | |||||
return "不支持"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getTimeStr(int hour, int minute, int second) { | |||||
String hourStr; | |||||
if (hour >= 0) { | |||||
hourStr = hour >= 10 ? "" + hour : "0" + hour; | |||||
} else { | |||||
hourStr = "NULL"; | |||||
} | |||||
String minuteStr; | |||||
if (minute >= 0) { | |||||
minuteStr = minute >= 10 ? "" + minute : "0" + minute; | |||||
} else { | |||||
minuteStr = "NULL"; | |||||
} | |||||
String secondStr; | |||||
if (second >= 0) { | |||||
secondStr = second >= 10 ? "" + second : "0" + second; | |||||
} else { | |||||
secondStr = "NULL"; | |||||
} | |||||
return hourStr + ":" + minuteStr + ":" + secondStr; | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_condom; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Looper; | |||||
import android.os.Message; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.ListView; | |||||
import android.widget.RadioButton; | |||||
import android.widget.SeekBar; | |||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.ShareCondom.ShareCondomData; | |||||
/** | |||||
* 共享套套机 | |||||
*/ | |||||
public class ShareCondomActivity extends BleBaseActivity implements View.OnClickListener, ShareCondomData.ShareCondomCallback { | |||||
private static final int MSG_TIMING = 100; | |||||
private Button btn_set; | |||||
private SeekBar seek_hour; | |||||
private SeekBar seek_minute; | |||||
private SeekBar seek_second; | |||||
private TextView tv_hour; | |||||
private TextView tv_minute; | |||||
private TextView tv_second; | |||||
private Button btn_get; | |||||
private Button btn_switch; | |||||
private RadioButton rb_open; | |||||
private RadioButton rb_close; | |||||
private ListView list_view; | |||||
private Button btn_out; | |||||
private Button btn_recycle; | |||||
private Button btn_open; | |||||
private TextView tv_time; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private ShareCondomData mShareCondomData; | |||||
private long mEndStamp = 0;// 剩余时间目标的结束时间 | |||||
/** | |||||
* 计时 | |||||
*/ | |||||
private Handler mHandler = new Handler(Looper.myLooper()) { | |||||
@Override | |||||
public void handleMessage(@NonNull Message msg) { | |||||
super.handleMessage(msg); | |||||
if (msg.what == MSG_TIMING) { | |||||
// 判断显示 | |||||
long stamp = mEndStamp - System.currentTimeMillis(); | |||||
int second = (int) stamp / 1000; | |||||
if (second > 0) { | |||||
tv_time.setText("剩余时间:" + second + "秒"); | |||||
// 1秒后重新刷新 | |||||
sendEmptyMessageDelayed(MSG_TIMING, 1000); | |||||
} else { | |||||
tv_time.setText(""); | |||||
// 停止刷新 | |||||
removeMessages(MSG_TIMING); | |||||
} | |||||
} | |||||
} | |||||
}; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_share_condom); | |||||
btn_set = findViewById(R.id.btn_set); | |||||
seek_hour = findViewById(R.id.seek_hour); | |||||
seek_minute = findViewById(R.id.seek_minute); | |||||
seek_second = findViewById(R.id.seek_second); | |||||
tv_hour = findViewById(R.id.tv_hour); | |||||
tv_minute = findViewById(R.id.tv_minute); | |||||
tv_second = findViewById(R.id.tv_second); | |||||
btn_get = findViewById(R.id.btn_get); | |||||
btn_switch = findViewById(R.id.btn_switch); | |||||
rb_open = findViewById(R.id.rb_open); | |||||
rb_close = findViewById(R.id.rb_close); | |||||
list_view = findViewById(R.id.list_view); | |||||
btn_out = findViewById(R.id.btn_out); | |||||
btn_recycle = findViewById(R.id.btn_recycle); | |||||
btn_open = findViewById(R.id.btn_open); | |||||
tv_time = findViewById(R.id.tv_time); | |||||
btn_set.setOnClickListener(this); | |||||
btn_get.setOnClickListener(this); | |||||
btn_switch.setOnClickListener(this); | |||||
btn_out.setOnClickListener(this); | |||||
btn_recycle.setOnClickListener(this); | |||||
btn_open.setOnClickListener(this); | |||||
// 滑动修改时间显示 | |||||
seek_hour.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_hour.setText(progress + "时"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
seek_minute.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_minute.setText(progress + "分"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
seek_second.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_second.setText((progress + 1) + "秒"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
// 获取Mac | |||||
mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
int id = v.getId(); | |||||
if (id == R.id.btn_set) { | |||||
int hour = seek_hour.getProgress(); | |||||
int minute = seek_minute.getProgress(); | |||||
int second = seek_second.getProgress() + 1; | |||||
if (mShareCondomData != null) { | |||||
addText("APP设置充电时间:" + getTimeStr(hour, minute, second)); | |||||
mShareCondomData.appSetCondomTime(hour, minute, second); | |||||
mEndStamp = System.currentTimeMillis() + (hour * 60 * 60 + minute * 60 + second) * 1000 + 1500;// 500是当前秒,1000是设备自己加的 | |||||
mHandler.removeMessages(MSG_TIMING); | |||||
mHandler.sendEmptyMessageDelayed(MSG_TIMING, 1000); | |||||
} | |||||
} else if (id == R.id.btn_get) { | |||||
if (mShareCondomData != null) { | |||||
addText("APP获取剩余充电时间"); | |||||
mShareCondomData.appGetCondomTime(); | |||||
} | |||||
} else if (id == R.id.btn_switch) { | |||||
boolean isOpen = rb_open.isChecked(); | |||||
if (mShareCondomData != null) { | |||||
addText("APP切换开关:" + isOpen); | |||||
mShareCondomData.appSwitch(isOpen); | |||||
} | |||||
} else if (id == R.id.btn_out) { | |||||
if (mShareCondomData != null) { | |||||
addText("APP仓位出仓"); | |||||
mShareCondomData.appOut(); | |||||
} | |||||
} else if (id == R.id.btn_recycle) { | |||||
if (mShareCondomData != null) { | |||||
addText("APP仓位回收"); | |||||
mShareCondomData.appRecycle(); | |||||
} | |||||
} else if (id == R.id.btn_open) { | |||||
if (mShareCondomData != null) { | |||||
addText("APP打开补货门"); | |||||
mShareCondomData.appOpen(); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
mHandler.removeCallbacksAndMessages(null); | |||||
mHandler = null; | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mBleDevice != null) { | |||||
mShareCondomData = new ShareCondomData(mBleDevice); | |||||
mShareCondomData.setShareCondomCallback(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void mcuSetCondomTime(int status) { | |||||
addText("MCU回复设置充电时间:" + getStatusStr(status)); | |||||
} | |||||
@Override | |||||
public void mcuGetCondomTime(int status, int hour, int minute, int second) { | |||||
addText("MCU回复查询剩余充电时间:" + getStatusStr(status) + ";" + getTimeStr(hour, minute, second)); | |||||
} | |||||
@Override | |||||
public void mcuSwitch(int status) { | |||||
addText("MCU回复开关:" + getStatusStr(status)); | |||||
} | |||||
@Override | |||||
public void mcuOut(int status) { | |||||
addText("MCU回复仓位出仓:" + getCondomOutStr(status)); | |||||
} | |||||
@Override | |||||
public void mcuRecycle(int status) { | |||||
addText("MCU回复仓位回收:" + getCondomRecycleStr(status)); | |||||
} | |||||
@Override | |||||
public void mcuOpen(int status) { | |||||
addText("MCU回复打开缺货仓:" + getCondomOutStr(status)); | |||||
} | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
mList.add(sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
} | |||||
private String getStatusStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "失败"; | |||||
case 2: | |||||
return "不支持"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getCondomOutStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "不支持"; | |||||
case 2: | |||||
return "电机或限位开关故障"; | |||||
case 3: | |||||
return "仓位已出仓"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getCondomRecycleStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "不支持"; | |||||
case 2: | |||||
return "电机或限位开关故障"; | |||||
case 3: | |||||
return "仓位未出仓"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getTimeStr(int hour, int minute, int second) { | |||||
String hourStr; | |||||
if (hour >= 0) { | |||||
hourStr = hour >= 10 ? "" + hour : "0" + hour; | |||||
} else { | |||||
hourStr = "NULL"; | |||||
} | |||||
String minuteStr; | |||||
if (minute >= 0) { | |||||
minuteStr = minute >= 10 ? "" + minute : "0" + minute; | |||||
} else { | |||||
minuteStr = "NULL"; | |||||
} | |||||
String secondStr; | |||||
if (second >= 0) { | |||||
secondStr = second >= 10 ? "" + second : "0" + second; | |||||
} else { | |||||
secondStr = "NULL"; | |||||
} | |||||
return hourStr + ":" + minuteStr + ":" + secondStr; | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.share_socket; | |||||
import android.os.Bundle; | |||||
import android.os.Handler; | |||||
import android.os.Looper; | |||||
import android.os.Message; | |||||
import android.view.View; | |||||
import android.widget.ArrayAdapter; | |||||
import android.widget.Button; | |||||
import android.widget.ListView; | |||||
import android.widget.RadioButton; | |||||
import android.widget.SeekBar; | |||||
import android.widget.Spinner; | |||||
import android.widget.TextView; | |||||
import com.pingwang.bluetoothlib.BleBaseActivity; | |||||
import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
import com.pingwang.bluetoothlib.device.BleDevice; | |||||
import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
import com.pingwang.bluetoothlib.listener.OnScanFilterListener; | |||||
import java.text.SimpleDateFormat; | |||||
import java.util.ArrayList; | |||||
import java.util.HashMap; | |||||
import java.util.List; | |||||
import java.util.Locale; | |||||
import java.util.Map; | |||||
import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
import androidx.annotation.NonNull; | |||||
import androidx.annotation.Nullable; | |||||
import cn.net.aicare.modulelibrary.module.ShareSocket.ShareSocketData; | |||||
/** | |||||
* 共享插座 | |||||
*/ | |||||
public class ShareSocketActivity extends BleBaseActivity implements View.OnClickListener, ShareSocketData.ShareSocketCallback, OnCallbackBle, OnScanFilterListener { | |||||
private static final int MSG_TEST_START_SCAN = 100; | |||||
private Button btn_set; | |||||
private SeekBar seek_hour; | |||||
private SeekBar seek_minute; | |||||
private SeekBar seek_second; | |||||
private TextView tv_hour; | |||||
private TextView tv_minute; | |||||
private TextView tv_second; | |||||
private Button btn_get; | |||||
private Button btn_switch; | |||||
private RadioButton rb_open; | |||||
private RadioButton rb_close; | |||||
private ListView list_view; | |||||
private Spinner sp; | |||||
private TextView tv_timing_0; | |||||
private TextView tv_timing_1; | |||||
private TextView tv_test; | |||||
private List<String> mList; | |||||
private ArrayAdapter mListAdapter; | |||||
private String mMac; | |||||
private BleDevice mBleDevice; | |||||
private ShareSocketData mShareSocketData; | |||||
private Map<Integer, Long> mTimingMap;// 计时map;key:编号;value:结束的时间戳 | |||||
private SimpleDateFormat mSDF; | |||||
private boolean mIsTest = false;// 是否在进行测试 | |||||
private long mTestAllStamp = 30 * 60 * 1000;// 完整测试时长 | |||||
private long mTestSingleStamp = 2 * 60 * 1000;// 单轮测试时长 | |||||
private long mTestStartStamp = 0;// 下发完整测试时长那一刻的时间戳 | |||||
private int mTest1SuccessCount = 0;// 成功次数 | |||||
private int mTest1AbnormalCount = 0;// 异常次数 | |||||
private int mTest1Abnormal10Count = 0;// 异常超过10秒的次数 | |||||
private int mTest1ResetCount = 0;// 复位次数 | |||||
private int mTest2SuccessCount = 0;// 成功次数 | |||||
private int mTest2AbnormalCount = 0;// 异常次数 | |||||
private int mTest2Abnormal10Count = 0;// 异常超过20秒的次数 | |||||
private int mTest2ResetCount = 0;// 复位次数 | |||||
private int mTestConnectSuccessCount = 0;// 测试时连接成功的次数 | |||||
private int mTestConnectFailCount = 0;// 测试时连接失败的次数 | |||||
private Handler mHandler = new Handler(Looper.myLooper()) { | |||||
@Override | |||||
public void handleMessage(@NonNull Message msg) { | |||||
super.handleMessage(msg); | |||||
long endStamp = mTimingMap.get(msg.what); | |||||
int timeStamp = (int) (endStamp - System.currentTimeMillis()) / 1000; | |||||
String text = "编号" + msg.what + "计时:" + timeStamp + "秒"; | |||||
switch (msg.what) { | |||||
case 0: | |||||
tv_timing_0.setText(text); | |||||
break; | |||||
case 1: | |||||
tv_timing_1.setText(text); | |||||
break; | |||||
} | |||||
// 判断倒计时结束了没有 | |||||
if (timeStamp > 0) { | |||||
// 没结束,1秒后继续 | |||||
mHandler.sendEmptyMessageDelayed(msg.what, 1000); | |||||
} else { | |||||
// 结束了,gg | |||||
mHandler.removeMessages(msg.what); | |||||
} | |||||
} | |||||
}; | |||||
// 测试Handler | |||||
private Handler mTestHandler = new Handler(Looper.myLooper()) { | |||||
@Override | |||||
public void handleMessage(@NonNull Message msg) { | |||||
super.handleMessage(msg); | |||||
switch (msg.what) { | |||||
case MSG_TEST_START_SCAN: | |||||
// 开始扫描设备 | |||||
addText("准备重连,开始扫描设备:" + mMac); | |||||
mBluetoothService.scanLeDevice(0); | |||||
break; | |||||
} | |||||
} | |||||
}; | |||||
@Override | |||||
protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
super.onCreate(savedInstanceState); | |||||
setContentView(R.layout.activity_share_socket); | |||||
btn_set = findViewById(R.id.btn_set); | |||||
seek_hour = findViewById(R.id.seek_hour); | |||||
seek_minute = findViewById(R.id.seek_minute); | |||||
seek_second = findViewById(R.id.seek_second); | |||||
tv_hour = findViewById(R.id.tv_hour); | |||||
tv_minute = findViewById(R.id.tv_minute); | |||||
tv_second = findViewById(R.id.tv_second); | |||||
btn_get = findViewById(R.id.btn_get); | |||||
btn_switch = findViewById(R.id.btn_switch); | |||||
rb_open = findViewById(R.id.rb_open); | |||||
rb_close = findViewById(R.id.rb_close); | |||||
list_view = findViewById(R.id.list_view); | |||||
sp = findViewById(R.id.sp); | |||||
tv_timing_0 = findViewById(R.id.tv_timing_0); | |||||
tv_timing_1 = findViewById(R.id.tv_timing_1); | |||||
tv_test = findViewById(R.id.tv_test); | |||||
btn_set.setOnClickListener(this); | |||||
btn_get.setOnClickListener(this); | |||||
btn_switch.setOnClickListener(this); | |||||
// 滑动修改时间显示 | |||||
seek_hour.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_hour.setText(progress + "时"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
seek_minute.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_minute.setText(progress + "分"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
seek_second.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() { | |||||
@Override | |||||
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) { | |||||
tv_second.setText((progress + 1) + "秒"); | |||||
} | |||||
@Override | |||||
public void onStartTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
@Override | |||||
public void onStopTrackingTouch(SeekBar seekBar) { | |||||
} | |||||
}); | |||||
// 获取Mac | |||||
mMac = getIntent().getStringExtra("mac"); | |||||
// 初始化列表 | |||||
mList = new ArrayList<>(); | |||||
mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
list_view.setAdapter(mListAdapter); | |||||
mTimingMap = new HashMap<>(); | |||||
mSDF = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); | |||||
} | |||||
@Override | |||||
public void onClick(View v) { | |||||
int id = v.getId(); | |||||
if (id == R.id.btn_set) { | |||||
int spId = sp.getSelectedItemPosition(); | |||||
int hour = seek_hour.getProgress(); | |||||
int minute = seek_minute.getProgress(); | |||||
int second = seek_second.getProgress() + 1; | |||||
if (mShareSocketData != null) { | |||||
addText("APP设置充电时间:" + getTimeStr(hour, minute, second)); | |||||
mShareSocketData.appSetSocketTime(spId, hour, minute, second); | |||||
// 保存到map | |||||
long endStamp = System.currentTimeMillis() + hour * 60 * 60 * 1000 + minute * 60 * 1000 + second * 1000 + 2000;// 最后包括这一秒,然后设备又多一秒 | |||||
mTimingMap.put(spId, endStamp); | |||||
// Handler开始计时 | |||||
mHandler.removeMessages(spId); | |||||
mHandler.sendEmptyMessageDelayed(spId, 1000); | |||||
} | |||||
} else if (id == R.id.btn_get) { | |||||
int spId = sp.getSelectedItemPosition(); | |||||
if (mShareSocketData != null) { | |||||
addText("APP获取剩余充电时间"); | |||||
mShareSocketData.appGetSocketTime(spId); | |||||
} | |||||
} else if (id == R.id.btn_switch) { | |||||
int spId = sp.getSelectedItemPosition(); | |||||
boolean isOpen = rb_open.isChecked(); | |||||
if (mShareSocketData != null) { | |||||
addText("APP切换开关:" + isOpen); | |||||
mShareSocketData.appSwitch(spId, isOpen); | |||||
} | |||||
} else if (id == R.id.btn_version) { | |||||
if (mShareSocketData != null) { | |||||
addText("APP获取设备版本号"); | |||||
mShareSocketData.appGetVersion(); | |||||
} | |||||
} else if (id == R.id.btn_test) { | |||||
if (!mIsTest && mShareSocketData != null) { | |||||
mIsTest = true; | |||||
addText("开始性能测试"); | |||||
startTest(); | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
protected void onDestroy() { | |||||
if (mBluetoothService != null) { | |||||
mBluetoothService.disconnectAll(); | |||||
} | |||||
super.onDestroy(); | |||||
} | |||||
@Override | |||||
public void onServiceSuccess() { | |||||
mBluetoothService.setOnCallback(this); | |||||
mBluetoothService.setOnScanFilterListener(this); | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mBleDevice != null) { | |||||
mShareSocketData = new ShareSocketData(mBleDevice); | |||||
mShareSocketData.setShareSocketCallback(this); | |||||
} | |||||
} | |||||
@Override | |||||
public void onScanning(BleValueBean data) { | |||||
// 扫描到了设备 | |||||
if (mIsTest && !mBluetoothService.isConnectStatus()) { | |||||
// 开始连接设备 | |||||
addText("扫描到设备,开始连接"); | |||||
mBluetoothService.connectDevice(mMac); | |||||
// 停止扫描 | |||||
mBluetoothService.stopScan(); | |||||
} | |||||
} | |||||
@Override | |||||
public boolean onFilter(BleValueBean bleValueBean) { | |||||
// 只扫描相同的设备 | |||||
return bleValueBean.getMac().equals(mMac); | |||||
} | |||||
@Override | |||||
public void onServiceErr() { | |||||
} | |||||
@Override | |||||
public void unbindServices() { | |||||
} | |||||
@Override | |||||
public void mcuSetSocketTime(int id, int status) { | |||||
addText("MCU回复设置充电时间:编号:" + id + ";" + getStatusStr(status)); | |||||
} | |||||
private int mCha1 = -1; | |||||
private int mCha2 = -1; | |||||
@Override | |||||
public void mcuGetSocketTime(int id, int status, int hour, int minute, int second) { | |||||
if (mCha1 >= 0 && mCha2 >= 0) { | |||||
// 已经回了2次了,多出来的回复不处理 | |||||
return; | |||||
} | |||||
addText("MCU回复查询剩余充电时间:编号:" + id + ";" + getStatusStr(status) + ";" + getTimeStr(hour, minute, second)); | |||||
long mcuStamp = hour * 60 * 60 * 1000 + minute * 60 * 1000 + second * 1000; | |||||
long appStamp = mTestAllStamp - (System.currentTimeMillis() - mTestStartStamp); | |||||
if (appStamp < 0) { | |||||
appStamp = 0; | |||||
} | |||||
if (mIsTest) { | |||||
int cha = Math.abs((int) (mcuStamp - appStamp)); | |||||
appStamp /= 1000; | |||||
int h = (int) (appStamp / 60 / 60); | |||||
int m = (int) (appStamp - hour * 60 * 60) / 60; | |||||
int s = (int) appStamp % 60; | |||||
addText("和APP的计时:" + getTimeStr(h, m, s) + "相差" + cha + "ms"); | |||||
cha /= 1000; | |||||
if (id == 0) { | |||||
mCha1 = cha; | |||||
} else if (id == 1) { | |||||
mCha2 = cha; | |||||
} | |||||
boolean needReset = false; | |||||
if (mCha1 >= 0 && mCha2 >= 0) { | |||||
// 两条数据都回来了 | |||||
if (mcuStamp == 0 && appStamp > 0) { | |||||
mTest1ResetCount++; | |||||
needReset = true; | |||||
} else if (mCha1 < 5000) { | |||||
mTest1SuccessCount++; | |||||
} else if (mCha1 < 10000) { | |||||
mTest1AbnormalCount++; | |||||
needReset = true; | |||||
} else { | |||||
mTest1Abnormal10Count++; | |||||
needReset = true; | |||||
} | |||||
if (mcuStamp == 0 && appStamp > 0) { | |||||
mTest2ResetCount++; | |||||
needReset = true; | |||||
} else if (mCha2 < 5000) { | |||||
mTest2SuccessCount++; | |||||
} else if (mCha2 < 10000) { | |||||
mTest2AbnormalCount++; | |||||
needReset = true; | |||||
} else { | |||||
mTest2Abnormal10Count++; | |||||
needReset = true; | |||||
} | |||||
// 刷新显示 | |||||
refreshTest(); | |||||
// 判断要不要重新发送充电时长 | |||||
if (needReset) { | |||||
// 有异常,需要重置 | |||||
addText("出现异常,需要重置充电时间"); | |||||
startTest(); | |||||
} else if (appStamp <= 0) { | |||||
// 几轮都走完了 | |||||
addText("测试完成,重新设置充电时间"); | |||||
startTest(); | |||||
} else { | |||||
// 没有问题 | |||||
addText("本轮测试结束,总时长还没结束,直接断开,不重置充电时长"); | |||||
if (mBleDevice != null) { | |||||
mBleDevice.disconnect(); | |||||
mBleDevice = null; | |||||
} | |||||
} | |||||
} | |||||
} | |||||
} | |||||
@Override | |||||
public void mcuSwitch(int id, int status) { | |||||
addText("MCU回复开关:编号:" + id + ";" + getStatusStr(status)); | |||||
} | |||||
@Override | |||||
public void mcuVersion(String version) { | |||||
addText("MCU回复版本:" + version); | |||||
} | |||||
@Override | |||||
public void onServicesDiscovered(String mac) { | |||||
mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
if (mIsTest && mBleDevice != null) { | |||||
mTestConnectSuccessCount++; | |||||
addText("连接成功:" + mMac + ",查询剩余充电时间"); | |||||
mShareSocketData = new ShareSocketData(mBleDevice); | |||||
mShareSocketData.setShareSocketCallback(this); | |||||
mCha1 = mCha2 = -1; | |||||
mShareSocketData.appGetSocketTime(0); | |||||
mShareSocketData.appGetSocketTime(1); | |||||
} | |||||
} | |||||
@Override | |||||
public void onDisConnected(String mac, int code) { | |||||
if (mIsTest) { | |||||
long stamp = mTestSingleStamp; | |||||
if (stamp < 0) { | |||||
stamp = 0; | |||||
} | |||||
mBleDevice = null; | |||||
if (code != 0) { | |||||
// 0是自己断开,不是0就说明是连接失败 | |||||
mTestConnectFailCount++; | |||||
addText("设备断开连接:" + code + "。正在测试,等待" + getTimeStrByStamp(10000) + "后重连"); | |||||
mTestHandler.sendEmptyMessageDelayed(MSG_TEST_START_SCAN, 10000); | |||||
} else { | |||||
// 自己主动断开要等待 | |||||
addText("主动断开连接:" + code + "。正在测试,等待" + getTimeStrByStamp(stamp) + "后重连"); | |||||
mTestHandler.sendEmptyMessageDelayed(MSG_TEST_START_SCAN, stamp); | |||||
} | |||||
} else { | |||||
addText("设备断开连接:" + code); | |||||
} | |||||
} | |||||
// 开始插口1的测试 | |||||
private void startTest() { | |||||
addText("设置充电总时长:" + getTimeStrByStamp(mTestAllStamp)); | |||||
mTestStartStamp = System.currentTimeMillis() + 2000L;// 1000毫秒是蓝牙的延迟,1000毫秒是MCU自己的延迟 | |||||
long stamp = mTestAllStamp; | |||||
stamp /= 1000; | |||||
int hour = (int) (stamp / 60 / 60); | |||||
int minute = (int) (stamp - hour * 60 * 60) / 60; | |||||
int second = (int) stamp % 60; | |||||
mShareSocketData.appSetSocketTime(0, hour, minute, second); | |||||
mShareSocketData.appSetSocketTime(1, hour, minute, second); | |||||
new Thread(() -> { | |||||
try { | |||||
Thread.sleep(2000); | |||||
} catch (Exception ignored) { | |||||
} | |||||
if (mBleDevice != null && mBleDevice.isConnectSuccess()) { | |||||
addText("设置充电总时长后断开连接"); | |||||
mBleDevice.disconnect(); | |||||
mBleDevice = null; | |||||
} | |||||
}).start(); | |||||
} | |||||
// 添加一条文本 | |||||
private void addText(String text) { | |||||
runOnUiThread(() -> { | |||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
mList.add(sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
mListAdapter.notifyDataSetChanged(); | |||||
list_view.smoothScrollToPosition(mList.size() - 1); | |||||
}); | |||||
} | |||||
private String getStatusStr(int status) { | |||||
switch (status) { | |||||
case 0: | |||||
return "成功"; | |||||
case 1: | |||||
return "失败"; | |||||
case 2: | |||||
return "不支持"; | |||||
} | |||||
return ""; | |||||
} | |||||
private String getTimeStr(int hour, int minute, int second) { | |||||
String hourStr; | |||||
if (hour >= 0) { | |||||
hourStr = hour >= 10 ? "" + hour : "0" + hour; | |||||
} else { | |||||
hourStr = "NULL"; | |||||
} | |||||
String minuteStr; | |||||
if (minute >= 0) { | |||||
minuteStr = minute >= 10 ? "" + minute : "0" + minute; | |||||
} else { | |||||
minuteStr = "NULL"; | |||||
} | |||||
String secondStr; | |||||
if (second >= 0) { | |||||
secondStr = second >= 10 ? "" + second : "0" + second; | |||||
} else { | |||||
secondStr = "NULL"; | |||||
} | |||||
return hourStr + ":" + minuteStr + ":" + secondStr; | |||||
} | |||||
/** | |||||
* 根据毫秒数获取时间字符串 | |||||
* | |||||
* @param stamp 毫秒 | |||||
* @return 时间 | |||||
*/ | |||||
private String getTimeStrByStamp(long stamp) { | |||||
String str = ""; | |||||
stamp /= 1000; | |||||
int hour = (int) (stamp / 60 / 60); | |||||
int minute = (int) (stamp - hour * 60 * 60) / 60; | |||||
int second = (int) stamp % 60; | |||||
if (hour > 0) { | |||||
str += hour + "小时"; | |||||
} | |||||
if (minute > 0) { | |||||
str += minute + "分钟"; | |||||
} | |||||
if (second > 0) { | |||||
str += second + "秒"; | |||||
} | |||||
return str; | |||||
} | |||||
/** | |||||
* 刷新测试统计 | |||||
*/ | |||||
private void refreshTest() { | |||||
String str = ""; | |||||
str += "\n连接次数:" + (mTestConnectSuccessCount + mTestConnectFailCount); | |||||
str += "\n连接成功次数:" + mTestConnectSuccessCount; | |||||
str += "\n连接失败次数:" + mTestConnectFailCount; | |||||
str += "\n连接成功率:" + (mTestConnectSuccessCount * 1.0f / (mTestConnectSuccessCount + mTestConnectFailCount) * 100) + "%"; | |||||
str += "\n\n插口1成功次数:" + mTest1SuccessCount; | |||||
str += "\n插口1重置次数:" + mTest1ResetCount; | |||||
str += "\n插口1异常不超过10秒次数:" + mTest1AbnormalCount; | |||||
str += "\n插口1异常超过10秒次数:" + mTest1Abnormal10Count; | |||||
str += "\n插口1成功率" + (mTest1SuccessCount * 1.0f / (mTest1SuccessCount + mTest1AbnormalCount + mTest1ResetCount + mTest1Abnormal10Count) * 100) + "%"; | |||||
str += "\n\n插口2成功次数:" + mTest2SuccessCount; | |||||
str += "\n插口2重置次数:" + mTest2ResetCount; | |||||
str += "\n插口2异常不超过10秒次数:" + mTest2AbnormalCount; | |||||
str += "\n插口2异常超过10秒次数:" + mTest2Abnormal10Count; | |||||
str += "\n插口2成功率" + (mTest2SuccessCount * 1.0f / (mTest2SuccessCount + mTest2AbnormalCount + mTest2ResetCount + mTest2Abnormal10Count) * 100) + "%"; | |||||
tv_test.setText(str); | |||||
} | |||||
} |
package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | |||||
import java.security.AlgorithmParameters; | |||||
import java.security.Key; | |||||
import javax.crypto.Cipher; | |||||
import javax.crypto.SecretKey; | |||||
import javax.crypto.spec.IvParameterSpec; | |||||
import javax.crypto.spec.SecretKeySpec; | |||||
public class AES128Util { | |||||
//算法名 | |||||
public static final String KEY_ALGORITHM = "AES"; | |||||
//加解密算法/模式/填充方式 | |||||
//可以任意选择,为了方便后面与iOS端的加密解密,采用与其相同的模式与填充方式 | |||||
//ECB模式只用密钥即可对数据进行加密解密,CBC模式需要添加一个参数iv | |||||
public static final String CIPHER_ALGORITHM = "AES/CBC/PKCS5Padding"; | |||||
//生成密钥 | |||||
private static byte[] generateKey(String aesKey) throws Exception { | |||||
// KeyGenerator kgen = KeyGenerator.getInstance(KEY_ALGORITHM); | |||||
// | |||||
// kgen.init(128, new SecureRandom(aesKey.getBytes())); | |||||
// | |||||
// SecretKey secretKey = kgen.generateKey(); | |||||
// | |||||
// byte[] encodeFormat = secretKey.getEncoded(); | |||||
// | |||||
// SecretKeySpec keySpec = new SecretKeySpec(encodeFormat, "AES"); | |||||
// | |||||
// return keySpec.getEncoded(); | |||||
return aesKey.getBytes(); | |||||
} | |||||
//生成iv | |||||
private static AlgorithmParameters generateIV(String ivVal) throws Exception { | |||||
//iv 为一个 16 字节的数组,这里采用和 iOS 端一样的构造方法,数据全为0 | |||||
//byte[] iv = new byte[16]; | |||||
//Arrays.fill(iv, (byte) 0x00); | |||||
//Arrays.fill(iv,ivVal.getBytes()); | |||||
byte[] iv; | |||||
if (ivVal == null || ivVal.length() == 0) { | |||||
iv = new byte[16]; | |||||
} else { | |||||
iv = ivVal.getBytes(); | |||||
} | |||||
AlgorithmParameters params = AlgorithmParameters.getInstance(KEY_ALGORITHM); | |||||
params.init(new IvParameterSpec(iv)); | |||||
return params; | |||||
} | |||||
//转化成JAVA的密钥格式 | |||||
private static Key convertToKey(byte[] keyBytes) throws Exception { | |||||
SecretKey secretKey = new SecretKeySpec(keyBytes, KEY_ALGORITHM); | |||||
return secretKey; | |||||
} | |||||
//加密 | |||||
public static String encrypt(String plainText, String aesKey, String ivVal) throws Exception { | |||||
byte[] data = plainText.getBytes(); | |||||
byte[] iv; | |||||
if (ivVal == null || ivVal.length() == 0) { | |||||
iv = new byte[16]; | |||||
} else { | |||||
iv = ivVal.getBytes(); | |||||
} | |||||
AlgorithmParameters params = AlgorithmParameters.getInstance(KEY_ALGORITHM); | |||||
params.init(new IvParameterSpec(iv)); | |||||
//转化为密钥 | |||||
Key key = convertToKey(aesKey.getBytes()); | |||||
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); | |||||
//设置为加密模式 | |||||
cipher.init(Cipher.ENCRYPT_MODE, key, params); | |||||
byte[] encryptData = cipher.doFinal(data); | |||||
return bytesToHexString(encryptData); | |||||
} | |||||
//解密 | |||||
public static String decrypt(String encryptedStr, String aesKey, String ivVal) throws Exception { | |||||
byte[] encryptedData = hexStringToByte(encryptedStr); | |||||
byte[] keyBytes = generateKey(aesKey); | |||||
Key key = convertToKey(keyBytes); | |||||
Cipher cipher = Cipher.getInstance(CIPHER_ALGORITHM); | |||||
AlgorithmParameters iv = generateIV(ivVal); | |||||
//设置为解密模式 | |||||
cipher.init(Cipher.DECRYPT_MODE, key, iv); | |||||
byte[] decryptData = cipher.doFinal(encryptedData); | |||||
return new String(decryptData); | |||||
} | |||||
/** | |||||
* 十六进制字符串转换成数组 | |||||
* | |||||
* @param hex | |||||
* @return | |||||
*/ | |||||
private static byte[] hexStringToByte(String hex) { | |||||
int len = (hex.length() / 2); | |||||
byte[] result = new byte[len]; | |||||
char[] achar = hex.toCharArray(); | |||||
for (int i = 0; i < len; i++) { | |||||
int pos = i * 2; | |||||
result[i] = (byte) (toByte(achar[pos]) << 4 | toByte(achar[pos + 1])); | |||||
} | |||||
return result; | |||||
} | |||||
private static byte toByte(char c) { | |||||
byte b = (byte) "0123456789abcdef".indexOf(c); | |||||
return b; | |||||
} | |||||
/** | |||||
* 把字节数组转换成16进制字符串 | |||||
* | |||||
* @param bArray | |||||
* @return | |||||
*/ | |||||
private static final String bytesToHexString(byte[] bArray) { | |||||
StringBuffer sb = new StringBuffer(bArray.length); | |||||
String sTemp; | |||||
for (int i = 0; i < bArray.length; i++) { | |||||
sTemp = Integer.toHexString(0xFF & bArray[i]); | |||||
if (sTemp.length() < 2) | |||||
sb.append(0); | |||||
sb.append(sTemp.toLowerCase()); | |||||
} | |||||
return sb.toString(); | |||||
} | |||||
} |
}); | }); | ||||
L.d("Files", "Size: " + file.length); | L.d("Files", "Size: " + file.length); | ||||
ArrayList<String> names = new ArrayList<String>(); | ArrayList<String> names = new ArrayList<String>(); | ||||
for (int i = 0; i < file.length; i++) { | |||||
L.d("Files", "FileName:" + file[i].getName()); | |||||
names.add(file[i].getName()); | |||||
for (File value : file) { | |||||
L.d("Files", "FileName:" + value.getName()); | |||||
names.add(value.getName()); | |||||
} | } | ||||
return names; | return names; | ||||
} | } | ||||
} | } |
package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | |||||
/** | |||||
* xing<br> | |||||
* 2019/3/7<br> | |||||
* 广播解析工具类 | |||||
*/ | |||||
public class MyBleStrUtils { | |||||
/** | |||||
* (16进制) | |||||
* BLE蓝牙返回的byte[] | |||||
* byte[]转字符串 | |||||
*/ | |||||
public static String byte2HexStr(byte[] b) { | |||||
if (b == null) | |||||
return ""; | |||||
StringBuilder hs = new StringBuilder(); | |||||
String stmp; | |||||
for (byte aB : b) { | |||||
int a = aB & 0XFF; | |||||
stmp = getHexString(a); | |||||
if (stmp.length() == 1) | |||||
hs.append("0").append(stmp); | |||||
else | |||||
hs.append(stmp); | |||||
hs.append(" "); | |||||
} | |||||
return hs.toString(); | |||||
} | |||||
/** | |||||
* int 10进制转16进制(返回大写字母) | |||||
* | |||||
* @return 16进制String | |||||
*/ | |||||
public static String getHexString(int number) { | |||||
return Integer.toHexString(number); | |||||
} | |||||
/** | |||||
* int到byte[] 由高位到低位 | |||||
* @param i 需要转换为byte数组的整行值。 | |||||
* @return byte数组 | |||||
*/ | |||||
public static byte[] intToByteArray(int i) { | |||||
byte[] result = new byte[4]; | |||||
result[0] = (byte)((i >> 24) & 0xFF); | |||||
result[1] = (byte)((i >> 16) & 0xFF); | |||||
result[2] = (byte)((i >> 8) & 0xFF); | |||||
result[3] = (byte)(i & 0xFF); | |||||
return result; | |||||
} | |||||
/** | |||||
* 时间戳(秒)转byte数组 由高位到低位 | |||||
* @param time 时间戳,精确到秒 | |||||
* @return byte[5]数组 | |||||
*/ | |||||
public static byte[] getTimestampByte(long time) { | |||||
byte[] result = new byte[5]; | |||||
result[4] = (byte)((time >> 32) & 0xFF); | |||||
result[3] = (byte)((time >> 24) & 0xFF); | |||||
result[2] = (byte)((time >> 16) & 0xFF); | |||||
result[1] = (byte)((time >> 8) & 0xFF); | |||||
result[0] = (byte)(time & 0xFF); | |||||
return result; | |||||
} | |||||
/** | |||||
* byte[]转long | |||||
* @param bytes 需要转换的数组 | |||||
* @param isBig 是否为大端序 | |||||
* @return 数值 | |||||
*/ | |||||
public static long byteArrayToLong(byte[] bytes,boolean isBig) { | |||||
long value=0; | |||||
int length = bytes.length; | |||||
if (isBig){ | |||||
for(int i = length; i >0; i--) { | |||||
int shift= ((length-1)-(length-i)) * 8; | |||||
value +=(bytes[(i-1)] & 0xFF) << shift; | |||||
} | |||||
}else { | |||||
for(int i = 0; i <length; i++) { | |||||
int shift= ((length-1)-i) * 8; | |||||
value +=(bytes[i] & 0xFF) << shift; | |||||
} | |||||
} | |||||
return value; | |||||
} | |||||
/** | |||||
* (16进制) | |||||
* BLE蓝牙返回的byte[] | |||||
* byte[]转字符串 | |||||
*/ | |||||
public static String getMac(byte[] b,boolean isBig) { | |||||
if (b == null) | |||||
return ""; | |||||
StringBuilder hs = new StringBuilder(); | |||||
String stmp; | |||||
if (isBig){ | |||||
for (byte aB : b) { | |||||
int a = aB & 0XFF; | |||||
stmp = getHexString(a); | |||||
if (stmp.length() == 1) | |||||
hs.append("0").append(stmp); | |||||
else | |||||
hs.append(stmp); | |||||
hs.append(":"); | |||||
} | |||||
}else { | |||||
for (int i = b.length - 1; i >= 0; i--) { | |||||
byte aB=b[i]; | |||||
int a = aB & 0XFF; | |||||
stmp = getHexString(a); | |||||
if (stmp.length() == 1) | |||||
hs.append("0").append(stmp); | |||||
else | |||||
hs.append(stmp); | |||||
hs.append(":"); | |||||
} | |||||
} | |||||
hs.deleteCharAt(hs.length()-1); | |||||
return hs.toString(); | |||||
} | |||||
/** | |||||
* mac地址转byte | |||||
* @param mac | |||||
* @return | |||||
*/ | |||||
public static byte[] getDeviceMacByte(String mac) { | |||||
byte[] macByte = new byte[6]; | |||||
if (mac.contains(":")) { | |||||
String[] macArr = mac.split(":"); | |||||
for (int i = 0; i < macArr.length; i++) { | |||||
macByte[macArr.length - i - 1] = (byte) Integer.parseInt(macArr[i], 16); | |||||
} | |||||
} | |||||
return macByte; | |||||
} | |||||
} |
public static String OTA_FILE_NAME = "OTA_FILE_NAME"; | public static String OTA_FILE_NAME = "OTA_FILE_NAME"; | ||||
/** | |||||
* 寻物器mac地址列表 | |||||
*/ | |||||
private final static String FIND_DEVICE_MAC_LIST="FIND_DEVICE_MAC_LIST"; | |||||
//------------------------------------- | //------------------------------------- | ||||
editor.putString(OTA_FILE_NAME, name); | editor.putString(OTA_FILE_NAME, name); | ||||
apply(editor); | apply(editor); | ||||
} | } | ||||
public String getFindDeviceMacList() { | |||||
return sp.getString(FIND_DEVICE_MAC_LIST, STR_DEFAULT); | |||||
} | |||||
public void putFindDeviceMacList(String name) { | |||||
SharedPreferences.Editor editor = sp.edit(); | |||||
editor.putString(FIND_DEVICE_MAC_LIST, name); | |||||
apply(editor); | |||||
} | |||||
/** | /** |
package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | ||||
import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
import java.util.Calendar; | |||||
import java.util.Locale; | import java.util.Locale; | ||||
/** | /** | ||||
public class TimeUtils { | public class TimeUtils { | ||||
public static String getTime(){ | public static String getTime(){ | ||||
java.text.SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
return format.format(System.currentTimeMillis())+":\n"; | return format.format(System.currentTimeMillis())+":\n"; | ||||
} | } | ||||
public static String getTimeSSS(){ | |||||
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss:SSS", Locale.US); | |||||
return format.format(System.currentTimeMillis())+":\n"; | |||||
} | |||||
public static String getDateString() { | |||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss", Locale.US); | |||||
return simpleDateFormat.format(System.currentTimeMillis()); | |||||
} | |||||
public static String getTime(long time){ | |||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); | |||||
return format.format(time)+":\n"; | |||||
} | |||||
/** | |||||
* 返回当前年 | |||||
*/ | |||||
public static int getYear() { | |||||
Calendar c = Calendar.getInstance(); | |||||
return c.get(Calendar.YEAR); | |||||
} | |||||
/** | |||||
* 返回当前月(1~12) | |||||
*/ | |||||
public static int getMonth() { | |||||
Calendar c = Calendar.getInstance(); | |||||
return c.get(Calendar.MONTH) + 1; | |||||
} | |||||
/** | |||||
* 返回当前日 | |||||
*/ | |||||
public static int getDay() { | |||||
Calendar c = Calendar.getInstance(); | |||||
return c.get(Calendar.DAY_OF_MONTH); | |||||
} | |||||
/** | |||||
* 返回当前日 | |||||
*/ | |||||
public static int getHour() { | |||||
Calendar c = Calendar.getInstance(); | |||||
return c.get(Calendar.HOUR_OF_DAY); | |||||
} | |||||
/** | |||||
* 返回当前日 | |||||
*/ | |||||
public static int getMinute() { | |||||
Calendar c = Calendar.getInstance(); | |||||
return c.get(Calendar.MINUTE); | |||||
} | |||||
public static int[] getTimeArr(){ | |||||
int[] time=new int[3]; | |||||
Calendar c = Calendar.getInstance(); | |||||
time[0] = c.get(Calendar.HOUR_OF_DAY); | |||||
time[1] = c.get(Calendar.MINUTE); | |||||
time[2]= c.get(Calendar.SECOND); | |||||
return time; | |||||
} | |||||
public static String getTimeM(){ | |||||
SimpleDateFormat format = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
return format.format(System.currentTimeMillis())+":\n"; | |||||
} | |||||
} | } |
<?xml version="1.0" encoding="utf-8"?> | |||||
<shape xmlns:android = "http://schemas.android.com/apk/res/android"> | |||||
<size | |||||
android:width = "0dp" | |||||
android:height = "10dp"/> | |||||
</shape> |
android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal" | |||||
android:layout_margin="10dp" | |||||
> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="Weight:" | |||||
android:textSize="18dp" | |||||
/> | |||||
<TextView | |||||
android:id="@+id/tv_baby_body_fat_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0.0" | |||||
android:textSize="18dp" | |||||
android:layout_marginStart="5dp" | |||||
/> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="Height:" | |||||
android:textSize="18dp" | |||||
android:layout_marginStart="20dp" | |||||
/> | |||||
<TextView | |||||
android:id="@+id/tv_baby_body_fat_height" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0.0" | |||||
android:textSize="18dp" | |||||
android:layout_marginStart="5dp" | |||||
/> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="adc:" | |||||
android:textSize="18dp" | |||||
android:layout_marginStart="20dp" | |||||
/> | |||||
<TextView | |||||
android:id="@+id/tv_baby_body_fat_adc" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0.0" | |||||
android:textSize="18dp" | |||||
android:layout_marginStart="5dp" | |||||
/> | |||||
</LinearLayout> | |||||
<TextView | <TextView | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout | |||||
xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<RadioGroup | |||||
android:id="@+id/unit" | |||||
android:layout_below="@+id/edit_Userid" | |||||
android:layout_width="match_parent" | |||||
android:orientation="horizontal" | |||||
android:layout_height="wrap_content"> | |||||
<RadioButton | |||||
android:id="@+id/kg" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:text="kg"/> | |||||
<RadioButton | |||||
android:id="@+id/jin" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:text="斤"/> | |||||
<RadioButton | |||||
android:id="@+id/st_lb" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:text="st:lb"/> | |||||
<RadioButton | |||||
android:id="@+id/lb" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:text="lb"/> | |||||
</RadioGroup> | |||||
<ListView | |||||
android:id="@+id/log_list" | |||||
android:layout_marginTop="20dp" | |||||
android:layout_below="@id/unit" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent"> | |||||
</ListView> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
> | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
android:orientation="vertical"> | |||||
<ScrollView | <ScrollView | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="0dp" | android:layout_height="0dp" | ||||
android:layout_weight="1" | |||||
> | |||||
android:layout_weight="1"> | |||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="vertical" | |||||
> | |||||
android:orientation="vertical"> | |||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | |||||
> | |||||
android:orientation="horizontal"> | |||||
<Button | <Button | ||||
android:id="@+id/btnClear" | android:id="@+id/btnClear" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="@string/clear" | |||||
/> | |||||
android:text="@string/clear" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnPause" | android:id="@+id/btnPause" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="暂停" | |||||
/> | |||||
android:text="暂停" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | |||||
> | |||||
android:orientation="horizontal"> | |||||
<Button | <Button | ||||
android:id="@+id/btnHandshake" | android:id="@+id/btnHandshake" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="@string/handshake" | |||||
/> | |||||
android:text="@string/handshake" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnVersion" | android:id="@+id/btnVersion" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读版本" | |||||
/> | |||||
android:text="读版本" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnBattery" | android:id="@+id/btnBattery" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读电量" | |||||
/> | |||||
android:text="读电量" /> | |||||
<Button | |||||
android:id="@+id/btnNameRssi" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读名称信号" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
android:padding="5dp"> | |||||
<Button | <Button | ||||
android:id="@+id/btnTimeRead" | android:id="@+id/btnTimeRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读时间" | |||||
/> | |||||
android:text="读时间" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnTimeWrite" | android:id="@+id/btnTimeWrite" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="写时间" | |||||
/> | |||||
android:text="写时间" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnMacRead" | android:id="@+id/btnMacRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读mac" | |||||
/> | |||||
android:text="读mac" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnBmRestart" | android:id="@+id/btnBmRestart" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="重启模块" | |||||
/> | |||||
android:text="重启模块" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
android:padding="5dp"> | |||||
<EditText | |||||
android:id="@+id/etMcuType" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="串口,i2c,spi" | |||||
android:text="1" | |||||
/> | |||||
<Button | <Button | ||||
android:id="@+id/btnMcuType" | android:id="@+id/btnMcuType" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="设置模式" | |||||
/> | |||||
android:text="设置模式" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnBmReset" | android:id="@+id/btnBmReset" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="出厂设置" | |||||
/> | |||||
android:text="出厂设置" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnUnits" | android:id="@+id/btnUnits" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读单位" | |||||
/> | |||||
android:text="读单位" /> | |||||
<EditText | |||||
android:id="@+id/etMcuType" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="串口,i2c,spi" | |||||
android:text="1" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
android:padding="5dp"> | |||||
<EditText | |||||
android:id="@+id/etCid" | |||||
android:layout_width="60dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0123456789" | |||||
android:hint="cid" | |||||
android:text="0" /> | |||||
<EditText | <EditText | ||||
android:id="@+id/etDid" | |||||
android:layout_width="200dp" | |||||
android:id="@+id/etVid" | |||||
android:layout_width="60dp" | |||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:hint="cidS,vidS,pidS,cid,vid,pid" | |||||
android:text="1,1,1,1,2,3" | |||||
/> | |||||
android:digits="0123456789" | |||||
android:hint="vid" | |||||
android:text="0" /> | |||||
<EditText | |||||
android:id="@+id/etPid" | |||||
android:layout_width="60dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0123456789" | |||||
android:hint="pid" | |||||
android:text="0" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnDidWrite" | android:id="@+id/btnDidWrite" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="写DID" | |||||
/> | |||||
android:text="写DID" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnDidRead" | android:id="@+id/btnDidRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读DID" | |||||
/> | |||||
android:text="读DID" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
<EditText | |||||
android:id="@+id/etName" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:maxLength="13" | |||||
/> | |||||
android:padding="5dp"> | |||||
<Button | <Button | ||||
android:id="@+id/btnNameWrite" | android:id="@+id/btnNameWrite" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="写名称" | |||||
/> | |||||
android:text="写名称" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnNameRead" | android:id="@+id/btnNameRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读名称" | |||||
/> | |||||
android:text="读名称" /> | |||||
<Button | <Button | ||||
android:id="@+id/btn_start_ble" | android:id="@+id/btn_start_ble" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="唤醒模块" | |||||
/> | |||||
android:text="唤醒模块" /> | |||||
<EditText | |||||
android:id="@+id/etName" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:maxLength="13" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
<EditText | |||||
android:id="@+id/etMacType" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:maxLength="1" | |||||
android:digits="0987654321" | |||||
/> | |||||
android:padding="5dp"> | |||||
<Button | <Button | ||||
android:id="@+id/btnMacTypeWrite" | android:id="@+id/btnMacTypeWrite" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="写Mac大小端" | |||||
/> | |||||
android:text="写Mac大小端" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnMacTypeRead" | android:id="@+id/btnMacTypeRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读Mac大小端" | |||||
/> | |||||
android:text="读Mac大小端" /> | |||||
<EditText | |||||
android:id="@+id/etMacType" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0987654321" | |||||
android:maxLength="1" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
<EditText | |||||
android:id="@+id/etBroadcastTime" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0987654321" | |||||
/> | |||||
android:padding="5dp"> | |||||
<Button | <Button | ||||
android:id="@+id/btnBroadcastTimeWrite" | android:id="@+id/btnBroadcastTimeWrite" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="写广播间隔" | |||||
/> | |||||
android:text="写广播间隔" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnBroadcastTimeRead" | android:id="@+id/btnBroadcastTimeRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读广播间隔" | |||||
/> | |||||
android:text="读广播间隔" /> | |||||
<EditText | |||||
android:id="@+id/etBroadcastTime" | |||||
android:layout_width="100dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0987654321" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:orientation="horizontal" | android:orientation="horizontal" | ||||
android:padding="5dp" | |||||
> | |||||
<EditText | |||||
android:id="@+id/etSleepTime" | |||||
android:layout_width="150dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0987654321," | |||||
android:text="1,60,1,1000" | |||||
android:hint="标记,时间,操作,广播时间" | |||||
/> | |||||
android:padding="5dp"> | |||||
<Button | <Button | ||||
android:id="@+id/btnSleepTimeWrite" | android:id="@+id/btnSleepTimeWrite" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="写自动休眠" | |||||
/> | |||||
android:text="写自动休眠" /> | |||||
<Button | <Button | ||||
android:id="@+id/btnSleepTimeRead" | android:id="@+id/btnSleepTimeRead" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="读自动休眠" | |||||
/> | |||||
android:text="读自动休眠" /> | |||||
<EditText | |||||
android:id="@+id/etSleepTime" | |||||
android:layout_width="150dp" | |||||
android:layout_height="wrap_content" | |||||
android:digits="0987654321," | |||||
android:hint="标记,时间,操作,广播时间" | |||||
android:text="1,60,1,1000" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
</LinearLayout> | </LinearLayout> | ||||
android:layout_weight="1" | android:layout_weight="1" | ||||
android:padding="10dp" | android:padding="10dp" | ||||
android:stackFromBottom="true" | android:stackFromBottom="true" | ||||
android:transcriptMode="alwaysScroll" | |||||
> | |||||
android:transcriptMode="alwaysScroll"> | |||||
</ListView> | </ListView> | ||||
</LinearLayout> | </LinearLayout> |
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/test" | |||||
android:text="流程测试" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
/> | |||||
</LinearLayout> | |||||
<ListView | <ListView | ||||
android:id="@+id/log_list" | android:id="@+id/log_list" | ||||
android:layout_marginTop="20dp" | android:layout_marginTop="20dp" |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" | |||||
android:text="SpO2上限" /> | |||||
<TextView | |||||
android:id="@+id/tv_sp_max" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" /> | |||||
<androidx.appcompat.widget.AppCompatSeekBar | |||||
android:id="@+id/sb_sp_max" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:max="255" | |||||
android:min="0" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" | |||||
android:text="SpO2下限" /> | |||||
<TextView | |||||
android:id="@+id/tv_sp_min" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" /> | |||||
<androidx.appcompat.widget.AppCompatSeekBar | |||||
android:id="@+id/sb_sp_min" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:max="255" | |||||
android:min="0" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" | |||||
android:text="脉率上限" /> | |||||
<TextView | |||||
android:id="@+id/tv_pr_max" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" /> | |||||
<androidx.appcompat.widget.AppCompatSeekBar | |||||
android:id="@+id/sb_pr_max" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:max="255" | |||||
android:min="0" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" | |||||
android:text="脉率下限" /> | |||||
<TextView | |||||
android:id="@+id/tv_pr_min" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" /> | |||||
<androidx.appcompat.widget.AppCompatSeekBar | |||||
android:id="@+id/sb_pr_min" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:max="255" | |||||
android:min="0" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" | |||||
android:text="血流灌注上限" /> | |||||
<TextView | |||||
android:id="@+id/tv_pl_max" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" /> | |||||
<androidx.appcompat.widget.AppCompatSeekBar | |||||
android:id="@+id/sb_pl_max" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:max="255" | |||||
android:min="0" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" | |||||
android:text="血流灌注下限" /> | |||||
<TextView | |||||
android:id="@+id/tv_pl_min" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="0.3" | |||||
android:gravity="center" /> | |||||
<androidx.appcompat.widget.AppCompatSeekBar | |||||
android:id="@+id/sb_pl_min" | |||||
android:layout_width="0dp" | |||||
android:layout_height="match_parent" | |||||
android:layout_weight="1" | |||||
android:max="255" | |||||
android:min="0" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/bt_alarm" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="设置警报" /> | |||||
<Button | |||||
android:id="@+id/bt_status" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="查询状态" /> | |||||
<Button | |||||
android:id="@+id/bt_pause" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="暂停接收" /> | |||||
<Button | |||||
android:id="@+id/bt_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/bt_version" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="查询版本号" /> | |||||
<TextView | |||||
android:id="@+id/tv_version" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="版本" | |||||
/> | |||||
</LinearLayout> | |||||
<ListView | |||||
android:id="@+id/lv_log" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:layout_marginTop="10dp" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="IMEI号:" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
<EditText | |||||
android:id="@+id/ed_imei" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:text="869324050002769" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_login" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="登录(仅一次)" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
<Button | |||||
android:id="@+id/btn_deviceId" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="获取设备Id" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
<Button | |||||
android:id="@+id/btn_data" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="获取数据" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
<Button | |||||
android:id="@+id/btn_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="清屏" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_test" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="测试环境" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
<Button | |||||
android:id="@+id/btn_produce" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_gravity="center" | |||||
android:padding="5dp" | |||||
android:text="生产环境" | |||||
android:textColor="#000000" | |||||
android:textSize="16dp" /> | |||||
<TextView | |||||
android:text="默认为生产环境,切换环境需要重新登录和获取设备id" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content"/> | |||||
</LinearLayout> | |||||
<ListView | |||||
android:id="@+id/listviw" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" /> | |||||
</LinearLayout> |
android:id="@+id/tv_broadcast_temp" | android:id="@+id/tv_broadcast_temp" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="30℃" | |||||
android:text="--℃" | |||||
android:layout_marginStart="5dp" | android:layout_marginStart="5dp" | ||||
/> | /> | ||||
<TextView | |||||
android:id="@+id/tv_broadcast_did" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="" | |||||
android:layout_marginStart="20dp" | |||||
/> | |||||
</LinearLayout> | </LinearLayout> | ||||
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" | |||||
> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical" | |||||
> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:padding="10dp"> | |||||
<EditText | |||||
android:id="@+id/et_type" | |||||
android:layout_width="200dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="透传数据" | |||||
android:text="01" | |||||
android:digits="0123456789abcdefABCDEF" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="发送" | |||||
/> | |||||
<Button | |||||
android:id="@+id/clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空" | |||||
/> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:padding="10dp"> | |||||
<Button | |||||
android:id="@+id/btn_set_unit" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="set_unit" | |||||
/> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<ListView | |||||
android:id="@+id/listview" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="2" | |||||
android:padding="10dp" | |||||
android:stackFromBottom="true" | |||||
android:transcriptMode="alwaysScroll" | |||||
> | |||||
</ListView> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_zero" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="去皮功能(归零功能)" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_weight_unit" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发重量单位" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_kg" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="kg" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_jin" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="斤" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_lb_oz" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="lb:oz" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_oz" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="oz" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_st_lb" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="st:lb" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_g" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="g" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_lb" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="lb" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_temp_unit" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发温度单位" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_c" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="℃" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_f" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="℉" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_auto_shutdown" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发自动关机" /> | |||||
<EditText | |||||
android:id="@+id/et_auto_shutdown" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:inputType="number" | |||||
android:text="60" /> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="3" | |||||
android:text="(秒)" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_timing" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="计时功能控制" /> | |||||
<EditText | |||||
android:id="@+id/et_timing" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:inputType="number" | |||||
android:text="30" /> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="3" | |||||
android:text="(秒)" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_positive_timing" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="正计时" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_negative_timing" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="倒计时" /> | |||||
</RadioGroup> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_timing_start" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="计时" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_timing_pause" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="暂停" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_timing_reset" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="重置" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_callback_timing" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP回复计时功能" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_timing_success" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="成功" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_timing_fail" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="失败" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_timing_not_support" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="不支持" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_alert" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="报警设置指令" /> | |||||
<EditText | |||||
android:id="@+id/et_alert" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:inputType="number" | |||||
android:text="5" /> | |||||
<TextView | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="3" | |||||
android:text="(秒)" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_alert_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="关闭(默认)" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_alert_open" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="打开" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_callback_alert" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP回复报警设置" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_alert_success" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="成功" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_alert_fail" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="失败" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_alert_not_support" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="不支持" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="vertical"> | |||||
<Button | |||||
android:id="@+id/btn_stop_alert" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="停止报警指令" /> | |||||
<Button | |||||
android:id="@+id/btn_callback_stop_alert" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP回复停止报警" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_stop_alert_success" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="成功" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_stop_alert_fail" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="失败" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_callback_stop_alert_not_support" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="不支持" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="5dp" | |||||
android:orientation="vertical"> | |||||
<Button | |||||
android:id="@+id/btn_brew_mode" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP设置冲煮模式" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_brew_mode_enter" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="进入冲煮模式" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_brew_mode_exit" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="退出冲煮模式" /> | |||||
</RadioGroup> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1dp" | |||||
android:background="?android:attr/listDivider" /> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_get_connect_number" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="连接个数" /> | |||||
<Button | |||||
android:id="@+id/btn_connect_info_list" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="连接的信息列表" /> | |||||
<EditText | |||||
android:id="@+id/et_send_data" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="10dp" | |||||
android:text="123" | |||||
android:textSize="18dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_device_id_0" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0" /> | |||||
<Button | |||||
android:id="@+id/btn_device_id_1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="1" /> | |||||
<Button | |||||
android:id="@+id/btn_device_id_2" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="2" /> | |||||
<Button | |||||
android:id="@+id/btn_device_id_3" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="3" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_device_id_4" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="4" /> | |||||
<Button | |||||
android:id="@+id/btn_device_id_5" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="5" /> | |||||
<Button | |||||
android:id="@+id/btn_device_id_6" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="6" /> | |||||
<Button | |||||
android:id="@+id/btn_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空" | |||||
/> | |||||
</LinearLayout> | |||||
<androidx.recyclerview.widget.RecyclerView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
/> | |||||
<LinearLayout | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_scan_ble" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="扫描设备" | |||||
/> | |||||
</LinearLayout> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_marginTop="10dp" | |||||
android:layout_weight="1" | |||||
android:padding="10dp" | |||||
android:stackFromBottom="true" | |||||
android:transcriptMode="alwaysScroll" | |||||
> | |||||
</ListView> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal" | |||||
android:gravity="center_vertical" | |||||
> | |||||
<Button | |||||
android:id="@+id/btn_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn_scan_ble" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="扫描设备" | |||||
/> | |||||
<TextView | |||||
android:id="@+id/tv_status" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="" | |||||
/> | |||||
</LinearLayout> | |||||
<androidx.recyclerview.widget.RecyclerView | |||||
android:id="@+id/rv_device" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="300dp" | |||||
/> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_marginTop="10dp" | |||||
android:layout_weight="1" | |||||
android:padding="10dp" | |||||
android:stackFromBottom="true" | |||||
android:transcriptMode="alwaysScroll" | |||||
> | |||||
</ListView> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical"> | |||||
<Button | |||||
android:id="@+id/btn_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空列表" /> | |||||
<Button | |||||
android:id="@+id/btn_get_device" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP获取设备信息" /> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<Button | |||||
android:id="@+id/btn_set_temp_unit" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发温度单位" /> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_set_c" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="℃" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_set_f" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="℉" /> | |||||
</RadioGroup> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_stop_alert" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP取消报警" /> | |||||
<Spinner | |||||
android:id="@+id/sp_stop_alert" | |||||
android:layout_width="wrap_content" | |||||
android:entries="@array/food_temp_probe" | |||||
android:layout_height="wrap_content" /> | |||||
</LinearLayout> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_target" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发目标温度" /> | |||||
<Spinner | |||||
android:id="@+id/sp_set_target" | |||||
android:layout_width="wrap_content" | |||||
android:entries="@array/food_temp_probe" | |||||
android:layout_height="wrap_content" /> | |||||
<EditText | |||||
android:id="@+id/et_set_target" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:inputType="number" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<RadioGroup | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_set_target_c" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="℃" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_set_target_f" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="℉" /> | |||||
</RadioGroup> | |||||
</LinearLayout> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_set_timing" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发定时" /> | |||||
<Spinner | |||||
android:id="@+id/sp_set_timing" | |||||
android:layout_width="wrap_content" | |||||
android:entries="@array/food_temp_probe" | |||||
android:layout_height="wrap_content" /> | |||||
<EditText | |||||
android:id="@+id/et_set_timing" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:inputType="number" /> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginEnd="5dp" | |||||
android:text="min" /> | |||||
</LinearLayout> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<Button | |||||
android:id="@+id/btn_open_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发设备开关机" /> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_open" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="开机" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关机" /> | |||||
</RadioGroup> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<Button | |||||
android:id="@+id/btn_sync_time" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP同步时间" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="年" /> | |||||
<EditText | |||||
android:id="@+id/et_year" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="月" /> | |||||
<EditText | |||||
android:id="@+id/et_month" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="日" /> | |||||
<EditText | |||||
android:id="@+id/et_day" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="时" /> | |||||
<EditText | |||||
android:id="@+id/et_hour" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="分" /> | |||||
<EditText | |||||
android:id="@+id/et_minute" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="秒" /> | |||||
<EditText | |||||
android:id="@+id/et_second" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:text="星期" /> | |||||
<EditText | |||||
android:id="@+id/et_week" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginStart="5dp" | |||||
android:inputType="number" /> | |||||
</LinearLayout> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1px" | |||||
android:background="@android:color/darker_gray" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_open_close_probe" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP下发探针开关机" /> | |||||
<Spinner | |||||
android:id="@+id/sp_open_close_probe" | |||||
android:layout_width="wrap_content" | |||||
android:entries="@array/food_temp_probe" | |||||
android:layout_height="wrap_content" /> | |||||
</LinearLayout> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_open_probe" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="开机" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_close_probe" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关机" /> | |||||
</RadioGroup> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1dp" | |||||
android:background="?android:attr/listDivider" /> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" | |||||
android:background="@android:color/white" /> | |||||
</LinearLayout> |
android:text="靠近报警阀值:" | android:text="靠近报警阀值:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar1" | android:id="@+id/seekBar1" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" | ||||
android:text="接收的阀值次数:" | android:text="接收的阀值次数:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar2" | android:id="@+id/seekBar2" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" | ||||
android:text="脱离报警时间:" | android:text="脱离报警时间:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar3" | android:id="@+id/seekBar3" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" | ||||
android:text="脱离报警次数:" | android:text="脱离报警次数:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar4" | android:id="@+id/seekBar4" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" | ||||
android:text="Gsensor灵敏度:" | android:text="Gsensor灵敏度:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar5" | android:id="@+id/seekBar5" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" | ||||
android:text="Gsensor不动的脱机时间:" | android:text="Gsensor不动的脱机时间:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar6" | android:id="@+id/seekBar6" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" | ||||
android:text="马达震动时间:" | android:text="马达震动时间:" | ||||
/> | /> | ||||
<aicare.net.cn.sdk.ailinksdkdemoandroid.view.SeekBarMin | |||||
<com.pinwang.ailinkblesdk.view.SeekBarMin | |||||
android:id="@+id/seekBar7" | android:id="@+id/seekBar7" | ||||
style="@style/Widget.AppCompat.SeekBar" | style="@style/Widget.AppCompat.SeekBar" | ||||
android:layout_width="0dp" | android:layout_width="0dp" |
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | android:padding="10dp"> | ||||
<EditText | |||||
android:id="@+id/et_type" | |||||
android:layout_width="200dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="透传数据" | |||||
android:text="4" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="发送" | |||||
/> | |||||
<Button | <Button | ||||
android:id="@+id/clear" | android:id="@+id/clear" |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout | |||||
xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/kg" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="kg" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/jin" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="斤" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/st_lb" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="ST:LB" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/lb" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="lb" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:gravity="center" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/cm" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="cm" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/inch" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="inch" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/ft_in" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="ft-in" | |||||
android:textAllCaps="false" /> | |||||
<TextView | |||||
android:layout_gravity="top" | |||||
android:gravity="top" | |||||
android:id="@+id/text" | |||||
android:text="体重单位:kg \n身高单位:cm, \n模式 身高体脂模式" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="60dp"/> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/deviceStatus" | |||||
android:text="获取设备状态" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content"/> | |||||
<Button | |||||
android:id="@+id/bodyfat" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="身高体脂模式" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="体重模式" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/baby" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="抱婴模式" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/voice_status" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="获取声音状态" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/voice_open" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="声音开" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/voice_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="声音关" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/height_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="体重身高模式" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/girl" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="女,18岁,165cm" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/man" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="男,28岁,170cm" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/finish" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="回复测量完成" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | |||||
<ListView | |||||
android:id="@+id/listView" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent"/> | |||||
</LinearLayout> |
android:padding="10dp" | android:padding="10dp" | ||||
android:text="@string/version" /> | android:text="@string/version" /> | ||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
<Button | |||||
android:id="@+id/btn_sphy" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/sphygmometer" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_tempgun" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/forehead_gun" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_temp" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/thermometer" | |||||
android:textSize="12dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
<Button | |||||
android:id="@+id/btn_height" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/height_meter" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_smart_mask" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/smart_mask" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_baby" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/baby_scale" | |||||
android:textSize="12dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
<Button | |||||
android:id="@+id/btn_baby_body_fat" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/baby_body_fat_scale" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_broadcast_scale" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/broadcast_scale" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_broadcast_blood_oxygen" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/oximeter" | |||||
android:textSize="12dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
<Button | |||||
android:id="@+id/btn_wifi_ble_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/wifi_ble_weight_scale" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_ble_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/ble_body_fat_scale" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_wifi_ble_tooth" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/wifi_ble_toothbrush" | |||||
android:textSize="12dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
<ScrollView | |||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
android:layout_height="match_parent"> | |||||
<Button | |||||
android:id="@+id/btn_ble" | |||||
android:layout_width="wrap_content" | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="@string/general_settings" | |||||
android:textSize="12dp" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
android:orientation="vertical" | |||||
android:padding="5dp"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_clear_shake_hands" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="不握手不加密" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_sphy" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="血压计" /> | |||||
<Button | |||||
android:id="@+id/btn_tempgun" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="额温枪" /> | |||||
<Button | |||||
android:id="@+id/btn_temp" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="体温计" /> | |||||
<Button | |||||
android:id="@+id/btn_baby" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="婴儿秤" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_height" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="身高仪" /> | |||||
<Button | |||||
android:id="@+id/btn_lock" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="电子锁" /> | |||||
<Button | |||||
android:id="@+id/wifi_config" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/device_wifi_config" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/eight_scale" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/eight_scale" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btn_ad_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="艾迪体脂秤" /> | |||||
<Button | |||||
android:id="@+id/btn_smart_mask" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="口罩" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_baby_body_fat" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="婴儿体脂两用秤" /> | |||||
<Button | |||||
android:id="@+id/btn_broadcast_scale" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="广播秤" /> | |||||
<Button | |||||
android:id="@+id/glucometer" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/blood_glucose_meter" | |||||
android:textSize="12dp" /> | |||||
</LinearLayout> | |||||
<Button | |||||
android:id="@+id/btn_broadcast_blood_oxygen" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="血氧仪" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_wifi_ble_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="WiFi+Ble体脂秤" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_margin="10dp" | |||||
android:gravity="center_vertical"> | |||||
<Button | |||||
android:id="@+id/btn_ble_weight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="Ble体脂秤" /> | |||||
<Button | |||||
android:id="@+id/btn_wifi_ble_tooth" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="牙刷(wifi+ble)" /> | |||||
</LinearLayout> | |||||
<Button | |||||
android:id="@+id/btn_ota" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/ota_general" | |||||
android:textSize="12dp" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ble" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="Ble通用设置" /> | |||||
<Button | |||||
android:id="@+id/btn_ble_test" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="BleTest" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn_transmission" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/penetrate" | |||||
android:textSize="12dp" /> | |||||
<Button | |||||
android:id="@+id/btnConnectTest" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="BleConnectTest" | |||||
/> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/wifi_config" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="WIFI设备(配置wifi)" /> | |||||
<Button | |||||
android:id="@+id/eight_scale" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="八极秤" /> | |||||
<Button | |||||
android:id="@+id/glucometer" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="血糖仪" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ota" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="OTA通用" /> | |||||
<Button | |||||
android:id="@+id/btn_transmission" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="透传" /> | |||||
<Button | |||||
android:id="@+id/btn_bld" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="百利达" | |||||
android:visibility="gone" /> | |||||
<Button | |||||
android:id="@+id/btn_bleBo" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="血氧(连接)" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_coffeeScale" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="咖啡秤" /> | |||||
<Button | |||||
android:id="@+id/btn_scooter" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="电滑板" /> | |||||
<Button | |||||
android:id="@+id/btn_shareCharger" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="共享充电器" /> | |||||
<Button | |||||
android:id="@+id/btn_share_socket" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="共享插座" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_broadcast_height" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="广播身高仪" /> | |||||
<Button | |||||
android:id="@+id/btn_hbfs" | |||||
android:text="身高体脂秤" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content"/> | |||||
<Button | |||||
android:id="@+id/btn_find" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="寻物器" /> | |||||
<Button | |||||
android:id="@+id/btn_4g_bs" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="4G血糖仪" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_food_temp" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="食品温度计" /> | |||||
<Button | |||||
android:id="@+id/btn_temp_humidity" | |||||
android:text="温湿度计" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content"/> | |||||
<Button | |||||
android:id="@+id/btn_share_condom" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="共享套套机" /> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
</LinearLayout> | |||||
</LinearLayout> | </LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical"> | |||||
<Button | |||||
android:id="@+id/btn_set" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP设置充电时间" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_hour" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="23" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_hour" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0时" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_minute" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="59" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_minute" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0分" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_second" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="58" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_second" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="1秒" /> | |||||
</LinearLayout> | |||||
<Button | |||||
android:id="@+id/btn_get" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP获取剩余充电时间" /> | |||||
<Button | |||||
android:id="@+id/btn_switch" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP切换开关" /> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_open" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="开" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关" /> | |||||
</RadioGroup> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1dp" | |||||
android:background="?android:attr/listDivider" /> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical"> | |||||
<Button | |||||
android:id="@+id/btn_set" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP设置充电时间" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_hour" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="23" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_hour" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0时" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_minute" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="59" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_minute" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0分" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_second" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="58" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_second" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="1秒" /> | |||||
</LinearLayout> | |||||
<Button | |||||
android:id="@+id/btn_get" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP获取剩余充电时间" /> | |||||
<TextView | |||||
android:id="@+id/tv_time" | |||||
android:text="" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" /> | |||||
<Button | |||||
android:id="@+id/btn_switch" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP切换开关" /> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_open" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="开" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关" /> | |||||
</RadioGroup> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<Button | |||||
android:id="@+id/btn_out" | |||||
android:text="出仓" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" /> | |||||
<Button | |||||
android:id="@+id/btn_recycle" | |||||
android:text="回收" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" /> | |||||
<Button | |||||
android:id="@+id/btn_open" | |||||
android:text="打开补仓门" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" /> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1dp" | |||||
android:background="?android:attr/listDivider" /> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:orientation="vertical"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="50dp" | |||||
android:gravity="center_vertical" | |||||
android:orientation="horizontal"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="插座编号" /> | |||||
<Spinner | |||||
android:id="@+id/sp" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:entries="@array/share_socket_id" /> | |||||
</LinearLayout> | |||||
<Button | |||||
android:id="@+id/btn_set" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP设置充电时间" /> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_hour" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="23" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_hour" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0时" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_minute" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="59" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_minute" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0分" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:orientation="horizontal"> | |||||
<SeekBar | |||||
android:id="@+id/seek_second" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:max="58" | |||||
android:progress="0" /> | |||||
<TextView | |||||
android:id="@+id/tv_second" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="1秒" /> | |||||
</LinearLayout> | |||||
<TextView | |||||
android:id="@+id/tv_timing_0" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:text="编号0计时:" /> | |||||
<TextView | |||||
android:id="@+id/tv_timing_1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="30dp" | |||||
android:gravity="center" | |||||
android:text="编号1计时:" /> | |||||
<Button | |||||
android:id="@+id/btn_get" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP获取剩余充电时间" /> | |||||
<Button | |||||
android:id="@+id/btn_switch" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="APP切换开关" /> | |||||
<RadioGroup | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal"> | |||||
<RadioButton | |||||
android:id="@+id/rb_open" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:checked="true" | |||||
android:text="开" /> | |||||
<RadioButton | |||||
android:id="@+id/rb_close" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关" /> | |||||
</RadioGroup> | |||||
<Button | |||||
android:id="@+id/btn_version" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:onClick="onClick" | |||||
android:text="APP获取设备版本号" /> | |||||
<Button | |||||
android:id="@+id/btn_test" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:onClick="onClick" | |||||
android:text="开始性能测试" /> | |||||
<TextView | |||||
android:id="@+id/tv_test" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="350dp" /> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<View | |||||
android:layout_width="match_parent" | |||||
android:layout_height="1dp" | |||||
android:background="?android:attr/listDivider" /> | |||||
<ListView | |||||
android:id="@+id/list_view" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" /> | |||||
</LinearLayout> |
<?xml version="1.0" encoding="utf-8"?> | <?xml version="1.0" encoding="utf-8"?> | ||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||||
android:orientation="vertical" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
> | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:focusable="true" | |||||
android:focusableInTouchMode="true" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:padding="10dp"> | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:padding="10dp"> | |||||
<Button | <Button | ||||
android:id="@+id/btn" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/search" | |||||
/> | |||||
android:id="@+id/btn" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/search" /> | |||||
<Button | <Button | ||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/stop" | |||||
/> | |||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/stop" /> | |||||
<Button | <Button | ||||
android:id="@+id/clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/clear" | |||||
/> | |||||
android:id="@+id/clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/clear" | |||||
/> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | |||||
android:padding="5dp"> | |||||
<TextView | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="名字:" /> | |||||
<EditText | |||||
android:id="@+id/et_filter_name" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:padding="5dp" | |||||
android:text="AiLink" /> | |||||
<Button | |||||
android:id="@+id/filter" | |||||
<TextView | |||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="@string/filter" | |||||
/> | |||||
android:text="mac:" /> | |||||
<EditText | |||||
android:id="@+id/et_filter_mac" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1.5" | |||||
android:digits="0123456789abcdefABCDEF" | |||||
android:padding="5dp" | |||||
android:text="" /> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
<ListView | <ListView | ||||
android:id="@+id/listview" | |||||
android:layout_width="match_parent" | |||||
android:padding="10dp" | |||||
android:layout_height="match_parent" | |||||
> | |||||
android:id="@+id/listview" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:padding="10dp"> | |||||
</ListView> | </ListView> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" | |||||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||||
xmlns:tools="http://schemas.android.com/tools" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:gravity="center_horizontal" | |||||
android:orientation="vertical" | |||||
tools:context=".MainActivity"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1"> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:id="@+id/ll_one" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_clear" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空" /> | |||||
<Button | |||||
android:id="@+id/btn_connect" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="连接" /> | |||||
<Button | |||||
android:id="@+id/btn_disconnect" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="断开" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:id="@+id/ll_two" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_heartbeat" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="心跳" /> | |||||
<Button | |||||
android:id="@+id/btn_open_light" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="开灯" /> | |||||
<Button | |||||
android:id="@+id/btn_close_light" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关灯" /> | |||||
<Button | |||||
android:id="@+id/btn_time" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="时间" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:id="@+id/ll_three" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_start_boost" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="助力" /> | |||||
<Button | |||||
android:id="@+id/btn_start_no_boost" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="非助力" /> | |||||
<Button | |||||
android:id="@+id/btn_set_unit_km" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="公里" /> | |||||
<Button | |||||
android:id="@+id/btn_set_unit_mi" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="英里" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:id="@+id/ll_four" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_zero_start" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="0启动" /> | |||||
<Button | |||||
android:id="@+id/btn_no_zero_start" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="非0启动" /> | |||||
<Button | |||||
android:id="@+id/btn_constant_speed" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="定速" /> | |||||
<Button | |||||
android:id="@+id/btn_no_constant_speed" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="不定速" /> | |||||
<Button | |||||
android:id="@+id/btn_reset" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:visibility="gone" | |||||
android:text="清空所有数据" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:id="@+id/ll_five" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_reset_device" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="恢复出厂设置" /> | |||||
<Button | |||||
android:id="@+id/btn_reset_mileage" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空里程" /> | |||||
<Button | |||||
android:id="@+id/btn_reset_time" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空时间" /> | |||||
<Button | |||||
android:id="@+id/btn_set_auto_shutdown_time" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="自动关机时间" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<EditText | |||||
android:id="@+id/et_old_pwd" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:digits="0123456789" | |||||
android:hint="oldPwd" | |||||
android:maxLength="6" | |||||
android:text="123456" /> | |||||
<EditText | |||||
android:id="@+id/et_new_pwd" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:digits="0123456789" | |||||
android:hint="newPwd" | |||||
android:maxLength="6" | |||||
android:text="123456" /> | |||||
<Button | |||||
android:id="@+id/btn_setLockCarPassword" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="修改密码" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_read_auto_shutdown_time" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读自动关机时间" /> | |||||
<Button | |||||
android:id="@+id/btn_gear_speed" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="设置档位速度" /> | |||||
<Button | |||||
android:id="@+id/btn_setMeterBackLight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="设置背光" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_setControllerTime" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="设置控制器的实时时间" /> | |||||
<Button | |||||
android:id="@+id/btn_readControllerTime" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读取控制器的时间" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_readControllerSingleMileage" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读取控制器单次行驶里程" /> | |||||
<Button | |||||
android:id="@+id/btn_readControllerAllMileage" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读取控制器总行驶里程" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_readControllerTemp" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读取控制器温度" /> | |||||
<Button | |||||
android:id="@+id/btn_readControllerDrivingCurrent" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读取控制器行驶电流" /> | |||||
<Button | |||||
android:id="@+id/btn_readControllerVoltage" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读电压" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_readAllPower" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读总容量" /> | |||||
<Button | |||||
android:id="@+id/btn_readLastPower" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读剩余容量" /> | |||||
<Button | |||||
android:id="@+id/btn_readBatteryDischargeNumber" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读充放电次数" /> | |||||
<Button | |||||
android:id="@+id/btn_readBatteryCode" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读电池信息" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_readCompanyVersion" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读版本" /> | |||||
<Button | |||||
android:id="@+id/btn_readMotorPulse" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读电机脉冲" /> | |||||
<Button | |||||
android:id="@+id/btn_readMotorPulseInterval" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读电机脉冲间隔" /> | |||||
<Button | |||||
android:id="@+id/btn_readMotorParameter" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读电机参数" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_readWheelSize" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读车轮尺寸" /> | |||||
<Button | |||||
android:id="@+id/btn_readFlashDataVersion" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读FLASH版本" /> | |||||
<Button | |||||
android:id="@+id/btn_readBootloaderVersion" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读Boot版本" /> | |||||
<Button | |||||
android:id="@+id/btn_readMeterBackLight" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读背光亮度" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_setAutoNightMode" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="夜间模式" /> | |||||
<Button | |||||
android:id="@+id/btn_readNightMode" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读夜间模式" /> | |||||
<Button | |||||
android:id="@+id/btn_setCallPhone" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="来电" /> | |||||
<Button | |||||
android:id="@+id/btn_setSMSData" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="短信" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_setSoftwareData" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="清空消息" /> | |||||
<Button | |||||
android:id="@+id/btn_readBlePassword" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="密码查询" /> | |||||
<Button | |||||
android:id="@+id/btn_setNavigationMessage" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="导航推送" /> | |||||
<Button | |||||
android:id="@+id/btn_setResetCmd" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="重置指令" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_setLockCar" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="锁车/解锁" /> | |||||
<Button | |||||
android:id="@+id/btn_readServicePassword" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="售后密码" /> | |||||
<Button | |||||
android:id="@+id/btn_setWeather" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="天气信息推送" /> | |||||
<Button | |||||
android:id="@+id/btn_update_conditions" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="升级条件" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_setDeviceLanguage" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="设置语言" /> | |||||
<Button | |||||
android:id="@+id/btn_getDeviceImageFontVersion" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读字库版本" /> | |||||
<Button | |||||
android:id="@+id/btn_getControllerVersion" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读控制器版本" /> | |||||
<Button | |||||
android:id="@+id/btn_getTpVersion" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读TP版本" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_setPair" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="配对" /> | |||||
<Button | |||||
android:id="@+id/btn_checkPwd" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="验证密码" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ota_boot" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="表头boot" /> | |||||
<Button | |||||
android:id="@+id/btn_ota_app" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="表头APP" /> | |||||
<Button | |||||
android:id="@+id/btn_ota_flash" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="表头flash" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ota_app_controller" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="控制器APP" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ota_type" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="静默升级" /> | |||||
<Button | |||||
android:id="@+id/btn_ble" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="BLE_OTA" /> | |||||
<Button | |||||
android:id="@+id/btn_ble_version" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="Ble_V" /> | |||||
<EditText | |||||
android:id="@+id/et_ble_ota_step" | |||||
android:layout_width="50dp" | |||||
android:layout_height="wrap_content" | |||||
android:text="" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_get_test_status" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="读测试状态" /> | |||||
<Button | |||||
android:id="@+id/btn_go_setProductionTest" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="进入整机测试" /> | |||||
<Button | |||||
android:id="@+id/btn_exit_setProductionTest" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="退出整机测试" /> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<ListView | |||||
android:id="@+id/listviewData" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" | |||||
android:padding="10dp" | |||||
android:stackFromBottom="true" | |||||
android:transcriptMode="alwaysScroll"> | |||||
</ListView> | |||||
</androidx.appcompat.widget.LinearLayoutCompat> |
<?xml version="1.0" encoding="utf-8"?> | |||||
<androidx.appcompat.widget.LinearLayoutCompat xmlns:android="http://schemas.android.com/apk/res/android" | |||||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||||
xmlns:tools="http://schemas.android.com/tools" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="match_parent" | |||||
android:gravity="center_horizontal" | |||||
android:orientation="vertical" | |||||
tools:context=".MainActivity"> | |||||
<ScrollView | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:paddingBottom="10dp" | |||||
android:orientation="vertical"> | |||||
<LinearLayout | |||||
android:id="@+id/ll_two" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
android:orientation="horizontal" | |||||
android:gravity="center_vertical" | |||||
> | |||||
<Button | |||||
android:id="@+id/btn_open_light" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/open_light" /> | |||||
<Button | |||||
android:id="@+id/btn_close_light" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="@string/close_light" /> | |||||
<TextView | |||||
android:id="@+id/tv_ota_version" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="v" | |||||
/> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ota_app" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:layout_weight="1" | |||||
android:text="@string/upgrade_watch" /> | |||||
<Button | |||||
android:id="@+id/btn_check_version" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_weight="1" | |||||
android:layout_marginTop="10dp" | |||||
/> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content"> | |||||
<Button | |||||
android:id="@+id/btn_ota_app_controller" | |||||
android:layout_width="0dp" | |||||
android:layout_height="wrap_content" | |||||
android:layout_marginTop="10dp" | |||||
android:layout_weight="1" | |||||
android:text="@string/upgrade_controller" /> | |||||
</LinearLayout> | |||||
</LinearLayout> | |||||
</ScrollView> | |||||
<ListView | |||||
android:id="@+id/listviewData" | |||||
android:layout_width="match_parent" | |||||
android:layout_height="0dp" | |||||
android:layout_weight="1" | |||||
android:padding="10dp" | |||||
android:stackFromBottom="true" | |||||
android:transcriptMode="alwaysScroll"> | |||||
</ListView> | |||||
</androidx.appcompat.widget.LinearLayoutCompat> |
<ScrollView | <ScrollView | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="0dp" | android:layout_height="0dp" | ||||
android:layout_weight="0.5"> | |||||
android:layout_weight="0.39"> | |||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | |||||
> | |||||
<Button | <Button | ||||
android:id="@+id/clear" | android:id="@+id/clear" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="获取版本" | android:text="获取版本" | ||||
android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
<Button | |||||
android:id="@+id/get_AIQ" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="IAQ数据" | |||||
android:textAllCaps="false" /> | |||||
<Button | |||||
android:id="@+id/close_power" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="关闭电源" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
<LinearLayout | <LinearLayout | ||||
android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | |||||
> | |||||
<Button | <Button | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="风扇控制" | android:text="风扇控制" | ||||
android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
<Button | |||||
android:id="@+id/set_mode" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="测试模式" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | |||||
<LinearLayout | |||||
android:layout_width="match_parent" | |||||
android:layout_height="wrap_content" | |||||
> | |||||
<Button | |||||
android:id="@+id/set_payload" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="显示payload" | |||||
android:textAllCaps="false" /> | |||||
</LinearLayout> | </LinearLayout> | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | android:padding="10dp"> | ||||
<EditText | |||||
android:id="@+id/et_type" | |||||
android:layout_width="200dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="透传数据" | |||||
android:text="4" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="发送" | |||||
/> | |||||
<Button | <Button | ||||
android:id="@+id/clear" | android:id="@+id/clear" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:text="@string/clear" | |||||
android:text="清空" | |||||
/> | /> | ||||
</LinearLayout> | </LinearLayout> | ||||
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | android:padding="10dp"> | ||||
<EditText | |||||
android:id="@+id/et_type" | |||||
android:layout_width="200dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="透传数据" | |||||
android:text="4" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="发送" | |||||
/> | |||||
<Button | <Button | ||||
android:id="@+id/clear" | android:id="@+id/clear" |
android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
android:padding="10dp"> | android:padding="10dp"> | ||||
<EditText | |||||
android:id="@+id/et_type" | |||||
android:layout_width="200dp" | |||||
android:layout_height="wrap_content" | |||||
android:hint="透传数据" | |||||
android:text="4" | |||||
/> | |||||
<Button | |||||
android:id="@+id/btn1" | |||||
android:layout_width="wrap_content" | |||||
android:layout_height="wrap_content" | |||||
android:text="发送" | |||||
/> | |||||
<Button | <Button | ||||
android:id="@+id/clear" | android:id="@+id/clear" | ||||
android:layout_width="wrap_content" | android:layout_width="wrap_content" |