| apply plugin: 'com.android.application' | apply plugin: 'com.android.application' | ||||
| apply plugin: 'com.jakewharton.butterknife' | apply plugin: 'com.jakewharton.butterknife' | ||||
| android { | android { | ||||
| compileSdkVersion 33 | |||||
| compileSdkVersion 34 | |||||
| defaultConfig { | defaultConfig { | ||||
| applicationId "aicare.net.cn.sdk.ailinksdkdemoandroid" | applicationId "aicare.net.cn.sdk.ailinksdkdemoandroid" | ||||
| minSdkVersion 21 | minSdkVersion 21 | ||||
| targetSdkVersion 33 | |||||
| versionName "1.11.14" | |||||
| targetSdkVersion 34 | |||||
| versionName "1.15.05" | |||||
| versionCode getVersionCodeNumber(versionName) | versionCode getVersionCodeNumber(versionName) | ||||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
| } | } | ||||
| } | } | ||||
| compileOptions { | compileOptions { | ||||
| sourceCompatibility '1.8' | |||||
| targetCompatibility '1.8' | |||||
| sourceCompatibility JavaVersion.VERSION_1_8 | |||||
| targetCompatibility JavaVersion.VERSION_1_8 | |||||
| } | } | ||||
| repositories { | repositories { | ||||
| implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | implementation 'androidx.constraintlayout:constraintlayout:2.0.4' | ||||
| implementation 'androidx.cardview:cardview:1.0.0' | implementation 'androidx.cardview:cardview:1.0.0' | ||||
| testImplementation 'junit:junit:4.12' | testImplementation 'junit:junit:4.12' | ||||
| implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.14.6'//蓝牙核心库 | |||||
| //OTA库,需要依赖核心库 | |||||
| // implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.1.6' | |||||
| implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.9.4'//蓝牙解析库 | |||||
| implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.14.17'//蓝牙核心库 | |||||
| implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.9.6'//蓝牙解析库,需要依赖核心库 | |||||
| implementation 'com.github.elinkthings:AILinkMqttRepositoryAndroid:1.2.0'//MQTT库 | |||||
| implementation 'androidx.recyclerview:recyclerview:1.3.2' | implementation 'androidx.recyclerview:recyclerview:1.3.2' | ||||
| implementation 'com.jakewharton:butterknife:10.2.3' | implementation 'com.jakewharton:butterknife:10.2.3' | ||||
| annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' | annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.3' |
| <activity android:name=".ClearShakeHandsActivity" /> | <activity android:name=".ClearShakeHandsActivity" /> | ||||
| <activity android:name=".ShowBleActivity" /> | <activity android:name=".ShowBleActivity" /> | ||||
| <activity android:name=".BabyCmdActivity" /> | <activity android:name=".BabyCmdActivity" /> | ||||
| <activity android:name=".TempGunCmdActivity" /> | <activity android:name=".TempGunCmdActivity" /> | ||||
| <activity android:name=".ConnectBleTestActivity" /> | <activity android:name=".ConnectBleTestActivity" /> | ||||
| <activity android:name=".ADWeightScaleCmdActivity" /> | <activity android:name=".ADWeightScaleCmdActivity" /> | ||||
| <activity android:name=".ADWeightScaleUserActivity" /> | <activity android:name=".ADWeightScaleUserActivity" /> | ||||
| <activity android:name=".modules.wifi_ble_scale.WeightScaleWifiBleActivity" /> | |||||
| <activity android:name=".WeightScaleBleActivity" /> | <activity android:name=".WeightScaleBleActivity" /> | ||||
| <activity android:name=".WifiConfigActivity" /> | <activity android:name=".WifiConfigActivity" /> | ||||
| <activity android:name=".EightBodyfatActivity" /> | |||||
| <activity android:name=".modules.eight_bodyfat.EightBodyfatActivity" /> | |||||
| <activity android:name=".modules.blood_glucose.BloodGlucoseActivity" /> | <activity android:name=".modules.blood_glucose.BloodGlucoseActivity" /> | ||||
| <activity android:name=".BabyBodyFatCmdActivity" /> | <activity android:name=".BabyBodyFatCmdActivity" /> | ||||
| <activity android:name=".BroadcastScaleActivity" /> | <activity android:name=".BroadcastScaleActivity" /> | ||||
| android:name=".modules.barometric_temp_humidity.BarometricTempHygrometerActivity" | android:name=".modules.barometric_temp_humidity.BarometricTempHygrometerActivity" | ||||
| android:screenOrientation="portrait" /> | android:screenOrientation="portrait" /> | ||||
| <activity android:name=".modules.wifible_sphy.WifiBleSphyActivity" /> | <activity android:name=".modules.wifible_sphy.WifiBleSphyActivity" /> | ||||
| <activity android:name=".modules.wifi_ble_scale.WeightScaleWifiBleActivity" /> | |||||
| <activity android:name=".modules.BleDemoActivity" /> | |||||
| <activity android:name=".modules.PublicWifiBleOtaActivity" /> | <activity android:name=".modules.PublicWifiBleOtaActivity" /> | ||||
| <activity android:name=".modules.eight_bodyfat.dual_band.EightDoubleBodyfatActivity" /> | |||||
| <activity android:name=".modules.PublicMqttActivity" /> | |||||
| <activity | |||||
| android:name=".modules.bw05watch.Bw05WatchActivity" | |||||
| android:screenOrientation="portrait" /> | |||||
| <activity android:name=".modules.ble_nutrition.BleNutritionNutrientActivity" /> | |||||
| <activity android:name=".modules.eight_bodyfat.EightBodyFatMcuActivity" /> | |||||
| <activity android:name=".modules.gasDetector.GasDetectorActivity" /> | |||||
| <provider | <provider | ||||
| android:name="androidx.core.content.FileProvider" | android:name="androidx.core.content.FileProvider" | ||||
| android:name="android.support.FILE_PROVIDER_PATHS" | android:name="android.support.FILE_PROVIDER_PATHS" | ||||
| android:resource="@xml/file_paths" /> | android:resource="@xml/file_paths" /> | ||||
| </provider> | </provider> | ||||
| <service android:name="com.pingwang.bluetoothlib.server.ELinkBleServer"/> | |||||
| <service | |||||
| android:name="org.eclipse.paho.android.service.MqttService" | |||||
| android:enabled="true" | |||||
| android:exported="true"></service> | |||||
| </application> | </application> | ||||
| </manifest> | </manifest> |
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
| import androidx.appcompat.app.AppCompatActivity; | import androidx.appcompat.app.AppCompatActivity; | ||||
| 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; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.AppBaseActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.base.AppBaseActivity; | ||||
| /** | /** | ||||
| * xing<br> | * xing<br> | ||||
| * 2022/4/6<br> | * 2022/4/6<br> |
| 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.listener.CallbackDisIm; | |||||
| import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | import com.pingwang.bluetoothlib.listener.OnBleCompanyListener; | ||||
| import com.pingwang.bluetoothlib.listener.OnBleDeviceDataListener; | import com.pingwang.bluetoothlib.listener.OnBleDeviceDataListener; | ||||
| import com.pingwang.bluetoothlib.listener.OnBleErrListener; | import com.pingwang.bluetoothlib.listener.OnBleErrListener; | ||||
| 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); | ||||
| bleDataUtils = BleDataUtils.getInstance(); | bleDataUtils = BleDataUtils.getInstance(); | ||||
| findViewById(R.id.btnClear).setOnClickListener(this); | |||||
| findViewById(R.id.btnClearShakeHands).setOnClickListener(this); | |||||
| findViewById(R.id.btnPause).setOnClickListener(this); | findViewById(R.id.btnPause).setOnClickListener(this); | ||||
| findViewById(R.id.btnHandshake).setOnClickListener(this); | findViewById(R.id.btnHandshake).setOnClickListener(this); | ||||
| findViewById(R.id.btnVersion).setOnClickListener(this); | findViewById(R.id.btnVersion).setOnClickListener(this); | ||||
| mAILinkBleManager.connectDevice(new BleValueBean(mAddress, mCid, mVid, mPid)); | mAILinkBleManager.connectDevice(new BleValueBean(mAddress, mCid, mVid, mPid)); | ||||
| addShowData("连接设备"); | addShowData("连接设备"); | ||||
| break; | break; | ||||
| case R.id.btnClear: | |||||
| case R.id.btnClearShakeHands: | |||||
| if (mList != null) | if (mList != null) | ||||
| mList.clear(); | mList.clear(); | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| sendData(sendBleBean); | sendData(sendBleBean); | ||||
| break; | break; | ||||
| case R.id.btnBroadcastTimeWrite: | 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); | |||||
| try { | |||||
| int time = Integer.parseInt(etBroadcastTime.getText().toString().trim()); | |||||
| byte[] broadcastTime = bleDataUtils.getBroadcastTime(time); | |||||
| sendBleBean = new SendBleBean(); | |||||
| sendBleBean.setHex(mBleSendCmdUtil.setBleBroadcastTime(broadcastTime)); | |||||
| sendData(sendBleBean); | |||||
| } catch (NumberFormatException e) { | |||||
| e.printStackTrace(); | |||||
| Toast.makeText(this, "请输入正确的广播时间", Toast.LENGTH_SHORT).show(); | |||||
| } | |||||
| break; | break; | ||||
| case R.id.btnDidRead: | case R.id.btnDidRead: | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| addShowData("服务与界面建立连接成功"); | addShowData("服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | mAILinkBleManager.setOnCallbackBle(this); | ||||
| mAILinkBleManager.deviceConnectListener(mAddress, true); | mAILinkBleManager.deviceConnectListener(mAddress, true); | ||||
| connectSuccess(); | connectSuccess(); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| CallbackDisIm.getInstance().removeListener(this); | |||||
| mAILinkBleManager.disconnectAll(); | mAILinkBleManager.disconnectAll(); | ||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mAILinkBleManager.removeOnCallbackBle(this); | mAILinkBleManager.removeOnCallbackBle(this); | ||||
| @Override | @Override | ||||
| public void onDisConnected(@NonNull String mac, int code) { | public void onDisConnected(@NonNull String mac, int code) { | ||||
| //TODO 连接断开 | //TODO 连接断开 | ||||
| L.iw(TAG, "连接断开"); | |||||
| L.i( "连接断开"); | |||||
| if (mAddress.equals(mac)) { | if (mAddress.equals(mac)) { | ||||
| Toast.makeText(mContext, "连接断开:" + code, Toast.LENGTH_SHORT).show(); | Toast.makeText(mContext, "连接断开:" + code, Toast.LENGTH_SHORT).show(); | ||||
| mBleDevice = null; | mBleDevice = null; | ||||
| @Override | @Override | ||||
| public void onBleBroadcastTime(int time) { | public void onBleBroadcastTime(int time) { | ||||
| addShowData("广播间隔:" + time); | addShowData("广播间隔:" + time); | ||||
| if (etBroadcastTime != null) { | |||||
| etBroadcastTime.setText(String.valueOf(time)); | |||||
| } | |||||
| } | } | ||||
| @Override | @Override | ||||
| "\n设备版本:" + mDeviceVersion + | "\n设备版本:" + mDeviceVersion + | ||||
| "\n设备:CID=0x" + Integer.toHexString(mCid) + " VID=0x" + Integer.toHexString(mVid) + " PID=0x" + Integer.toHexString(mPid) + | "\n设备:CID=0x" + Integer.toHexString(mCid) + " VID=0x" + Integer.toHexString(mVid) + " PID=0x" + Integer.toHexString(mPid) + | ||||
| "\n手机型号:" + AppPhoneInfoUtils.getPhoneInfo() + " " + AppPhoneInfoUtils.getBrand() + | "\n手机型号:" + AppPhoneInfoUtils.getPhoneInfo() + " " + AppPhoneInfoUtils.getBrand() + | ||||
| "\n手机系统:" + AppPhoneInfoUtils.getSystemVersionString()+ | |||||
| "\n手机系统:" + AppPhoneInfoUtils.getSystemVersionString() + | |||||
| "\n手机电量:" + systemBattery; | "\n手机电量:" + systemBattery; | ||||
| L.iw(appData); | L.iw(appData); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| mDevice = BroadcastScaleDeviceData.getInstance(); | mDevice = BroadcastScaleDeviceData.getInstance(); | ||||
| mDevice.setOnNotifyData(this); | mDevice.setOnNotifyData(this); | ||||
| AILinkBleManager.getInstance().setOnBleBroadcastDataListener(this); | |||||
| AILinkBleManager.getInstance().addOnBleBroadcastDataListener(this); | |||||
| AILinkBleManager.getInstance().startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | AILinkBleManager.getInstance().startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | ||||
| } | } | ||||
| mDevice.clear(); | mDevice.clear(); | ||||
| mDevice = null; | mDevice = null; | ||||
| } | } | ||||
| AILinkBleManager.getInstance().removeOnBleBroadcastDataListener(this); | |||||
| } | } | ||||
| private BleDevice mBleDevice; | private BleDevice mBleDevice; | ||||
| private String mAddress; | private String mAddress; | ||||
| private BleSendCmdUtil mBleSendCmdUtil; | private BleSendCmdUtil mBleSendCmdUtil; | ||||
| private int type=0x01; | |||||
| private int mCid = 0x01; | |||||
| private byte unit = 0; | private byte unit = 0; | ||||
| private boolean mPauseRefresh = 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) { | ||||
| setContentView(R.layout.activity_clear_shake_hands); | setContentView(R.layout.activity_clear_shake_hands); | ||||
| mContext = this; | mContext = this; | ||||
| mAddress = getIntent().getStringExtra("mac"); | mAddress = getIntent().getStringExtra("mac"); | ||||
| type = getIntent().getIntExtra("type", -1); | |||||
| mCid = getIntent().getIntExtra("cid", -1); | |||||
| mBleSendCmdUtil = BleSendCmdUtil.getInstance(); | mBleSendCmdUtil = BleSendCmdUtil.getInstance(); | ||||
| init(); | init(); | ||||
| 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); | ||||
| findViewById(R.id.btnPause).setOnClickListener(this); | |||||
| findViewById(R.id.btn_set_unit).setOnClickListener(this); | findViewById(R.id.btn_set_unit).setOnClickListener(this); | ||||
| findViewById(R.id.btn1).setOnClickListener(this); | findViewById(R.id.btn1).setOnClickListener(this); | ||||
| findViewById(R.id.clear).setOnClickListener(this); | findViewById(R.id.clear).setOnClickListener(this); | ||||
| findViewById(R.id.btnClearShakeHands).setOnClickListener(this); | |||||
| et_type = findViewById(R.id.et_type); | et_type = findViewById(R.id.et_type); | ||||
| } | } | ||||
| } | } | ||||
| break; | break; | ||||
| case R.id.btnPause: | |||||
| mPauseRefresh = !mPauseRefresh; | |||||
| break; | |||||
| case R.id.btn1: | case R.id.btn1: | ||||
| String cmd = et_type.getText().toString().trim(); | String cmd = et_type.getText().toString().trim(); | ||||
| byte[] bytes=new byte[cmd.length()/2]; | |||||
| for (int i=0;i<=cmd.length()-2;i+=2){ | |||||
| 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); | int i1 = Integer.parseInt(cmd.substring(i, i + 2), 16); | ||||
| bytes[i>>1]=(byte)i1; | |||||
| bytes[i >> 1] = (byte) i1; | |||||
| } | } | ||||
| SendMcuBean sendDataBean = new SendMcuBean(); | SendMcuBean sendDataBean = new SendMcuBean(); | ||||
| sendDataBean.setHex(type,bytes); | |||||
| sendDataBean.setHex(mCid, bytes); | |||||
| mBleDevice.sendData(sendDataBean); | mBleDevice.sendData(sendDataBean); | ||||
| mList.add(TimeUtils.getTime() + "发送->" + BleStrUtils.byte2HexStr(bytes)); | |||||
| mList.add(TimeUtils.getTime() + "发送(A7)->" + BleStrUtils.byte2HexStr(bytes)); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| break; | break; | ||||
| case R.id.clear: | case R.id.clear: | ||||
| mList.clear(); | mList.clear(); | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| break; | break; | ||||
| case R.id.btnClearShakeHands: | |||||
| byte[] send = mBleSendCmdUtil.setClearShakeHands(); | |||||
| SendBleBean sendBleBean = new SendBleBean(); | |||||
| sendBleBean.setHex(send); | |||||
| mBleDevice.sendData(sendBleBean); | |||||
| mList.add(TimeUtils.getTime() + "发送(A6)->" + BleStrUtils.byte2HexStr(send)); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| data[1] = unit; | data[1] = unit; | ||||
| sendMcuBean.setHex(0x01, data); | sendMcuBean.setHex(0x01, data); | ||||
| mBleDevice.sendData(sendMcuBean); | mBleDevice.sendData(sendMcuBean); | ||||
| mList.add(TimeUtils.getTime() + "发送->" + BleStrUtils.byte2HexStr(data)); | |||||
| mList.add(TimeUtils.getTime() + "发送(A7)->" + BleStrUtils.byte2HexStr(data)); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| } | } | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mBleDevice = mAILinkBleManager.getBleDevice(mAddress); | mBleDevice = mAILinkBleManager.getBleDevice(mAddress); | ||||
| //设置不加密 | |||||
| mBleDevice.setA7Encryption(false); | mBleDevice.setA7Encryption(false); | ||||
| mBleDevice.setOnBleDeviceDataListener(ClearShakeHandsActivity.this); | mBleDevice.setOnBleDeviceDataListener(ClearShakeHandsActivity.this); | ||||
| mBleDevice.setOnBleVersionListener(ClearShakeHandsActivity.this); | mBleDevice.setOnBleVersionListener(ClearShakeHandsActivity.this); | ||||
| mBleDevice.setOnBleOtherDataListener(ClearShakeHandsActivity.this); | mBleDevice.setOnBleOtherDataListener(ClearShakeHandsActivity.this); | ||||
| byte[] bytes = mBleSendCmdUtil.setClearShakeHands(); | |||||
| SendBleBean sendBleBean=new SendBleBean(); | |||||
| sendBleBean.setHex(bytes); | |||||
| mBleDevice.sendData(sendBleBean); | |||||
| mBleDevice.sendData(new SendBleBean(mBleSendCmdUtil.getBleVersion())); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onNotifyData(String uuid, byte[] hex, int type) { | public void onNotifyData(String uuid, byte[] hex, int type) { | ||||
| mList.add(TimeUtils.getTime() + "notify->" + BleStrUtils.byte2HexStr(hex)); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| addData("notify(A7)->" + BleStrUtils.byte2HexStr(hex)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onNotifyDataA6(byte[] hex) { | |||||
| mList.add(TimeUtils.getTime() + "notify->" + BleStrUtils.byte2HexStr(hex)); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| public void onNotifyDataA6(String uuid, byte[] hex) { | |||||
| addData("notify(A6)->" + BleStrUtils.byte2HexStr(hex)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onNotifyOtherData(byte[] data) { | |||||
| mList.add(TimeUtils.getTime() + "notify->" + BleStrUtils.byte2HexStr(data)); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| public void onNotifyOtherData(String uuid, byte[] data) { | |||||
| addData("notify(透传)->" + BleStrUtils.byte2HexStr(data)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onBmVersion(String version) { | public void onBmVersion(String version) { | ||||
| mList.add(TimeUtils.getTime() + "版本号:" + version); | |||||
| addData("版本号:" + version); | |||||
| } | |||||
| private void addData(String data) { | |||||
| if (mPauseRefresh) | |||||
| return; | |||||
| mList.add(TimeUtils.getTime() + "->" + data); | |||||
| 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.base.BleBaseActivity; | |||||
| 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.base.BleBaseActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
| import cn.net.aicare.modulelibrary.module.height.HeightDeviceData; | import cn.net.aicare.modulelibrary.module.height.HeightDeviceData; | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| logList.add(0, "绑定服务成功"); | |||||
| addText(0, "绑定服务成功"); | |||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mAILinkBleManager.setOnCallbackBle(this); | mAILinkBleManager.setOnCallbackBle(this); | ||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mAILinkBleManager !=null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | mAILinkBleManager.removeOnCallbackBle(this); | ||||
| } | } | ||||
| } | } | ||||
| listView = findViewById(R.id.listView); | listView = findViewById(R.id.listView); | ||||
| mMHandler = new WeakReference<>(new MHandler()).get(); | mMHandler = new WeakReference<>(new MHandler()).get(); | ||||
| findViewById(R.id.btnPause).setOnClickListener(this); | |||||
| findViewById(R.id.kg).setOnClickListener(this); | findViewById(R.id.kg).setOnClickListener(this); | ||||
| findViewById(R.id.jin).setOnClickListener(this); | findViewById(R.id.jin).setOnClickListener(this); | ||||
| findViewById(R.id.st_lb).setOnClickListener(this); | findViewById(R.id.st_lb).setOnClickListener(this); | ||||
| @Override | @Override | ||||
| public void onDisConnected(String mac, int code) { | public void onDisConnected(String mac, int code) { | ||||
| if (mac.equals(mAddress)) { | if (mac.equals(mAddress)) { | ||||
| logList.add(0, "连接已经断开"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "连接已经断开"); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onVersion(String version) { | public void onVersion(String version) { | ||||
| logList.add(0, "版本号:" + version); | |||||
| addText(0, "版本号:" + version); | |||||
| } | } | ||||
| case HeightBodyFatBleUntils.MCU_SET_USER_RESULT: | case HeightBodyFatBleUntils.MCU_SET_USER_RESULT: | ||||
| mMHandler.removeMessages(SETUSER); | mMHandler.removeMessages(SETUSER); | ||||
| logList.add(0, "下发用户结果:" + resultStr); | |||||
| addText(0, "下发用户结果:" + resultStr); | |||||
| break; | break; | ||||
| case HeightBodyFatBleUntils.MCU_SET_UNIT_RESULT: | case HeightBodyFatBleUntils.MCU_SET_UNIT_RESULT: | ||||
| if (result == 0) { | if (result == 0) { | ||||
| if (currentHUnit == 0) { | if (currentHUnit == 0) { | ||||
| } | } | ||||
| text.setText("体重单位: " + currentWUnit + | |||||
| "\n身高单位: " + currentHUnit + | |||||
| text.setText("体重单位: " + getWeightUnitStr(currentWUnit) + | |||||
| "\n身高单位: " + getHeightUnitStr(currentHUnit) + | |||||
| "\n模式:" + currentMode + " 声音: " + currentVoice); | "\n模式:" + currentMode + " 声音: " + currentVoice); | ||||
| } | } | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| logList.add(0, "设置单位结果:" + resultStr); | |||||
| addText(0, "设置单位结果:" + resultStr); | |||||
| break; | break; | ||||
| case HeightBodyFatBleUntils.MCU_SET_WORK_MODE_RESULT: | case HeightBodyFatBleUntils.MCU_SET_WORK_MODE_RESULT: | ||||
| if (result == 0) { | if (result == 0) { | ||||
| currentMode = selectMode; | currentMode = selectMode; | ||||
| text.setText("体重单位: " + currentWUnit + | |||||
| "\n身高单位: " + currentHUnit + | |||||
| text.setText("体重单位: " + getWeightUnitStr(currentWUnit) + | |||||
| "\n身高单位: " + getHeightUnitStr(currentHUnit) + | |||||
| "\n模式:" + currentMode + " 声音: " + currentVoice); | "\n模式:" + currentMode + " 声音: " + currentVoice); | ||||
| } | } | ||||
| mMHandler.removeMessages(SETMODE); | mMHandler.removeMessages(SETMODE); | ||||
| logList.add(0, "设置工作模式:" + resultStr); | |||||
| addText(0, "设置工作模式:" + resultStr); | |||||
| break; | break; | ||||
| case HeightBodyFatBleUntils.MUC_REQUEST_VOICE_SET_RESULT: | case HeightBodyFatBleUntils.MUC_REQUEST_VOICE_SET_RESULT: | ||||
| if (result == 0) { | if (result == 0) { | ||||
| currentVoice = selectVoice; | currentVoice = selectVoice; | ||||
| text.setText("体重单位: " + currentWUnit + | |||||
| "\n身高单位: " + currentHUnit + | |||||
| text.setText("体重单位: " + getWeightUnitStr(currentWUnit) + | |||||
| "\n身高单位: " + getHeightUnitStr(currentHUnit) + | |||||
| "\n模式:" + currentMode + " 声音: " + currentVoice); | "\n模式:" + currentMode + " 声音: " + currentVoice); | ||||
| } | } | ||||
| mMHandler.removeMessages(VOICE); | mMHandler.removeMessages(VOICE); | ||||
| logList.add(0, "设置声音结果:" + resultStr); | |||||
| addText(0, "设置声音结果:" + resultStr); | |||||
| break; | break; | ||||
| default:break; | |||||
| default: | |||||
| break; | |||||
| } | } | ||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onMcuRequestUser() { | public void onMcuRequestUser() { | ||||
| logList.add(0, "请求下发用户,点击下发用户"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "请求下发用户,点击下发用户"); | |||||
| } | } | ||||
| text.setText("体重单位: " + currentWUnit + | text.setText("体重单位: " + currentWUnit + | ||||
| "\n身高单位: " + currentHUnit + | "\n身高单位: " + currentHUnit + | ||||
| "\n模式:" + currentMode + " 声音: " + currentVoice); | "\n模式:" + currentMode + " 声音: " + currentVoice); | ||||
| logList.add(0, "体重状态 模式:" + workMode + " 电池电量: " + battery + " 电池状态: " + batteryStatus | |||||
| + "\n 体重单位: " + weightUnit + " 身高单位: " + heightUnit + " 声音状态: " + voice); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "体重状态 模式:" + workMode + " 电池电量: " + battery + " 电池状态: " + batteryStatus | |||||
| + "\n 体重单位: " + getWeightUnitStr(weightUnit) + " 身高单位: " + getHeightUnitStr(heightUnit) + " 声音状态: " + voice); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onWeightBodyFat(int workMode, int weightMode, int weight, int decimals, int unit) { | public void onWeightBodyFat(int workMode, int weightMode, int weight, int decimals, int unit) { | ||||
| logList.add(0, "体重体脂 模式:" + workMode + " 测量状态: " + weightMode + "\n 体重: " + weight | |||||
| + " 小数位: " + decimals + " 单位: " + unit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "体重体脂 模式:" + workMode + " 测量状态: " + weightMode + "\n 体重: " + weight | |||||
| + " 小数位: " + decimals + " 单位: " + getWeightUnitStr(unit)); | |||||
| if (weightMode == 2) { | if (weightMode == 2) { | ||||
| mMHandler.removeMessages(ADC); | mMHandler.removeMessages(ADC); | ||||
| mMHandler.removeMessages(FINISH); | mMHandler.removeMessages(FINISH); | ||||
| @Override | @Override | ||||
| public void onWeightBaby(int workMode, int weightMode, int adultWeight, int adultBabyWeight, int babyWeight, int decimals, int unit) { | 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(); | |||||
| addText(0, "抱婴体重 模式:" + workMode + " 测量状态:" + weightMode + " 成人体重:" + adultWeight + | |||||
| "\n 抱婴体重:" + adultBabyWeight + " 婴儿体重:" + babyWeight + " 小数位:" + decimals + " 单位" + getWeightUnitStr(unit)); | |||||
| if (weightMode == 2) { | if (weightMode == 2) { | ||||
| mMHandler.removeMessages(FINISH); | mMHandler.removeMessages(FINISH); | ||||
| @Override | @Override | ||||
| public void onWeight(int workMode, int weightMode, int weight, int decimals, int unit) { | public void onWeight(int workMode, int weightMode, int weight, int decimals, int unit) { | ||||
| logList.add(0, "体重 模式:" + workMode + " 测量状态: " + weightMode + "\n 体重: " + weight | |||||
| + " 小数位: " + decimals + " 单位: " + unit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "体重 模式:" + workMode + " 测量状态: " + weightMode + "\n 体重: " + weight | |||||
| + " 小数位: " + decimals + " 单位: " + getWeightUnitStr(unit)); | |||||
| if (weightMode == 2) { | if (weightMode == 2) { | ||||
| mMHandler.removeMessages(FINISH); | mMHandler.removeMessages(FINISH); | ||||
| mMHandler.sendEmptyMessageDelayed(FINISH, 40000); | mMHandler.sendEmptyMessageDelayed(FINISH, 40000); | ||||
| } | } | ||||
| if (mHeightBodyFatUser!=null) { | |||||
| if (mHeightBodyFatUser != null) { | |||||
| mHeightBodyFatUser.setWeight(weight); | mHeightBodyFatUser.setWeight(weight); | ||||
| mHeightBodyFatUser.setDecimals(decimals); | mHeightBodyFatUser.setDecimals(decimals); | ||||
| @Override | @Override | ||||
| public void onAdc(int workMode, int status, int adcType, long adc, int arithmetic) { | public void onAdc(int workMode, int status, int adcType, long adc, int arithmetic) { | ||||
| mMHandler.removeMessages(ADC); | mMHandler.removeMessages(ADC); | ||||
| logList.add(0, "阻抗数据 模式:" + workMode + " 测量状态: " + status + "\n 阻抗类型: " + adcType | |||||
| addText(0, "阻抗数据 模式:" + workMode + " 测量状态: " + status + "\n 阻抗类型: " + adcType | |||||
| + " 阻抗: " + adc + " 算法位: " + arithmetic); | + " 阻抗: " + adc + " 算法位: " + arithmetic); | ||||
| // arithmetic | // arithmetic | ||||
| String weightToKg = AllUnitUtils.getWeightToKg(mHeightBodyFatUser.getUnit(), String.valueOf(mHeightBodyFatUser.getWeight()), mHeightBodyFatUser.getDecimals()); | String weightToKg = AllUnitUtils.getWeightToKg(mHeightBodyFatUser.getUnit(), String.valueOf(mHeightBodyFatUser.getWeight()), mHeightBodyFatUser.getDecimals()); | ||||
| BodyFatData bodyFatData = AicareBleConfig.getBodyFatData(AlgorithmUtil.AlgorithmType.TYPE_AICARE, sex, mHeightBodyFatUser.getAge(), Double.parseDouble(weightToKg), | BodyFatData bodyFatData = AicareBleConfig.getBodyFatData(AlgorithmUtil.AlgorithmType.TYPE_AICARE, sex, mHeightBodyFatUser.getAge(), Double.parseDouble(weightToKg), | ||||
| mHeightBodyFatUser.getHeight(), mHeightBodyFatUser.getAdc()); | mHeightBodyFatUser.getHeight(), mHeightBodyFatUser.getAdc()); | ||||
| logList.add( "体脂数据:" + "\n 体脂率: " + bodyFatData.getBfr() + " 皮下脂肪: " + bodyFatData.getSfr() + | |||||
| "\n 内脏脂肪: " + bodyFatData.getUvi() + " 肌肉率: " + bodyFatData.getRom() + | |||||
| "\n 基础代谢率: " + bodyFatData.getBmr() + " 身体年龄:" + bodyFatData.getBodyAge()+ | |||||
| "\n 水分: " + bodyFatData.getVwc() + " 蛋白率:" + bodyFatData.getPp()+ | |||||
| "\n BMI: " + bodyFatData.getBmi() + " 骨量:" + bodyFatData.getBm() | |||||
| ); | |||||
| addText("体脂数据:" + "\n 体脂率: " + bodyFatData.getBfr() + " 皮下脂肪: " + bodyFatData.getSfr() + | |||||
| "\n 内脏脂肪: " + bodyFatData.getUvi() + " 肌肉率: " + bodyFatData.getRom() + | |||||
| "\n 基础代谢率: " + bodyFatData.getBmr() + " 身体年龄:" + bodyFatData.getBodyAge() + | |||||
| "\n 水分: " + bodyFatData.getVwc() + " 蛋白率:" + bodyFatData.getPp() + | |||||
| "\n BMI: " + bodyFatData.getBmi() + " 骨量:" + bodyFatData.getBm() | |||||
| ); | |||||
| } | } | ||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onHeart(int workMode, int status, int heart) { | public void onHeart(int workMode, int status, int heart) { | ||||
| logList.add(0, "心率数据 模式:" + workMode + " 测量状态: " + status + " 心率: " + heart); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "心率数据 模式:" + workMode + " 测量状态: " + status + " 心率: " + heart); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onTEMP(int workMode, int sign, int temp, int decimals, int unit) { | public void onTEMP(int workMode, int sign, int temp, int decimals, int unit) { | ||||
| logList.add(0, "温度数据 模式:" + workMode + " 温度: " + temp + " 正负: " + sign + "小数 : " + decimals + " 单位 : " + unit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "温度数据 模式:" + workMode + " 温度: " + temp + " 正负: " + sign + "小数 : " + decimals + " 单位 : " + unit); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onHeight(int workMode, int height, int decimals, int unit) { | public void onHeight(int workMode, int height, int decimals, int unit) { | ||||
| logList.add(0, "身高数据 模式:" + workMode + " 身高: " + height + " 小数位: " + decimals + "单位 : " + unit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "身高数据 模式:" + workMode + " 身高: " + height + " 小数位: " + decimals + "单位 : " + getHeightUnitStr(unit)); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onBodyfat1(int workMode, int bfr, int sfr, int vfr, int rom, int bmr, int age) { | public void onBodyfat1(int workMode, int bfr, int sfr, int vfr, int rom, int bmr, int age) { | ||||
| logList.add(0, "体脂数据 模式:" + workMode + "\n 体脂率: " + bfr + " 皮下脂肪: " + sfr | |||||
| addText(0, "体脂数据 模式:" + workMode + "\n 体脂率: " + bfr + " 皮下脂肪: " + sfr | |||||
| + "\n 内脏脂肪: " + vfr + " 肌肉路: " + rom + "\n 基础代谢率: " + bmr + " 年龄" + age); | + "\n 内脏脂肪: " + vfr + " 肌肉路: " + rom + "\n 基础代谢率: " + bmr + " 年龄" + age); | ||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onBodyfat2(int workMode, int bm, int water, int pp, int bmi, int heart, int obesityLevels) { | public void onBodyfat2(int workMode, int bm, int water, int pp, int bmi, int heart, int obesityLevels) { | ||||
| logList.add(0, "体脂数据 模式:" + workMode + " 骨量: " + bm + " 水分: " + water | |||||
| addText(0, "体脂数据 模式:" + workMode + " 骨量: " + bm + " 水分: " + water | |||||
| + "\n 蛋白率: " + pp + " bmi: " + bmi + " 心率: " + heart + " \n肥胖等级" + obesityLevels); | + "\n 蛋白率: " + pp + " bmi: " + bmi + " 心率: " + heart + " \n肥胖等级" + obesityLevels); | ||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onVoice(int status) { | public void onVoice(int status) { | ||||
| mMHandler.removeMessages(VOICESTATUS); | mMHandler.removeMessages(VOICESTATUS); | ||||
| logList.add(0, "声音状态 模式:" + status); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "声音状态 模式:" + status); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onFinish(int workMode) { | public void onFinish(int workMode) { | ||||
| logList.add(0, "测量完成 模式:" + workMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "测量完成 模式:" + workMode); | |||||
| mMHandler.removeMessages(FINISH); | mMHandler.removeMessages(FINISH); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onError(int error) { | public void onError(int error) { | ||||
| logList.add(0, "错误码: " + error); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "错误码: " + error); | |||||
| } | } | ||||
| @Override | @Override | ||||
| switch (v.getId()) { | switch (v.getId()) { | ||||
| case R.id.kg: | case R.id.kg: | ||||
| selectWUnit = 0; | selectWUnit = 0; | ||||
| logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发体重单位 :" + getHeightUnitStr(currentHUnit)+","+getWeightUnitStr(selectWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.jin: | case R.id.jin: | ||||
| selectWUnit = 1; | selectWUnit = 1; | ||||
| logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发体重单位 :" + getHeightUnitStr(currentHUnit)+","+getWeightUnitStr(selectWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.st_lb: | case R.id.st_lb: | ||||
| selectWUnit = 4; | selectWUnit = 4; | ||||
| logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发体重单位 :" + getHeightUnitStr(currentHUnit)+","+getWeightUnitStr(selectWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.lb: | case R.id.lb: | ||||
| selectWUnit = 6; | selectWUnit = 6; | ||||
| logList.add(0, "下发体重单位 :" + selectWUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, selectWUnit)); | |||||
| addText(0, "下发体重单位 :" + getHeightUnitStr(currentHUnit)+","+getWeightUnitStr(selectWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(currentHUnit, currentHUnit)); | |||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.girl: | case R.id.girl: | ||||
| logList.add(0, "下用户 女 18岁 165cm :" + selectWUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| mHeightBodyFatUser=new HeightBodyFatUser(0,18,165,0,0); | |||||
| addText(0, "下用户 女 18岁 165cm :" + selectWUnit); | |||||
| mHeightBodyFatUser = new HeightBodyFatUser(0, 18, 165, 0, 0); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUser(mHeightBodyFatUser.getSex(), mHeightBodyFatUser.getAge(), mHeightBodyFatUser.getHeight())); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUser(mHeightBodyFatUser.getSex(), mHeightBodyFatUser.getAge(), mHeightBodyFatUser.getHeight())); | ||||
| mMHandler.removeMessages(SETUSER); | mMHandler.removeMessages(SETUSER); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUSER, 3000); | mMHandler.sendEmptyMessageDelayed(SETUSER, 3000); | ||||
| break; | break; | ||||
| case R.id.man: | case R.id.man: | ||||
| logList.add(0, "下用户 男 28岁 170cm :" + selectWUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| mHeightBodyFatUser=new HeightBodyFatUser(1,28,170,0,0); | |||||
| addText(0, "下用户 男 28岁 170cm :" + selectWUnit); | |||||
| mHeightBodyFatUser = new HeightBodyFatUser(1, 28, 170, 0, 0); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUser(mHeightBodyFatUser.getSex(), mHeightBodyFatUser.getAge(), mHeightBodyFatUser.getHeight())); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUser(mHeightBodyFatUser.getSex(), mHeightBodyFatUser.getAge(), mHeightBodyFatUser.getHeight())); | ||||
| mMHandler.removeMessages(SETUSER); | mMHandler.removeMessages(SETUSER); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUSER, 3000); | mMHandler.sendEmptyMessageDelayed(SETUSER, 3000); | ||||
| break; | break; | ||||
| case R.id.cm: | case R.id.cm: | ||||
| selectHUnit = 0; | selectHUnit = 0; | ||||
| logList.add(0, "下发身高单位 :" + selectHUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发身高单位 :" + getHeightUnitStr(selectHUnit)+","+getWeightUnitStr(currentWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.inch: | case R.id.inch: | ||||
| selectHUnit = 1; | selectHUnit = 1; | ||||
| logList.add(0, "下发身高单位 :" + selectHUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发身高单位 :" + getHeightUnitStr(selectHUnit)+","+getWeightUnitStr(currentWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.ft_in: | case R.id.ft_in: | ||||
| selectHUnit = 2; | selectHUnit = 2; | ||||
| logList.add(0, "下发身高单位 :" + selectHUnit); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发身高单位 :" + getHeightUnitStr(selectHUnit)+","+getWeightUnitStr(currentWUnit)); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setUnit(selectHUnit, currentWUnit)); | ||||
| mMHandler.removeMessages(SETUNIT); | mMHandler.removeMessages(SETUNIT); | ||||
| mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | mMHandler.sendEmptyMessageDelayed(SETUNIT, 3000); | ||||
| break; | break; | ||||
| case R.id.baby: | case R.id.baby: | ||||
| selectMode = 2; | selectMode = 2; | ||||
| logList.add(0, "下发工作模式 :" + selectMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发工作模式 :" + selectMode); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | ||||
| mMHandler.removeMessages(SETMODE); | mMHandler.removeMessages(SETMODE); | ||||
| mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | ||||
| break; | break; | ||||
| case R.id.bodyfat: | case R.id.bodyfat: | ||||
| selectMode = 1; | selectMode = 1; | ||||
| logList.add(0, "下发工作模式 :" + selectMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发工作模式 :" + selectMode); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | ||||
| mMHandler.removeMessages(SETMODE); | mMHandler.removeMessages(SETMODE); | ||||
| mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | ||||
| break; | break; | ||||
| case R.id.weight: | case R.id.weight: | ||||
| selectMode = 3; | selectMode = 3; | ||||
| logList.add(0, "下发工作模式 :" + selectMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发工作模式 :" + selectMode); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | ||||
| mMHandler.removeMessages(SETMODE); | mMHandler.removeMessages(SETMODE); | ||||
| mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | ||||
| break; | break; | ||||
| case R.id.height_weight: | case R.id.height_weight: | ||||
| selectMode = 4; | selectMode = 4; | ||||
| logList.add(0, "下发工作模式 :" + selectMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发工作模式 :" + selectMode); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setWorkMode(selectMode)); | ||||
| mMHandler.removeMessages(SETMODE); | mMHandler.removeMessages(SETMODE); | ||||
| mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | mMHandler.sendEmptyMessageDelayed(SETMODE, 3000); | ||||
| break; | break; | ||||
| case R.id.deviceStatus: | case R.id.deviceStatus: | ||||
| logList.add(0, "请求设备状态 :" ); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "请求设备状态 :"); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.getDeviceStatus()); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.getDeviceStatus()); | ||||
| mMHandler.removeMessages(DEVICESTATUS); | mMHandler.removeMessages(DEVICESTATUS); | ||||
| mMHandler.sendEmptyMessageDelayed(DEVICESTATUS, 3000); | mMHandler.sendEmptyMessageDelayed(DEVICESTATUS, 3000); | ||||
| break; | break; | ||||
| case R.id.voice_open: | case R.id.voice_open: | ||||
| selectVoice = 1; | selectVoice = 1; | ||||
| logList.add(0, "设置声音 :" + selectMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "设置声音 :" + selectMode); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setVoiceStatus(selectVoice)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setVoiceStatus(selectVoice)); | ||||
| mMHandler.removeMessages(VOICE); | mMHandler.removeMessages(VOICE); | ||||
| mMHandler.sendEmptyMessageDelayed(VOICE, 3000); | mMHandler.sendEmptyMessageDelayed(VOICE, 3000); | ||||
| break; | break; | ||||
| case R.id.voice_close: | case R.id.voice_close: | ||||
| selectVoice = 2; | selectVoice = 2; | ||||
| logList.add(0, "设置声音 :" + selectMode); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "设置声音 :" + selectMode); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setVoiceStatus(selectVoice)); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.setVoiceStatus(selectVoice)); | ||||
| mMHandler.removeMessages(VOICE); | mMHandler.removeMessages(VOICE); | ||||
| mMHandler.sendEmptyMessageDelayed(VOICE, 3000); | mMHandler.sendEmptyMessageDelayed(VOICE, 3000); | ||||
| break; | break; | ||||
| case R.id.voice_status: | case R.id.voice_status: | ||||
| logList.add(0, "获取声音状态"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "获取声音状态"); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.getVoiceStatus()); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.getVoiceStatus()); | ||||
| mMHandler.removeMessages(VOICESTATUS); | mMHandler.removeMessages(VOICESTATUS); | ||||
| mMHandler.sendEmptyMessageDelayed(VOICESTATUS, 3000); | mMHandler.sendEmptyMessageDelayed(VOICESTATUS, 3000); | ||||
| break; | break; | ||||
| case R.id.finish: | case R.id.finish: | ||||
| logList.add(0, "回复测量完成"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "回复测量完成"); | |||||
| HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.replyTestFinish()); | HeightBodyFatBleData.getInstance().sendData(HeightBodyFatBleUntils.replyTestFinish()); | ||||
| break; | break; | ||||
| case R.id.btnPause: | |||||
| pauseRefresh = !pauseRefresh; | |||||
| if (pauseRefresh) { | |||||
| addText(0, "暂停刷新"); | |||||
| } else { | |||||
| addText(0, "继续刷新"); | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| super.handleMessage(msg); | super.handleMessage(msg); | ||||
| switch (msg.what) { | switch (msg.what) { | ||||
| case SETMODE: | case SETMODE: | ||||
| logList.add(0, "下发模式没有回复"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发模式没有回复"); | |||||
| break; | break; | ||||
| case SETUNIT: | case SETUNIT: | ||||
| logList.add(0, "下发单位没有回复"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发单位没有回复"); | |||||
| break; | break; | ||||
| case SETUSER: | case SETUSER: | ||||
| logList.add(0, "下发用户没有回复"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "下发用户没有回复"); | |||||
| break; | break; | ||||
| case FINISH: | case FINISH: | ||||
| logList.add(0, "没有回复测量完成指令(\n为了检测是否有回复。" + | |||||
| addText(0, "没有回复测量完成指令(\n为了检测是否有回复。" + | |||||
| "app会在接收到稳定体重的时候。开启定时器。去确认设备是否有回复测量完成。" + | "app会在接收到稳定体重的时候。开启定时器。去确认设备是否有回复测量完成。" + | ||||
| "\n如果回复。此消息可以忽略)"+"\n 每次测量(母婴模式。的测量完成也只能发一次),测量完成的命令只能发一次!!!!。"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| "\n如果回复。此消息可以忽略)" + "\n 每次测量(母婴模式。的测量完成也只能发一次),测量完成的命令只能发一次!!!!。"); | |||||
| break; | break; | ||||
| case ADC: | case ADC: | ||||
| logList.add(0, "没有测量阻抗的指令(\n为了检测是否有回复。app会在接收到稳定体重的时候。开启定时器。去确认设备是否有回复测量阻抗的状态。\n如果回复。此消息可以忽略)"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "没有测量阻抗的指令(\n为了检测是否有回复。app会在接收到稳定体重的时候。开启定时器。去确认设备是否有回复测量阻抗的状态。\n如果回复。此消息可以忽略)"); | |||||
| break; | break; | ||||
| case DEVICESTATUS: | case DEVICESTATUS: | ||||
| logList.add(0, "没有接收到设备状态(\n为了检测是否有回复。app会在点击获取设备状态指令的时候。开启定时器。去确认设备是否有回复设备状态。\n如果回复。此消息可以忽略)"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText("没有接收到设备状态(\n为了检测是否有回复。app会在点击获取设备状态指令的时候。开启定时器。去确认设备是否有回复设备状态。\n如果回复。此消息可以忽略)"); | |||||
| break; | break; | ||||
| case VOICE: | case VOICE: | ||||
| logList.add(0, "没有声音设置的回复(\n为了检测是否有回复。app会在点击设置声音的时候。开启定时器。去确认设备是否有回复设置声音。\n如果回复。此消息可以忽略)"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText("没有声音设置的回复(\n为了检测是否有回复。app会在点击设置声音的时候。开启定时器。去确认设备是否有回复设置声音。\n如果回复。此消息可以忽略)"); | |||||
| break; | break; | ||||
| case VOICESTATUS: | case VOICESTATUS: | ||||
| logList.add(0, "没有声音状态的回复(\n为了检测是否有回复。app会在点击声音状态的时候。开启定时器。去确认设备是否有回复声音状态。\n如果回复。此消息可以忽略)"); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| addText(0, "没有声音状态的回复(\n为了检测是否有回复。app会在点击声音状态的时候。开启定时器。去确认设备是否有回复声音状态。\n如果回复。此消息可以忽略)"); | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| 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 getHeightUnitStr(int unit) { | |||||
| switch (unit) { | |||||
| case 0: | |||||
| return "cm"; | |||||
| case 1: | |||||
| return "inch"; | |||||
| case 2: | |||||
| return "feet"; | |||||
| } | |||||
| return ""; | |||||
| } | |||||
| private boolean pauseRefresh = false; | |||||
| private void addText(String text) { | |||||
| addText(0, text); | |||||
| } | |||||
| private void addText(int index, String text) { | |||||
| if (pauseRefresh) { | |||||
| return; | |||||
| } | |||||
| logList.add(index, text); | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| } | } |
| import androidx.recyclerview.widget.LinearLayoutManager; | import androidx.recyclerview.widget.LinearLayoutManager; | ||||
| import androidx.recyclerview.widget.RecyclerView; | import androidx.recyclerview.widget.RecyclerView; | ||||
| import com.pingwang.bluetoothlib.AILinkSDK; | |||||
| import com.pingwang.bluetoothlib.bean.BleHandshakeBean; | |||||
| import com.pingwang.bluetoothlib.bean.BleScanAddAilinkBean; | import com.pingwang.bluetoothlib.bean.BleScanAddAilinkBean; | ||||
| 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 aicare.net.cn.sdk.ailinksdkdemoandroid.home.MainActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.home.MainActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.toothbrush.ToothBrushWifiBleActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.toothbrush.ToothBrushWifiBleActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.MyBleStrUtils; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.view.MyItemDecoration; | import aicare.net.cn.sdk.ailinksdkdemoandroid.view.MyItemDecoration; | ||||
| import cn.net.aicare.modulelibrary.module.RopeSkipping.RopeSkippingBleData; | import cn.net.aicare.modulelibrary.module.RopeSkipping.RopeSkippingBleData; | ||||
| import cn.net.aicare.modulelibrary.module.scooter.SkateboardBleConfig; | import cn.net.aicare.modulelibrary.module.scooter.SkateboardBleConfig; | ||||
| RecyclerView recyclerView = findViewById(R.id.rv_data); | RecyclerView recyclerView = findViewById(R.id.rv_data); | ||||
| recyclerView.setLayoutManager(new LinearLayoutManager(mContext)); | recyclerView.setLayoutManager(new LinearLayoutManager(mContext)); | ||||
| recyclerView.addItemDecoration(new MyItemDecoration(mContext, LinearLayoutManager.VERTICAL, 1, mContext.getResources() | recyclerView.addItemDecoration(new MyItemDecoration(mContext, LinearLayoutManager.VERTICAL, 1, mContext.getResources() | ||||
| .getColor(R.color.public_press_bg))); | |||||
| .getColor(R.color.public_press_bg))); | |||||
| 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); | ||||
| EditText et_filter_name = findViewById(R.id.et_filter_name); | EditText et_filter_name = findViewById(R.id.et_filter_name); | ||||
| EditText et_filter_mac = findViewById(R.id.et_filter_mac); | EditText et_filter_mac = findViewById(R.id.et_filter_mac); | ||||
| EditText et_cid = findViewById(R.id.et_cid); | EditText et_cid = findViewById(R.id.et_cid); | ||||
| et_cid.setText(String.valueOf(mScanCid)); | |||||
| if (mScanCid > 0) { | |||||
| et_cid.setText(MyBleStrUtils.getHexString(mScanCid)); | |||||
| } else { | |||||
| et_cid.setText(String.valueOf(mScanCid)); | |||||
| } | |||||
| btn.setOnClickListener(new View.OnClickListener() { | btn.setOnClickListener(new View.OnClickListener() { | ||||
| BleLog.i(TAG, "搜索设备"); | BleLog.i(TAG, "搜索设备"); | ||||
| try { | try { | ||||
| String cidStr = et_cid.getText().toString().trim(); | String cidStr = et_cid.getText().toString().trim(); | ||||
| if (cidStr.startsWith("0x")) { | |||||
| mScanCid = Integer.parseInt(cidStr, 16); | |||||
| } else { | |||||
| mScanCid = Integer.parseInt(cidStr); | |||||
| } | |||||
| mScanCid = Integer.parseInt(cidStr, 16); | |||||
| } catch (NumberFormatException e) { | } catch (NumberFormatException e) { | ||||
| mScanCid = -1; | mScanCid = -1; | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||
| mFilterName = et_filter_name.getText().toString().trim(); | mFilterName = et_filter_name.getText().toString().trim(); | ||||
| mFilterMac = et_filter_mac.getText().toString().trim(); | mFilterMac = et_filter_mac.getText().toString().trim(); | ||||
| long scanOut = 30 * 1000; | |||||
| if (mType == BleDeviceConfig.SMART_SCOOTER) { | if (mType == BleDeviceConfig.SMART_SCOOTER) { | ||||
| List<BleScanAddAilinkBean> list = new ArrayList<>(); | List<BleScanAddAilinkBean> list = new ArrayList<>(); | ||||
| list.add(new BleScanAddAilinkBean(0x37, 0x03, 0x01, SkateboardBleConfig.UUID_BROADCAST)); | list.add(new BleScanAddAilinkBean(0x37, 0x03, 0x01, SkateboardBleConfig.UUID_BROADCAST)); | ||||
| mAILinkBleManager.startScan(30 * 1000, list, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||||
| mAILinkBleManager.startScan(scanOut, list, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||||
| } else { | } else { | ||||
| //0000FEE7=手表 | //0000FEE7=手表 | ||||
| mAILinkBleManager.startScan(30 * 1000, BleConfig.UUID_BROADCAST_AILINK, BleConfig.UUID_SERVER_BROADCAST_AILINK, UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||||
| mAILinkBleManager.startScan(scanOut, BleConfig.UUID_BROADCAST_AILINK, BleConfig.UUID_SERVER_BROADCAST_AILINK, UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||||
| // BleScanUtil.scanLeDevice(AILinkBleManager.getInstance(), scanOut); | |||||
| } | } | ||||
| mBleValueList.clear(); | mBleValueList.clear(); | ||||
| listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
| @Override | @Override | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mAILinkBleManager.stopScan(10000); | |||||
| mAILinkBleManager.stopScan(); | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| mVid = bleValueBean.getVid(); | mVid = bleValueBean.getVid(); | ||||
| mPid = bleValueBean.getPid(); | mPid = bleValueBean.getPid(); | ||||
| mBleName = bleValueBean.getName(); | mBleName = bleValueBean.getName(); | ||||
| if (mType == BleDeviceConfig.CLEAR_SHAKE_HANDS) { | if (mType == BleDeviceConfig.CLEAR_SHAKE_HANDS) { | ||||
| //验证不握手,不加密的界面使用 | //验证不握手,不加密的界面使用 | ||||
| //设置不握手 | |||||
| BleConfig.setHandshakeStatus(mac, false); | BleConfig.setHandshakeStatus(mac, false); | ||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mAILinkBleManager.stopScan(); | mAILinkBleManager.stopScan(); | ||||
| Intent intent = new Intent(); | Intent intent = new Intent(); | ||||
| intent.setClass(ShowBleActivity.this, ToothBrushWifiBleActivity.class); | intent.setClass(ShowBleActivity.this, ToothBrushWifiBleActivity.class); | ||||
| intent.putExtra("type", mType); | intent.putExtra("type", mType); | ||||
| intent.putExtra("cid", mCid); | |||||
| intent.putExtra("mac", mac); | intent.putExtra("mac", mac); | ||||
| startActivity(intent); | startActivity(intent); | ||||
| String data2 = BleStrUtils.byte2HexStr(bleValueBean.getManufacturerData()); | String data2 = BleStrUtils.byte2HexStr(bleValueBean.getManufacturerData()); | ||||
| showData.append(data2); | showData.append(data2); | ||||
| HintDataDialogFragment.newInstance() | HintDataDialogFragment.newInstance() | ||||
| .setTitle("自定义厂商数据", 0) | |||||
| .setContent(showData.toString(), false) | |||||
| .setOk("", 0) | |||||
| .show(getSupportFragmentManager()); | |||||
| .setTitle("自定义厂商数据", 0) | |||||
| .setContent(showData.toString(), false) | |||||
| .setOk("", 0) | |||||
| .show(getSupportFragmentManager()); | |||||
| } | } | ||||
| }); | }); | ||||
| recyclerView.setAdapter(listAdapter); | recyclerView.setAdapter(listAdapter); | ||||
| @Override | @Override | ||||
| public void onServicesDiscovered(@NonNull String mac) { | public void onServicesDiscovered(@NonNull String mac) { | ||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mac); | |||||
| initEncryption(bleDevice); | |||||
| if (mac.equalsIgnoreCase(mNoEncryptionMac)) { | if (mac.equalsIgnoreCase(mNoEncryptionMac)) { | ||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mac); | |||||
| bleDevice.setA7Encryption(false); | bleDevice.setA7Encryption(false); | ||||
| mNoEncryptionMac = ""; | mNoEncryptionMac = ""; | ||||
| Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | ||||
| startActivityForResult(intent, REQUEST_PERMISSION_CODE); | startActivityForResult(intent, REQUEST_PERMISSION_CODE); | ||||
| } | } | ||||
| /** | |||||
| * 初始化加密 | |||||
| * 主要用于license设备,不用加密 | |||||
| */ | |||||
| public static void initEncryption(BleDevice bleDevice) { | |||||
| if (bleDevice == null) { | |||||
| return; | |||||
| } | |||||
| BleValueBean bleValueBean = bleDevice.getBleValueBean(); | |||||
| if (bleValueBean != null) { | |||||
| BleHandshakeBean licenseDevice = AILinkSDK.getInstance().isLicenseDevice(bleValueBean.getCid(), bleValueBean.getVid(), bleValueBean.getPid()); | |||||
| if (licenseDevice != null) { | |||||
| //license设备,不用加密 | |||||
| bleDevice.setA7Encryption(false); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | } |
| import com.pingwang.bluetoothlib.device.SendDataBean; | import com.pingwang.bluetoothlib.device.SendDataBean; | ||||
| import com.pingwang.bluetoothlib.listener.CallbackDisIm; | import com.pingwang.bluetoothlib.listener.CallbackDisIm; | ||||
| import com.pingwang.bluetoothlib.listener.OnBleDeviceDataListener; | import com.pingwang.bluetoothlib.listener.OnBleDeviceDataListener; | ||||
| import com.pingwang.bluetoothlib.listener.OnBleMtuListener; | |||||
| import com.pingwang.bluetoothlib.listener.OnBleOtherDataListener; | import com.pingwang.bluetoothlib.listener.OnBleOtherDataListener; | ||||
| import com.pingwang.bluetoothlib.listener.OnCallbackDis; | import com.pingwang.bluetoothlib.listener.OnCallbackDis; | ||||
| 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 com.pingwang.bluetoothlib.utils.UuidUtils; | import com.pingwang.bluetoothlib.utils.UuidUtils; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||||
| 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 java.util.UUID; | import java.util.UUID; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
| /** | /** | ||||
| * xing<br> | * xing<br> | ||||
| private List<String> mList; | private List<String> mList; | ||||
| private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
| private Context mContext; | private Context mContext; | ||||
| private EditText et_cmd, et_uuid, et_uuid_server, et_time, et_notify; | |||||
| private EditText et_cmd, et_uuid, et_uuid_server, et_time, et_notify, etIncrementNumber; | |||||
| private BleDevice mBleDevice; | private BleDevice mBleDevice; | ||||
| private String mAddress; | private String mAddress; | ||||
| private int sendTime = 1000; | private int sendTime = 1000; | ||||
| private UUID sendUuidServer = null; | private UUID sendUuidServer = null; | ||||
| private String uuidEnd = "-0000-1000-8000-00805F9B34FB"; | private String uuidEnd = "-0000-1000-8000-00805F9B34FB"; | ||||
| private String sendCmd; | private String sendCmd; | ||||
| private byte[] sendCmdB; | |||||
| private long mSendNumber = 0; | private long mSendNumber = 0; | ||||
| private long mReceiveNumber = 0; | private long mReceiveNumber = 0; | ||||
| private boolean mShowLog = true; | private boolean mShowLog = true; | ||||
| private int mNum = 1; | |||||
| private boolean mIncrementSend = false; | |||||
| private int mNum = 0; | |||||
| private int mNumMax = 514; | |||||
| 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) { | ||||
| break; | break; | ||||
| case SEND_DATA: | case SEND_DATA: | ||||
| if (sendUuid != null && sendUuidServer != null) { | |||||
| mNum++; | |||||
| SendDataBean sendDataBean = new SendDataBean(String.valueOf(mNum).getBytes(), sendUuid, BleConfig.WRITE_DATA, sendUuidServer); | |||||
| mBleDevice.sendData(sendDataBean); | |||||
| if (sendTime > 0) { | |||||
| mHandler.sendEmptyMessageDelayed(SEND_DATA, sendTime); | |||||
| int intervalTime = sendTime; | |||||
| if (sendUuid != null && sendUuidServer != null && mBleDevice != null) { | |||||
| byte[] sendData = sendCmdB; | |||||
| if (mIncrementSend) { | |||||
| //递增字节发送 | |||||
| mNum++; | |||||
| if (mNum > mNumMax) { | |||||
| addLog("递增发送结束"); | |||||
| mNum = 1; | |||||
| return; | |||||
| } | |||||
| sendData = new byte[mNum]; | |||||
| for (int i = 0; i < mNum; i++) { | |||||
| sendData[i] = (byte) (i); | |||||
| } | |||||
| intervalTime = sendTime + mNum; | |||||
| addLog("发送数据量:" + mNum); | |||||
| } | |||||
| SendDataBean sendDataBean = new SendDataBean(sendData, sendUuid, BleConfig.WRITE_DATA, sendUuidServer); | |||||
| mBleDevice.sendDataNow(sendDataBean); | |||||
| if (intervalTime > 0) { | |||||
| mHandler.sendEmptyMessageDelayed(SEND_DATA, intervalTime); | |||||
| } | } | ||||
| mSendNumber += sendDataBean.getHex().length; | mSendNumber += sendDataBean.getHex().length; | ||||
| tv_send_number.setText(String.valueOf(mSendNumber)); | tv_send_number.setText(String.valueOf(mSendNumber)); | ||||
| } else { | |||||
| addLog("请先设置特征UUID和服务UUID"); | |||||
| } | } | ||||
| break; | break; | ||||
| findViewById(R.id.btn_notify_status).setOnClickListener(this); | findViewById(R.id.btn_notify_status).setOnClickListener(this); | ||||
| findViewById(R.id.btn_uuid_server).setOnClickListener(this); | findViewById(R.id.btn_uuid_server).setOnClickListener(this); | ||||
| findViewById(R.id.btn_log).setOnClickListener(this); | findViewById(R.id.btn_log).setOnClickListener(this); | ||||
| findViewById(R.id.btnIncrementSend).setOnClickListener(this); | |||||
| etIncrementNumber = findViewById(R.id.etIncrementNumber); | |||||
| et_cmd = findViewById(R.id.et_cmd); | et_cmd = findViewById(R.id.et_cmd); | ||||
| et_uuid = findViewById(R.id.et_uuid); | et_uuid = findViewById(R.id.et_uuid); | ||||
| et_time = findViewById(R.id.et_time); | et_time = findViewById(R.id.et_time); | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| switch (v.getId()) { | switch (v.getId()) { | ||||
| case R.id.btn1: | case R.id.btn1: | ||||
| try { | |||||
| mNumMax = Integer.parseInt(etIncrementNumber.getText().toString().trim()); | |||||
| } catch (NumberFormatException e) { | |||||
| e.printStackTrace(); | |||||
| mNumMax = 514; | |||||
| } | |||||
| sendCmd = et_cmd.getText().toString().trim(); | sendCmd = et_cmd.getText().toString().trim(); | ||||
| sendCmdB = BleDensityUtil.getInstance().toBytes(sendCmd); | |||||
| mHandler.removeMessages(SEND_DATA); | mHandler.removeMessages(SEND_DATA); | ||||
| mHandler.sendEmptyMessage(SEND_DATA); | mHandler.sendEmptyMessage(SEND_DATA); | ||||
| break; | break; | ||||
| case R.id.btn_uuid: | case R.id.btn_uuid: | ||||
| String uuid = et_uuid.getText().toString().trim().toUpperCase(Locale.ENGLISH); | String uuid = et_uuid.getText().toString().trim().toUpperCase(Locale.ENGLISH); | ||||
| sendUuid = UuidUtils.getUuid(uuid); | sendUuid = UuidUtils.getUuid(uuid); | ||||
| addLog("设置特征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); | ||||
| sendUuidServer = UuidUtils.getUuid(uuidServer); | sendUuidServer = UuidUtils.getUuid(uuidServer); | ||||
| addLog("设置服务UUID"); | |||||
| break; | break; | ||||
| case R.id.btn_time: | case R.id.btn_time: | ||||
| String time = et_time.getText().toString().trim().toUpperCase(Locale.ENGLISH); | String time = et_time.getText().toString().trim().toUpperCase(Locale.ENGLISH); | ||||
| sendTime = Integer.parseInt(time); | sendTime = Integer.parseInt(time); | ||||
| addLog("设置时间间隔(ms):" + sendTime); | |||||
| break; | break; | ||||
| case R.id.btn_notify: | case R.id.btn_notify: | ||||
| String notify = et_notify.getText().toString().trim().toUpperCase(Locale.ENGLISH); | String notify = et_notify.getText().toString().trim().toUpperCase(Locale.ENGLISH); | ||||
| readNotify(notify, mNotify); | readNotify(notify, mNotify); | ||||
| addLog("设置Notify UUID"); | |||||
| break; | break; | ||||
| case R.id.btn_notify_status: | case R.id.btn_notify_status: | ||||
| mNotify = !mNotify; | mNotify = !mNotify; | ||||
| ((Button) v).setText("log:" + (mShowLog ? "Y" : "N")); | ((Button) v).setText("log:" + (mShowLog ? "Y" : "N")); | ||||
| break; | break; | ||||
| case R.id.btnIncrementSend: | |||||
| mIncrementSend = !mIncrementSend; | |||||
| // mBleDevice.setMtu(mNumMax); | |||||
| ((Button) v).setText("递增发送:" + (mIncrementSend ? "Y" : "N")); | |||||
| break; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| private void addLog(String log) { | |||||
| if (mShowLog) { | |||||
| mList.add(TimeUtils.getTimeSSS() + log); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| } | |||||
| } | |||||
| //---------------------------------服务--------------------------------------------------- | //---------------------------------服务--------------------------------------------------- | ||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mBleDevice.setOnBleOtherDataListener(this); | mBleDevice.setOnBleOtherDataListener(this); | ||||
| mBleDevice.setOnBleDeviceDataListener(this); | mBleDevice.setOnBleDeviceDataListener(this); | ||||
| mBleDevice.setOnBleMtuListener(new OnBleMtuListener() { | |||||
| @Override | |||||
| public void OnMtu(int mtu) { | |||||
| addLog("系统返回MTU:" + mtu); | |||||
| } | |||||
| }); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| //TODO 连接断开 | //TODO 连接断开 | ||||
| BleLog.i(TAG, "连接断开"); | BleLog.i(TAG, "连接断开"); | ||||
| mList.add(TimeUtils.getTime() + "连接断开"); | mList.add(TimeUtils.getTime() + "连接断开"); | ||||
| mHandler.removeMessages(SEND_DATA); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| finish(); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Override | @Override | ||||
| public void bleClose() { | public void bleClose() { | ||||
| mHandler.removeMessages(SEND_DATA); | |||||
| addLog("蓝牙关闭"); | |||||
| BleLog.i(TAG, "蓝牙未开启,可请求开启"); | BleLog.i(TAG, "蓝牙未开启,可请求开启"); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onNotifyOtherData(String uuid, byte[] hex) { | public void onNotifyOtherData(String uuid, byte[] hex) { | ||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| hex[0]= (byte) (hex[0]+1); | |||||
| SendDataBean sendDataBean = new SendDataBean(hex,BleConfig.UUID_WRITE_AILINK,BleConfig.WRITE_DATA,BleConfig.UUID_SERVER_AILINK); | |||||
| hex[0] = (byte) (hex[0] + 1); | |||||
| SendDataBean sendDataBean = new SendDataBean(hex, BleConfig.UUID_WRITE_AILINK, BleConfig.WRITE_DATA, BleConfig.UUID_SERVER_AILINK); | |||||
| mBleDevice.sendDataNow(sendDataBean); | mBleDevice.sendDataNow(sendDataBean); | ||||
| } | } | ||||
| if (mShowLog) { | if (mShowLog) { |
| public class TransmissionActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, TransmissionDeviceData.MyBleCallback { | public class TransmissionActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, TransmissionDeviceData.MyBleCallback { | ||||
| private TextView tv_device_info; | private TextView tv_device_info; | ||||
| private EditText et, et_cid,et_a6,et_customize,et_name; | |||||
| private Button send,send_a6, bt_clear, bt_clear_log,bt_cid,send_customize; | |||||
| private EditText et, et_cid, et_a6, et_customize, et_name; | |||||
| private Button send, send_a6, bt_clear, bt_clear_log, bt_cid, send_customize; | |||||
| private ListView mListView; | private ListView mListView; | ||||
| private List<String> mlogList; | private List<String> mlogList; | ||||
| private final int ToRefreUi = 1; | private final int ToRefreUi = 1; | ||||
| private ArrayAdapter listAdapter; | private ArrayAdapter listAdapter; | ||||
| private String mAddress; | private String mAddress; | ||||
| private TransmissionDeviceData mTransmissionDeviceData; | private TransmissionDeviceData mTransmissionDeviceData; | ||||
| private boolean isPause = false; | |||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mAILinkBleManager.setOnCallbackBle(this); | mAILinkBleManager.setOnCallbackBle(this); | ||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | ||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| if (tv_device_info!=null) { | |||||
| tv_device_info.setText("MAC:"+bleDevice.getMac()); | |||||
| if (tv_device_info != null) { | |||||
| tv_device_info.setText("MAC:" + bleDevice.getMac()); | |||||
| } | } | ||||
| mTransmissionDeviceData = new TransmissionDeviceData(bleDevice); | mTransmissionDeviceData = new TransmissionDeviceData(bleDevice); | ||||
| mTransmissionDeviceData.setMyBleCallback(this); | mTransmissionDeviceData.setMyBleCallback(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mAILinkBleManager !=null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | mAILinkBleManager.removeOnCallbackBle(this); | ||||
| } | } | ||||
| } | } | ||||
| send_a6.setOnClickListener(this); | send_a6.setOnClickListener(this); | ||||
| send_customize.setOnClickListener(this); | send_customize.setOnClickListener(this); | ||||
| findViewById(R.id.send_name).setOnClickListener(this); | findViewById(R.id.send_name).setOnClickListener(this); | ||||
| findViewById(R.id.btPause).setOnClickListener(this); | |||||
| bt_clear.setOnClickListener(this); | bt_clear.setOnClickListener(this); | ||||
| bt_cid.setOnClickListener(this); | bt_cid.setOnClickListener(this); | ||||
| bt_clear_log.setOnClickListener(this); | bt_clear_log.setOnClickListener(this); | ||||
| } | } | ||||
| } else if (id == R.id.bt_clear) { | } else if (id == R.id.bt_clear) { | ||||
| et.setText(""); | et.setText(""); | ||||
| et_a6.setText(""); | |||||
| et_customize.setText(""); | |||||
| } else if (id == R.id.bt_clear_log) { | } else if (id == R.id.bt_clear_log) { | ||||
| mlogList.clear(); | mlogList.clear(); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| if (mTransmissionDeviceData != null) { | if (mTransmissionDeviceData != null) { | ||||
| mTransmissionDeviceData.getCid(); | mTransmissionDeviceData.getCid(); | ||||
| } | } | ||||
| }else if (id == R.id.send_a6) { | |||||
| } else if (id == R.id.send_a6) { | |||||
| String hex = et_a6.getText().toString().toUpperCase().trim(); | String hex = et_a6.getText().toString().toUpperCase().trim(); | ||||
| if (!TextUtils.isEmpty(hex)) { | if (!TextUtils.isEmpty(hex)) { | ||||
| byte[] hexStr = BleStrUtils.stringToByte(hex); | byte[] hexStr = BleStrUtils.stringToByte(hex); | ||||
| if (mTransmissionDeviceData != null) { | if (mTransmissionDeviceData != null) { | ||||
| mTransmissionDeviceData.setSendDataA6( hexStr); | |||||
| mTransmissionDeviceData.setSendDataA6(hexStr); | |||||
| } | } | ||||
| } | } | ||||
| }else if (id == R.id.send_customize) { | |||||
| } else if (id == R.id.send_customize) { | |||||
| String hex = et_customize.getText().toString().toUpperCase().trim(); | String hex = et_customize.getText().toString().toUpperCase().trim(); | ||||
| if (!TextUtils.isEmpty(hex)) { | if (!TextUtils.isEmpty(hex)) { | ||||
| byte[] hexStr = BleStrUtils.stringToByte(hex); | byte[] hexStr = BleStrUtils.stringToByte(hex); | ||||
| if (mTransmissionDeviceData != null) { | if (mTransmissionDeviceData != null) { | ||||
| mTransmissionDeviceData.setSendDataCustomize( hexStr); | |||||
| mTransmissionDeviceData.setSendDataCustomize(hexStr); | |||||
| } | } | ||||
| } | } | ||||
| }else if (id == R.id.send_name) { | |||||
| } else if (id == R.id.send_name) { | |||||
| String name = et_name.getText().toString().trim(); | String name = et_name.getText().toString().trim(); | ||||
| if (!TextUtils.isEmpty(name)) { | if (!TextUtils.isEmpty(name)) { | ||||
| byte[] names = BleDataUtils.getInstance().getBleName(name); | byte[] names = BleDataUtils.getInstance().getBleName(name); | ||||
| mTransmissionDeviceData.setSendDataA6(BleSendCmdUtil.getInstance().setBleName(names)); | mTransmissionDeviceData.setSendDataA6(BleSendCmdUtil.getInstance().setBleName(names)); | ||||
| } | } | ||||
| }else if (id == R.id.btPause){ | |||||
| isPause = !isPause; | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void showData(String data, int type) { | public void showData(String data, int type) { | ||||
| mlogList.add(0, "收 payload数据" + TimeUtils.getTimeSSS() +"cid=" + type + "\n" + data); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | |||||
| addLog( "收A7 payload数据" + TimeUtils.getTimeSSS() + "cid=" + type + "\n" + data); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @Override | @Override | ||||
| public void onCid(int cid, int vid, int pid) { | public void onCid(int cid, int vid, int pid) { | ||||
| mlogList.add(0, "收" + TimeUtils.getTime() + "cid:" + cid + "||vid:" + vid + "||pid:" + pid); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | |||||
| addLog("收" + TimeUtils.getTime() + "cid:" + cid + "||vid:" + vid + "||pid:" + pid); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void otherData(byte[] hex, String data) { | public void otherData(byte[] hex, String data) { | ||||
| mlogList.add(0, "收 透传数据" + TimeUtils.getTime() + data); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | |||||
| addLog("收 透传数据" + TimeUtils.getTime() + data); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void sendData(String data) { | |||||
| mlogList.add(0, "发 " + TimeUtils.getTimeSSS() + data); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | |||||
| public void a6Data(byte[] hex, String data) { | |||||
| addLog("收A6 payload数据" + TimeUtils.getTime() + data); | |||||
| } | } | ||||
| @Override | |||||
| public void sendData(String data) { | |||||
| addLog("发 " + TimeUtils.getTimeSSS() + data); | |||||
| } | |||||
| @Override | |||||
| public void onDisConnected(String mac, int code) { | |||||
| mlogList.add(0, "连接断开: " + mac + " code:" + code); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | |||||
| } | |||||
| private class MHandler extends Handler { | private class MHandler extends Handler { | ||||
| @Override | @Override | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| if (mAILinkBleManager !=null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | mAILinkBleManager.disconnectAll(); | ||||
| } | } | ||||
| } | } | ||||
| private void addLog(String log) { | |||||
| if (isPause){ | |||||
| return; | |||||
| } | |||||
| mlogList.add(0, log); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | |||||
| } | |||||
| } | } |
| private List<User> mUsers; | private List<User> mUsers; | ||||
| private User selectUser; | private User selectUser; | ||||
| private int weighunit = BodyFatDataUtil.KG; | private int weighunit = BodyFatDataUtil.KG; | ||||
| private ListView loglistView; | |||||
| private ListView loglistView; | |||||
| private ListView userlistView; | private ListView userlistView; | ||||
| @Override | @Override | ||||
| initdata(); | initdata(); | ||||
| } | } | ||||
| private void initView(){ | |||||
| private void initView() { | |||||
| findViewById(R.id.history).setOnClickListener(this); | findViewById(R.id.history).setOnClickListener(this); | ||||
| findViewById(R.id.userlist).setOnClickListener(this); | findViewById(R.id.userlist).setOnClickListener(this); | ||||
| findViewById(R.id.user).setOnClickListener(this); | findViewById(R.id.user).setOnClickListener(this); | ||||
| } | } | ||||
| private void initdata(){ | |||||
| private void initdata() { | |||||
| mAddress = getIntent().getStringExtra("mac"); | mAddress = getIntent().getStringExtra("mac"); | ||||
| WeakReference weakReference = new WeakReference(new MHandler()); | WeakReference weakReference = new WeakReference(new MHandler()); | ||||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mlogList); | listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mlogList); | ||||
| loglistView.setAdapter(listAdapter); | loglistView.setAdapter(listAdapter); | ||||
| User defaultUser=getdefault(); | |||||
| User defaultUser = getdefault(); | |||||
| selectUser = defaultUser; | selectUser = defaultUser; | ||||
| mUsers = new ArrayList<>(); | mUsers = new ArrayList<>(); | ||||
| userlistView.setAdapter(userAdapter); | userlistView.setAdapter(userAdapter); | ||||
| } | } | ||||
| private User getdefault(){ | |||||
| private User getdefault() { | |||||
| User user = new User(); | User user = new User(); | ||||
| user.setModeType(BodyFatDataUtil.MODE_ORDINARY); | user.setModeType(BodyFatDataUtil.MODE_ORDINARY); | ||||
| user.setSex(BodyFatDataUtil.SEX_MAN); | user.setSex(BodyFatDataUtil.SEX_MAN); | ||||
| user.setId(1); | user.setId(1); | ||||
| return user; | return user; | ||||
| } | } | ||||
| private void setUnitinit() { | private void setUnitinit() { | ||||
| kg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | kg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| mlogList.add(0, "服务与界面建立断开连接成功"); | mlogList.add(0, "服务与界面建立断开连接成功"); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| if (mAILinkBleManager !=null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | mAILinkBleManager.removeOnCallbackBle(this); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onWeightData(int status, float weight, int weightUnit, int decimals) { | public void onWeightData(int status, float weight, int weightUnit, int decimals) { | ||||
| String data = "体重数据类型:" + (status==BodyFatDataUtil.WEIGHT_TESTING?"实时":"稳定") + "\n体重: " + weight + " 单位:" + weightUnit + " 小数点位: " + decimals; | |||||
| String data = "体重数据类型:" + (status == BodyFatDataUtil.WEIGHT_TESTING ? "实时" : "稳定") + "\n体重: " + weight + " 单位:" + weightUnit + " 小数点位: " + decimals; | |||||
| if (mOldData.equals(data)) { | if (mOldData.equals(data)) { | ||||
| return; | return; | ||||
| } | } | ||||
| if (status == BodyFatDataUtil.WEIGHT_RESULT) { | |||||
| //稳定体重 | |||||
| selectUser.setWeight(weight); | |||||
| mMHandler.sendEmptyMessage(TO_REFRE_USER); | |||||
| } | |||||
| mOldData = data; | mOldData = data; | ||||
| mlogList.add(0, data); | mlogList.add(0, data); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| @Override | @Override | ||||
| public void onAdc(int adc, int algorithmic) { | public void onAdc(int adc, int algorithmic) { | ||||
| mlogList.add(0, "阻抗:" + adc + " 算法位:" + algorithmic); | mlogList.add(0, "阻抗:" + adc + " 算法位:" + algorithmic); | ||||
| selectUser.setAdc(adc); | |||||
| mMHandler.sendEmptyMessage(TO_REFRE_USER); | |||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| } | } | ||||
| } | } | ||||
| private final int ToRefreUi = 300; | private final int ToRefreUi = 300; | ||||
| private final int TO_REFRE_USER = 301; | |||||
| private class MHandler extends Handler { | private class MHandler extends Handler { | ||||
| listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
| } | } | ||||
| break; | break; | ||||
| case TO_REFRE_USER: | |||||
| if (userAdapter != null) { | |||||
| mUserlogList.clear(); | |||||
| if (mUsers!=null) { | |||||
| for (User user : mUsers) { | |||||
| mUserlogList.add(user.toString()); | |||||
| } | |||||
| } | |||||
| userAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| break; | |||||
| } | } | ||||
| } | } |
| public interface OnItemClickListener { | public interface OnItemClickListener { | ||||
| void onItemClick(int position); | void onItemClick(int position); | ||||
| void onLongClick(int position); | void onLongClick(int position); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onBindViewHolder(@NonNull KeyViewHolder holder, int position) { | public void onBindViewHolder(@NonNull KeyViewHolder holder, int position) { | ||||
| BleValueBean data = mList.get(position); | BleValueBean data = mList.get(position); | ||||
| String showData=data.getMac()+"="+data.getName()+"=" + data.getCid() + ";" + data.getVid() + ";" + data.getPid()+"="+data.getRssi(); | |||||
| String showData = data.getMac() + "=" + data.getRssi() + "\n" + data.getName() + "=" + getHexString(data.getCid()) + ";" + getHexString(data.getVid()) + ";" + getHexString(data.getPid()); | |||||
| holder.mTvTitle.setText(showData); | holder.mTvTitle.setText(showData); | ||||
| holder.mTvTitle.setOnClickListener(v -> { | holder.mTvTitle.setOnClickListener(v -> { | ||||
| if (listener != null) | if (listener != null) | ||||
| } | } | ||||
| } | } | ||||
| private String getHexString(int value) { | |||||
| if (value < 10) { | |||||
| return "0x0" + Integer.toHexString(value); | |||||
| } | |||||
| return "0x" + Integer.toHexString(value); | |||||
| } | |||||
| } | } |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.base; | |||||
| import android.content.Context; | |||||
| import android.content.pm.ActivityInfo; | |||||
| import android.os.Build; | |||||
| import android.os.Bundle; | |||||
| import android.os.Handler; | |||||
| import android.os.Message; | |||||
| import android.view.KeyEvent; | |||||
| import android.view.MenuItem; | |||||
| import android.view.View; | |||||
| import android.widget.TextView; | |||||
| import androidx.annotation.Nullable; | |||||
| import androidx.appcompat.widget.Toolbar; | |||||
| import java.lang.ref.WeakReference; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | |||||
| /** | |||||
| * 2019/4/16 11:55 | |||||
| * activity的基类, 共有的功能都可以写在这里 | |||||
| */ | |||||
| public abstract class BleAppNewBaseActivity extends BleNewBaseActivity { | |||||
| /** | |||||
| * 上下文对象 | |||||
| */ | |||||
| protected Context mContext; | |||||
| protected String TAG = this.getClass().getName(); | |||||
| protected Handler mHandler = new MyHandler(this); | |||||
| @Nullable | |||||
| protected TextView mTvTopTitle; | |||||
| @Nullable | |||||
| protected Toolbar mToolbar; | |||||
| //--------------ble--------------- | |||||
| @Override | |||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
| super.onCreate(savedInstanceState); | |||||
| if (getLayoutId() != 0) { | |||||
| initWindows(); | |||||
| setContentView(getLayoutId()); | |||||
| SaveActivityData(savedInstanceState); | |||||
| mContext = this; | |||||
| init(); | |||||
| } else if (getLayoutView() != null) { | |||||
| initWindows(); | |||||
| setContentView(getLayoutView()); | |||||
| SaveActivityData(savedInstanceState); | |||||
| mContext = this; | |||||
| init(); | |||||
| } | |||||
| } | |||||
| protected void SaveActivityData(Bundle savedInstanceState) { | |||||
| } | |||||
| /** | |||||
| * handler消息,使用弱引用,避免泄露问题 | |||||
| */ | |||||
| private static class MyHandler extends Handler { | |||||
| private WeakReference<BleAppNewBaseActivity> mActivity; | |||||
| MyHandler(BleAppNewBaseActivity activity) { | |||||
| mActivity = new WeakReference<>(activity); | |||||
| } | |||||
| @Override | |||||
| public void handleMessage(Message msg) { | |||||
| if (mActivity.get() == null) { | |||||
| return; | |||||
| } | |||||
| mActivity.get().uiHandlerMessage(msg); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * handler消息处理 | |||||
| */ | |||||
| protected abstract void uiHandlerMessage(Message msg); | |||||
| /** | |||||
| * 在绑定布局前的操作(状态,任务栏等的设置) | |||||
| */ | |||||
| protected void initWindows() { | |||||
| setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);//禁止横屏 | |||||
| //设置状态栏文字为黑色 | |||||
| if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { | |||||
| getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 获取当前activity的布局 | |||||
| * | |||||
| * @return int | |||||
| */ | |||||
| protected abstract int getLayoutId(); | |||||
| /** | |||||
| * 获取当前activity的布局 | |||||
| * | |||||
| * @return View | |||||
| */ | |||||
| protected View getLayoutView() { | |||||
| return null; | |||||
| } | |||||
| /** | |||||
| * 初始化 | |||||
| */ | |||||
| protected final void init() { | |||||
| addInit(); | |||||
| initView(); | |||||
| initData(); | |||||
| initListener(); | |||||
| } | |||||
| protected void addInit() { | |||||
| } | |||||
| //-----------------------权限---------------------------------------- | |||||
| protected void initPermissions() { | |||||
| new CheckPermissionUtils(this).checkPermissions(new CheckPermissionUtils.OnPermissionListener() { | |||||
| @Override | |||||
| public void onPermissionsOk() { | |||||
| BleAppNewBaseActivity.this.onPermissionsOk(); | |||||
| } | |||||
| }); | |||||
| } | |||||
| /** | |||||
| * 权限ok | |||||
| */ | |||||
| protected void onPermissionsOk() { | |||||
| } | |||||
| /** | |||||
| * 初始化事件 | |||||
| */ | |||||
| protected abstract void initListener(); | |||||
| /** | |||||
| * 初始化数据 | |||||
| */ | |||||
| protected abstract void initData(); | |||||
| /** | |||||
| * 初始化,绑定布局 | |||||
| */ | |||||
| protected abstract void initView(); | |||||
| // @Override | |||||
| // public boolean onCreateOptionsMenu(Menu menu) { | |||||
| // getMenuInflater().inflate(R.menu.public_toolbar_menu, menu); | |||||
| // MenuItem item = menu.findItem(R.id.img_public_right); | |||||
| // if (item != null) { | |||||
| // item.setIcon(R.drawable.me_manssage); | |||||
| // } | |||||
| // return true; | |||||
| // } | |||||
| @Override | |||||
| public boolean onOptionsItemSelected(MenuItem item) { | |||||
| int i = item.getItemId(); | |||||
| if (i == android.R.id.home) { | |||||
| myFinish(); | |||||
| return true; | |||||
| } | |||||
| return super.onOptionsItemSelected(item); | |||||
| } | |||||
| /** | |||||
| * 返回键 | |||||
| */ | |||||
| @Override | |||||
| public boolean onKeyDown(int keyCode, KeyEvent event) { | |||||
| if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0) { | |||||
| myFinish(); | |||||
| return true; | |||||
| } | |||||
| return super.onKeyDown(keyCode, event); | |||||
| } | |||||
| /** | |||||
| * 返回 | |||||
| */ | |||||
| protected void myFinish() { | |||||
| finish(); | |||||
| } | |||||
| protected void onClickRight() { | |||||
| } | |||||
| @Override | |||||
| protected void onStart() { | |||||
| super.onStart(); | |||||
| } | |||||
| @Override | |||||
| protected void onRestart() { | |||||
| super.onRestart(); | |||||
| } | |||||
| @Override | |||||
| protected void onResume() { | |||||
| super.onResume(); | |||||
| } | |||||
| @Override | |||||
| protected void onPause() { | |||||
| super.onPause(); | |||||
| } | |||||
| @Override | |||||
| protected void onStop() { | |||||
| super.onStop(); | |||||
| } | |||||
| @Override | |||||
| protected void onDestroy() { | |||||
| super.onDestroy(); | |||||
| if (mHandler != null) { | |||||
| mHandler.removeCallbacksAndMessages(null); | |||||
| } | |||||
| } | |||||
| } |
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | ||||
| public class MyApplication extends Application { | public class MyApplication extends Application { | ||||
| private static MyApplication sInstance; | private static MyApplication sInstance; |
| * 八电极体脂秤 | * 八电极体脂秤 | ||||
| */ | */ | ||||
| public final static int EIGHT_BODY_FAT_SCALE = 0x13; | public final static int EIGHT_BODY_FAT_SCALE = 0x13; | ||||
| /** | |||||
| * 八电极体脂秤 MCU算法 | |||||
| */ | |||||
| public final static int EIGHT_BODY_FAT_SCALE_MCU = 0x32; | |||||
| /** | |||||
| * 八电极体脂秤(双频_APP) | |||||
| */ | |||||
| public final static int EIGHT_BODY_FAT_SCALE_DUAL_BAND_APP = 0x0052; | |||||
| /** | |||||
| * 八电极体脂秤(双频_MCU) | |||||
| */ | |||||
| public final static int EIGHT_BODY_FAT_SCALE_DUAL_BAND_MCU = 0x0068; | |||||
| /** | /** | ||||
| * 风速计 | * 风速计 | ||||
| * 蓝牙营养秤 | * 蓝牙营养秤 | ||||
| */ | */ | ||||
| public final static int BLE_NUTRITION_SCALE = 0x0034; | public final static int BLE_NUTRITION_SCALE = 0x0034; | ||||
| /** | |||||
| * 蓝牙营养秤(支持营养元素) | |||||
| */ | |||||
| public final static int BLE_NUTRITION_SCALE_NUTRIENT = 0x006C; | |||||
| /** | /** | ||||
| * 蓝牙牙刷 | * 蓝牙牙刷 | ||||
| * 气压温湿度计 | * 气压温湿度计 | ||||
| */ | */ | ||||
| public static final int BAROMETRIC_TEMP_HUMIDITY = 0x005C; | public static final int BAROMETRIC_TEMP_HUMIDITY = 0x005C; | ||||
| /** | |||||
| * 气体检测仪(BLE) | |||||
| */ | |||||
| public static final int BLE_GAS_DETECTOR = 0x006F; | |||||
| //------------------特殊 | //------------------特殊 | ||||
| /** | /** |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.home; | package aicare.net.cn.sdk.ailinksdkdemoandroid.home; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.ADWeightScaleCmdActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.ADWeightScaleCmdActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.BroadcastScaleActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.BroadcastScaleActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.ClearShakeHandsActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.ClearShakeHandsActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.ConnectBleTestActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.ConnectBleTestActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.EightBodyfatActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.HeightCmdActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.HeightCmdActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.HeightWeightScaleActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.HeightWeightScaleActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.ShowBleActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.SmartMaskActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.SmartMaskActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.SphyCmdActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.SphyCmdActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.TempCmdActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.TempCmdActivity; | ||||
| 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.find.FindDeviceNewActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.PublicBleNetworkCmdActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.PublicBleNetworkCmdActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.PublicMqttActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.PublicWifiBleOtaActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.TempInstrument.TempInstrumentActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.TempInstrument.TempInstrumentActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.airdetector.AirDetectorActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.airdetector.AirDetectorActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity.BarometricTempHygrometerActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.barometric_temp_humidity.BarometricTempHygrometerActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.ble_nutrition.BleNutritionActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.ble_nutrition.BleNutritionActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.ble_nutrition.BleNutritionNutrientActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_glucose.BloodGlucoseActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_glucose.BloodGlucoseActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_pressure_tc.BloodPressureTcActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.blood_pressure_tc.BloodPressureTcActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.body_scale_4g.BodyScale4GActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.body_scale_4g.BodyScale4GActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_height.BroadcastHeightActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_height.BroadcastHeightActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_nutrition.BroadNutritionActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_nutrition.BroadNutritionActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_weight_sacle.BroadcastWeightScaleActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.broadcast_weight_sacle.BroadcastWeightScaleActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.bw05watch.Bw05WatchActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.coffee_scale.CoffeeScaleActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.coffee_scale.CoffeeScaleActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat.EightBodyFatMcuActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat.EightBodyfatActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat.dual_band.EightDoubleBodyfatActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.fascia_gun.FasciaGunActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.fascia_gun.FasciaGunActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.food_temp.FoodTempActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.food_temp.FoodTempActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.gasDetector.GasDetectorActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.leaone_broadcast.LeaOneBroadcastActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.leaone_broadcast.LeaOneBroadcastActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.meat_probe.MeatProbeActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.meat_probe.MeatProbeActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.meat_probe_charger.MeatProbeChargerActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.meat_probe_charger.MeatProbeChargerActivity; | ||||
| */ | */ | ||||
| public static ArrayList<JumpBean> getHomeDataList() { | public static ArrayList<JumpBean> getHomeDataList() { | ||||
| ArrayList<JumpBean> beanList = new ArrayList<>(); | ArrayList<JumpBean> beanList = new ArrayList<>(); | ||||
| Class<?> publicJumpActivity = ShowBleActivity.class; | |||||
| // 不握手不加密 | |||||
| // beanList.add(new JumpBean(BleDeviceConfig.CLEAR_SHAKE_HANDS, R.string.item_no_handshake_encryption, publicJumpActivity, ClearShakeHandsActivity.class)); | |||||
| // Ble通用设置 | // Ble通用设置 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_GENERAL_SETTINGS, R.string.item_ble_general_settings, null, BleCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_GENERAL_SETTINGS, R.string.item_ble_general_settings, publicJumpActivity, BleCmdActivity.class)); | |||||
| // BLE通用配网 | // BLE通用配网 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.PUBLIC_BLE_NETWORK, R.string.item_ble_universal_distribution_network, null, PublicBleNetworkCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.PUBLIC_BLE_NETWORK, R.string.item_ble_universal_distribution_network, publicJumpActivity, PublicBleNetworkCmdActivity.class)); | |||||
| // Ble test | // Ble test | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_TEST, R.string.item_ble_test, null, TestCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_TEST, R.string.item_ble_test, publicJumpActivity, TestCmdActivity.class)); | |||||
| // Ble connect test | // Ble connect test | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_ble_connect_test, ConnectBleTestActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_ble_connect_test, null, ConnectBleTestActivity.class)); | |||||
| // OTA通用 | |||||
| // beanList.add(new JumpBean(BleDeviceConfig.OTA, R.string.item_ota, publicJumpActivity, TestOtaActivity.class)); | |||||
| //MQTT通用 | |||||
| beanList.add(new JumpBean(BleDeviceConfig.OTA, R.string.item_mqtt, null, PublicMqttActivity.class)); | |||||
| // 透传 | // 透传 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.PENETRATE, R.string.item_penetrate, null, TransmissionActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.PENETRATE, R.string.item_penetrate, publicJumpActivity, TransmissionActivity.class)); | |||||
| //气体检测仪 | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_GAS_DETECTOR, R.string.gas_detector, publicJumpActivity, GasDetectorActivity.class)); | |||||
| // 广播秤 | // 广播秤 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_body_fat_scale_broadcast, BroadcastScaleActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_body_fat_scale_broadcast, null, BroadcastScaleActivity.class)); | |||||
| // Ble体脂秤 | // Ble体脂秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_BODY_FAT_SCALE, R.string.item_body_fat_scale_ble, null, WeightScaleBleActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_BODY_FAT_SCALE, R.string.item_body_fat_scale_ble, publicJumpActivity, WeightScaleBleActivity.class)); | |||||
| // 4G体脂秤 | // 4G体脂秤 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_body_fat_scale_4g, BodyScale4GActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_body_fat_scale_4g, null, BodyScale4GActivity.class)); | |||||
| // WiFi+Ble体脂秤 | // WiFi+Ble体脂秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE, R.string.item_body_fat_scale_wifi_ble, null, WeightScaleWifiBleActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE, R.string.item_body_fat_scale_wifi_ble, publicJumpActivity, WeightScaleWifiBleActivity.class)); | |||||
| // 八极秤 | // 八极秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.EIGHT_BODY_FAT_SCALE, R.string.item_body_fat_scale_eight, null, EightBodyfatActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.EIGHT_BODY_FAT_SCALE, R.string.item_body_fat_scale_eight, publicJumpActivity, EightBodyfatActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.EIGHT_BODY_FAT_SCALE_MCU, R.string.item_body_fat_scale_eight_mcu, publicJumpActivity, EightBodyFatMcuActivity.class)); | |||||
| //八电极秤,双频 APP | |||||
| beanList.add(new JumpBean(BleDeviceConfig.EIGHT_BODY_FAT_SCALE_DUAL_BAND_APP, R.string.item_body_fat_scale_eight_dual_band, publicJumpActivity, EightDoubleBodyfatActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.EIGHT_BODY_FAT_SCALE_DUAL_BAND_MCU, R.string.item_body_fat_scale_eight_dual_band_mcu, publicJumpActivity, EightDoubleBodyfatActivity.class)); | |||||
| // 艾迪体脂秤 | // 艾迪体脂秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_AD, R.string.item_body_fat_scale_aidi, null, ADWeightScaleCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_AD, R.string.item_body_fat_scale_aidi, publicJumpActivity, ADWeightScaleCmdActivity.class)); | |||||
| // 婴儿秤 | // 婴儿秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BABY_SCALE, R.string.item_baby_scale, null, BabyCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BABY_SCALE, R.string.item_baby_scale, publicJumpActivity, BabyCmdActivity.class)); | |||||
| // 婴儿体脂两用秤 | // 婴儿体脂两用秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BABY_BODY_FAT, R.string.item_baby_body_fat_scale, null, BabyBodyFatCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BABY_BODY_FAT, R.string.item_baby_body_fat_scale, publicJumpActivity, BabyBodyFatCmdActivity.class)); | |||||
| // Ble体重秤 | // Ble体重秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_SCALE, R.string.item_weight_scale_ble, null, WeightScaleActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.WEIGHT_SCALE, R.string.item_weight_scale_ble, publicJumpActivity, WeightScaleActivity.class)); | |||||
| // 广播体重秤 | // 广播体重秤 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_weight_scale_broadcast, BroadcastWeightScaleActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_weight_scale_broadcast, null, BroadcastWeightScaleActivity.class)); | |||||
| // 蓝牙营养秤 | // 蓝牙营养秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_NUTRITION_SCALE, R.string.item_nutritional_scale_ble, null, BleNutritionActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_NUTRITION_SCALE, R.string.item_nutritional_scale_ble, publicJumpActivity, BleNutritionActivity.class)); | |||||
| //支持营养元素的营养秤 | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_NUTRITION_SCALE_NUTRIENT, R.string.item_nutritional_scale_ble_nutrient, publicJumpActivity, BleNutritionNutrientActivity.class)); | |||||
| // 广播营养秤 | // 广播营养秤 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_nutritional_scale_broadcast, BroadNutritionActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_nutritional_scale_broadcast, null, BroadNutritionActivity.class)); | |||||
| // 咖啡秤 | // 咖啡秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.COFFEE_SCALE, R.string.item_coffee_scale, null, CoffeeScaleActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.COFFEE_SCALE, R.string.item_coffee_scale, publicJumpActivity, CoffeeScaleActivity.class)); | |||||
| // 身高体脂秤 | // 身高体脂秤 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.HEIGHT_BODY_FAT, R.string.item_height_body_fat_scale, null, HeightWeightScaleActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.HEIGHT_BODY_FAT, R.string.item_height_body_fat_scale, publicJumpActivity, HeightWeightScaleActivity.class)); | |||||
| // 身高仪 | // 身高仪 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.HEIGHT_METER, R.string.item_height_measuring_ble, null, HeightCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.HEIGHT_METER, R.string.item_height_measuring_ble, publicJumpActivity, HeightCmdActivity.class)); | |||||
| // 广播身高仪 | // 广播身高仪 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_height_measuring_broadcast, BroadcastHeightActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_height_measuring_broadcast, null, BroadcastHeightActivity.class)); | |||||
| // BLE血压计 | // BLE血压计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLOOD_PRESSURE, R.string.item_sphygmometer_ble, null, SphyCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLOOD_PRESSURE, R.string.item_sphygmometer_ble, publicJumpActivity, SphyCmdActivity.class)); | |||||
| // wifi血压计 | // wifi血压计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SPHY_WIFI_BLE, R.string.item_sphygmometer_wifi, null, WifiBleSphyActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SPHY_WIFI_BLE, R.string.item_sphygmometer_wifi, publicJumpActivity, WifiBleSphyActivity.class)); | |||||
| // 血压计透传 | // 血压计透传 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SPHYGMOMETER_PENETRATE, R.string.item_sphygmometer_penetrate, null, BloodPressureTcActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SPHYGMOMETER_PENETRATE, R.string.item_sphygmometer_penetrate, publicJumpActivity, BloodPressureTcActivity.class)); | |||||
| // 血糖仪 | // 血糖仪 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLOOD_GLUCOSE, R.string.item_blood_glucose_meter_ble, null, BloodGlucoseActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLOOD_GLUCOSE, R.string.item_blood_glucose_meter_ble, publicJumpActivity, BloodGlucoseActivity.class)); | |||||
| // 4G血糖仪 | // 4G血糖仪 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_blood_glucose_meter_4g, BloodSugar4GActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_blood_glucose_meter_4g, null, BloodSugar4GActivity.class)); | |||||
| // 血氧仪(广播) | // 血氧仪(广播) | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_oximeter_broadcast, BroadcastBloodOxygenActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_oximeter_broadcast, null, BroadcastBloodOxygenActivity.class)); | |||||
| // 血氧(连接) | // 血氧(连接) | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_BOOLD_OXYGEN, R.string.item_oximeter_ble, null, BloodOxygenActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_BOOLD_OXYGEN, R.string.item_oximeter_ble, publicJumpActivity, BloodOxygenActivity.class)); | |||||
| // 额温枪 | // 额温枪 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.INFRARED_THERMOMETER, R.string.item_infrared_thermometer, null, TempGunCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.INFRARED_THERMOMETER, R.string.item_infrared_thermometer, publicJumpActivity, TempGunCmdActivity.class)); | |||||
| // 体温计 | // 体温计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.THERMOMETER, R.string.item_thermometer, null, TempCmdActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.THERMOMETER, R.string.item_thermometer, publicJumpActivity, TempCmdActivity.class)); | |||||
| // 测温仪 | // 测温仪 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.TEMP_INSTRUMENT, R.string.item_auto_thermometer, null, TempInstrumentActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.TEMP_INSTRUMENT, R.string.item_auto_thermometer, publicJumpActivity, TempInstrumentActivity.class)); | |||||
| // 食品温度计 | // 食品温度计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.FOOD_TEMP, R.string.item_food_thermometer, null, FoodTempActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.FOOD_TEMP, R.string.item_food_thermometer, publicJumpActivity, FoodTempActivity.class)); | |||||
| // 食物探针 | // 食物探针 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.MEAT_PROBE, R.string.item_meat_probe, null, MeatProbeActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.MEAT_PROBE, R.string.item_meat_probe, publicJumpActivity, MeatProbeActivity.class)); | |||||
| // 探针充电盒 | // 探针充电盒 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.MEAT_PROBE_CHARGER, R.string.item_probe_charging_box, null, MeatProbeChargerActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.MEAT_PROBE_CHARGER, R.string.item_probe_charging_box, publicJumpActivity, MeatProbeChargerActivity.class)); | |||||
| // 牙刷(wifi+ble) | // 牙刷(wifi+ble) | ||||
| beanList.add(new JumpBean(BleDeviceConfig.TOOTHBRUSH_WIFI_BLE, R.string.item_toothbrush_wifi_ble, null, ToothBrushWifiBleActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.TOOTHBRUSH_WIFI_BLE, R.string.item_toothbrush_wifi_ble, publicJumpActivity, ToothBrushWifiBleActivity.class)); | |||||
| // 牙刷测试 | // 牙刷测试 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.TOOTHBRUSH_TEST, R.string.item_toothbrush_test, null, ToothbrushTestActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.TOOTHBRUSH_TEST, R.string.item_toothbrush_test, publicJumpActivity, ToothbrushTestActivity.class)); | |||||
| // 口罩 | // 口罩 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SMART_MASK, R.string.item_smart_mask, null, SmartMaskActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SMART_MASK, R.string.item_smart_mask, publicJumpActivity, SmartMaskActivity.class)); | |||||
| // 筋膜枪 | // 筋膜枪 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.FASCIA_GUN, R.string.item_fascia_gun, null, FasciaGunActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.FASCIA_GUN, R.string.item_fascia_gun, publicJumpActivity, FasciaGunActivity.class)); | |||||
| // 跳绳 | // 跳绳 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.ROPE_SKIPPING, R.string.item_rope_skipping, null, RopeSkippingActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.ROPE_SKIPPING, R.string.item_rope_skipping, publicJumpActivity, RopeSkippingActivity.class)); | |||||
| // 跳绳设置模式 | // 跳绳设置模式 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_rope_skipping_set_mode, RopeSkippingSetActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_rope_skipping_set_mode, null, RopeSkippingSetActivity.class)); | |||||
| // 温湿度计 | // 温湿度计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.TEMP_Humidity, R.string.item_hygrothermograph, null, TempHumidityActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.TEMP_Humidity, R.string.item_hygrothermograph, publicJumpActivity, TempHumidityActivity.class)); | |||||
| // 气压温湿度计 | // 气压温湿度计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BAROMETRIC_TEMP_HUMIDITY, R.string.item_barothermohygrograph, null, BarometricTempHygrometerActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BAROMETRIC_TEMP_HUMIDITY, R.string.item_barothermohygrograph, publicJumpActivity, BarometricTempHygrometerActivity.class)); | |||||
| // ble噪音计 | // ble噪音计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_NOISE_METER, R.string.item_noise_meter_ble, null, BleNoiseMeterActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.BLE_NOISE_METER, R.string.item_noise_meter_ble, publicJumpActivity, BleNoiseMeterActivity.class)); | |||||
| // wifi+ble噪音计 | // wifi+ble噪音计 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.WIFI_BLE_NOISE_METER, R.string.item_noise_meter_wifi_ble, null, WifiBleNoiseMeterActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.WIFI_BLE_NOISE_METER, R.string.item_noise_meter_wifi_ble, publicJumpActivity, WifiBleNoiseMeterActivity.class)); | |||||
| // 空气检测仪 | // 空气检测仪 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.MQTT_AIR_DETECTOR, R.string.item_air_Detector, null, AirDetectorActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.MQTT_AIR_DETECTOR, R.string.item_air_Detector, publicJumpActivity, AirDetectorActivity.class)); | |||||
| // 电滑板Cm02 | // 电滑板Cm02 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SMART_SCOOTER_CM02, R.string.item_scooter_cm02, null, AiLinkScooterActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SMART_SCOOTER_CM02, R.string.item_scooter_cm02, publicJumpActivity, AiLinkScooterActivity.class)); | |||||
| // 共享充电器 | // 共享充电器 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SHARE_CHARGER, R.string.item_shared_charger, null, ShareChargerActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SHARE_CHARGER, R.string.item_shared_charger, publicJumpActivity, ShareChargerActivity.class)); | |||||
| // 共享插座 | // 共享插座 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SHARE_SOCKET, R.string.item_shared_socket, null, ShareSocketActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SHARE_SOCKET, R.string.item_shared_socket, publicJumpActivity, ShareSocketActivity.class)); | |||||
| // 共享套套机 | // 共享套套机 | ||||
| beanList.add(new JumpBean(BleDeviceConfig.SHARE_CONDOM, R.string.item_condom, null, ShareCondomActivity.class)); | |||||
| beanList.add(new JumpBean(BleDeviceConfig.SHARE_CONDOM, R.string.item_condom, publicJumpActivity, ShareCondomActivity.class)); | |||||
| // 寻物器 | // 寻物器 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_finder, FindDeviceNewActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_finder, null, FindDeviceNewActivity.class)); | |||||
| // LeaOne测试 | // LeaOne测试 | ||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_leaone, LeaOneBroadcastActivity.class, null)); | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_leaone, null, LeaOneBroadcastActivity.class)); | |||||
| // wifi+ble ota工具 | |||||
| beanList.add(new JumpBean(BleDeviceConfig.WIFI_BLE_OTA, BleDeviceConfig.WEIGHT_BODY_FAT_SCALE_WIFI_BLE, R.string.wifi_ble_ota_tool, publicJumpActivity, PublicWifiBleOtaActivity.class)); | |||||
| //bw05暨芯手表 | |||||
| beanList.add(new JumpBean(IGNORE_TYPE, R.string.item_bw05_watch, null, Bw05WatchActivity.class)); | |||||
| return beanList; | return beanList; | ||||
| } | } | ||||
| public static ArrayList<JumpBean> getHideDataList() { | public static ArrayList<JumpBean> getHideDataList() { | ||||
| ArrayList<JumpBean> hideList = new ArrayList<>(); | ArrayList<JumpBean> hideList = new ArrayList<>(); | ||||
| Class<?> publicJumpActivity = ShowBleActivity.class; | |||||
| // 不握手不加密 | // 不握手不加密 | ||||
| hideList.add(new JumpBean(BleDeviceConfig.CLEAR_SHAKE_HANDS, R.string.item_no_handshake_encryption, null, ClearShakeHandsActivity.class)); | |||||
| hideList.add(new JumpBean(BleDeviceConfig.CLEAR_SHAKE_HANDS, R.string.item_no_handshake_encryption, publicJumpActivity, ClearShakeHandsActivity.class)); | |||||
| // wifi 配置 | // wifi 配置 | ||||
| hideList.add(new JumpBean(IGNORE_TYPE, R.string.item_wifi_config, WifiConfigActivity.class, null)); | |||||
| hideList.add(new JumpBean(IGNORE_TYPE, R.string.item_wifi_config, null, WifiConfigActivity.class)); | |||||
| return hideList; | return hideList; | ||||
| } | } | ||||
| /** | /** | ||||
| * 要跳转的目标Activity | * 要跳转的目标Activity | ||||
| * | |||||
| * @param type | * @param type | ||||
| * @return | * @return | ||||
| */ | */ |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.home; | package aicare.net.cn.sdk.ailinksdkdemoandroid.home; | ||||
| import java.util.List; | |||||
| /** | /** | ||||
| * 说明: | * 说明: | ||||
| * | * | ||||
| public class JumpBean { | public class JumpBean { | ||||
| private int itemType; | private int itemType; | ||||
| private List<Integer> itemTypeList; | |||||
| /** | /** | ||||
| * cid | * cid | ||||
| */ | */ | ||||
| */ | */ | ||||
| private int itemNameResId; | private int itemNameResId; | ||||
| /** | /** | ||||
| * 需要单独跳转的 Activity | |||||
| * 需要单独跳转的 Activity, null 表示不需要跳转 | |||||
| */ | */ | ||||
| private Class<?> jumpActivityClass; | private Class<?> jumpActivityClass; | ||||
| import android.graphics.Rect; | import android.graphics.Rect; | ||||
| import android.os.Build; | import android.os.Build; | ||||
| import android.os.Bundle; | import android.os.Bundle; | ||||
| import android.os.Handler; | |||||
| import android.os.Looper; | |||||
| import android.os.Message; | |||||
| import android.text.Editable; | |||||
| import android.text.TextUtils; | |||||
| import android.text.TextWatcher; | |||||
| import android.view.Menu; | import android.view.Menu; | ||||
| import android.view.MenuItem; | import android.view.MenuItem; | ||||
| import android.view.View; | import android.view.View; | ||||
| import android.widget.EditText; | |||||
| import androidx.annotation.NonNull; | import androidx.annotation.NonNull; | ||||
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
| import com.pingwang.bluetoothlib.AILinkBleManager; | import com.pingwang.bluetoothlib.AILinkBleManager; | ||||
| import com.pingwang.bluetoothlib.AILinkSDK; | import com.pingwang.bluetoothlib.AILinkSDK; | ||||
| import com.pingwang.bluetoothlib.bean.AilinkLicenseBean; | import com.pingwang.bluetoothlib.bean.AilinkLicenseBean; | ||||
| import com.pingwang.bluetoothlib.bean.BleValueBean; | |||||
| import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
| import com.pingwang.bluetoothlib.utils.BleLog; | import com.pingwang.bluetoothlib.utils.BleLog; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| private Context mContext; | private Context mContext; | ||||
| private RecyclerView rvList; | private RecyclerView rvList; | ||||
| private ArrayList<JumpBean> mList = new ArrayList<>(); | |||||
| private ArrayList<JumpBean> homeDataList = HomeDataManager.getHomeDataList(); | |||||
| private CharSequence inputData = ""; | |||||
| private HomeListAdapter mHomeListAdapter; | |||||
| private Handler mHandler = new Handler(Looper.getMainLooper()) { | |||||
| @Override | |||||
| public void handleMessage(@NonNull Message msg) { | |||||
| if (mHomeListAdapter != null) { | |||||
| mHomeListAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| } | |||||
| }; | |||||
| @Override | @Override | ||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
| initListener(); | initListener(); | ||||
| int bodyComposition = new BhBodyComposition().getBodyComposition(); | int bodyComposition = new BhBodyComposition().getBodyComposition(); | ||||
| L.i("bodyComposition:" + bodyComposition); | L.i("bodyComposition:" + bodyComposition); | ||||
| EditText etSearch = findViewById(R.id.etSearch); | |||||
| etSearch.addTextChangedListener(new TextWatcher() { | |||||
| /** | |||||
| * @param s 年代 | |||||
| * @param start 开始 | |||||
| * @param count 数 | |||||
| * @param after | |||||
| */ | |||||
| @Override | |||||
| public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |||||
| } | |||||
| /** | |||||
| * 文本更改 | |||||
| * | |||||
| * @param s 年代 | |||||
| * @param start 开始 | |||||
| * @param before 之前 | |||||
| * @param count 数 | |||||
| */ | |||||
| @Override | |||||
| public void onTextChanged(CharSequence s, int start, int before, int count) { | |||||
| inputData = s; | |||||
| } | |||||
| /** | |||||
| * 文本更改后 | |||||
| * | |||||
| * @param s 年代 | |||||
| */ | |||||
| @Override | |||||
| public void afterTextChanged(Editable s) { | |||||
| String data = inputData.toString().trim(); | |||||
| if (TextUtils.isEmpty(data)) { | |||||
| //未输入内容,显示全部 | |||||
| mList.clear(); | |||||
| mList.addAll(homeDataList); | |||||
| mHandler.sendEmptyMessage(1); | |||||
| } else { | |||||
| refreshList(data); | |||||
| } | |||||
| } | |||||
| }); | |||||
| findViewById(R.id.ivClear).setOnClickListener(new View.OnClickListener() { | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| etSearch.setText(""); | |||||
| } | |||||
| }); | |||||
| } | |||||
| private void refreshList(String data) { | |||||
| ArrayList<JumpBean> list = new ArrayList<>(); | |||||
| for (JumpBean jumpBean : homeDataList) { | |||||
| String name = mContext.getString(jumpBean.getItemNameResId()).toUpperCase(); | |||||
| if (name.contains(data.toUpperCase())) { | |||||
| list.add(jumpBean); | |||||
| } | |||||
| } | |||||
| mList.clear(); | |||||
| mList.addAll(list); | |||||
| mHandler.sendEmptyMessage(1); | |||||
| } | } | ||||
| list.add(new AilinkLicenseBean(0x2F, 0x03, 0x09)); | list.add(new AilinkLicenseBean(0x2F, 0x03, 0x09)); | ||||
| list.add(new AilinkLicenseBean(0x2F, 0x03, 0x01)); | list.add(new AilinkLicenseBean(0x2F, 0x03, 0x01)); | ||||
| list.add(new AilinkLicenseBean(65544, 103, 0)); | list.add(new AilinkLicenseBean(65544, 103, 0)); | ||||
| list.add(new AilinkLicenseBean(65544, 21, 0)); | |||||
| list.add(new AilinkLicenseBean(0x02, 0x99, 0x01)); | |||||
| AILinkSDK.getInstance().initLicense(list); | AILinkSDK.getInstance().initLicense(list); | ||||
| } | |||||
| private int count = 0; | |||||
| private OnCallbackBle mOnCallbackBle = new OnCallbackBle() { | |||||
| @Override | |||||
| public void onStartScan() { | |||||
| OnCallbackBle.super.onStartScan(); | |||||
| } | |||||
| @Override | |||||
| public void onScanning(BleValueBean data) { | |||||
| // AILinkBleManager.getInstance().removeOnCallbackBle(mOnCallbackBle); | |||||
| } | |||||
| }; | |||||
| } | |||||
| protected void initView() { | protected void initView() { | ||||
| BleLog.init(true); | BleLog.init(true); | ||||
| AILinkBleManager.getInstance().init(mContext, new AILinkBleManager.onInitListener() { | AILinkBleManager.getInstance().init(mContext, new AILinkBleManager.onInitListener() { | ||||
| @Override | @Override | ||||
| public void onInitSuccess() { | public void onInitSuccess() { | ||||
| AILinkBleManager.getInstance().startScan(0); | |||||
| // AILinkBleManager.getInstance().setOnCallbackBle(mOnCallbackBle); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onInitFailure() { | public void onInitFailure() { | ||||
| L.e("初始化失败"); | |||||
| } | } | ||||
| }); | }); | ||||
| rvList = findViewById(R.id.rv_list); | rvList = findViewById(R.id.rv_list); | ||||
| rvList.setLayoutManager(new LinearLayoutManager(this)); | rvList.setLayoutManager(new LinearLayoutManager(this)); | ||||
| HomeListAdapter adapter = new HomeListAdapter(this, HomeDataManager.getHomeDataList()); | |||||
| rvList.setAdapter(adapter); | |||||
| adapter.setItemClickListener(new HomeListAdapter.ItemClickListener() { | |||||
| mList.clear(); | |||||
| mList.addAll(homeDataList); | |||||
| mHomeListAdapter = new HomeListAdapter(this, mList); | |||||
| rvList.setAdapter(mHomeListAdapter); | |||||
| mHomeListAdapter.setItemClickListener(new HomeListAdapter.ItemClickListener() { | |||||
| @Override | @Override | ||||
| public void onItemClick(JumpBean bean) { | public void onItemClick(JumpBean bean) { | ||||
| count = 0; | |||||
| if (bean.getJumpActivityClass() != null) { | if (bean.getJumpActivityClass() != null) { | ||||
| startActivity(bean.getJumpActivityClass()); | |||||
| startActivity(bean.getItemType(), bean.getCid(), bean.getJumpActivityClass()); | |||||
| } else if (bean.getTargetActivityClass() != null) { | |||||
| startActivity(bean.getTargetActivityClass()); | |||||
| } else { | } else { | ||||
| startActivity(bean.getItemType(),bean.getCid()); | |||||
| startActivity(bean.getItemType(), bean.getCid(), ShowBleActivity.class); | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| }); | }); | ||||
| } | } | ||||
| private void startActivity(int type,int cid) { | |||||
| Intent intent = new Intent(this, ShowBleActivity.class); | |||||
| private void startActivity(int type, int cid, Class<?> activityClass) { | |||||
| Intent intent = new Intent(this, activityClass); | |||||
| intent.putExtra("type", type); | intent.putExtra("type", type); | ||||
| intent.putExtra("cid", cid); | intent.putExtra("cid", cid); | ||||
| startActivity(intent); | startActivity(intent); |
| * | * | ||||
| * @author xing | * @author xing | ||||
| */ | */ | ||||
| public class BleDemoActivity extends BleBaseActivity { | |||||
| public class BleDemoActivity extends BleBaseActivity { | |||||
| private ListView list_view; | private ListView list_view; | ||||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules; | |||||
| import android.os.Message; | |||||
| import android.text.TextUtils; | |||||
| import android.view.View; | |||||
| import android.widget.ArrayAdapter; | |||||
| import android.widget.EditText; | |||||
| import android.widget.ListView; | |||||
| import android.widget.TextView; | |||||
| import com.elinkthings.elinkmqttlib.listener.OnMqttConnectListener; | |||||
| import com.elinkthings.elinkmqttlib.listener.OnMqttMessageListener; | |||||
| import com.elinkthings.elinkmqttlib.listener.OnMqttOtherMessageListener; | |||||
| import com.elinkthings.elinkmqttlib.mqtt.MqttDevice; | |||||
| import com.elinkthings.elinkmqttlib.mqtt.MqttManager; | |||||
| import com.pingwang.bluetoothlib.utils.BleStrUtils; | |||||
| import java.util.ArrayList; | |||||
| import java.util.Arrays; | |||||
| import java.util.List; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.AppBaseActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
| /** | |||||
| * 公共mqtt界面 | |||||
| * | |||||
| * @author xing | |||||
| * @date 2024/04/19 | |||||
| */ | |||||
| public class PublicMqttActivity extends AppBaseActivity implements View.OnClickListener, OnMqttMessageListener, OnMqttOtherMessageListener { | |||||
| private final int REFRESH_DATA = 1; | |||||
| private EditText etAppUserId; | |||||
| private EditText etDeviceId; | |||||
| private EditText etSendData; | |||||
| private EditText etSendDataDeviceId; | |||||
| private TextView tvDeviceList; | |||||
| private List<String> mList; | |||||
| private ArrayAdapter listAdapter; | |||||
| private ListView lv_log; | |||||
| /** | |||||
| * _mac地址用于加解密,这里随便写一个,实际使用时需要替换 | |||||
| */ | |||||
| private String mMac = "00:00:00:00:00:00"; | |||||
| @Override | |||||
| protected void uiHandlerMessage(Message msg) { | |||||
| if (msg.what == REFRESH_DATA) { | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| protected int getLayoutId() { | |||||
| return R.layout.activity_public_mqtt; | |||||
| } | |||||
| @Override | |||||
| protected void initListener() { | |||||
| MqttManager.getInstance().addOnMqttConnectListener(new OnMqttConnectListener() { | |||||
| @Override | |||||
| public void onConnected() { | |||||
| addLog("Mqtt连接成功"); | |||||
| } | |||||
| @Override | |||||
| public void onConnecting() { | |||||
| addLog("Mqtt正在连接中"); | |||||
| } | |||||
| @Override | |||||
| public void onDisconnect(int errCode) { | |||||
| addLog("Mqtt断开连接,错误码:" + errCode); | |||||
| } | |||||
| @Override | |||||
| public void onSubscribeSuccess(String... topics) { | |||||
| addLog("订阅成功:\n" + Arrays.toString(topics)); | |||||
| for (String topic : topics) { | |||||
| MqttDevice device = MqttManager.getInstance().getDeviceForTopic(topic); | |||||
| device.setOnMqttMessageListener(PublicMqttActivity.this); | |||||
| device.setOnMqttOtherMessageListener(PublicMqttActivity.this); | |||||
| device.setOnA7EncryptionListener(new MqttDevice.OnA7EncryptionListener() { | |||||
| @Override | |||||
| public byte[] onA7Encryption(int cid, byte[] cidBytes, byte[] payload) { | |||||
| // return AiLinkPwdUtil.mcuEncrypt(cidBytes, getMacByte(mMac), payload); | |||||
| return payload; | |||||
| } | |||||
| }); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onSubscribeFail(String... topics) { | |||||
| addLog("订阅失败:\n" + Arrays.toString(topics)); | |||||
| } | |||||
| }); | |||||
| } | |||||
| @Override | |||||
| public void onMessage(String topic, String deviceId, int cid, byte[] payload) { | |||||
| addLog("设备ID:" + deviceId + " 接收到消息:" + BleStrUtils.byte2HexStr(payload)); | |||||
| } | |||||
| @Override | |||||
| public void onSendSuccess(String topic, String deviceId, byte[] payload) { | |||||
| addLog("设备ID:" + deviceId + " 发送消息成功:" + BleStrUtils.byte2HexStr(payload)); | |||||
| } | |||||
| @Override | |||||
| public void onSendFailure(String topic, String deviceId, byte[] payload, int errCode, int retryCount) { | |||||
| addLog("设备ID:" + deviceId + " 发送消息失败:" + BleStrUtils.byte2HexStr(payload)); | |||||
| } | |||||
| @Override | |||||
| public void onOtherMessage(String topic, String deviceId, byte[] hex) { | |||||
| addLog("设备ID:" + deviceId + " 接收到透传消息:" + BleStrUtils.byte2HexStr(hex)); | |||||
| } | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| int id = v.getId(); | |||||
| if (id == R.id.btnClearShakeHands) { | |||||
| mList.clear(); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| } else if (id == R.id.btnConnectMqtt) { | |||||
| String appId = etAppUserId.getText().toString(); | |||||
| if (TextUtils.isEmpty(appId)) { | |||||
| addLog("App Id不能为空"); | |||||
| return; | |||||
| } | |||||
| //禁止etAppUserId编辑 | |||||
| etAppUserId.setEnabled(false); | |||||
| MqttManager.getInstance().init(this, appId); | |||||
| addLog("正在连接Mqtt:" + appId); | |||||
| MqttManager.getInstance().connectMqtt(); | |||||
| } else if (id == R.id.btnDisconnectMqtt) { | |||||
| etAppUserId.setEnabled(true); | |||||
| addLog("正在断开Mqtt连接"); | |||||
| MqttManager.getInstance().disconnect(); | |||||
| } else if (id == R.id.btnAddDevice) { | |||||
| String deviceId = etDeviceId.getText().toString(); | |||||
| MqttManager.getInstance().addDevice(deviceId); | |||||
| addLog("添加设备:" + deviceId); | |||||
| etDeviceId.setText(""); | |||||
| refreshDeviceList(); | |||||
| } else if (id == R.id.btnRemoveDevice) { | |||||
| String deviceId = etDeviceId.getText().toString(); | |||||
| MqttManager.getInstance().removeDevice(deviceId); | |||||
| addLog("移除设备:" + deviceId); | |||||
| etDeviceId.setText(""); | |||||
| refreshDeviceList(); | |||||
| } else if (id == R.id.btnSendData) { | |||||
| String data = etSendData.getText().toString().trim(); | |||||
| data = data.replaceAll(" ", ""); | |||||
| if (TextUtils.isEmpty(data)) { | |||||
| addLog("发送数据不能为空"); | |||||
| return; | |||||
| } | |||||
| String deviceId = etSendDataDeviceId.getText().toString(); | |||||
| if (TextUtils.isEmpty(deviceId)) { | |||||
| addLog("设备Id不能为空"); | |||||
| return; | |||||
| } | |||||
| byte[] bytes = new byte[0]; | |||||
| try { | |||||
| bytes = BleStrUtils.stringToByte(data); | |||||
| } catch (Exception e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| MqttDevice device = MqttManager.getInstance().getDevice(deviceId); | |||||
| if (device != null) { | |||||
| if (bytes.length == 0) { | |||||
| addLog("发送数据不能为空"); | |||||
| return; | |||||
| } | |||||
| device.sendData(bytes); | |||||
| addLog("发送数据:" + data + " 设备:" + deviceId); | |||||
| } else { | |||||
| addLog("设备不存在或者未连接:" + deviceId); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| protected void initData() { | |||||
| mList = new ArrayList<>(); | |||||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
| lv_log.setAdapter(listAdapter); | |||||
| } | |||||
| @Override | |||||
| protected void initView() { | |||||
| findViewById(R.id.btnClearShakeHands).setOnClickListener(this); | |||||
| findViewById(R.id.btnConnectMqtt).setOnClickListener(this); | |||||
| findViewById(R.id.btnDisconnectMqtt).setOnClickListener(this); | |||||
| etAppUserId = (EditText) findViewById(R.id.etAppUserId); | |||||
| etDeviceId = (EditText) findViewById(R.id.etDeviceId); | |||||
| findViewById(R.id.btnAddDevice).setOnClickListener(this); | |||||
| findViewById(R.id.btnRemoveDevice).setOnClickListener(this); | |||||
| tvDeviceList = (TextView) findViewById(R.id.tvDeviceList); | |||||
| lv_log = findViewById(R.id.lv_log); | |||||
| etSendData = (EditText) findViewById(R.id.etSendData); | |||||
| etSendDataDeviceId = (EditText) findViewById(R.id.etSendDataDeviceId); | |||||
| findViewById(R.id.btnSendData).setOnClickListener(this); | |||||
| } | |||||
| private void refreshDeviceList() { | |||||
| List<String> deviceList = MqttManager.getInstance().getDeviceList(); | |||||
| String deviceListStr = TextUtils.join(",", deviceList); | |||||
| tvDeviceList.setText(deviceListStr); | |||||
| } | |||||
| /** | |||||
| * 添加日志 | |||||
| * | |||||
| * @param log 日志 | |||||
| */ | |||||
| private void addLog(String log) { | |||||
| log = TimeUtils.getTimeSSS() + log; | |||||
| mList.add(0, log); | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | |||||
| } | |||||
| /** | |||||
| * 获取mac字节 | |||||
| * | |||||
| * @param mac mac | |||||
| * @return {@link byte[]} | |||||
| */ | |||||
| private byte[] getMacByte(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; | |||||
| } | |||||
| } |
| 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.btnClear).setOnClickListener(this); | |||||
| findViewById(R.id.btnClearShakeHands).setOnClickListener(this); | |||||
| findViewById(R.id.btnGetConfig).setOnClickListener(this); | findViewById(R.id.btnGetConfig).setOnClickListener(this); | ||||
| findViewById(R.id.btnSetUnit).setOnClickListener(this); | findViewById(R.id.btnSetUnit).setOnClickListener(this); | ||||
| mBleDevice.sendData(sendBleBean); | mBleDevice.sendData(sendBleBean); | ||||
| break; | break; | ||||
| case R.id.btnClear: | |||||
| case R.id.btnClearShakeHands: | |||||
| if (mList != null) | if (mList != null) | ||||
| mList.clear(); | mList.clear(); | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.airdetector; | package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.airdetector; | ||||
| import android.app.AlertDialog; | import android.app.AlertDialog; | ||||
| import android.content.ClipData; | |||||
| import android.content.ClipboardManager; | |||||
| import android.content.Context; | |||||
| import android.content.Intent; | import android.content.Intent; | ||||
| import android.os.Message; | import android.os.Message; | ||||
| import android.util.SparseArray; | import android.util.SparseArray; | ||||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | ||||
| listAdapterPayload = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mListPayload); | listAdapterPayload = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mListPayload); | ||||
| list_view.setAdapter(listAdapter); | list_view.setAdapter(listAdapter); | ||||
| list_view.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() { | |||||
| @Override | |||||
| public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) { | |||||
| copyTextToClipboard(AirDetectorActivity.this, mList.get(position)); | |||||
| return true; | |||||
| } | |||||
| }); | |||||
| list_view_payload.setAdapter(listAdapterPayload); | list_view_payload.setAdapter(listAdapterPayload); | ||||
| initSettingTypes(); | initSettingTypes(); | ||||
| initAlarmModeSP(); | initAlarmModeSP(); | ||||
| } | } | ||||
| private void copyTextToClipboard(Context context, String text) { | |||||
| ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE); | |||||
| if (clipboard != null) { | |||||
| clipboard.setPrimaryClip(ClipData.newPlainText("label", text)); | |||||
| Toast.makeText(context, "已复制到剪切板", Toast.LENGTH_SHORT).show(); | |||||
| } | |||||
| } | |||||
| private void initAlarmModeSP() { | private void initAlarmModeSP() { | ||||
| ArrayList<String> modeList = new ArrayList<>(); | ArrayList<String> modeList = new ArrayList<>(); | ||||
| modeList.add("选择模式"); | modeList.add("选择模式"); | ||||
| @Override | @Override | ||||
| public void onNotifyOtherData(String uuid, byte[] hex) { | public void onNotifyOtherData(String uuid, byte[] hex) { | ||||
| if (stopFlag) { | |||||
| return; | |||||
| } | |||||
| String data = BleStrUtils.byte2HexStr(hex); | String data = BleStrUtils.byte2HexStr(hex); | ||||
| addTextWithTime("接收到未知指令:" + data); | addTextWithTime("接收到未知指令:" + data); | ||||
| } | } |
| import cn.net.aicare.modulelibrary.module.airDetector.AirConst; | import cn.net.aicare.modulelibrary.module.airDetector.AirConst; | ||||
| import cn.net.aicare.modulelibrary.module.airDetector.AlarmClockStatement; | import cn.net.aicare.modulelibrary.module.airDetector.AlarmClockStatement; | ||||
| import cn.net.aicare.modulelibrary.module.airDetector.BrightnessStatement; | import cn.net.aicare.modulelibrary.module.airDetector.BrightnessStatement; | ||||
| import cn.net.aicare.modulelibrary.module.airDetector.StatusBean; | |||||
| import cn.net.aicare.modulelibrary.module.airDetector.SupportBean; | import cn.net.aicare.modulelibrary.module.airDetector.SupportBean; | ||||
| import cn.net.aicare.modulelibrary.module.airDetector.StatusBean; | |||||
| /** | /** | ||||
| * @author yesp | * @author yesp |
| import androidx.annotation.Nullable; | import androidx.annotation.Nullable; | ||||
| import com.pingwang.bluetoothlib.bean.SupportUnitBean; | import com.pingwang.bluetoothlib.bean.SupportUnitBean; | ||||
| import com.pingwang.bluetoothlib.config.CmdConfig; | |||||
| import com.pingwang.bluetoothlib.device.BleDevice; | import com.pingwang.bluetoothlib.device.BleDevice; | ||||
| import com.pingwang.bluetoothlib.listener.OnBleSettingListener; | |||||
| import java.math.BigDecimal; | import java.math.BigDecimal; | ||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.TimeUtils; | |||||
| import cn.net.aicare.modulelibrary.module.BleNutrition.BleNutritionData; | import cn.net.aicare.modulelibrary.module.BleNutrition.BleNutritionData; | ||||
| import cn.net.aicare.modulelibrary.module.BleNutrition.BleNutritionHistoryBean; | |||||
| public class BleNutritionActivity extends BleBaseActivity implements View.OnClickListener, BleNutritionData.BleNutritionCallback { | |||||
| public class BleNutritionActivity extends BleBaseActivity implements View.OnClickListener, BleNutritionData.BleNutritionCallback, OnBleSettingListener { | |||||
| private static final String TAG = "Tag1"; | private static final String TAG = "Tag1"; | ||||
| private String mMac; | private String mMac; | ||||
| private BleDevice mBleDevice; | private BleDevice mBleDevice; | ||||
| private boolean mBuzzOpen = false; | |||||
| private BleNutritionData mBleNutritionData; | private BleNutritionData mBleNutritionData; | ||||
| @Override | @Override | ||||
| btn_clear.setOnClickListener(this); | btn_clear.setOnClickListener(this); | ||||
| btn_set_unit.setOnClickListener(this); | btn_set_unit.setOnClickListener(this); | ||||
| btn_set_zero.setOnClickListener(this); | btn_set_zero.setOnClickListener(this); | ||||
| findViewById(R.id.btnVoice).setOnClickListener(this); | |||||
| findViewById(R.id.btnReadHistory).setOnClickListener(this); | |||||
| findViewById(R.id.btnClearHistory).setOnClickListener(this); | |||||
| findViewById(R.id.btnSynTime).setOnClickListener(this); | |||||
| rb_list = new ArrayList<>(); | rb_list = new ArrayList<>(); | ||||
| rb_list.add(findViewById(R.id.rb_g)); | rb_list.add(findViewById(R.id.rb_g)); | ||||
| } else if (id == R.id.btn_set_zero) { | } else if (id == R.id.btn_set_zero) { | ||||
| // 去皮指令 | // 去皮指令 | ||||
| setZero(); | setZero(); | ||||
| } else if (id == R.id.btnVoice) { | |||||
| //蜂鸣器开关切换 | |||||
| mBuzzOpen = !mBuzzOpen; | |||||
| setBuzz(mBuzzOpen); | |||||
| } else if (id == R.id.btnReadHistory) { | |||||
| // 获取历史数据 | |||||
| getHistoryData(); | |||||
| } else if (id == R.id.btnClearHistory) { | |||||
| // 清空历史数据 | |||||
| clearHistoryData(); | |||||
| } else if (id == R.id.btnSynTime) { | |||||
| // 同步时间 | |||||
| appSynTime(); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | mBleDevice = mAILinkBleManager.getBleDevice(mMac); | ||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mBleDevice.setOnBleSettingListener(this); | |||||
| mBleNutritionData = new BleNutritionData(mBleDevice); | mBleNutritionData = new BleNutritionData(mBleDevice); | ||||
| mBleNutritionData.setBleNutritionCallback(this); | mBleNutritionData.setBleNutritionCallback(this); | ||||
| addText("连接成功:" + mMac); | addText("连接成功:" + mMac); | ||||
| addText(str); | addText(str); | ||||
| } | } | ||||
| @Override | |||||
| public void onHistoryRecord(int schedule, List<BleNutritionHistoryBean> list) { | |||||
| if (schedule < 99) { | |||||
| addText("获取历史数据:进度" + schedule + "%"); | |||||
| return; | |||||
| } | |||||
| addText("获取历史数据:进度" + schedule + "%"); | |||||
| addText("获取历史数据:" + list.size() + "条"); | |||||
| StringBuilder str = new StringBuilder(); | |||||
| for (BleNutritionHistoryBean bean : list) { | |||||
| str.append("时间:").append(TimeUtils.getTimeNoNewline(bean.getTime() * 1000L)).append(";"); | |||||
| str.append("重量:").append(bean.getSymbol() == 1 ? "-" : "").append(bean.getWeight()).append(";"); | |||||
| str.append("单位:").append(getUnitStr(bean.getUnit())).append(";"); | |||||
| str.append("小数点:").append(bean.getDecimal()).append(";"); | |||||
| str.append("\n"); | |||||
| } | |||||
| addText("历史数据:\n" + str.toString()); | |||||
| addText("APP获取历史数据完成"); | |||||
| } | |||||
| @Override | |||||
| public void onClearHistoryRecord(int status) { | |||||
| addText("清除历史数据结果:" + (status == 0x00 ? "成功" : "失败")); | |||||
| } | |||||
| private SimpleDateFormat sdf; | private SimpleDateFormat sdf; | ||||
| // 添加一条文本 | // 添加一条文本 | ||||
| } | } | ||||
| } | } | ||||
| /** | |||||
| * 设置蜂鸣器 | |||||
| * | |||||
| * @param open 开放 | |||||
| */ | |||||
| private void setBuzz(boolean open) { | |||||
| if (mBleNutritionData != null) { | |||||
| mBleNutritionData.setBuzz(open); | |||||
| addText("APP下发蜂鸣器指令:" + open); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * APP 下发单位 | * APP 下发单位 | ||||
| */ | */ | ||||
| } | } | ||||
| return unitStr; | return unitStr; | ||||
| } | } | ||||
| /** | |||||
| * 获取历史数据 | |||||
| */ | |||||
| public void getHistoryData() { | |||||
| if (mBleNutritionData != null) { | |||||
| mBleNutritionData.getHistoryData(0); | |||||
| addText("APP下发获取历史数据指令"); | |||||
| } | |||||
| } | |||||
| public void clearHistoryData() { | |||||
| if (mBleNutritionData != null) { | |||||
| mBleNutritionData.clearHistoryData(); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 应用同步时间 | |||||
| */ | |||||
| public void appSynTime() { | |||||
| if (mBleNutritionData != null) { | |||||
| mBleNutritionData.appSynTime(); | |||||
| addText("APP下发同步时间指令"); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void OnSettingReturn(int cmdType, int cmdData) { | |||||
| if (cmdType == CmdConfig.SET_DEVICE_TIME_UNIX) { | |||||
| addText("MCU上发同步时间结果:" + (cmdData == 0 ? "成功" : "失败")); | |||||
| } | |||||
| } | |||||
| } | } |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.ble_nutrition; | |||||
| 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 androidx.annotation.Nullable; | |||||
| import com.pingwang.bluetoothlib.bean.SupportUnitBean; | |||||
| import com.pingwang.bluetoothlib.config.CmdConfig; | |||||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||||
| import com.pingwang.bluetoothlib.listener.OnBleSettingListener; | |||||
| 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 aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.UnitUtils; | |||||
| import cn.net.aicare.modulelibrary.module.ble_nutrition_nutrient.BleNutritionNutrientData; | |||||
| import cn.net.aicare.modulelibrary.module.ble_nutrition_nutrient.FoodNutrientBean; | |||||
| /** | |||||
| * 支持营养元素的蓝牙营养秤 | |||||
| * | |||||
| * @author xing | |||||
| * @date 2024/06/15 | |||||
| */ | |||||
| public class BleNutritionNutrientActivity extends BleBaseActivity implements View.OnClickListener, BleNutritionNutrientData.OnNutritionNutrientListener, OnBleSettingListener { | |||||
| private static final String TAG = "Tag1"; | |||||
| private Button btn_clear; | |||||
| private ListView list_view; | |||||
| private Button btn_set_unit; | |||||
| private Button btn_set_zero; | |||||
| private List<RadioButton> rb_list; | |||||
| private List<String> mList; | |||||
| private ArrayAdapter mListAdapter; | |||||
| private String mMac; | |||||
| private BleDevice mBleDevice; | |||||
| private BleNutritionNutrientData mBleNutritionNutrientData; | |||||
| @Override | |||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
| super.onCreate(savedInstanceState); | |||||
| setContentView(R.layout.activity_ble_nutrition_nutrient); | |||||
| btn_clear = findViewById(R.id.btn_clear); | |||||
| list_view = findViewById(R.id.list_view); | |||||
| btn_set_unit = findViewById(R.id.btn_set_unit); | |||||
| btn_set_zero = findViewById(R.id.btn_set_zero); | |||||
| btn_clear.setOnClickListener(this); | |||||
| btn_set_unit.setOnClickListener(this); | |||||
| btn_set_zero.setOnClickListener(this); | |||||
| findViewById(R.id.btnSendApple).setOnClickListener(this); | |||||
| findViewById(R.id.btnSendBeef).setOnClickListener(this); | |||||
| rb_list = new ArrayList<>(); | |||||
| rb_list.add(findViewById(R.id.rb_g)); | |||||
| rb_list.add(findViewById(R.id.rb_ml)); | |||||
| rb_list.add(findViewById(R.id.rb_lb_oz)); | |||||
| rb_list.add(findViewById(R.id.rb_oz)); | |||||
| rb_list.add(findViewById(R.id.rb_kg)); | |||||
| rb_list.add(findViewById(R.id.rb_jin)); | |||||
| rb_list.add(findViewById(R.id.rb_milk_ml)); | |||||
| rb_list.add(findViewById(R.id.rb_water_ml)); | |||||
| rb_list.add(findViewById(R.id.rb_milk_fl_oz)); | |||||
| rb_list.add(findViewById(R.id.rb_water_fl_oz)); | |||||
| rb_list.add(findViewById(R.id.rb_lb)); | |||||
| // 单位只能单选 | |||||
| for (RadioButton radioButton : rb_list) { | |||||
| radioButton.setOnClickListener(v -> { | |||||
| for (RadioButton rb : rb_list) { | |||||
| rb.setChecked(rb == v); | |||||
| } | |||||
| }); | |||||
| } | |||||
| // 获取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_clear) { | |||||
| // 清空文本框 | |||||
| clearText(); | |||||
| } else if (id == R.id.btn_set_unit) { | |||||
| // 设置单位 | |||||
| setUnit(); | |||||
| } else if (id == R.id.btn_set_zero) { | |||||
| // 去皮指令 | |||||
| setZero(); | |||||
| } else if (id == R.id.btnSendApple) { | |||||
| // 苹果 | |||||
| sendFoodApple(); | |||||
| } else if (id == R.id.btnSendBeef) { | |||||
| // 牛肉 | |||||
| sendFoodBeef(); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| protected void onDestroy() { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | |||||
| super.onDestroy(); | |||||
| } | |||||
| @Override | |||||
| public void onServiceSuccess() { | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | |||||
| mBleDevice.setOnBleSettingListener(this); | |||||
| mBleNutritionNutrientData = new BleNutritionNutrientData(mBleDevice); | |||||
| mBleNutritionNutrientData.setBleNutritionCallback(this); | |||||
| addText("连接成功:" + mMac); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onServiceErr() { | |||||
| } | |||||
| @Override | |||||
| public void unbindServices() { | |||||
| } | |||||
| @Override | |||||
| public void onBmVersion(String version) { | |||||
| addText("MCU上发BM版本:" + version); | |||||
| } | |||||
| @Override | |||||
| public void onSupportUnit(List<SupportUnitBean> list) { | |||||
| String str = ""; | |||||
| for (SupportUnitBean supportUnitBean : list) { | |||||
| str += supportUnitBean.toString() + ";"; | |||||
| if (supportUnitBean.getType() != null && supportUnitBean.getType().equals("8")) { | |||||
| // 遍历所有单位,有这个支持单位就显示 | |||||
| for (int i = 0; i < rb_list.size(); i++) { | |||||
| boolean hasUnit = false; | |||||
| for (Integer integer : supportUnitBean.getSupportUnit()) { | |||||
| if (integer != null && integer == i) { | |||||
| hasUnit = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| rb_list.get(i).setEnabled(hasUnit); | |||||
| } | |||||
| // 再次遍历,如果选中了不支持的单位,就重新选择 | |||||
| boolean unitDisable = false; | |||||
| for (int i = 0; i < rb_list.size(); i++) { | |||||
| if (!rb_list.get(i).isEnabled() && rb_list.get(i).isChecked()) { | |||||
| unitDisable = true; | |||||
| rb_list.get(i).setChecked(false); | |||||
| } | |||||
| if (rb_list.get(i).isEnabled() && unitDisable) { | |||||
| unitDisable = false; | |||||
| rb_list.get(i).setChecked(true); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| addText("MCU上发支持单位列表:\n" + str); | |||||
| } | |||||
| @Override | |||||
| public void onWeight(int no, int weight, int unit, int decimal, int symbol, int type) { | |||||
| float w = weight; | |||||
| // 正负 | |||||
| if (symbol == 1) { | |||||
| w *= -1; | |||||
| } | |||||
| // 小数点 | |||||
| w = (float) (w / Math.pow(10, decimal)); | |||||
| // 保留小数位 | |||||
| String weightStr = getPreFloatStr(w, decimal); | |||||
| String str = "MCU上发重量:" + weightStr + getUnitStr(unit) + "\n流水号:" + no + ",原始重量:" + weight + ",单位:" + unit + ",小数点:" + decimal + ",符号:" + symbol + ",重量类型:" + type; | |||||
| addText(str); | |||||
| if (type == 2) { | |||||
| if (foodNutrientBean != null ) { | |||||
| //稳定重量 | |||||
| if (unit == 0x04) { | |||||
| foodNutrientBean.setWeightToG(Double.parseDouble(weightStr)*1000); | |||||
| }else if (unit == 0x05){ | |||||
| foodNutrientBean.setWeightToG(Double.parseDouble(weightStr)*500); | |||||
| }else if (unit == 0x00){ | |||||
| foodNutrientBean.setWeightToG(Double.parseDouble(weightStr)); | |||||
| }else if (unit == 0x03){ | |||||
| foodNutrientBean.setWeightToG(UnitUtils.ozToG(Float.parseFloat(weightStr))); | |||||
| }else { | |||||
| addText("不支持的重量单位,当前只支持g,oz,kg,斤:" + unit); | |||||
| return; | |||||
| } | |||||
| mBleNutritionNutrientData.setNutrient(foodNutrientBean); | |||||
| addText("APP下发营养元素数据:" + foodNutrientBean.toString()); | |||||
| addText("APP下发营养元素数据(Int):" + foodNutrientBean.toStringInt()); | |||||
| } else { | |||||
| L.i("未选择食物"); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onUnitResult(int status) { | |||||
| String statusStr = ""; | |||||
| switch (status) { | |||||
| case 0: | |||||
| statusStr = "成功"; | |||||
| break; | |||||
| case 1: | |||||
| statusStr = "失败"; | |||||
| break; | |||||
| case 2: | |||||
| statusStr = "不支持"; | |||||
| break; | |||||
| } | |||||
| String str = "MCU上发设置单位结果:" + statusStr; | |||||
| addText(str); | |||||
| } | |||||
| @Override | |||||
| public void onErr(int weightErr, int batteryErr) { | |||||
| String weightErrStr = ""; | |||||
| switch (weightErr) { | |||||
| case 0: | |||||
| weightErrStr = "正常"; | |||||
| break; | |||||
| case 1: | |||||
| weightErrStr = "超重"; | |||||
| break; | |||||
| } | |||||
| String batteryErrStr = ""; | |||||
| switch (batteryErr) { | |||||
| case 0: | |||||
| batteryErrStr = "正常"; | |||||
| break; | |||||
| case 1: | |||||
| batteryErrStr = "低电"; | |||||
| break; | |||||
| } | |||||
| String str = "MCU上发异常报警:\n重量状态:" + weightErrStr + "\n电池状态:" + batteryErrStr; | |||||
| addText(str); | |||||
| } | |||||
| 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); | |||||
| } | |||||
| // 清空文本 | |||||
| private void clearText() { | |||||
| mList.clear(); | |||||
| mListAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| // 保留小数位 | |||||
| private String getPreFloatStr(float f, int decimal) { | |||||
| BigDecimal bigDecimal = new BigDecimal(f); | |||||
| return bigDecimal.setScale(decimal, BigDecimal.ROUND_HALF_UP).toString(); | |||||
| } | |||||
| /** | |||||
| * APP 发送归零指令 | |||||
| */ | |||||
| private void setZero() { | |||||
| if (mBleNutritionNutrientData != null) { | |||||
| mBleNutritionNutrientData.setZero(); | |||||
| addText("APP下发去皮指令"); | |||||
| } | |||||
| } | |||||
| private FoodNutrientBean foodNutrientBean; | |||||
| private void sendFoodApple() { | |||||
| foodNutrientBean = new FoodNutrientBean(); | |||||
| foodNutrientBean.setKcal(65); | |||||
| foodNutrientBean.setFat(0.16); | |||||
| foodNutrientBean.setSatFat(0); | |||||
| foodNutrientBean.setTransFat(0); | |||||
| foodNutrientBean.setCholesterol(0); | |||||
| foodNutrientBean.setNa(1); | |||||
| foodNutrientBean.setK(104); | |||||
| foodNutrientBean.setTotalCarbohydrate(15.4); | |||||
| foodNutrientBean.setFiber(2.1); | |||||
| foodNutrientBean.setSugar(13.3); | |||||
| foodNutrientBean.setProtein(0.15); | |||||
| addText("选择 苹果"); | |||||
| } | |||||
| private void sendFoodBeef() { | |||||
| foodNutrientBean = new FoodNutrientBean(); | |||||
| foodNutrientBean.setKcal(164); | |||||
| foodNutrientBean.setFat(9.4); | |||||
| foodNutrientBean.setSatFat(3.55); | |||||
| foodNutrientBean.setTransFat(0.389); | |||||
| foodNutrientBean.setCholesterol(58); | |||||
| foodNutrientBean.setNa(51); | |||||
| foodNutrientBean.setK(332); | |||||
| foodNutrientBean.setTotalCarbohydrate(20); | |||||
| foodNutrientBean.setFiber(0); | |||||
| foodNutrientBean.setSugar(0); | |||||
| foodNutrientBean.setProtein(20.1); | |||||
| addText("选择 牛肉"); | |||||
| } | |||||
| /** | |||||
| * APP 下发单位 | |||||
| */ | |||||
| private void setUnit() { | |||||
| if (mBleNutritionNutrientData != null) { | |||||
| int unit = -1; | |||||
| for (int i = 0; i < rb_list.size(); i++) { | |||||
| if (rb_list.get(i).isChecked()) { | |||||
| unit = i; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (unit == -1) { | |||||
| addText("APP下发单位:失败:未选择单位"); | |||||
| return; | |||||
| } | |||||
| mBleNutritionNutrientData.setUnit(unit); | |||||
| addText("APP下发单位:" + unit + ":" + getUnitStr(unit)); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 获取单位字符串 | |||||
| * | |||||
| * @param unit 0 | |||||
| * @return g | |||||
| */ | |||||
| private String getUnitStr(int unit) { | |||||
| String unitStr = ""; | |||||
| switch (unit) { | |||||
| case 0x00: | |||||
| unitStr = "g"; | |||||
| break; | |||||
| case 0x01: | |||||
| unitStr = "ml"; | |||||
| break; | |||||
| case 0x02: | |||||
| unitStr = "lb:oz"; | |||||
| break; | |||||
| case 0x03: | |||||
| unitStr = "oz"; | |||||
| break; | |||||
| case 0x04: | |||||
| unitStr = "kg"; | |||||
| break; | |||||
| case 0x05: | |||||
| unitStr = "斤"; | |||||
| break; | |||||
| case 0x06: | |||||
| unitStr = "牛奶ml"; | |||||
| break; | |||||
| case 0x07: | |||||
| unitStr = "水ml"; | |||||
| break; | |||||
| case 0x08: | |||||
| unitStr = "牛奶floz"; | |||||
| break; | |||||
| case 0x09: | |||||
| unitStr = "水floz"; | |||||
| break; | |||||
| case 0x0A: | |||||
| unitStr = "lb"; | |||||
| break; | |||||
| } | |||||
| return unitStr; | |||||
| } | |||||
| @Override | |||||
| public void OnSettingReturn(int cmdType, int cmdData) { | |||||
| if (cmdType == CmdConfig.SET_DEVICE_TIME_UNIX) { | |||||
| addText("MCU上发同步时间结果:" + (cmdData == 0 ? "成功" : "失败")); | |||||
| } | |||||
| } | |||||
| } |
| log_list = findViewById(R.id.log_list); | log_list = findViewById(R.id.log_list); | ||||
| mLogList = new ArrayList<>(); | mLogList = new ArrayList<>(); | ||||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mLogList); | listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mLogList); | ||||
| log_list.setAdapter(listAdapter); | |||||
| log_list.setAdapter(listAdapter); | |||||
| mmol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | mmol.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | ||||
| @Override | @Override | ||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { |
| import java.util.Locale; | import java.util.Locale; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.UnitUtils; | |||||
| import cn.net.aicare.algorithmutil.AlgorithmUtil; | import cn.net.aicare.algorithmutil.AlgorithmUtil; | ||||
| import cn.net.aicare.algorithmutil.BodyFatData; | import cn.net.aicare.algorithmutil.BodyFatData; | ||||
| private EditText et_vid; | private EditText et_vid; | ||||
| private EditText et_pid; | private EditText et_pid; | ||||
| private String url = "https://ailink.aicare.net.cn"; | private String url = "https://ailink.aicare.net.cn"; | ||||
| private String userId = "622733"; | |||||
| private String roomId = "4376156"; | |||||
| private SeekBar seek_height; | private SeekBar seek_height; | ||||
| private SeekBar seek_age; | private SeekBar seek_age; | ||||
| private TextView tv_height; | private TextView tv_height; | ||||
| private int mHeight; | private int mHeight; | ||||
| private int mAge; | private int mAge; | ||||
| private int mGender; | private int mGender; | ||||
| private String mCid; | |||||
| private String mVid; | |||||
| private String mPid; | |||||
| @Override | @Override | ||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | protected void onCreate(@Nullable Bundle savedInstanceState) { | ||||
| } | } | ||||
| public void login() throws Throwable { | public void login() throws Throwable { | ||||
| String mUrl=url + "/api/user/login?key=inet_elink&username=10037&password=5abd06d6f6ef0e022e11b8a41f57ebda"; | |||||
| String mUrl = url + "/api/user/login?key=inet_elink&username=" + userId + "&password=a0277db099cbb609cbda238c74a44aae"; | |||||
| URL uri = new URL(mUrl); | URL uri = new URL(mUrl); | ||||
| HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | ||||
| // Post请求必须设置允许输出 | // Post请求必须设置允许输出 | ||||
| httpURLConnection.setRequestMethod("POST"); | httpURLConnection.setRequestMethod("POST"); | ||||
| httpURLConnection.setInstanceFollowRedirects(true); | httpURLConnection.setInstanceFollowRedirects(true); | ||||
| // 配置请求Content-Type | // 配置请求Content-Type | ||||
| httpURLConnection.setRequestProperty("Content-Type", | |||||
| "application/x-www-form-urlencode"); | |||||
| httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencode"); | |||||
| // 设置连接超时时间 | // 设置连接超时时间 | ||||
| httpURLConnection.setConnectTimeout(6 * 1000); | httpURLConnection.setConnectTimeout(6 * 1000); | ||||
| // 开始连接 | // 开始连接 | ||||
| } | } | ||||
| public void getDeviceId() throws Throwable { | |||||
| public void getMyDeviceId() throws Throwable { | |||||
| String cid = et_cid.getText().toString().trim(); | |||||
| String vid = et_vid.getText().toString().trim(); | |||||
| String pid = et_pid.getText().toString().trim(); | |||||
| if (TextUtils.isEmpty(cid) || TextUtils.isEmpty(vid) || TextUtils.isEmpty(pid)) { | |||||
| loglist.add(0, "请先输入CID,VID,PID"); | |||||
| logAdapter.notifyDataSetChanged(); | |||||
| return; | |||||
| } | |||||
| StringBuilder stringBuilder = new StringBuilder(); | StringBuilder stringBuilder = new StringBuilder(); | ||||
| stringBuilder.append(url); | stringBuilder.append(url); | ||||
| stringBuilder.append("/api/device/getDeviceBySN?key=inet_elink&appUserId="); | stringBuilder.append("/api/device/getDeviceBySN?key=inet_elink&appUserId="); | ||||
| stringBuilder.append(token); | stringBuilder.append(token); | ||||
| stringBuilder.append("&deviceSN="); | stringBuilder.append("&deviceSN="); | ||||
| stringBuilder.append(imei); | stringBuilder.append(imei); | ||||
| stringBuilder.append("&cid="); | |||||
| stringBuilder.append(cid); | |||||
| stringBuilder.append("&vid="); | |||||
| stringBuilder.append(vid); | |||||
| stringBuilder.append("&pid="); | |||||
| stringBuilder.append(pid); | |||||
| Log.e(TAG, stringBuilder.toString()); | Log.e(TAG, stringBuilder.toString()); | ||||
| URL uri = new URL(stringBuilder.toString()); | URL uri = new URL(stringBuilder.toString()); | ||||
| HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | ||||
| try { | try { | ||||
| if (datajson.length() > 0) { | if (datajson.length() > 0) { | ||||
| myDeviceId = datajson.getJSONObject(0).getString("deviceId"); | myDeviceId = datajson.getJSONObject(0).getString("deviceId"); | ||||
| mCid = datajson.getJSONObject(0).getString("cid"); | |||||
| mVid = datajson.getJSONObject(0).getString("vid"); | |||||
| mPid = datajson.getJSONObject(0).getString("pid"); | |||||
| } | } | ||||
| loglist.add(0, "设备信息" + result); | loglist.add(0, "设备信息" + result); | ||||
| logAdapter.notifyDataSetChanged(); | logAdapter.notifyDataSetChanged(); | ||||
| httpURLConnection.setRequestMethod("POST"); | httpURLConnection.setRequestMethod("POST"); | ||||
| httpURLConnection.setInstanceFollowRedirects(true); | httpURLConnection.setInstanceFollowRedirects(true); | ||||
| // 配置请求Content-Type | // 配置请求Content-Type | ||||
| httpURLConnection.setRequestProperty("Content-Type", | |||||
| "application/x-www-form-urlencode"); | |||||
| httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencode"); | |||||
| // 设置连接超时时间 | // 设置连接超时时间 | ||||
| httpURLConnection.setConnectTimeout(6 * 1000); | httpURLConnection.setConnectTimeout(6 * 1000); | ||||
| // 开始连接 | // 开始连接 | ||||
| private boolean isFirstBind = true; | private boolean isFirstBind = true; | ||||
| public void bindDevice() throws Throwable { | public void bindDevice() throws Throwable { | ||||
| if (TextUtils.isEmpty(mCid) || TextUtils.isEmpty(mVid) || TextUtils.isEmpty(mPid)) { | |||||
| runOnUiThread(() -> { | |||||
| loglist.add(0, "请先获取设备ID"); | |||||
| logAdapter.notifyDataSetChanged(); | |||||
| }); | |||||
| return; | |||||
| } | |||||
| StringBuilder stringBuilder = new StringBuilder(); | StringBuilder stringBuilder = new StringBuilder(); | ||||
| stringBuilder.append(url); | stringBuilder.append(url); | ||||
| stringBuilder.append("/api/device/add?key=inet_elink&appUserId=" + appid); | stringBuilder.append("/api/device/add?key=inet_elink&appUserId=" + appid); | ||||
| stringBuilder.append("&token=" + token); | stringBuilder.append("&token=" + token); | ||||
| stringBuilder.append("&deviceSN=" + imei); | stringBuilder.append("&deviceSN=" + imei); | ||||
| stringBuilder.append("&mac=" + imei); | stringBuilder.append("&mac=" + imei); | ||||
| stringBuilder.append("&roomId=" + 86360); | |||||
| stringBuilder.append("&roomId=" + roomId); | |||||
| stringBuilder.append("&deviceName=" + "4G体脂秤"); | stringBuilder.append("&deviceName=" + "4G体脂秤"); | ||||
| stringBuilder.append("&cid=" + et_cid.getText().toString()); | |||||
| stringBuilder.append("&vid=" + et_vid.getText().toString()); | |||||
| stringBuilder.append("&pid=" + et_pid.getText().toString()); | |||||
| stringBuilder.append("&cid=" + mCid); | |||||
| stringBuilder.append("&vid=" + mVid); | |||||
| stringBuilder.append("&pid=" + mPid); | |||||
| stringBuilder.append("&supportUnit=" + ""); | stringBuilder.append("&supportUnit=" + ""); | ||||
| // stringBuilder.append("&version=" + "1.0"); | // stringBuilder.append("&version=" + "1.0"); | ||||
| Log.e(TAG, stringBuilder.toString()); | Log.e(TAG, stringBuilder.toString()); | ||||
| httpURLConnection.setRequestMethod("POST"); | httpURLConnection.setRequestMethod("POST"); | ||||
| httpURLConnection.setInstanceFollowRedirects(true); | httpURLConnection.setInstanceFollowRedirects(true); | ||||
| // 配置请求Content-Type | // 配置请求Content-Type | ||||
| httpURLConnection.setRequestProperty("Content-Type", | |||||
| "application/x-www-form-urlencode"); | |||||
| httpURLConnection.setRequestProperty("Content-Type", "application/x-www-form-urlencode"); | |||||
| // 设置连接超时时间 | // 设置连接超时时间 | ||||
| httpURLConnection.setConnectTimeout(6 * 1000); | httpURLConnection.setConnectTimeout(6 * 1000); | ||||
| // 开始连接 | // 开始连接 | ||||
| stringBuilder.append(myDeviceId); | stringBuilder.append(myDeviceId); | ||||
| stringBuilder.append("&maxId="); | stringBuilder.append("&maxId="); | ||||
| stringBuilder.append(maxId); | stringBuilder.append(maxId); | ||||
| stringBuilder.append("&subUserId=0"); | |||||
| stringBuilder.append("&subUserId=0&source=1"); | |||||
| Log.e(TAG, stringBuilder.toString()); | Log.e(TAG, stringBuilder.toString()); | ||||
| URL uri = new URL(stringBuilder.toString()); | URL uri = new URL(stringBuilder.toString()); | ||||
| HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | HttpURLConnection httpURLConnection = (HttpURLConnection) uri.openConnection(); | ||||
| int algorithm = json.getInt("deviceAlgorithm"); | int algorithm = json.getInt("deviceAlgorithm"); | ||||
| BigDecimal bigDecimal = BigDecimal.valueOf(weightSource / Math.pow(10, weightDecimal)); | BigDecimal bigDecimal = BigDecimal.valueOf(weightSource / Math.pow(10, weightDecimal)); | ||||
| String weightStr = bigDecimal.setScale(weightDecimal, BigDecimal.ROUND_HALF_UP).toString(); | |||||
| String weightStr = bigDecimal.setScale(weightDecimal, BigDecimal.ROUND_HALF_UP) | |||||
| .toString(); | |||||
| if (weightUnit == 4){ | |||||
| float[] floats = UnitUtils.LbToSt(Float.parseFloat(weightStr)); | |||||
| weightStr = (int)floats[0] + ":" + UnitUtils.getHoldDecimal(weightDecimal,floats[1]); | |||||
| } | |||||
| BodyFatData bodyFatData = AlgorithmUtil.getBodyFatData(algorithm, (mGender == 0 ? 2 : 1), mAge, bigDecimal.floatValue(), mHeight, adc); | BodyFatData bodyFatData = AlgorithmUtil.getBodyFatData(algorithm, (mGender == 0 ? 2 : 1), mAge, bigDecimal.floatValue(), mHeight, adc); | ||||
| switch (weightUnit) { | switch (weightUnit) { | ||||
| @Override | @Override | ||||
| public void run() { | public void run() { | ||||
| try { | try { | ||||
| getDeviceId(); | |||||
| getMyDeviceId(); | |||||
| } catch (Throwable throwable) { | } catch (Throwable throwable) { | ||||
| throwable.printStackTrace(); | throwable.printStackTrace(); | ||||
| } | } | ||||
| }).start(); | }).start(); | ||||
| } else if (v.getId() == R.id.btn_produce) { | } else if (v.getId() == R.id.btn_produce) { | ||||
| url = "https://ailink.aicare.net.cn"; | url = "https://ailink.aicare.net.cn"; | ||||
| userId = "622733"; | |||||
| roomId = "4376156"; | |||||
| } else if (v.getId() == R.id.btn_test) { | } else if (v.getId() == R.id.btn_test) { | ||||
| url = "http://test.ailink.app.aicare.net.cn"; | url = "http://test.ailink.app.aicare.net.cn"; | ||||
| userId = "21578"; | |||||
| roomId = "82731"; | |||||
| } | } | ||||
| } | } |
| 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.listener.OnBleBroadcastDataListener; | |||||
| 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.R; | import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | ||||
| public class BroadNutritionActivity extends BleBaseActivity implements View.OnClickListener, OnScanFilterListener { | |||||
| public class BroadNutritionActivity extends BleBaseActivity implements View.OnClickListener, OnScanFilterListener, OnBleBroadcastDataListener { | |||||
| private ListView list_view; | private ListView list_view; | ||||
| private Button btn_start; | private Button btn_start; | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mAILinkBleManager.stopScan(); | mAILinkBleManager.stopScan(); | ||||
| mAILinkBleManager.removeOnBleBroadcastDataListener(this); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mAILinkBleManager.setOnScanFilterListener(this); | mAILinkBleManager.setOnScanFilterListener(this); | ||||
| mAILinkBleManager.addOnBleBroadcastDataListener(this); | |||||
| } | } | ||||
| @Override | @Override | ||||
| private String mMac; | private String mMac; | ||||
| @Override | @Override | ||||
| public void onScanRecord(BleValueBean bleValueBean) { | |||||
| byte[] manufacturerData = bleValueBean.getManufacturerData(); | |||||
| public void onBleBroadcastData(BleValueBean bleValueBean, byte[] payload) { | |||||
| mMac = bleValueBean.getMac(); | mMac = bleValueBean.getMac(); | ||||
| onNotifyData("",manufacturerData, bleValueBean.getCid(), bleValueBean.getVid(), bleValueBean.getPid()); | |||||
| notifyData(payload); | |||||
| } | } | ||||
| private String mOldText = ""; | |||||
| private SimpleDateFormat mSdf; | private SimpleDateFormat mSdf; | ||||
| // 添加一条文本 | // 添加一条文本 | ||||
| if (mSdf == null) { | if (mSdf == null) { | ||||
| mSdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | mSdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | ||||
| } | } | ||||
| mList.add(mSdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
| if (mOldText.equals(text)) { | |||||
| return; | |||||
| } | |||||
| mOldText = text; | |||||
| String log = mSdf.format(System.currentTimeMillis()) + ":\n" + text; | |||||
| mList.add(log); | |||||
| mListAdapter.notifyDataSetChanged(); | mListAdapter.notifyDataSetChanged(); | ||||
| list_view.smoothScrollToPosition(mList.size() - 1); | list_view.smoothScrollToPosition(mList.size() - 1); | ||||
| } | } | ||||
| * | * | ||||
| * @param hex payloads | * @param hex payloads | ||||
| */ | */ | ||||
| private void notifyData(byte[] hex) { | |||||
| public void notifyData(byte[] hex) { | |||||
| if (hex.length >= 10) { | if (hex.length >= 10) { | ||||
| int no = hex[0] & 0xff; | int no = hex[0] & 0xff; | ||||
| int type = hex[1] & 0xff; | int type = hex[1] & 0xff; | ||||
| BigDecimal dc = new BigDecimal(f); | BigDecimal dc = new BigDecimal(f); | ||||
| return dc.setScale(decimal, BigDecimal.ROUND_HALF_UP).toString(); | return dc.setScale(decimal, BigDecimal.ROUND_HALF_UP).toString(); | ||||
| } | } | ||||
| } | } |
| if (AILinkBleManager.getInstance() != null) { | if (AILinkBleManager.getInstance() != null) { | ||||
| mDevice = BroadcastWeightScaleDeviceData.getInstance(); | mDevice = BroadcastWeightScaleDeviceData.getInstance(); | ||||
| mDevice.setOnNotifyData(this); | mDevice.setOnNotifyData(this); | ||||
| AILinkBleManager.getInstance().setOnBleBroadcastDataListener(this); | |||||
| AILinkBleManager.getInstance().addOnBleBroadcastDataListener(this); | |||||
| AILinkBleManager.getInstance().startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | AILinkBleManager.getInstance().startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | ||||
| } | } | ||||
| } | } | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i("ljl", "服务与界面连接断开"); | BleLog.i("ljl", "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| AILinkBleManager.getInstance().setOnBleBroadcastDataListener(null); | |||||
| AILinkBleManager.getInstance().removeOnBleBroadcastDataListener(this); | |||||
| } | } | ||||
| @Override | @Override |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.bw05watch; | |||||
| import android.Manifest; | |||||
| import android.annotation.SuppressLint; | |||||
| 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.Editable; | |||||
| import android.text.TextUtils; | |||||
| import android.text.TextWatcher; | |||||
| import android.view.View; | |||||
| import android.widget.ArrayAdapter; | |||||
| import android.widget.Button; | |||||
| import android.widget.CheckBox; | |||||
| import android.widget.EditText; | |||||
| import android.widget.ListView; | |||||
| import android.widget.Toast; | |||||
| import androidx.annotation.Nullable; | |||||
| import androidx.core.app.ActivityCompat; | |||||
| import com.pingwang.bluetoothlib.config.BleConfig; | |||||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||||
| import com.pingwang.bluetoothlib.listener.CallbackDisIm; | |||||
| import com.pingwang.bluetoothlib.listener.OnCallbackDis; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Locale; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.CheckPermissionUtils; | |||||
| import cn.net.aicare.modulelibrary.module.bw05.Bw05WatchBleDevice; | |||||
| import cn.net.aicare.modulelibrary.module.bw05.OnBw05WatchDataListener; | |||||
| /** | |||||
| * @author ljl | |||||
| * on 2024/6/4 | |||||
| */ | |||||
| public class Bw05WatchActivity extends BleBaseActivity implements OnBw05WatchDataListener, | |||||
| View.OnClickListener, OnCallbackDis { | |||||
| //01:B6:EC:E6:C8:8D | |||||
| private String connectMac = ""; | |||||
| private Button btnSetTime, btnQueryInfo, btnQueryThreshold; | |||||
| private Button btnSetCheckTime, btnSetBleName, btnSetThreshold; | |||||
| private Button btnConnect, btnClearLog; | |||||
| private EditText etCheckTime, etBleName; | |||||
| private EditText etHrMin, etHrMax; | |||||
| private EditText etSpo2Min, etSpo2Max; | |||||
| private EditText etTempMin, etTempMax; | |||||
| private EditText etSbpMin, etSbpMax; | |||||
| private EditText etDbpMin, etDbpMax; | |||||
| private EditText etMac; | |||||
| private CheckBox cbCheckTime; | |||||
| private ListView log_list; | |||||
| private List<String> mList; | |||||
| private ArrayAdapter mListAdapter; | |||||
| private String checkTimeOp; | |||||
| private Bw05WatchBleDevice mBw05WatchBleDevice; | |||||
| @Override | |||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
| super.onCreate(savedInstanceState); | |||||
| setContentView(R.layout.activity_bw05_watch); | |||||
| initView(); | |||||
| initData(); | |||||
| } | |||||
| private void initView() { | |||||
| btnSetTime = findViewById(R.id.btnSetTime); | |||||
| btnSetTime.setOnClickListener(this); | |||||
| btnQueryInfo = findViewById(R.id.btnQueryInfo); | |||||
| btnQueryInfo.setOnClickListener(this); | |||||
| btnQueryThreshold = findViewById(R.id.btnQueryThreshold); | |||||
| btnQueryThreshold.setOnClickListener(this); | |||||
| btnSetCheckTime = findViewById(R.id.btnSetCheckTime); | |||||
| btnSetCheckTime.setOnClickListener(this); | |||||
| btnSetBleName = findViewById(R.id.btnSetBleName); | |||||
| btnSetBleName.setOnClickListener(this); | |||||
| btnSetThreshold = findViewById(R.id.btnSetThreshold); | |||||
| btnSetThreshold.setOnClickListener(this); | |||||
| btnConnect = findViewById(R.id.btnConnect); | |||||
| btnConnect.setOnClickListener(this); | |||||
| btnClearLog = findViewById(R.id.btnClearLog); | |||||
| btnClearLog.setOnClickListener(this); | |||||
| etCheckTime = findViewById(R.id.etCheckTime); | |||||
| etBleName = findViewById(R.id.etBleName); | |||||
| etHrMin = findViewById(R.id.etHrMin); | |||||
| etHrMax = findViewById(R.id.etHrMax); | |||||
| etSpo2Min = findViewById(R.id.etSpo2Min); | |||||
| etSpo2Max = findViewById(R.id.etSpo2Max); | |||||
| etTempMin = findViewById(R.id.etTempMin); | |||||
| etTempMax = findViewById(R.id.etTempMax); | |||||
| etSbpMin = findViewById(R.id.etSbpMin); | |||||
| etSbpMax = findViewById(R.id.etSbpMax); | |||||
| etDbpMin = findViewById(R.id.etDbpMin); | |||||
| etDbpMax = findViewById(R.id.etDbpMax); | |||||
| etMac = findViewById(R.id.etMac); | |||||
| cbCheckTime = findViewById(R.id.cbCheckTime); | |||||
| checkTimeOp = cbCheckTime.isChecked() ? "1" : "0"; | |||||
| cbCheckTime.setOnCheckedChangeListener((buttonView, isChecked) -> { | |||||
| if (isChecked) { | |||||
| checkTimeOp = "1"; | |||||
| } else { | |||||
| checkTimeOp = "0"; | |||||
| } | |||||
| }); | |||||
| etTempMin.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) { | |||||
| if (s.toString().length() == 1 && s.toString().equals(".")) { | |||||
| s.clear(); | |||||
| } | |||||
| } | |||||
| }); | |||||
| etTempMax.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) { | |||||
| if (s.toString().length() == 1 && s.toString().equals(".")) { | |||||
| s.clear(); | |||||
| } | |||||
| } | |||||
| }); | |||||
| log_list = findViewById(R.id.log_list); | |||||
| } | |||||
| private void initData() { | |||||
| mList = new ArrayList<>(); | |||||
| mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
| log_list.setAdapter(mListAdapter); | |||||
| new CheckPermissionUtils(this).checkPermissions(() -> { | |||||
| }); | |||||
| // 没有蓝牙权限就请求蓝牙权限 | |||||
| if (!hasBluetooth()) { | |||||
| requestBluetooth(); | |||||
| return; | |||||
| } | |||||
| // 没有定位权限就请求定位权限 | |||||
| if (!hasLocationPermission()) { | |||||
| requestLocationPermission(this); | |||||
| return; | |||||
| } | |||||
| // 没有定位服务就请求定位服务 | |||||
| if (!hasLocationService()) { | |||||
| requestLocationService(); | |||||
| return; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| if (v == null) { | |||||
| return; | |||||
| } | |||||
| switch (v.getId()) { | |||||
| case R.id.btnSetTime: | |||||
| //设置时间 | |||||
| if (mBw05WatchBleDevice != null) { | |||||
| mBw05WatchBleDevice.setTime(); | |||||
| } | |||||
| break; | |||||
| case R.id.btnQueryInfo: | |||||
| //查询信息 | |||||
| if (mBw05WatchBleDevice != null) { | |||||
| mBw05WatchBleDevice.queryInfo(); | |||||
| } | |||||
| break; | |||||
| case R.id.btnQueryThreshold: | |||||
| //查询阈值 | |||||
| if (mBw05WatchBleDevice != null) { | |||||
| mBw05WatchBleDevice.queryThreshold(); | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetCheckTime: | |||||
| //设置检测间隔时间 | |||||
| if (!TextUtils.isEmpty(etCheckTime.getText().toString())) { | |||||
| if (etCheckTime.getText().toString().length() < 4 && mBw05WatchBleDevice != null) { | |||||
| mBw05WatchBleDevice.setCheckTime(checkTimeOp + formatDataStr(etCheckTime.getText().toString(), 3)); | |||||
| } | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetBleName: | |||||
| //设置蓝牙名称 | |||||
| if (!TextUtils.isEmpty(etBleName.getText().toString())) { | |||||
| if (mBw05WatchBleDevice != null) { | |||||
| mBw05WatchBleDevice.setBleName(etBleName.getText().toString()); | |||||
| } | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetThreshold: | |||||
| //设置阈值 | |||||
| if (!TextUtils.isEmpty(getFloatThresholdValue(etTempMin.getText().toString(), etTempMin.getHint().toString())) | |||||
| && !TextUtils.isEmpty(getFloatThresholdValue(etTempMax.getText().toString(), etTempMax.getHint().toString()))) { | |||||
| if (mBw05WatchBleDevice != null) { | |||||
| StringBuilder stringBuilder = new StringBuilder(); | |||||
| stringBuilder.append(getIntThresholdValue(etHrMin.getText().toString(), etHrMin.getHint().toString())); | |||||
| stringBuilder.append(getIntThresholdValue(etHrMax.getText().toString(), etHrMax.getHint().toString())); | |||||
| stringBuilder.append(getIntThresholdValue(etSpo2Min.getText().toString(), etSpo2Min.getHint().toString())); | |||||
| stringBuilder.append(getIntThresholdValue(etSpo2Max.getText().toString(), etSpo2Max.getHint().toString())); | |||||
| // stringBuilder.append(getIntThresholdValue(etSbpMin.getText().toString(), etSbpMin.getHint().toString())); | |||||
| // stringBuilder.append(getIntThresholdValue(etSbpMax.getText().toString(), etSbpMax.getHint().toString())); | |||||
| // stringBuilder.append(getIntThresholdValue(etDbpMin.getText().toString(), etDbpMin.getHint().toString())); | |||||
| // stringBuilder.append(getIntThresholdValue(etDbpMax.getText().toString(), etDbpMax.getHint().toString())); | |||||
| stringBuilder.append(getFloatThresholdValue(etTempMin.getText().toString(), etTempMin.getHint().toString())); | |||||
| stringBuilder.append(getFloatThresholdValue(etTempMax.getText().toString(), etTempMax.getHint().toString())); | |||||
| String payLoadStr = stringBuilder.toString(); | |||||
| mBw05WatchBleDevice.setRangeValue(payLoadStr); | |||||
| } | |||||
| } | |||||
| break; | |||||
| case R.id.btnConnect: | |||||
| //连接设备 | |||||
| if (btnConnect.getText().toString().equals("连接")) { | |||||
| if (!TextUtils.isEmpty(etMac.getText().toString()) && isValidMacAddress(etMac.getText().toString()) && mAILinkBleManager != null) { | |||||
| connectMac = etMac.getText().toString(); | |||||
| connectBle(connectMac.toUpperCase()); | |||||
| } else { | |||||
| Toast.makeText(this, "地址出错", Toast.LENGTH_SHORT).show(); | |||||
| } | |||||
| } else { | |||||
| if (mAILinkBleManager != null && !TextUtils.isEmpty(connectMac)) { | |||||
| mAILinkBleManager.disconnect(connectMac.toUpperCase()); | |||||
| } | |||||
| } | |||||
| break; | |||||
| case R.id.btnClearLog: | |||||
| clearText(); | |||||
| break; | |||||
| default: | |||||
| break; | |||||
| } | |||||
| } | |||||
| // 清空文本 | |||||
| private void clearText() { | |||||
| mList.clear(); | |||||
| mListAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| private SimpleDateFormat mSdf; | |||||
| // 添加一条文本 | |||||
| private void addText(String text) { | |||||
| if (mSdf == null) { | |||||
| mSdf = new SimpleDateFormat("HH:mm:ss:SSS", Locale.US); | |||||
| } | |||||
| mList.add(mSdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
| mListAdapter.notifyDataSetChanged(); | |||||
| log_list.smoothScrollToPosition(mList.size() - 1); | |||||
| } | |||||
| @Override | |||||
| public void onServiceSuccess() { | |||||
| CallbackDisIm.getInstance().addListListener(this); | |||||
| } | |||||
| @Override | |||||
| public void onServiceErr() { | |||||
| } | |||||
| @Override | |||||
| public void unbindServices() { | |||||
| } | |||||
| @Override | |||||
| public void bleClose() { | |||||
| addText("蓝牙未开启,请退出打开蓝牙重试"); | |||||
| } | |||||
| @Override | |||||
| public void onDataStr(String dataStr) { | |||||
| addText(dataStr); | |||||
| } | |||||
| @Override | |||||
| public void onConnecting(String mac) { | |||||
| addText("正在连接设备:" + mac); | |||||
| } | |||||
| @Override | |||||
| public void onConnectionSuccess(String mac) { | |||||
| BleConfig.setHandshakeStatus(mac, false); | |||||
| } | |||||
| @Override | |||||
| public void onServicesDiscovered(String mac) { | |||||
| addText("连接成功:" + mac); | |||||
| if (mAILinkBleManager != null) { | |||||
| runOnUiThread(() -> { | |||||
| btnConnect.setText("断开"); | |||||
| }); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mac); | |||||
| Bw05WatchBleDevice.init(bleDevice); | |||||
| mBw05WatchBleDevice = Bw05WatchBleDevice.getInstance(); | |||||
| mBw05WatchBleDevice.setOnBw05WatchDataListener(this); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onDisConnected(String mac, int code) { | |||||
| addText("连接断开:" + mac + "错误码:" + code); | |||||
| runOnUiThread(() -> { | |||||
| btnConnect.setText("连接"); | |||||
| }); | |||||
| } | |||||
| @Override | |||||
| protected void onDestroy() { | |||||
| super.onDestroy(); | |||||
| CallbackDisIm.getInstance().removeListener(this); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnect(connectMac); | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 转整数 | |||||
| * | |||||
| * @param inputStr 输入的数据 | |||||
| * @return | |||||
| */ | |||||
| private int getIntData(String inputStr) { | |||||
| try { | |||||
| return Integer.parseInt(inputStr); | |||||
| } catch (Exception e) { | |||||
| return -1000; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 转浮点型 | |||||
| * | |||||
| * @param inputStr 输入的数据 | |||||
| * @return | |||||
| */ | |||||
| private float getFloatData(String inputStr) { | |||||
| try { | |||||
| return Float.parseFloat(inputStr); | |||||
| } catch (Exception e) { | |||||
| return -1000; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 阈值整数数值处理 | |||||
| * | |||||
| * @param inputStr | |||||
| * @param hintStr | |||||
| * @return | |||||
| */ | |||||
| private String getIntThresholdValue(String inputStr, String hintStr) { | |||||
| if (TextUtils.isEmpty(inputStr)) { | |||||
| return formatDataStr(hintStr, 3); | |||||
| } else { | |||||
| return formatDataStr(inputStr, 3); | |||||
| } | |||||
| } | |||||
| private String getFloatThresholdValue(String inputStr, String hintStr) { | |||||
| if (TextUtils.isEmpty(inputStr)) { | |||||
| return hintStr; | |||||
| } else { | |||||
| if ((Float.parseFloat(inputStr) + "").length() > 4) { | |||||
| Toast.makeText(this, "输入的范围过大", Toast.LENGTH_SHORT).show(); | |||||
| return ""; | |||||
| } else { | |||||
| return formatDataStr((Float.parseFloat(inputStr) + ""), 4); | |||||
| } | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 不足有效数据位需要补零 | |||||
| * | |||||
| * @param dataStr 输入的数据 | |||||
| * @param digit 该数据的有效数据位 | |||||
| * @return | |||||
| */ | |||||
| private String formatDataStr(String dataStr, int digit) { | |||||
| if (dataStr.length() < digit) { | |||||
| int diff = digit - dataStr.length(); | |||||
| StringBuilder newDataStr = new StringBuilder(); | |||||
| for (int i = 0; i < diff; i++) { | |||||
| newDataStr.append("0"); | |||||
| } | |||||
| newDataStr.append(dataStr); | |||||
| return newDataStr.toString(); | |||||
| } else { | |||||
| return dataStr; | |||||
| } | |||||
| } | |||||
| /** | |||||
| * 判断输入的是否是合法的mac地址 | |||||
| * | |||||
| * @param inputMacStr | |||||
| * @return | |||||
| */ | |||||
| private boolean isValidMacAddress(String inputMacStr) { | |||||
| String regex = "^([0-9a-fA-F]{2}:){5}[0-9a-fA-F]{2}$"; | |||||
| return inputMacStr.matches(regex); | |||||
| } | |||||
| public static final int REQUEST_PERMISSION_CODE = 1500; | |||||
| /** | |||||
| * 是否有定位权限 | |||||
| * | |||||
| * @return boolean | |||||
| */ | |||||
| private boolean hasLocationPermission() { | |||||
| return ActivityCompat.checkSelfPermission(this, 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) this.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); | |||||
| } | |||||
| /** | |||||
| * 申请打开蓝牙 | |||||
| */ | |||||
| @SuppressLint("MissingPermission") | |||||
| 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.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.CallbackDisIm; | |||||
| import com.pingwang.bluetoothlib.listener.OnCallbackDis; | |||||
| import com.pingwang.bluetoothlib.utils.BleDensityUtil; | |||||
| import java.text.SimpleDateFormat; | import java.text.SimpleDateFormat; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | ||||
| import cn.net.aicare.modulelibrary.module.CoffeeScale.CoffeeScaleData; | import cn.net.aicare.modulelibrary.module.CoffeeScale.CoffeeScaleData; | ||||
| public class CoffeeScaleActivity extends BleBaseActivity implements View.OnClickListener, CoffeeScaleData.CoffeeScaleCallback { | |||||
| /** | |||||
| * 咖啡秤 | |||||
| * | |||||
| * @author xing | |||||
| * @date 2024/04/18 | |||||
| */ | |||||
| public class CoffeeScaleActivity extends BleBaseActivity implements View.OnClickListener, CoffeeScaleData.CoffeeScaleCallback, OnCallbackDis { | |||||
| private static final String TAG = "Tag1"; | private static final String TAG = "Tag1"; | ||||
| private Button btn_clear; | private Button btn_clear; | ||||
| private Button btnPause; | |||||
| private Button btn_zero; | private Button btn_zero; | ||||
| private Button btn_set_weight_unit; | private Button btn_set_weight_unit; | ||||
| private Button btn_set_temp_unit; | private Button btn_set_temp_unit; | ||||
| private List<String> mList; | private List<String> mList; | ||||
| private ArrayAdapter mListAdapter; | private ArrayAdapter mListAdapter; | ||||
| private boolean mPauseRefresh = false; | |||||
| private String mMac; | private String mMac; | ||||
| private BleDevice mBleDevice; | private BleDevice mBleDevice; | ||||
| private CoffeeScaleData mCoffeeScaleData; | private CoffeeScaleData mCoffeeScaleData; | ||||
| setContentView(R.layout.activity_coffee_scale); | setContentView(R.layout.activity_coffee_scale); | ||||
| btn_clear = findViewById(R.id.btn_clear); | btn_clear = findViewById(R.id.btn_clear); | ||||
| btnPause = findViewById(R.id.btnPause); | |||||
| btn_zero = findViewById(R.id.btn_zero); | btn_zero = findViewById(R.id.btn_zero); | ||||
| btn_set_weight_unit = findViewById(R.id.btn_set_weight_unit); | btn_set_weight_unit = findViewById(R.id.btn_set_weight_unit); | ||||
| btn_set_temp_unit = findViewById(R.id.btn_set_temp_unit); | btn_set_temp_unit = findViewById(R.id.btn_set_temp_unit); | ||||
| list_view = findViewById(R.id.list_view); | list_view = findViewById(R.id.list_view); | ||||
| btn_clear.setOnClickListener(this); | btn_clear.setOnClickListener(this); | ||||
| btnPause.setOnClickListener(this); | |||||
| btn_zero.setOnClickListener(this); | btn_zero.setOnClickListener(this); | ||||
| btn_set_weight_unit.setOnClickListener(this); | btn_set_weight_unit.setOnClickListener(this); | ||||
| btn_set_temp_unit.setOnClickListener(this); | btn_set_temp_unit.setOnClickListener(this); | ||||
| mList = new ArrayList<>(); | mList = new ArrayList<>(); | ||||
| mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | ||||
| list_view.setAdapter(mListAdapter); | list_view.setAdapter(mListAdapter); | ||||
| CallbackDisIm.getInstance().addListListener(this); | |||||
| } | } | ||||
| @Override | @Override | ||||
| // 清空文本框 | // 清空文本框 | ||||
| clearText(); | clearText(); | ||||
| break; | break; | ||||
| case R.id.btnPause: | |||||
| // 清空文本框 | |||||
| mPauseRefresh = !mPauseRefresh; | |||||
| break; | |||||
| case R.id.btn_zero: | case R.id.btn_zero: | ||||
| // APP下发去皮功能(归零功能) | // APP下发去皮功能(归零功能) | ||||
| //某些秤可能需要进入冲煮模式才能使用,并且设备上面的定时和归零可用 | |||||
| appSetZero(); | appSetZero(); | ||||
| break; | break; | ||||
| case R.id.btn_set_weight_unit: | case R.id.btn_set_weight_unit: | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| CallbackDisIm.getInstance().removeListener(this); | |||||
| if (mAILinkBleManager != null) { | if (mAILinkBleManager != null) { | ||||
| mAILinkBleManager.disconnectAll(); | mAILinkBleManager.disconnectAll(); | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public void onWeightResult(int status, int weightUnit, int weightDecimal, int weightSource, int err) { | |||||
| String weightStr = (status == 1 ? "稳定重量" : "实时重量") + ":" + BleDensityUtil.getInstance().holdDecimals(weightSource, weightDecimal) + getWeightUnitStr(weightUnit); | |||||
| String text = "体重数据:" + weightStr; | |||||
| addText(text); | |||||
| } | |||||
| @Override | |||||
| public void onTempResult(int tempUnit, int tempDecimal, int tempSource) { | |||||
| String tempStr = BleDensityUtil.getInstance().holdDecimals(tempSource, tempDecimal) + getTempUnitStr(tempUnit); | |||||
| String text = "温度数据:" + tempStr; | |||||
| addText(text); | |||||
| } | |||||
| // APP下发去皮功能(归零功能) | // APP下发去皮功能(归零功能) | ||||
| private void appSetZero() { | private void appSetZero() { | ||||
| Log.i(TAG, "去皮功能(归零功能)"); | Log.i(TAG, "去皮功能(归零功能)"); | ||||
| } | } | ||||
| SimpleDateFormat sdf; | SimpleDateFormat sdf; | ||||
| // 添加一条文本 | // 添加一条文本 | ||||
| private void addText(String text) { | private void addText(String text) { | ||||
| if (mPauseRefresh) { | |||||
| return; | |||||
| } | |||||
| if (sdf == null) { | if (sdf == null) { | ||||
| sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | ||||
| } | } | ||||
| } | } | ||||
| return ""; | return ""; | ||||
| } | } | ||||
| private String getAlertOpStr(int op) { | private String getAlertOpStr(int op) { | ||||
| switch (op) { | switch (op) { | ||||
| case 0: | case 0: | ||||
| } | } | ||||
| return ""; | return ""; | ||||
| } | } | ||||
| @Override | |||||
| public void onDisConnected(String mac, int code) { | |||||
| if (mac.equalsIgnoreCase(mMac)) { | |||||
| addText("设备:" + mac + "断开连接:" + code); | |||||
| finish(); | |||||
| } | |||||
| } | |||||
| } | } |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat; | |||||
| import android.os.Bundle; | |||||
| import android.view.View; | |||||
| import android.widget.ArrayAdapter; | |||||
| import android.widget.CompoundButton; | |||||
| import android.widget.ListView; | |||||
| import android.widget.RadioButton; | |||||
| import androidx.annotation.Nullable; | |||||
| import com.pingwang.bluetoothlib.AILinkBleManager; | |||||
| 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 aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||||
| import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatMcuDeviceData; | |||||
| import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatUtil; | |||||
| /** | |||||
| * 八电极秤 MCU | |||||
| */ | |||||
| public class EightBodyFatMcuActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, EightBodyFatMcuDeviceData.onEightBodyFatMcuCallback { | |||||
| private List<String> loglist; | |||||
| private ListView log_list; | |||||
| private ArrayAdapter listAdapter; | |||||
| private String mAddress; | |||||
| private EightBodyFatMcuDeviceData mEightBodyFatDeviceData; | |||||
| private RadioButton kg, jing, stlb, lb, C, F; | |||||
| @Override | |||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
| super.onCreate(savedInstanceState); | |||||
| setContentView(R.layout.activity_eight_body_fata); | |||||
| mAddress = getIntent().getStringExtra("mac"); | |||||
| init(); | |||||
| loglist = new ArrayList<>(); | |||||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, loglist); | |||||
| log_list.setAdapter(listAdapter); | |||||
| } | |||||
| private void init() { | |||||
| log_list = findViewById(R.id.log_list); | |||||
| kg = findViewById(R.id.kg); | |||||
| jing = findViewById(R.id.jin); | |||||
| stlb = findViewById(R.id.st_lb); | |||||
| lb = findViewById(R.id.lb); | |||||
| C = findViewById(R.id.c); | |||||
| F = findViewById(R.id.f); | |||||
| findViewById(R.id.support_unit).setOnClickListener(this); | |||||
| kg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.setWeightUnit(EightBodyFatUtil.KG); | |||||
| } | |||||
| } | |||||
| }); | |||||
| jing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.setWeightUnit(EightBodyFatUtil.JIN); | |||||
| } | |||||
| } | |||||
| }); | |||||
| stlb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.setWeightUnit(EightBodyFatUtil.ST); | |||||
| } | |||||
| } | |||||
| }); | |||||
| lb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.setWeightUnit(EightBodyFatUtil.LB); | |||||
| } | |||||
| } | |||||
| }); | |||||
| C.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.setTempUnit(EightBodyFatUtil.C); | |||||
| } | |||||
| } | |||||
| }); | |||||
| F.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.setTempUnit(EightBodyFatUtil.F); | |||||
| } | |||||
| } | |||||
| }); | |||||
| kg.setChecked(true); | |||||
| C.setChecked(true); | |||||
| } | |||||
| @Override | |||||
| public void onServiceSuccess() { | |||||
| loglist.add(0, "绑定服务成功"); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | |||||
| mEightBodyFatDeviceData = new EightBodyFatMcuDeviceData(bleDevice); | |||||
| mEightBodyFatDeviceData.setEightBodyFatCallback(this); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onServiceErr() { | |||||
| } | |||||
| @Override | |||||
| public void unbindServices() { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onDisConnected(String mac, int code) { | |||||
| if (mAddress.equals(mac)) { | |||||
| addLog("连接断开:" + code); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| if (v.getId() == R.id.support_unit) { | |||||
| if (mEightBodyFatDeviceData != null) | |||||
| mEightBodyFatDeviceData.getUnitList(); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onState(int opCode, int result) { | |||||
| //0x01 : 校准 0x02 : 温度单位切换 0x03:重量单位切换 | |||||
| String opCodeStr = ""; | |||||
| if (opCode == 0x01) { | |||||
| opCodeStr = "校准"; | |||||
| } else if (opCode == 0x02) { | |||||
| opCodeStr = "温度单位切换"; | |||||
| } else if (opCode == 0x03) { | |||||
| opCodeStr = "重量单位切换"; | |||||
| } | |||||
| String resultStr = ""; | |||||
| if (result == 0x00) { | |||||
| resultStr = "操作成功"; | |||||
| } else if (result == 0x01) { | |||||
| resultStr = "操作失败"; | |||||
| } else if (result == 0x02) { | |||||
| resultStr = "正在操作中"; | |||||
| } | |||||
| addLog("设备返回操作指令:" + opCodeStr + " 结果:" + resultStr); | |||||
| } | |||||
| private double weightValue; | |||||
| @Override | |||||
| public void onWeight(int status, int weight, int unit, int decimal) { | |||||
| String statusStr = ""; | |||||
| if (status == 0x01) { | |||||
| statusStr = "实时体重"; | |||||
| } else if (status == 0x02) { | |||||
| statusStr = "稳定体重"; | |||||
| } | |||||
| if (decimal == 0) { | |||||
| weightValue = weight; | |||||
| } else { | |||||
| weightValue = weight / (decimal * 10.0); | |||||
| } | |||||
| String unitStr = ""; | |||||
| if (unit == EightBodyFatUtil.KG) { | |||||
| unitStr = "kg"; | |||||
| } else if (unit == EightBodyFatUtil.JIN) { | |||||
| unitStr = "斤"; | |||||
| } else if (unit == EightBodyFatUtil.ST) { | |||||
| unitStr = "lb(未转换为st:lb)"; | |||||
| } else if (unit == EightBodyFatUtil.LB) { | |||||
| unitStr = "lb"; | |||||
| } | |||||
| addLog("体重:" + statusStr + " " + weightValue + unitStr); | |||||
| } | |||||
| @Override | |||||
| public void onHeight(int status, int height, int unit) { | |||||
| String statusStr = ""; | |||||
| if (status == 0x01) { | |||||
| statusStr = "测量中"; | |||||
| } else if (status == 0x03) { | |||||
| statusStr = "测量失败"; | |||||
| } else if (status == 0x02) { | |||||
| statusStr = "测量完成"; | |||||
| } | |||||
| String unitStr = ""; | |||||
| if (unit == 0x00) { | |||||
| unitStr = "cm"; | |||||
| } else if (unit == 0x01) { | |||||
| unitStr = "inch"; | |||||
| } else if (unit == 0x02) { | |||||
| unitStr = "ft-in"; | |||||
| } | |||||
| addLog("身高:" + statusStr + " " + height + unitStr); | |||||
| } | |||||
| @Override | |||||
| public void onImpedance(int status, EightBodyFatMcuDeviceData.EightBodyFatAdc eightBodyFatAdc, int arithmetic) { | |||||
| String statusStr = ""; | |||||
| if (status == EightBodyFatUtil.IMPEDANCE_MEASUREMENT) { | |||||
| statusStr = "测量中"; | |||||
| } else if (status == EightBodyFatUtil.IMPEDANCE_FAILED) { | |||||
| statusStr = "测量失败"; | |||||
| } else if (status == EightBodyFatUtil.IMPEDANCE_SUCCESS_MCU) { | |||||
| statusStr = "测量完成"; | |||||
| } | |||||
| String partStr = ""; | |||||
| int part = eightBodyFatAdc.getPart(); | |||||
| int adc = eightBodyFatAdc.getAdc(); | |||||
| if (part == 0x00) { | |||||
| partStr = "双脚阻抗"; | |||||
| } else if (part == 0x01) { | |||||
| partStr = "双手阻抗"; | |||||
| } else if (part == 0x02) { | |||||
| partStr = "左手阻抗"; | |||||
| } else if (part == 0x03) { | |||||
| partStr = "右手阻抗"; | |||||
| } else if (part == 0x04) { | |||||
| partStr = "左脚阻抗"; | |||||
| } else if (part == 0x05) { | |||||
| partStr = "右脚阻抗"; | |||||
| } else if (part == 0x06) { | |||||
| partStr = "左全身阻抗"; | |||||
| } else if (part == 0x07) { | |||||
| partStr = "右全身阻抗"; | |||||
| } else if (part == 0x08) { | |||||
| partStr = "右手左脚阻抗"; | |||||
| } else if (part == 0x09) { | |||||
| partStr = "左手右脚阻抗"; | |||||
| } else if (part == 0x0A) { | |||||
| partStr = "躯干阻抗"; | |||||
| } | |||||
| addLog("阻抗:" + statusStr + " " + partStr + " : " + adc); | |||||
| } | |||||
| @Override | |||||
| public void onHeartRate(int status, int heartRate) { | |||||
| String statusStr = ""; | |||||
| if (status == EightBodyFatUtil.HEART_RATE_MEASUREMENT) { | |||||
| statusStr = "测量中"; | |||||
| } else if (status == EightBodyFatUtil.HEART_RATE_SUCCESS) { | |||||
| statusStr = "测量成功"; | |||||
| } else if (status == EightBodyFatUtil.HEART_RATE_FAILED) { | |||||
| statusStr = "测量失败"; | |||||
| } | |||||
| addLog("心率:" + statusStr + " " + heartRate); | |||||
| } | |||||
| @Override | |||||
| public void onTemp(int sign, int temp, int unit, int decimal) { | |||||
| double tempValue = temp / (decimal * 10.0); | |||||
| if (decimal == 0) { | |||||
| tempValue = temp; | |||||
| } | |||||
| if (sign == 1) { | |||||
| tempValue = -tempValue; | |||||
| } | |||||
| String unitStr = ""; | |||||
| if (unit == EightBodyFatUtil.C) { | |||||
| unitStr = "℃"; | |||||
| } else if (unit == EightBodyFatUtil.F) { | |||||
| unitStr = "℉"; | |||||
| } | |||||
| addLog("温度:" + tempValue + unitStr); | |||||
| } | |||||
| @Override | |||||
| public void onSyncUserInfo() { | |||||
| addLog("请求同步用户信息:" + "默认传入用户:用户ID:1, 普通人:0, 性别:男,身高:180,年龄27"); | |||||
| if (mEightBodyFatDeviceData != null) { | |||||
| mEightBodyFatDeviceData.setUserInfo(1, 0, 1, 27, 180); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onCompletionData() { | |||||
| addLog("请求补充体脂数据"); | |||||
| } | |||||
| @Override | |||||
| public void onBodyFatData(int step, EightBodyFatMcuDeviceData.EightBodyFatInfo bodyFat) { | |||||
| addLog("体脂测量中,步骤:" + step); | |||||
| } | |||||
| @Override | |||||
| public void onTestSuccess(EightBodyFatMcuDeviceData.EightBodyFatInfo bodyFat) { | |||||
| addLog("体脂数据:" + bodyFat.toString()); | |||||
| } | |||||
| @Override | |||||
| public void onErrCode(int code) { | |||||
| addLog("错误码:" + code); | |||||
| } | |||||
| @Override | |||||
| public void onVersion(String version) { | |||||
| addLog("当前版本:" + version); | |||||
| } | |||||
| @Override | |||||
| public void onSupportUnit(List<SupportUnitBean> list) { | |||||
| addLog("支持单位:"); | |||||
| for (SupportUnitBean supportUnitBean : list) { | |||||
| addLog(supportUnitBean.toString()); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void showData(String data) { | |||||
| addLog(data); | |||||
| } | |||||
| @Override | |||||
| protected void onDestroy() { | |||||
| super.onDestroy(); | |||||
| AILinkBleManager.getInstance().disconnect(mAddress); | |||||
| } | |||||
| private String mOldLog = ""; | |||||
| /** | |||||
| * 添加日志 | |||||
| * | |||||
| * @param log 日志 | |||||
| */ | |||||
| private void addLog(String log) { | |||||
| if (mOldLog.equalsIgnoreCase(log)) { | |||||
| return; | |||||
| } | |||||
| mOldLog = log; | |||||
| loglist.add(0, log); | |||||
| if (listAdapter != null) { | |||||
| listAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| } | |||||
| } |
| package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat; | |||||
| import android.os.Bundle; | import android.os.Bundle; | ||||
| import android.view.View; | import android.view.View; | ||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||
| import java.util.List; | import java.util.List; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.EightBodyFatAlgorithms; | import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.EightBodyFatAlgorithms; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.EightBodyFatBean; | import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.EightBodyFatBean; | ||||
| listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, loglist); | listAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, loglist); | ||||
| log_list.setAdapter(listAdapter); | log_list.setAdapter(listAdapter); | ||||
| weight = 60; | |||||
| if (mEightBodyfatAdc == null) { | |||||
| mEightBodyfatAdc = new EightBodyfatAdc(); | |||||
| } | |||||
| mEightBodyfatAdc.setAdcFoot(5784349); | |||||
| mEightBodyfatAdc.setAdcHand(5121114); | |||||
| mEightBodyfatAdc.setAdcLeftHand(12854746); | |||||
| mEightBodyfatAdc.setAdcRightHand(15738341); | |||||
| mEightBodyfatAdc.setAdcLeftFoot(1074604); | |||||
| mEightBodyfatAdc.setAdcRightFoot(13046299); | |||||
| mEightBodyfatAdc.setAdcLeftBody(7480094); | |||||
| mEightBodyfatAdc.setAdcRightBody(7480094); | |||||
| kaimengJieMi(mEightBodyfatAdc); | |||||
| // weight = 60; | |||||
| // if (mEightBodyfatAdc == null) { | |||||
| // mEightBodyfatAdc = new EightBodyfatAdc(); | |||||
| // } | |||||
| // mEightBodyfatAdc.setAdcFoot(5784349); | |||||
| // mEightBodyfatAdc.setAdcHand(5121114); | |||||
| // mEightBodyfatAdc.setAdcLeftHand(12854746); | |||||
| // mEightBodyfatAdc.setAdcRightHand(15738341); | |||||
| // mEightBodyfatAdc.setAdcLeftFoot(1074604); | |||||
| // mEightBodyfatAdc.setAdcRightFoot(13046299); | |||||
| // mEightBodyfatAdc.setAdcLeftBody(7480094); | |||||
| // mEightBodyfatAdc.setAdcRightBody(7480094); | |||||
| // kaimengJieMi(mEightBodyfatAdc); | |||||
| } | } | ||||
| package aicare.net.cn.sdk.ailinksdkdemoandroid; | |||||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat; | |||||
| public class EightBodyfatAdc { | public class EightBodyfatAdc { | ||||
| /** | |||||
| * 双脚阻抗 | |||||
| */ | |||||
| private int adcFoot; //双脚阻抗, | private int adcFoot; //双脚阻抗, | ||||
| /** | |||||
| * 双手阻抗 | |||||
| */ | |||||
| private int adcHand;//双手阻抗 | private int adcHand;//双手阻抗 | ||||
| /** | |||||
| * 左手阻抗 | |||||
| */ | |||||
| private int adcLeftHand; //左手阻抗 | private int adcLeftHand; //左手阻抗 | ||||
| /** | |||||
| * 右手阻抗 | |||||
| */ | |||||
| private int adcRightHand; //右手阻抗 | private int adcRightHand; //右手阻抗 | ||||
| /** | |||||
| * 左脚阻抗 | |||||
| */ | |||||
| private int adcLeftFoot; //左脚阻抗 | private int adcLeftFoot; //左脚阻抗 | ||||
| /** | |||||
| * 右脚阻抗 | |||||
| */ | |||||
| private int adcRightFoot; //右脚阻抗 | private int adcRightFoot; //右脚阻抗 | ||||
| /** | |||||
| * 左身体阻抗 | |||||
| */ | |||||
| private int adcLeftBody; | private int adcLeftBody; | ||||
| /** | |||||
| * 右身体阻抗 | |||||
| */ | |||||
| private int adcRightBody; | private int adcRightBody; | ||||
| /** | |||||
| * 阻抗右手左脚 | |||||
| */ | |||||
| private int adcRightHandLeftFoot; | private int adcRightHandLeftFoot; | ||||
| /** | |||||
| * 阻抗左手右脚 | |||||
| */ | |||||
| private int adcLeftHandRightFoot; | private int adcLeftHandRightFoot; | ||||
| /** | |||||
| * 阻抗身体 | |||||
| */ | |||||
| private int adcBody; | private int adcBody; | ||||
| /** | |||||
| * 算法ID | |||||
| */ | |||||
| private int algorithms; | private int algorithms; | ||||
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat.dual_band; | |||||
| 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.CompoundButton; | |||||
| import android.widget.EditText; | |||||
| import android.widget.ListView; | |||||
| import android.widget.RadioButton; | |||||
| import androidx.annotation.NonNull; | |||||
| import androidx.annotation.Nullable; | |||||
| 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 java.util.Map; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleBaseActivity; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.JsonLoader; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.L; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.utils.UnitUtils; | |||||
| import cn.net.aicare.modulelibrary.module.EightBodyfatscale.EightBodyFatUtil; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.BaseEightDoubleBodyFatData; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.EightDoubleBodyFatAdcBean; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.EightDoubleBodyFatBean; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.EightDoubleBodyFatBleConfig; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.EightDoubleBodyFatBleDeviceData; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.EightDoubleBodyFatBleMcuDeviceData; | |||||
| import cn.net.aicare.modulelibrary.module.EightDoubleBodyfatScale.OnEightDoubleBodyFatCallback; | |||||
| /** | |||||
| * 双频八电极秤(mcu算法) | |||||
| * | |||||
| * @author xing | |||||
| * @date 2024/03/14 | |||||
| */ | |||||
| public class EightDoubleBodyfatActivity extends BleBaseActivity implements View.OnClickListener, OnCallbackBle, OnEightDoubleBodyFatCallback { | |||||
| /** | |||||
| * 刷新键 | |||||
| */ | |||||
| private final int REFRESH_KEY = 0x01; | |||||
| private List<String> mLoglist; | |||||
| private ListView log_list; | |||||
| private ArrayAdapter mAdapter; | |||||
| private String mAddress; | |||||
| private BaseEightDoubleBodyFatData mEightDoubleBodyFatData; | |||||
| private RadioButton kg, jing, stlb, lb; | |||||
| private EditText et_weight, et_height, et_age, et_sex; | |||||
| private String mWeightKg = "78"; | |||||
| private UserInfoBean mUserInfoBean; | |||||
| private Map<String, String> mMap; | |||||
| private int mCid; | |||||
| private Handler mHandler = new Handler(Looper.getMainLooper()) { | |||||
| @Override | |||||
| public void handleMessage(@NonNull Message msg) { | |||||
| super.handleMessage(msg); | |||||
| if (msg.what == REFRESH_KEY) { | |||||
| if (mAdapter != null) { | |||||
| mAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| } | |||||
| } | |||||
| }; | |||||
| @Override | |||||
| protected void onCreate(@Nullable Bundle savedInstanceState) { | |||||
| super.onCreate(savedInstanceState); | |||||
| setContentView(R.layout.activity_eight_double_body_fata); | |||||
| mAddress = getIntent().getStringExtra("mac"); | |||||
| mCid = getIntent().getIntExtra("cid", 0); | |||||
| initView(); | |||||
| initListener(); | |||||
| initData(); | |||||
| } | |||||
| private void initData() { | |||||
| mLoglist = new ArrayList<>(); | |||||
| mAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mLoglist); | |||||
| log_list.setAdapter(mAdapter); | |||||
| mMap = JsonLoader.loadJsonFromAsset(this, "text.json"); | |||||
| initUserInfo(); | |||||
| Button test_bodyfit = findViewById(R.id.test_bodyfit); | |||||
| test_bodyfit.setOnClickListener(new View.OnClickListener() { | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| List<EightDoubleBodyFatAdcBean> list = new ArrayList<>(); | |||||
| EightDoubleBodyFatAdcBean adcBean = new EightDoubleBodyFatAdcBean(); | |||||
| adcBean.setAdcRightHand(2433844368L); | |||||
| adcBean.setAdcLeftHand(3781622117L); | |||||
| adcBean.setAdcBody(1349958013L); | |||||
| adcBean.setAdcRightFoot(1365295937L); | |||||
| adcBean.setAdcLeftFoot(1903359127L); | |||||
| adcBean.setFrequencyId(0x01); | |||||
| adcBean.setAlgorithmsId(0x01); | |||||
| list.add(adcBean); | |||||
| EightDoubleBodyFatAdcBean adcBean100 = new EightDoubleBodyFatAdcBean(); | |||||
| adcBean100.setAdcRightHand(2447381468L); | |||||
| adcBean100.setAdcLeftHand(1909750593L); | |||||
| adcBean100.setAdcBody(2954962439L); | |||||
| adcBean100.setAdcRightFoot(4036701847L); | |||||
| adcBean100.setAdcLeftFoot(2421978775L); | |||||
| adcBean100.setFrequencyId(0x02); | |||||
| adcBean100.setAlgorithmsId(0x01); | |||||
| list.add(adcBean100); | |||||
| onTestCompleted(list); | |||||
| } | |||||
| }); | |||||
| } | |||||
| private void initUserInfo() { | |||||
| mWeightKg = et_weight.getText().toString().trim(); | |||||
| String height = et_height.getText().toString().trim(); | |||||
| String age = et_age.getText().toString().trim(); | |||||
| String sex = et_sex.getText().toString().trim(); | |||||
| if (mUserInfoBean == null) { | |||||
| mUserInfoBean = new UserInfoBean(); | |||||
| } | |||||
| mUserInfoBean.setAge(Integer.parseInt(age)); | |||||
| mUserInfoBean.setSex(Integer.parseInt(sex)); | |||||
| mUserInfoBean.setHeightCm(Integer.parseInt(height)); | |||||
| mUserInfoBean.setWeightKg(Float.parseFloat(mWeightKg)); | |||||
| } | |||||
| private void initView() { | |||||
| et_weight = findViewById(R.id.et_weight); | |||||
| et_height = findViewById(R.id.et_height); | |||||
| et_age = findViewById(R.id.et_age); | |||||
| et_sex = findViewById(R.id.et_sex); | |||||
| log_list = findViewById(R.id.log_list); | |||||
| kg = findViewById(R.id.kg); | |||||
| jing = findViewById(R.id.jin); | |||||
| stlb = findViewById(R.id.st_lb); | |||||
| lb = findViewById(R.id.lb); | |||||
| } | |||||
| private void initListener() { | |||||
| findViewById(R.id.support_unit).setOnClickListener(this); | |||||
| findViewById(R.id.btn_clear_log).setOnClickListener(this); | |||||
| kg.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightDoubleBodyFatData != null) { | |||||
| mEightDoubleBodyFatData.setWeightUnit(EightBodyFatUtil.KG); | |||||
| } | |||||
| } | |||||
| } | |||||
| }); | |||||
| jing.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightDoubleBodyFatData != null) { | |||||
| mEightDoubleBodyFatData.setWeightUnit(EightBodyFatUtil.JIN); | |||||
| } | |||||
| } | |||||
| } | |||||
| }); | |||||
| stlb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightDoubleBodyFatData != null) { | |||||
| mEightDoubleBodyFatData.setWeightUnit(EightBodyFatUtil.ST); | |||||
| } | |||||
| } | |||||
| } | |||||
| }); | |||||
| lb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { | |||||
| @Override | |||||
| public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { | |||||
| if (isChecked) { | |||||
| if (mEightDoubleBodyFatData != null) { | |||||
| mEightDoubleBodyFatData.setWeightUnit(EightBodyFatUtil.LB); | |||||
| } | |||||
| } | |||||
| } | |||||
| }); | |||||
| kg.setChecked(true); | |||||
| } | |||||
| @Override | |||||
| public void onServiceSuccess() { | |||||
| showData("绑定服务成功"); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | |||||
| if (mCid == EightDoubleBodyFatBleConfig.CID_APP) { | |||||
| mEightDoubleBodyFatData = EightDoubleBodyFatBleDeviceData.init(bleDevice); | |||||
| } else if (mCid == EightDoubleBodyFatBleConfig.CID_MCU) { | |||||
| mEightDoubleBodyFatData = EightDoubleBodyFatBleMcuDeviceData.init(bleDevice); | |||||
| } else { | |||||
| L.e("无效的CID:" + mCid); | |||||
| return; | |||||
| } | |||||
| mEightDoubleBodyFatData.setEightBodyFatCallback(this); | |||||
| } | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onServiceErr() { | |||||
| } | |||||
| @Override | |||||
| public void unbindServices() { | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onDisConnected(String mac, int code) { | |||||
| showData("连接断开:" + mac + " code=" + code); | |||||
| } | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| if (v.getId() == R.id.support_unit) { | |||||
| if (mEightDoubleBodyFatData != null) { | |||||
| mEightDoubleBodyFatData.getUnitList(); | |||||
| } | |||||
| } else if (v.getId() == R.id.btn_clear_log) { | |||||
| mLoglist.clear(); | |||||
| mHandler.sendEmptyMessage(REFRESH_KEY); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onErrCode(int state) { | |||||
| showData("错误码:" + state); | |||||
| } | |||||
| @Override | |||||
| public void onUnitState(int state) { | |||||
| showData("单位状态:" + state); | |||||
| } | |||||
| @Override | |||||
| public void onTestCompleted(List<EightDoubleBodyFatAdcBean> adcBeanList) { | |||||
| initUserInfo(); | |||||
| mLoglist.add(0, "测试完成:" + adcBeanList.size()); | |||||
| for (EightDoubleBodyFatAdcBean adcBean : adcBeanList) { | |||||
| String data = ""; | |||||
| data += (adcBean.getFrequencyId() == 0x01) ? "频率:20kHz" : "频率:100kHz"; | |||||
| data += "\n 左手阻抗:" + adcBean.getAdcLeftHand(); | |||||
| data += "\n 右手阻抗:" + adcBean.getAdcRightHand(); | |||||
| data += "\n 左脚阻抗:" + adcBean.getAdcLeftFoot(); | |||||
| data += "\n 右脚阻抗:" + adcBean.getAdcRightFoot(); | |||||
| data += "\n 躯干阻抗:" + adcBean.getAdcBody(); | |||||
| data += "\n 算法:" + adcBean.getAlgorithmsId(); | |||||
| mLoglist.add(0, data); | |||||
| } | |||||
| mLoglist.add(0, "用户信息:" + mUserInfoBean.toString()); | |||||
| mHandler.sendEmptyMessage(REFRESH_KEY); | |||||
| getBodyFatData(adcBeanList); | |||||
| } | |||||
| // private HetaiHttpUtils mHetaiHttpUtils; | |||||
| private void getBodyFatData(List<EightDoubleBodyFatAdcBean> adcBeanList) { | |||||
| if (mCid != EightDoubleBodyFatBleConfig.CID_APP) { | |||||
| return; | |||||
| } | |||||
| // ParamsHetaiBean paramsHetaiBean = new ParamsHetaiBean(); | |||||
| // paramsHetaiBean.setAge(String.valueOf(mUserInfoBean.getAge())); | |||||
| // paramsHetaiBean.setSex(String.valueOf(mUserInfoBean.getSex())); | |||||
| // paramsHetaiBean.setHeightCm(String.valueOf(mUserInfoBean.getHeightCm())); | |||||
| // paramsHetaiBean.setWeightKg(String.valueOf(mUserInfoBean.getWeightKg())); | |||||
| // for (EightDoubleBodyFatAdcBean adcBean : adcBeanList) { | |||||
| // if (adcBean.getFrequencyId() == 0x01) { | |||||
| // //20khz | |||||
| // paramsHetaiBean.setZ20KhzLeftArmEnCode(String.valueOf(adcBean.getAdcLeftHand())); | |||||
| // paramsHetaiBean.setZ20KhzRightArmEnCode(String.valueOf(adcBean.getAdcRightHand())); | |||||
| // paramsHetaiBean.setZ20KhzLeftLegEnCode(String.valueOf(adcBean.getAdcLeftFoot())); | |||||
| // paramsHetaiBean.setZ20KhzRightLegEnCode(String.valueOf(adcBean.getAdcRightFoot())); | |||||
| // paramsHetaiBean.setZ20KhzTrunkEnCode(String.valueOf(adcBean.getAdcBody())); | |||||
| // | |||||
| // } else if (adcBean.getFrequencyId() == 0x02) { | |||||
| // //100khz | |||||
| // paramsHetaiBean.setZ100KhzLeftArmEnCode(String.valueOf(adcBean.getAdcLeftHand())); | |||||
| // paramsHetaiBean.setZ100KhzRightArmEnCode(String.valueOf(adcBean.getAdcRightHand())); | |||||
| // paramsHetaiBean.setZ100KhzLeftLegEnCode(String.valueOf(adcBean.getAdcLeftFoot())); | |||||
| // paramsHetaiBean.setZ100KhzRightLegEnCode(String.valueOf(adcBean.getAdcRightFoot())); | |||||
| // paramsHetaiBean.setZ100KhzTrunkEnCode(String.valueOf(adcBean.getAdcBody())); | |||||
| // } | |||||
| // } | |||||
| // //获取数据 | |||||
| // if (mHetaiHttpUtils == null) { | |||||
| // mHetaiHttpUtils = new HetaiHttpUtils(); | |||||
| // } | |||||
| // mHetaiHttpUtils.postGetBody270(paramsHetaiBean, new OnHttpListener<HttpHetaiListBean>() { | |||||
| // @Override | |||||
| // public void onSuccess(HttpHetaiListBean data) { | |||||
| // List<HttpHetaiBean> httpHetaiBeans = data.getData(); | |||||
| // if (httpHetaiBeans != null) { | |||||
| // mLoglist.add(0, "获取数据成功:" + httpHetaiBeans.size()); | |||||
| // for (HttpHetaiBean httpHetaiBean : httpHetaiBeans) { | |||||
| // String show = mMap.get(httpHetaiBean.getName()) + ":" + httpHetaiBean.getValue() + " " + | |||||
| // (httpHetaiBean.getUnit() == null ? "" : httpHetaiBean.getUnit()) + | |||||
| // (httpHetaiBean.getLevel() == null ? "" : "\n" + httpHetaiBean.getLevel().toString()); | |||||
| // mLoglist.add(0, show); | |||||
| // L.i(httpHetaiBean.toString()); | |||||
| // } | |||||
| // mHandler.sendEmptyMessage(REFRESH_KEY); | |||||
| // } else { | |||||
| // showData("体脂数据为空:" + data.toString()); | |||||
| // } | |||||
| // | |||||
| // } | |||||
| // | |||||
| // @Override | |||||
| // public void onFailed(HttpHetaiListBean data) { | |||||
| // showData("获取数据失败"); | |||||
| // } | |||||
| // }); | |||||
| } | |||||
| @Override | |||||
| public void onWeight(int state, int weight, int decimal, int unit, int batteryStatus, int power) { | |||||
| //测量状态 1实时体重 2稳定体重 | |||||
| float weightF = Float.parseFloat(UnitUtils.getHoldDecimal(decimal, weight)); | |||||
| String stateStr = ""; | |||||
| if (state == EightDoubleBodyFatBleConfig.STATUS_WEIGHT_REAL_TIME_WEIGH) { | |||||
| stateStr = "实时体重"; | |||||
| } else if (state == EightDoubleBodyFatBleConfig.STATUS_WEIGHT_STABILIZATION_WEIGHT) { | |||||
| stateStr = "稳定体重"; | |||||
| mWeightKg = String.valueOf(weightF); | |||||
| if (et_weight != null) { | |||||
| et_weight.setText(mWeightKg); | |||||
| } | |||||
| } | |||||
| if (unit == EightDoubleBodyFatBleConfig.STATUS_ST) { | |||||
| showData("测量状态:" + state + stateStr + " 体重:" + lbToStlb(weightF) + " 体重单位:" + unit + " 小数点位" + decimal); | |||||
| } else { | |||||
| showData("测量状态:" + state + stateStr + " 体重:" + weightF + " 体重单位:" + unit + " 小数点位" + decimal); | |||||
| } | |||||
| } | |||||
| public static String lbToStlb(float lb) { | |||||
| int st = (int) lb / 14; | |||||
| float mlb = lb % 14f; | |||||
| return st + ":" + mlb; | |||||
| } | |||||
| @Override | |||||
| public void onImpedanceStatus(int status) { | |||||
| String adc = ""; | |||||
| switch (status) { | |||||
| case EightDoubleBodyFatBleConfig.STATUS_IMPEDANCE_MEASUREMENT: | |||||
| adc = "阻抗测量中"; | |||||
| break; | |||||
| case EightDoubleBodyFatBleConfig.STATUS_IMPEDANCE_SUCCESS: | |||||
| //阻抗测量成功 | |||||
| adc = "阻抗测量成功"; | |||||
| break; | |||||
| case EightDoubleBodyFatBleConfig.STATUS_IMPEDANCE_FAILED: | |||||
| adc = "阻抗测量失败"; | |||||
| //阻抗测量失败 | |||||
| break; | |||||
| } | |||||
| showData(adc); | |||||
| } | |||||
| @Override | |||||
| public void onVersion(String version) { | |||||
| showData("当前版本:" + version); | |||||
| } | |||||
| @Override | |||||
| public void onSupportUnit(List<SupportUnitBean> list) { | |||||
| mLoglist.add(0, "支持单位:"); | |||||
| for (SupportUnitBean supportUnitBean : list) { | |||||
| mLoglist.add(0, supportUnitBean.toString()); | |||||
| } | |||||
| mHandler.sendEmptyMessage(REFRESH_KEY); | |||||
| } | |||||
| @Override | |||||
| public void onBodyFat(EightDoubleBodyFatBean bodyFatBean) { | |||||
| if (bodyFatBean == null) { | |||||
| showData("体脂数据为空"); | |||||
| return; | |||||
| } | |||||
| showData("体脂数据:" + bodyFatBean); | |||||
| } | |||||
| @Override | |||||
| public void onHeartRate(int status, int heartRate) { | |||||
| String statusStr = ""; | |||||
| if (status == 0x01) { | |||||
| statusStr = "心率测量中"; | |||||
| } else if (status == 0x02) { | |||||
| statusStr = "心率测量成功:" + heartRate; | |||||
| } else if (status == 0x03) { | |||||
| statusStr = "心率测量失败"; | |||||
| } | |||||
| showData(statusStr); | |||||
| } | |||||
| @Override | |||||
| public void onTemperature(int temp, int unit, int decimal) { | |||||
| showData("温度:" + temp + " 单位:" + unit + " 小数点位" + decimal); | |||||
| } | |||||
| @Override | |||||
| public void onSyncUser() { | |||||
| if (mEightDoubleBodyFatData != null && mEightDoubleBodyFatData instanceof EightDoubleBodyFatBleMcuDeviceData) { | |||||
| ((EightDoubleBodyFatBleMcuDeviceData) mEightDoubleBodyFatData).setUserInfo(0, 0, mUserInfoBean.getAge(), mUserInfoBean.getSex(), mUserInfoBean.getHeightCm()); | |||||
| } | |||||
| showData("设备请求同步用户信息"); | |||||
| } | |||||
| private String mOldData = ""; | |||||
| @Override | |||||
| public void showData(String data) { | |||||
| if (mOldData.equals(data)) { | |||||
| return; | |||||
| } | |||||
| mOldData = data; | |||||
| mLoglist.add(0, data); | |||||
| mHandler.sendEmptyMessage(REFRESH_KEY); | |||||
| } | |||||
| @Override | |||||
| protected void onDestroy() { | |||||
| super.onDestroy(); | |||||
| if (mAILinkBleManager!=null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | |||||
| } | |||||
| } |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat.dual_band; | |||||
| public class UserInfoBean { | |||||
| private int age; | |||||
| private int heightCm; | |||||
| private float weightKg; | |||||
| private int sex; | |||||
| public int getAge() { | |||||
| return age; | |||||
| } | |||||
| public void setAge(int age) { | |||||
| this.age = age; | |||||
| } | |||||
| public int getHeightCm() { | |||||
| return heightCm; | |||||
| } | |||||
| public void setHeightCm(int heightCm) { | |||||
| this.heightCm = heightCm; | |||||
| } | |||||
| public float getWeightKg() { | |||||
| return weightKg; | |||||
| } | |||||
| public void setWeightKg(float weightKg) { | |||||
| this.weightKg = weightKg; | |||||
| } | |||||
| public int getSex() { | |||||
| return sex; | |||||
| } | |||||
| public void setSex(int sex) { | |||||
| this.sex = sex; | |||||
| } | |||||
| @Override | |||||
| public String toString() { | |||||
| return "UserInfoBean{" + "age=" + age + ", heightCm=" + heightCm + ", weightKg=" + weightKg + ", sex=" + sex + '}'; | |||||
| } | |||||
| } |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.modules.gasDetector; | |||||
| import android.os.Message; | |||||
| import android.text.TextUtils; | |||||
| import android.view.View; | |||||
| import android.widget.ArrayAdapter; | |||||
| import android.widget.EditText; | |||||
| import android.widget.ListView; | |||||
| import com.pingwang.bluetoothlib.AILinkBleManager; | |||||
| import com.pingwang.bluetoothlib.device.BleDevice; | |||||
| import com.pingwang.bluetoothlib.listener.OnCallbackBle; | |||||
| import java.text.SimpleDateFormat; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.Locale; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.R; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.base.BleAppNewBaseActivity; | |||||
| import cn.net.aicare.modulelibrary.module.gasDetector.GasDetectorCurrentInfoBean; | |||||
| import cn.net.aicare.modulelibrary.module.gasDetector.GasDetectorDevice; | |||||
| import cn.net.aicare.modulelibrary.module.gasDetector.GasDetectorHistoryInfoBean; | |||||
| import cn.net.aicare.modulelibrary.module.gasDetector.OnGasDetectorInfoListener; | |||||
| /** | |||||
| * 气体探测器界面 | |||||
| * | |||||
| * @author xing | |||||
| * @date 2024/09/05 | |||||
| */ | |||||
| public class GasDetectorActivity extends BleAppNewBaseActivity implements View.OnClickListener, OnCallbackBle, OnGasDetectorInfoListener { | |||||
| private String mMac = ""; | |||||
| private EditText etInterval, etDensity, etHpa, etInHg; | |||||
| private GasDetectorDevice mGasDetectorDevice; | |||||
| private ListView list_view; | |||||
| private List<String> mList; | |||||
| private ArrayAdapter mListAdapter; | |||||
| @Override | |||||
| protected void uiHandlerMessage(Message msg) { | |||||
| } | |||||
| @Override | |||||
| protected int getLayoutId() { | |||||
| return R.layout.activity_gas_detector; | |||||
| } | |||||
| @Override | |||||
| protected void initListener() { | |||||
| } | |||||
| @Override | |||||
| public void onClick(View v) { | |||||
| switch (v.getId()) { | |||||
| case R.id.btnGetCurInfo: | |||||
| //实时信息 | |||||
| mGasDetectorDevice.getCurrentInfo(); | |||||
| addText("获取实时信息"); | |||||
| break; | |||||
| case R.id.btnSyncTime: | |||||
| //同步时间 | |||||
| mGasDetectorDevice.setSyncTime(); | |||||
| addText("同步时间"); | |||||
| break; | |||||
| case R.id.btnGetCO2Density: | |||||
| //CO2报警浓度 | |||||
| mGasDetectorDevice.getCo2Alarm(); | |||||
| addText("获取CO2报警浓度"); | |||||
| break; | |||||
| case R.id.btnGetCODensity: | |||||
| //CO报警浓度 | |||||
| mGasDetectorDevice.getCoAlarm(); | |||||
| addText("获取CO报警浓度"); | |||||
| break; | |||||
| case R.id.btnGetO2Density: | |||||
| //O2报警浓度 | |||||
| mGasDetectorDevice.getO2Alarm(); | |||||
| addText("获取O2报警浓度"); | |||||
| break; | |||||
| case R.id.btnGetCO2Interval: | |||||
| //CO2间隔 | |||||
| mGasDetectorDevice.getCo2Interval(); | |||||
| addText("获取CO2间隔"); | |||||
| break; | |||||
| case R.id.btnGetCOInterval: | |||||
| //CO间隔 | |||||
| mGasDetectorDevice.getCoInterval(); | |||||
| addText("获取CO间隔"); | |||||
| break; | |||||
| case R.id.btnGetHistoryInterval: | |||||
| //历史记录间隔 | |||||
| mGasDetectorDevice.getOfflineHistoryInterval(); | |||||
| addText("获取历史记录间隔"); | |||||
| break; | |||||
| case R.id.btnGetCO2Switch: | |||||
| //CO2开关 | |||||
| mGasDetectorDevice.getCo2Switch(); | |||||
| addText("获取CO2开关"); | |||||
| break; | |||||
| case R.id.btnGetCOSwitch: | |||||
| //CO开关 | |||||
| mGasDetectorDevice.getCoSwitch(); | |||||
| addText("获取CO开关"); | |||||
| break; | |||||
| case R.id.btnGetSoundSwitch: | |||||
| //声音开关 | |||||
| mGasDetectorDevice.getSoundSwitch(); | |||||
| addText("获取声音开关"); | |||||
| break; | |||||
| case R.id.btnGetShakeSwitch: | |||||
| //震动开关 | |||||
| mGasDetectorDevice.getShockSwitch(); | |||||
| addText("获取震动开关"); | |||||
| break; | |||||
| case R.id.btnGetTempUnit: | |||||
| //温度单位 | |||||
| mGasDetectorDevice.getTempUnit(); | |||||
| addText("获取温度单位"); | |||||
| break; | |||||
| case R.id.btnGetPressureUnit: | |||||
| //气压单位 | |||||
| mGasDetectorDevice.getAirPressureUnit(); | |||||
| addText("获取气压单位"); | |||||
| break; | |||||
| case R.id.btnGetScreenOffTime: | |||||
| //息屏时间 | |||||
| mGasDetectorDevice.getScreenOffTime(); | |||||
| addText("获取息屏时间"); | |||||
| break; | |||||
| case R.id.btnGetShutdownTime: | |||||
| //关机时间 | |||||
| mGasDetectorDevice.getShutdownTime(); | |||||
| addText("获取关机时间"); | |||||
| break; | |||||
| case R.id.btnGetHistory: | |||||
| //历史记录 | |||||
| mGasDetectorDevice.getOfflineHistory(0); | |||||
| addText("获取历史记录"); | |||||
| break; | |||||
| case R.id.btnClearHistory: | |||||
| //清空历史记录 | |||||
| mGasDetectorDevice.setClearOfflineHistory(); | |||||
| addText("清空历史记录"); | |||||
| break; | |||||
| case R.id.btnSetCo2Density: | |||||
| //设置Co2浓度 | |||||
| try { | |||||
| int densityCo2 = Integer.parseInt(etDensity.getText().toString()); | |||||
| mGasDetectorDevice.setCo2Alarm(densityCo2); | |||||
| addText("设置CO2报警浓度:" + densityCo2); | |||||
| } catch (NumberFormatException e) { | |||||
| addText("请输入正确的数字"); | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetO2Density: | |||||
| //设置O2浓度 | |||||
| try { | |||||
| int densityO2 = Integer.parseInt(etDensity.getText().toString()); | |||||
| mGasDetectorDevice.setO2Alarm(densityO2); | |||||
| addText("设置O2报警浓度:" + densityO2); | |||||
| } catch (NumberFormatException e) { | |||||
| addText("请输入正确的数字"); | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetCo2Interval: | |||||
| //设置CO2间隔 | |||||
| try { | |||||
| int intervalCo2 = Integer.parseInt(etInterval.getText().toString()); | |||||
| mGasDetectorDevice.setCo2Interval(intervalCo2); | |||||
| addText("设置CO2间隔:" + intervalCo2); | |||||
| } catch (NumberFormatException e) { | |||||
| addText("请输入正确的数字"); | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetCoInterval: | |||||
| //设置CO间隔 | |||||
| try { | |||||
| int intervalCo = Integer.parseInt(etInterval.getText().toString()); | |||||
| mGasDetectorDevice.setCoInterval(intervalCo); | |||||
| addText("设置CO间隔:" + intervalCo); | |||||
| } catch (NumberFormatException e) { | |||||
| addText("请输入正确的数字"); | |||||
| } | |||||
| break; | |||||
| case R.id.btnSetPressureCali: | |||||
| //气压校准 | |||||
| try { | |||||
| int hpa = Integer.parseInt(etHpa.getText().toString()); | |||||
| int inHg = Integer.parseInt(etInHg.getText().toString()); | |||||
| mGasDetectorDevice.setAirPressureCalibration(hpa, inHg); | |||||
| addText("设置气压校准:hpa=" + hpa + " inHg=" + inHg); | |||||
| } catch (NumberFormatException e) { | |||||
| addText("请输入正确的数字"); | |||||
| } | |||||
| break; | |||||
| } | |||||
| } | |||||
| @Override | |||||
| protected void initData() { | |||||
| mMac = getIntent().getStringExtra("mac"); | |||||
| mList = new ArrayList<>(); | |||||
| mListAdapter = new ArrayAdapter<>(this, android.R.layout.simple_list_item_1, mList); | |||||
| list_view.setAdapter(mListAdapter); | |||||
| addText("连接成功:" + mMac); | |||||
| onServiceSuccess(); | |||||
| } | |||||
| @Override | |||||
| protected void initView() { | |||||
| etDensity = (EditText) findViewById(R.id.etDensity); | |||||
| etInterval = (EditText) findViewById(R.id.etInterval); | |||||
| etHpa = (EditText) findViewById(R.id.etHpa); | |||||
| etInHg = (EditText) findViewById(R.id.etInHg); | |||||
| list_view = findViewById(R.id.list_view); | |||||
| } | |||||
| @Override | |||||
| public void onServiceSuccess() { | |||||
| if (TextUtils.isEmpty(mMac)) { | |||||
| return; | |||||
| } | |||||
| if (mGasDetectorDevice != null) { | |||||
| return; | |||||
| } | |||||
| AILinkBleManager.getInstance().setOnCallbackBle(this); | |||||
| BleDevice bleDevice = AILinkBleManager.getInstance().getBleDevice(mMac); | |||||
| mGasDetectorDevice = GasDetectorDevice.init(bleDevice); | |||||
| mGasDetectorDevice.addOnGasDetectorInfoListener(this); | |||||
| mGasDetectorDevice.setOnShowData(new GasDetectorDevice.OnShowData() { | |||||
| @Override | |||||
| public void showData(String data) { | |||||
| addText("收到的vlaue数据:" + data); | |||||
| } | |||||
| }); | |||||
| } | |||||
| @Override | |||||
| public void onServiceErr() { | |||||
| } | |||||
| @Override | |||||
| public void unbindServices() { | |||||
| } | |||||
| @Override | |||||
| public void onDisConnected(String mac, int code) { | |||||
| if (mac.equals(this.mMac)) { | |||||
| if (mGasDetectorDevice != null) { | |||||
| mGasDetectorDevice.removeOnGasDetectorInfoListener(this); | |||||
| mGasDetectorDevice = null; | |||||
| } | |||||
| addText("断开连接:" + mac + " code:" + code); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onCurrentInfo(GasDetectorCurrentInfoBean currentInfoBean) { | |||||
| addText("当前信息:" + currentInfoBean.toString()); | |||||
| } | |||||
| @Override | |||||
| public void onCo2Density(int density) { | |||||
| addText("CO2报警浓度(单位ppm):" + density); | |||||
| } | |||||
| @Override | |||||
| public void onCo2Interval(int interval) { | |||||
| addText("CO2间隔(单位min)0代表一直:" + interval); | |||||
| } | |||||
| @Override | |||||
| public void onCo2Switch(int status) { | |||||
| addText("CO2开关:" + (status == 0 ? "打开" : "关闭")); | |||||
| } | |||||
| @Override | |||||
| public void onCoDensity(int density) { | |||||
| addText("CO报警浓度(单位ppm):" + density); | |||||
| } | |||||
| @Override | |||||
| public void onCoInterval(int interval) { | |||||
| addText("CO间隔(单位min)0代表一直:" + interval); | |||||
| } | |||||
| @Override | |||||
| public void onCoSwitch(int status) { | |||||
| addText("CO开关:" + (status == 0 ? "打开" : "关闭")); | |||||
| } | |||||
| @Override | |||||
| public void onO2Density(int density) { | |||||
| addText("O2报警浓度(单位%):" + density); | |||||
| } | |||||
| @Override | |||||
| public void onHistorySaveInterval(int interval) { | |||||
| addText("历史记录保存间隔(单位:分钟,0代表一直):" + interval); | |||||
| } | |||||
| @Override | |||||
| public void onTempUnit(int unit) { | |||||
| addText("温度单位:" + (unit == 0 ? "℃" : "℉")); | |||||
| } | |||||
| @Override | |||||
| public void onPressureUnit(int unit) { | |||||
| addText("气压单位:" + (unit == 0 ? "hPa" : "inHg")); | |||||
| } | |||||
| @Override | |||||
| public void onPressureCalibration(int hpa, int inHg) { | |||||
| addText("气压校准:hpa=" + hpa + " inHg=" + inHg); | |||||
| } | |||||
| @Override | |||||
| public void onBrightness(int brightness) { | |||||
| addText("亮度:" + brightness); | |||||
| } | |||||
| @Override | |||||
| public void onSoundSwitch(int status) { | |||||
| addText("声音开关:" + (status == 0 ? "打开" : "关闭")); | |||||
| } | |||||
| @Override | |||||
| public void onShockSwitch(int status) { | |||||
| addText("震动开关:" + (status == 0 ? "打开" : "关闭")); | |||||
| } | |||||
| @Override | |||||
| public void onSyncTime(long time) { | |||||
| addText("同步时间成功:time=" + time + " 格式化:" + sdf.format(time * 1000)); | |||||
| } | |||||
| @Override | |||||
| public void onScreenOffTime(int time) { | |||||
| addText("息屏时间(单位,秒)0代表从不:" + time); | |||||
| } | |||||
| @Override | |||||
| public void onShutdownTime(int time) { | |||||
| addText("关机时间(单位,小时)0代表从不:" + time); | |||||
| } | |||||
| @Override | |||||
| public void onHistoryInfo(GasDetectorHistoryInfoBean historyInfoBean) { | |||||
| addText("历史记录:" + historyInfoBean.toString()); | |||||
| if (historyInfoBean.getAllCount() != historyInfoBean.getCount()) { | |||||
| mGasDetectorDevice.getOfflineHistory(historyInfoBean.getCount()); | |||||
| } | |||||
| } | |||||
| @Override | |||||
| public void onClearHistory() { | |||||
| addText("清空历史记录成功"); | |||||
| } | |||||
| private SimpleDateFormat sdf; | |||||
| private String mOldText = ""; | |||||
| private void addText(String text) { | |||||
| if (mOldText.equals(text)) { | |||||
| return; | |||||
| } | |||||
| if (sdf == null) { | |||||
| sdf = new SimpleDateFormat("HH:mm:ss", Locale.US); | |||||
| } | |||||
| mList.add(0, sdf.format(System.currentTimeMillis()) + ":\n" + text); | |||||
| mListAdapter.notifyDataSetChanged(); | |||||
| } | |||||
| @Override | |||||
| protected void onDestroy() { | |||||
| super.onDestroy(); | |||||
| AILinkBleManager.getInstance().removeOnCallbackBle(this); | |||||
| if (mGasDetectorDevice != null) { | |||||
| mGasDetectorDevice.clear(); | |||||
| } | |||||
| } | |||||
| } |
| */ | */ | ||||
| private void cancelDialog() { | private void cancelDialog() { | ||||
| ShowListDialogFragment.newInstance().setTitle("选择探针").setCancel("取消", 0).setCancelBlank(true).setBackground(true).setBottom(false).setList(mDialogMacList) | ShowListDialogFragment.newInstance().setTitle("选择探针").setCancel("取消", 0).setCancelBlank(true).setBackground(true).setBottom(false).setList(mDialogMacList) | ||||
| .setOnDialogListener(new ShowListDialogFragment.onDialogListener() { | |||||
| .setOnDialogListener(new ShowListDialogFragment.onDialogListener() { | |||||
| @Override | @Override | ||||
| public void onItemListener(int position) { | public void onItemListener(int position) { | ||||
| Toast.makeText(MeatProbeChargerActivity.this, mDialogMacList.get(position).getName() + "设置该指令", Toast.LENGTH_SHORT).show(); | Toast.makeText(MeatProbeChargerActivity.this, mDialogMacList.get(position).getName() + "设置该指令", Toast.LENGTH_SHORT).show(); |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | |||||
| import com.pingwang.bluetoothlib.AILinkBleManager; | |||||
| import com.pingwang.bluetoothlib.bean.BleScanAddAilinkBean; | |||||
| import com.pingwang.bluetoothlib.config.BleConfig; | |||||
| import com.pingwang.bluetoothlib.server.ELinkBleServer; | |||||
| import com.pingwang.bluetoothlib.utils.UuidUtils; | |||||
| import java.util.ArrayList; | |||||
| import java.util.List; | |||||
| import java.util.UUID; | |||||
| /** | |||||
| * 蓝牙扫描设备工具 | |||||
| * 因为 AILink 现在接了不是 AILink 协议的设备,比如旧的营养秤 UUID 不同 | |||||
| */ | |||||
| public class BleScanUtil { | |||||
| /** | |||||
| * 开始扫描设备 | |||||
| * | |||||
| * @param blueToothService 蓝牙服务 | |||||
| * @param timeout 延迟 ms | |||||
| */ | |||||
| public static void scanLeDevice(ELinkBleServer blueToothService, long timeout) { | |||||
| blueToothService.scanLeDevice(timeout, getScanLeDeviceMap()); | |||||
| } | |||||
| public static void scanLeDevice(AILinkBleManager aiLinkBleManager, long timeout) { | |||||
| aiLinkBleManager.startScan(timeout, getScanLeDeviceMap()); | |||||
| } | |||||
| public static List<BleScanAddAilinkBean> getScanLeDeviceMap() { | |||||
| List<BleScanAddAilinkBean> list = new ArrayList<>(); | |||||
| list.add(getAifresh()); | |||||
| list.add(getAifit02()); | |||||
| list.add(getAifit03()); | |||||
| list.add(getOkOk()); | |||||
| return list; | |||||
| } | |||||
| public static UUID[] getScanLeDeviceUUID() { | |||||
| UUID[] uuids = new UUID[]{UUID.fromString("0000FFB0-0000-1000-8000-00805F9B34FB"),// 旧的营养秤 AC05 | |||||
| // UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"),// 华盛达手表 | |||||
| BleConfig.UUID_SERVER_AILINK, BleConfig.UUID_SERVER_BROADCAST_AILINK}; | |||||
| return uuids; | |||||
| } | |||||
| /** | |||||
| * 好营养AC05的设备 | |||||
| * | |||||
| * @return {@link BleScanAddAilinkBean} | |||||
| */ | |||||
| private static BleScanAddAilinkBean getAifresh() { | |||||
| // 旧的营养秤 | |||||
| BleScanAddAilinkBean bleScanAddAilinkBean = new BleScanAddAilinkBean(); | |||||
| bleScanAddAilinkBean.setDeviceServiceUUID(new UUID[]{UuidUtils.getUuid("0000FFB0-0000-1000-8000-00805F9B34FB")}); | |||||
| byte[] bytes = new byte[]{(byte) 0xAC, 0x05}; | |||||
| bleScanAddAilinkBean.setDeviceBroadcast(bytes, 0, bytes.length); | |||||
| bleScanAddAilinkBean.setCid(0x0037); | |||||
| bleScanAddAilinkBean.setVid(0x0000); | |||||
| bleScanAddAilinkBean.setPid(0x0000); | |||||
| return bleScanAddAilinkBean; | |||||
| } | |||||
| /** | |||||
| * 好身材AC02的体脂秤,带温度 | |||||
| * | |||||
| * @return {@link BleScanAddAilinkBean} | |||||
| */ | |||||
| private static BleScanAddAilinkBean getAifit02() { | |||||
| // 旧的好身材 | |||||
| BleScanAddAilinkBean bleScanAddAilinkBean = new BleScanAddAilinkBean(); | |||||
| bleScanAddAilinkBean.setDeviceServiceUUID(new UUID[]{UuidUtils.getUuid("0000FFB0-0000-1000-8000-00805F9B34FB")}); | |||||
| byte[] bytes = new byte[]{(byte) 0xAC, 0x02}; | |||||
| bleScanAddAilinkBean.setDeviceBroadcast(bytes, 0, bytes.length); | |||||
| bleScanAddAilinkBean.setCid(0x005E); | |||||
| bleScanAddAilinkBean.setVid(0x0070); | |||||
| bleScanAddAilinkBean.setPid(0x0001); | |||||
| return bleScanAddAilinkBean; | |||||
| } | |||||
| /** | |||||
| * 好身材AC03的体脂秤,带温度 | |||||
| * | |||||
| * @return {@link BleScanAddAilinkBean} | |||||
| */ | |||||
| private static BleScanAddAilinkBean getAifit03() { | |||||
| // 旧的好身材 | |||||
| BleScanAddAilinkBean bleScanAddAilinkBean = new BleScanAddAilinkBean(); | |||||
| bleScanAddAilinkBean.setDeviceServiceUUID(new UUID[]{UuidUtils.getUuid("0000FFB0-0000-1000-8000-00805F9B34FB")}); | |||||
| byte[] bytes = new byte[]{(byte) 0xAC, 0x03}; | |||||
| bleScanAddAilinkBean.setDeviceBroadcast(bytes, 0, bytes.length); | |||||
| bleScanAddAilinkBean.setCid(0x005E); | |||||
| bleScanAddAilinkBean.setVid(0x0070); | |||||
| bleScanAddAilinkBean.setPid(0x0001); | |||||
| return bleScanAddAilinkBean; | |||||
| } | |||||
| private static BleScanAddAilinkBean getOkOk() { | |||||
| // OKOK广播秤 | |||||
| BleScanAddAilinkBean bleScanAddAilinkBean = new BleScanAddAilinkBean(); | |||||
| bleScanAddAilinkBean.setDeviceServiceUUID(null); | |||||
| byte[] bytes = new byte[]{(byte) 0x00, 0x00}; | |||||
| bleScanAddAilinkBean.setDeviceBroadcast(bytes, 6, 6+bytes.length); | |||||
| bleScanAddAilinkBean.setCid(0x08+0xFFFF); | |||||
| bleScanAddAilinkBean.setVid(0x0001); | |||||
| bleScanAddAilinkBean.setPid(0x0002); | |||||
| return bleScanAddAilinkBean; | |||||
| } | |||||
| } |
| import java.util.Locale; | import java.util.Locale; | ||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.EightBodyfatAdc; | |||||
| import aicare.net.cn.sdk.ailinksdkdemoandroid.modules.eight_bodyfat.EightBodyfatAdc; | |||||
| public class EightBodyFatAlgorithms { | public class EightBodyFatAlgorithms { | ||||
| BhErrorType bhErrorType = BhErrorType.values()[bhBodyComposition.getBodyComposition()]; | BhErrorType bhErrorType = BhErrorType.values()[bhBodyComposition.getBodyComposition()]; | ||||
| if (bhErrorType == BhErrorType.NONE) { | if (bhErrorType == BhErrorType.NONE) { | ||||
| eightBodyFatBean.setBhSkeletalMuscleKg(bhBodyComposition.bhSkeletalMuscleKg + ""); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKgLevel(bhBodyComposition.bhSkeletalMuscleKgLevel + ""); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKgListStandardOrExcellent(bhBodyComposition.bhMuscleKgListStandardOrExcellent + ""); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKgListUnderOrStandard(bhBodyComposition.bhSkeletalMuscleKgListUnderOrStandard + ""); | |||||
| eightBodyFatBean.setWeight(String.valueOf(bhBodyComposition.bhWeightKg)); | |||||
| eightBodyFatBean.setBmi(Adecimal(bhBodyComposition.bhBMI)); | |||||
| eightBodyFatBean.setBmr((float) bhBodyComposition.bhBMR); | |||||
| eightBodyFatBean.setUvi((float) bhBodyComposition.bhVFAL); | |||||
| eightBodyFatBean.setBm(String.valueOf(bhBodyComposition.bhBoneKg)); | |||||
| eightBodyFatBean.setBfr(Adecimal(bhBodyComposition.bhBodyFatRate)); | |||||
| eightBodyFatBean.setVwc(Adecimal(bhBodyComposition.bhWaterRate)); | |||||
| eightBodyFatBean.setRom(Adecimal(bhBodyComposition.bhMuscleRate)); | |||||
| eightBodyFatBean.setBodyAge(bhBodyComposition.bhBodyAge); | |||||
| eightBodyFatBean.setPp(Adecimal(bhBodyComposition.bhProteinRate)); | |||||
| eightBodyFatBean.setSfr(Adecimal(bhBodyComposition.bhBodyFatSubCutRate)); | |||||
| eightBodyFatBean.setFatMassBody(String.valueOf(bhBodyComposition.bhBodyFatKgTrunk)); | |||||
| eightBodyFatBean.setFatMassLeftTop(String.valueOf(bhBodyComposition.bhBodyFatKgLeftArm)); | |||||
| eightBodyFatBean.setFatMassLeftBottom(String.valueOf(bhBodyComposition.bhBodyFatKgLeftLeg)); | |||||
| eightBodyFatBean.setFatMassRightTop(String.valueOf(bhBodyComposition.bhBodyFatKgRightArm)); | |||||
| eightBodyFatBean.setFatMassRightBottom(String.valueOf(bhBodyComposition.bhBodyFatKgRightLeg)); | |||||
| eightBodyFatBean.setArithmetic(algorithms); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKg(String.valueOf(bhBodyComposition.bhSkeletalMuscleKg)); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKgLevel(String.valueOf(bhBodyComposition.bhSkeletalMuscleKgLevel)); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKgListStandardOrExcellent(String.valueOf(bhBodyComposition.bhMuscleKgListStandardOrExcellent)); | |||||
| eightBodyFatBean.setBhSkeletalMuscleKgListUnderOrStandard(String.valueOf(bhBodyComposition.bhSkeletalMuscleKgListUnderOrStandard)); | |||||
| // System.out.println("解密阻抗-左側全身(Ω)=" + body.bhZLeftBodyDeCode); | |||||
| // System.out.println("解密阻抗-左手(Ω)=" + body.bhZLeftArmDeCode); | |||||
| // System.out.println("解密阻抗-右手(Ω)=" + body.bhZRightArmDeCode); | |||||
| // System.out.println("解密阻抗-左腳(Ω)=" + body.bhZLeftLegDeCode); | |||||
| // System.out.println("解密阻抗-右腳(Ω)=" + body.bhZRightLegDeCode); | |||||
| eightBodyFatBean.setAdcLeftHand(bhBodyComposition.bhZLeftArmDeCode); | |||||
| eightBodyFatBean.setAdcRightHand(bhBodyComposition.bhZRightArmDeCode); | |||||
| eightBodyFatBean.setAdcLeftFoot(bhBodyComposition.bhZLeftLegDeCode); | |||||
| eightBodyFatBean.setAdcRightFoot(bhBodyComposition.bhZRightLegDeCode); | |||||
| eightBodyFatBean.setAdcLeftBody(bhBodyComposition.bhZLeftBodyDeCode); | |||||
| } else { | |||||
| L.e("getAlgorithmsData: " + bhErrorType.toString()); | |||||
| } | } | ||||
| break; | break; |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | ||||
| public class EightBodyFatBean { | public class EightBodyFatBean { | ||||
| /** | |||||
| * 体重 | |||||
| */ | |||||
| private String weight; //体重, | private String weight; //体重, | ||||
| /** | |||||
| * 身体质量指数 | |||||
| */ | |||||
| private float bmi; //体质指数, | private float bmi; //体质指数, | ||||
| /** | |||||
| * 体脂率 | |||||
| */ | |||||
| private float bfr; //体脂率, | private float bfr; //体脂率, | ||||
| /** | |||||
| * 皮下脂肪率 | |||||
| */ | |||||
| private float sfr; //皮下脂肪率, | private float sfr; //皮下脂肪率, | ||||
| /** | |||||
| * 内脏脂肪率 | |||||
| */ | |||||
| private float uvi; //内脏脂肪率, | private float uvi; //内脏脂肪率, | ||||
| /** | |||||
| * 肌肉率 | |||||
| */ | |||||
| private float rom; //肌肉率, | private float rom; //肌肉率, | ||||
| /** | |||||
| * 基础代谢率 | |||||
| */ | |||||
| private float bmr; //基础代谢率, | private float bmr; //基础代谢率, | ||||
| /** | |||||
| * 骨量 | |||||
| */ | |||||
| private String bm; //骨骼质量, | private String bm; //骨骼质量, | ||||
| /** | |||||
| * 水分 | |||||
| */ | |||||
| private float vwc; //水含量, | private float vwc; //水含量, | ||||
| /** | |||||
| * 身体年龄 | |||||
| */ | |||||
| private int bodyAge; //身体年龄, | private int bodyAge; //身体年龄, | ||||
| /** | |||||
| * 蛋白率 | |||||
| */ | |||||
| private float pp; //蛋白率, | private float pp; //蛋白率, | ||||
| /** | |||||
| * 双脚阻抗 | |||||
| */ | |||||
| private double adcFoot; //双脚阻抗, | private double adcFoot; //双脚阻抗, | ||||
| /** | |||||
| * 双手阻抗 | |||||
| */ | |||||
| private double adcHand;//双手阻抗 | private double adcHand;//双手阻抗 | ||||
| /** | |||||
| * 阻抗左手 | |||||
| */ | |||||
| private double adcLeftHand; //左手阻抗 | private double adcLeftHand; //左手阻抗 | ||||
| /** | |||||
| * 阻抗右手 | |||||
| */ | |||||
| private double adcRightHand; //右手阻抗 | private double adcRightHand; //右手阻抗 | ||||
| /** | |||||
| * 阻抗左脚 | |||||
| */ | |||||
| private double adcLeftFoot; //左脚阻抗 | private double adcLeftFoot; //左脚阻抗 | ||||
| private double adcRightFoot; //右脚阻抗 | |||||
| /** | |||||
| * 阻抗右脚 | |||||
| */ | |||||
| private double adcRightFoot; | |||||
| /** | |||||
| * 阻抗左身体 | |||||
| */ | |||||
| private double adcLeftBody; | private double adcLeftBody; | ||||
| /** | |||||
| * 阻抗右身体 | |||||
| */ | |||||
| private double adcRightBody; | private double adcRightBody; | ||||
| /** | |||||
| * 阻抗右手左脚 | |||||
| */ | |||||
| private double adcRightHandLeftFoot; | private double adcRightHandLeftFoot; | ||||
| /** | |||||
| * 阻抗左手右脚 | |||||
| */ | |||||
| private double adcLeftHandRightFoot; | private double adcLeftHandRightFoot; | ||||
| /** | /** | ||||
| * adc身体 | * adc身体 | ||||
| */ | */ | ||||
| private double adcBody; | private double adcBody; | ||||
| /** | /** | ||||
| * 算术 | |||||
| * 算法ID | |||||
| */ | */ | ||||
| private int arithmetic; | private int arithmetic; | ||||
| /** | /** | ||||
| * 心率 | * 心率 | ||||
| */ | */ | ||||
| private int heartRate; | private int heartRate; | ||||
| /** | |||||
| * 体脂-右上 | |||||
| */ | |||||
| private String fatMassRightTop; //体脂-右上 | private String fatMassRightTop; //体脂-右上 | ||||
| /** | |||||
| * 体脂-右下 | |||||
| */ | |||||
| private String fatMassRightBottom; //体脂-右下 | private String fatMassRightBottom; //体脂-右下 | ||||
| /** | |||||
| * 体脂-左上 | |||||
| */ | |||||
| private String fatMassLeftTop; //体脂-左上 | private String fatMassLeftTop; //体脂-左上 | ||||
| /** | |||||
| * 体脂-左下 | |||||
| */ | |||||
| private String fatMassLeftBottom; //体脂-左下 | private String fatMassLeftBottom; //体脂-左下 | ||||
| /** | |||||
| * 体脂-躯干 | |||||
| */ | |||||
| private String fatMassBody; //体脂-躯干 | private String fatMassBody; //体脂-躯干 | ||||
| /** | |||||
| * 肌肉-右上 | |||||
| */ | |||||
| private String muscleMassRightTop; //肌肉-右上 | private String muscleMassRightTop; //肌肉-右上 | ||||
| /** | |||||
| * 肌肉-右下 | |||||
| */ | |||||
| private String muscleMassRightBottom; //肌肉-右下 | private String muscleMassRightBottom; //肌肉-右下 | ||||
| /** | |||||
| * 肌肉-左上 | |||||
| */ | |||||
| private String muscleMassLeftTop; //肌肉-左上 | private String muscleMassLeftTop; //肌肉-左上 | ||||
| /** | |||||
| * 肌肉-左下 | |||||
| */ | |||||
| private String muscleMassLeftBottom; //肌肉-左下 | private String muscleMassLeftBottom; //肌肉-左下 | ||||
| /** | |||||
| * 肌肉-躯干 | |||||
| */ | |||||
| private String muscleMassBody; //肌肉-躯干 | private String muscleMassBody; //肌肉-躯干 | ||||
| /** | |||||
| * 测试阻抗 | |||||
| */ | |||||
| private String testAdc; | private String testAdc; | ||||
| /** | /** | ||||
| @Override | @Override | ||||
| public String toString() { | public String toString() { | ||||
| return "EightBodyFatBean{" + "weight='" + weight + '\'' + ", bmi=" + bmi + ", bfr=" + bfr + ", sfr=" + sfr + ", uvi=" + uvi + ", rom=" + rom + ", bmr=" + bmr + ", bm='" + bm + '\'' + ", " + | |||||
| "vwc=" + vwc + ", bodyAge=" + bodyAge + ", pp=" + pp + ", adcFoot=" + adcFoot + ", adcHand=" + adcHand + ", adcLeftHand=" + adcLeftHand + ", adcRightHand=" + adcRightHand + ", " + | |||||
| "adcLeftFoot=" + adcLeftFoot + ", adcRightFoot=" + adcRightFoot + ", adcLeftBody=" + adcLeftBody + ", adcRightBody=" + adcRightBody + ", adcRightHandLeftFoot=" + adcRightHandLeftFoot + ", adcLeftHandRightFoot=" + adcLeftHandRightFoot + ", adcBody=" + adcBody + ", arithmetic=" + arithmetic + ", heartRate=" + heartRate + ", fatMassRightTop='" + fatMassRightTop + '\'' + ", fatMassRightBottom='" + fatMassRightBottom + '\'' + ", fatMassLeftTop='" + fatMassLeftTop + '\'' + ", fatMassLeftBottom='" + fatMassLeftBottom + '\'' + ", fatMassBody='" + fatMassBody + '\'' + ", muscleMassRightTop='" + muscleMassRightTop + '\'' + ", muscleMassRightBottom='" + muscleMassRightBottom + '\'' + ", muscleMassLeftTop='" + muscleMassLeftTop + '\'' + ", muscleMassLeftBottom='" + muscleMassLeftBottom + '\'' + ", muscleMassBody='" + muscleMassBody + '\'' + ", testAdc='" + testAdc + '\'' + '}'; | |||||
| return "EightBodyFatBean{" + "体重=" + weight + ", bmi=" + bmi + ", 体脂率=" + bfr + | |||||
| ", 皮下脂肪率=" + sfr + ", 内脏脂肪率=" + uvi + ", 肌肉率=" + rom + ", 基础代谢率=" + bmr + ", 骨量=" + bm + | |||||
| ", 水分=" + vwc + ", 身体年龄=" + bodyAge + ", 蛋白率=" + pp + ", 双脚阻抗=" + adcFoot + | |||||
| ", 双手阻抗=" + adcHand + ", 阻抗左手=" + adcLeftHand + ", 阻抗右手=" + adcRightHand + | |||||
| ", 阻抗左脚=" + adcLeftFoot + ", 阻抗右脚=" + adcRightFoot + ", 阻抗左身体=" + adcLeftBody + | |||||
| ", 阻抗右身体=" + adcRightBody + ", 阻抗右手左脚=" + adcRightHandLeftFoot + | |||||
| ", 阻抗左手右脚=" + adcLeftHandRightFoot + ", 身体阻抗=" + adcBody + | |||||
| ", 算法ID=" + arithmetic + ", 心率=" + heartRate + ", fatMassRightTop=" + fatMassRightTop + | |||||
| ", fatMassRightBottom=" + fatMassRightBottom + ", fatMassLeftTop=" + fatMassLeftTop + | |||||
| ", fatMassLeftBottom=" + fatMassLeftBottom + ", fatMassBody=" + fatMassBody + | |||||
| ", muscleMassRightTop=" + muscleMassRightTop + ", muscleMassRightBottom=" + muscleMassRightBottom + | |||||
| ", muscleMassLeftTop=" + muscleMassLeftTop + ", muscleMassLeftBottom=" + muscleMassLeftBottom | |||||
| + ", muscleMassBody=" + muscleMassBody + ", testAdc=" + testAdc + '}'; | |||||
| } | } | ||||
| } | } |
| import android.net.Uri; | import android.net.Uri; | ||||
| import android.os.Build; | import android.os.Build; | ||||
| import androidx.core.content.FileProvider; | |||||
| import java.io.File; | import java.io.File; | ||||
| import androidx.core.content.FileProvider; | |||||
| /** | /** | ||||
| * 兼容android 7.0以上获取uri异常的工具类 | * 兼容android 7.0以上获取uri异常的工具类 | ||||
| */ | */ |
| package aicare.net.cn.sdk.ailinksdkdemoandroid.utils; | |||||
| import android.content.Context; | |||||
| import android.content.res.AssetManager; | |||||
| import org.json.JSONArray; | |||||
| import org.json.JSONException; | |||||
| import org.json.JSONObject; | |||||
| import java.io.BufferedReader; | |||||
| import java.io.IOException; | |||||
| import java.io.InputStream; | |||||
| import java.io.InputStreamReader; | |||||
| import java.util.HashMap; | |||||
| import java.util.Map; | |||||
| /** | |||||
| * json装载机 | |||||
| * | |||||
| * @author xing | |||||
| * @date 2024/04/29 | |||||
| */ | |||||
| public class JsonLoader { | |||||
| public static JSONObject loadJSONFromAsset(Context context, String fileName) { | |||||
| JSONObject jsonObject = null; | |||||
| AssetManager manager = context.getAssets(); | |||||
| try (InputStream is = manager.open(fileName); | |||||
| BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"))) { | |||||
| StringBuilder sb = new StringBuilder(); | |||||
| String line; | |||||
| while ((line = reader.readLine()) != null) { | |||||
| sb.append(line); | |||||
| } | |||||
| jsonObject = new JSONObject(sb.toString()); | |||||
| } catch (IOException | JSONException e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| return jsonObject; | |||||
| } | |||||
| public static Map<String, String> loadJsonFromAsset(Context context, String fileName) { | |||||
| JSONObject jsonObject = loadJSONFromAsset(context, fileName); | |||||
| Map<String, String> map = new HashMap<>(); | |||||
| try { | |||||
| if (jsonObject != null) { | |||||
| JSONArray dataList = jsonObject.getJSONArray("data"); | |||||
| for (int i = 0; i < dataList.length(); i++) { | |||||
| JSONObject data = dataList.getJSONObject(i); | |||||
| String nameEn = data.getString("name"); | |||||
| String nameZh = nameEn; | |||||
| if (data.has("nameNew")) { | |||||
| nameZh = data.getString("nameNew"); | |||||
| } | |||||
| map.put(nameEn, nameZh); | |||||
| } | |||||
| } | |||||
| } catch (JSONException e) { | |||||
| e.printStackTrace(); | |||||
| } | |||||
| return map; | |||||
| } | |||||
| } |
| } | } | ||||
| } | } | ||||
| public static void iStack(String msg) { | |||||
| if (isLog) { | |||||
| logContent("", msg+"\n"+Log.getStackTraceString(new Throwable()), 0); | |||||
| } | |||||
| } | |||||
| /** | /** | ||||
| * 信息日志 | * 信息日志 | ||||
| */ | */ |
| * @return 16进制String | * @return 16进制String | ||||
| */ | */ | ||||
| public static String getHexString(int number) { | public static String getHexString(int number) { | ||||
| return Integer.toHexString(number); | |||||
| if (number<10) { | |||||
| return "0"+Integer.toHexString(number).toUpperCase(); | |||||
| } | |||||
| return Integer.toHexString(number).toUpperCase(); | |||||
| } | } | ||||
| } | } |
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); | ||||
| return format.format(time)+":\n"; | return format.format(time)+":\n"; | ||||
| } | } | ||||
| public static String getTimeNoNewline(long time){ | |||||
| SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US); | |||||
| return format.format(time); | |||||
| } | |||||
| /** | /** | ||||
| * 返回当前年 | * 返回当前年 | ||||
| */ | */ |
| public static float CToF(float c) { | public static float CToF(float c) { | ||||
| float f = c * 1.8F + 32; | float f = c * 1.8F + 32; | ||||
| return f; | return f; | ||||
| } | |||||
| } | |||||
| public static float CToFOne(float c) { | public static float CToFOne(float c) { | ||||
| float c = (f - 32) / 1.8f; | float c = (f - 32) / 1.8f; | ||||
| return c; | return c; | ||||
| } | } | ||||
| /** | /** | ||||
| * 华氏度转度 | * 华氏度转度 | ||||
| */ | */ | ||||
| //----------转换用---------- | //----------转换用---------- | ||||
| public static String getHoldDecimal(int decimal, int value) { | |||||
| float v = (float) (value / (Math.pow(10,decimal))); | |||||
| return getHoldDecimal(decimal, v); | |||||
| } | |||||
| /** | /** | ||||
| * 保留小数位,不足后面补0 | * 保留小数位,不足后面补0 | ||||
| * | * | ||||
| return df.format(value).replace(",", "."); | return df.format(value).replace(",", "."); | ||||
| } | } | ||||
| String s = String.format(Locale.US, "%."+decimal+"f", value); | |||||
| String s = String.format(Locale.US, "%." + decimal + "f", value); | |||||
| return s; | return s; | ||||
| } | } | ||||
| <vector android:height="24dp" android:tint="#F30606" | |||||
| android:viewportHeight="24" android:viewportWidth="24" | |||||
| android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | |||||
| <path android:fillColor="@android:color/white" android:pathData="M6,19c0,1.1 0.9,2 2,2h8c1.1,0 2,-0.9 2,-2V7H6v12zM19,4h-3.5l-1,-1h-5l-1,1H5v2h14V4z"/> | |||||
| </vector> |
| android:orientation="horizontal"> | android:orientation="horizontal"> | ||||
| <Button | <Button | ||||
| android:id="@+id/btnClear" | |||||
| android:id="@+id/btnClearShakeHands" | |||||
| 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" /> | ||||
| android:id="@+id/etBroadcastTime" | android:id="@+id/etBroadcastTime" | ||||
| android:layout_width="100dp" | android:layout_width="100dp" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:digits="0987654321" /> | |||||
| android:digits="0987654321" | |||||
| android:text="100" | |||||
| /> | |||||
| </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 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_width="match_parent" | ||||
| android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
| android:orientation="vertical"> | |||||
| xmlns:tools="http://schemas.android.com/tools" | |||||
| android:orientation="vertical" | |||||
| tools:context="com.pinwang.ailinkblesdk.modules.ble_nutrition.BleNutritionActivity"> | |||||
| <ScrollView | <ScrollView | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="设置单位" /> | android:text="设置单位" /> | ||||
| <Button | |||||
| android:id="@+id/btnVoice" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="蜂鸣器开关" /> | |||||
| </LinearLayout> | </LinearLayout> | ||||
| <LinearLayout | <LinearLayout | ||||
| </LinearLayout> | </LinearLayout> | ||||
| <LinearLayout | |||||
| android:orientation="horizontal" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnReadHistory" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="读取历史" | |||||
| /> | |||||
| <Button | |||||
| android:id="@+id/btnClearHistory" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="清除历史" | |||||
| /> | |||||
| <Button | |||||
| android:id="@+id/btnSynTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="同步时间" | |||||
| /> | |||||
| </LinearLayout> | |||||
| </LinearLayout> | </LinearLayout> | ||||
| </ScrollView> | </ScrollView> |
| <?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" | |||||
| xmlns:tools="http://schemas.android.com/tools" | |||||
| android:orientation="vertical" | |||||
| tools:context="com.pinwang.ailinkblesdk.modules.ble_nutrition.BleNutritionActivity"> | |||||
| <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> | |||||
| <View | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="1dp" | |||||
| android:background="?android:attr/listDivider" /> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_margin="5dp" | |||||
| android:orientation="horizontal"> | |||||
| <Button | |||||
| android:id="@+id/btn_set_zero" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="去皮指令" /> | |||||
| <Button | |||||
| android:id="@+id/btn_set_unit" | |||||
| 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_marginStart="5dp" | |||||
| android:orientation="horizontal"> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_g" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:checked="true" | |||||
| android:text="g" /> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_ml" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="ml" /> | |||||
| <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_kg" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="kg" /> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_jin" | |||||
| 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_marginStart="5dp" | |||||
| android:orientation="horizontal"> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_milk_ml" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="牛奶ml" /> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_water_ml" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="水ml" /> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_milk_fl_oz" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="牛奶floz" /> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_water_fl_oz" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="水floz" /> | |||||
| <RadioButton | |||||
| android:id="@+id/rb_lb" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="lb" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:orientation="vertical" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnSendApple" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="选择食物:苹果" | |||||
| /> | |||||
| <Button | |||||
| android:id="@+id/btnSendBeef" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="选择食物:牛肉" | |||||
| /> | |||||
| </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> |
| android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
| android:orientation="vertical"> | android:orientation="vertical"> | ||||
| <TextView | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="请先登录,然后获取设备ID,再绑定设备." | |||||
| /> | |||||
| <LinearLayout | <LinearLayout | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:id="@+id/ed_imei" | android:id="@+id/ed_imei" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="866156054199057" /> | |||||
| android:text="" /> | |||||
| </LinearLayout> | </LinearLayout> | ||||
| <EditText | <EditText | ||||
| android:id="@+id/et_cid" | android:id="@+id/et_cid" | ||||
| android:inputType="number" | android:inputType="number" | ||||
| android:text="57" | |||||
| android:text="" | |||||
| android:layout_width="50dp" | android:layout_width="50dp" | ||||
| android:layout_height="wrap_content" /> | android:layout_height="wrap_content" /> | ||||
| <EditText | <EditText | ||||
| android:id="@+id/et_vid" | android:id="@+id/et_vid" | ||||
| android:inputType="number" | android:inputType="number" | ||||
| android:text="44" | |||||
| android:text="" | |||||
| android:layout_width="50dp" | android:layout_width="50dp" | ||||
| android:layout_height="wrap_content" /> | android:layout_height="wrap_content" /> | ||||
| <EditText | <EditText | ||||
| android:id="@+id/et_pid" | android:id="@+id/et_pid" | ||||
| android:inputType="number" | android:inputType="number" | ||||
| android:text="1" | |||||
| android:text="" | |||||
| android:layout_width="50dp" | android:layout_width="50dp" | ||||
| android:layout_height="wrap_content" /> | android:layout_height="wrap_content" /> | ||||
| <?xml version="1.0" encoding="utf-8"?> | |||||
| <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||||
| xmlns:app="http://schemas.android.com/apk/res-auto" | |||||
| 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"> | |||||
| <EditText | |||||
| android:id="@+id/etMac" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:hint="请输入需要连接的设备MAC地址" | |||||
| android:paddingStart="20dp" | |||||
| android:inputType="textCapCharacters" | |||||
| android:digits="0123456789abcdefABCDEF:" | |||||
| android:maxLength="17" | |||||
| android:textSize="14dp" /> | |||||
| <Button | |||||
| android:id="@+id/btnConnect" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="连接" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginStart="10dp" | |||||
| android:layout_marginTop="10dp" | |||||
| android:orientation="horizontal"> | |||||
| <Button | |||||
| android:id="@+id/btnSetTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="设置时间" /> | |||||
| <Button | |||||
| android:id="@+id/btnQueryInfo" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="查询信息" /> | |||||
| <Button | |||||
| android:id="@+id/btnQueryThreshold" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="获取本地存储数据" /> | |||||
| <Button | |||||
| android:id="@+id/btnClearLog" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="清空log" /> | |||||
| </LinearLayout> | |||||
| <androidx.appcompat.widget.LinearLayoutCompat | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="horizontal"> | |||||
| <EditText | |||||
| android:id="@+id/etCheckTime" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:hint="检测间隔时间(分)" | |||||
| android:paddingStart="20dp" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <CheckBox | |||||
| android:id="@+id/cbCheckTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:checked="true" | |||||
| android:text="开启/关闭测量"/> | |||||
| <Button | |||||
| android:id="@+id/btnSetCheckTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="设置检测间隔时间" /> | |||||
| </androidx.appcompat.widget.LinearLayoutCompat> | |||||
| <androidx.appcompat.widget.LinearLayoutCompat | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="horizontal"> | |||||
| <EditText | |||||
| android:id="@+id/etBleName" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="match_parent" | |||||
| android:layout_weight="1" | |||||
| android:hint="蓝牙名称" | |||||
| android:paddingStart="20dp" | |||||
| android:inputType="text" | |||||
| android:textSize="14dp" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetBleName" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="match_parent" | |||||
| android:text="设置检测间隔时间" /> | |||||
| </androidx.appcompat.widget.LinearLayoutCompat> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="心率:低值" /> | |||||
| <EditText | |||||
| android:id="@+id/etHrMin" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="60" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="高值" /> | |||||
| <EditText | |||||
| android:id="@+id/etHrMax" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="120" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginStart="10dp" | |||||
| android:text="血氧:低值" /> | |||||
| <EditText | |||||
| android:id="@+id/etSpo2Min" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="95" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="高值" /> | |||||
| <EditText | |||||
| android:id="@+id/etSpo2Max" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="100" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" | |||||
| android:visibility="gone" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="收缩压:低值" /> | |||||
| <EditText | |||||
| android:id="@+id/etSbpMin" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="90" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="高值" /> | |||||
| <EditText | |||||
| android:id="@+id/etSbpMax" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="140" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginStart="10dp" | |||||
| android:text="舒张压:低值" /> | |||||
| <EditText | |||||
| android:id="@+id/etDbpMin" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="60" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="高值" /> | |||||
| <EditText | |||||
| android:id="@+id/etDbpMax" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="90" | |||||
| android:inputType="number" | |||||
| android:maxLength="3" | |||||
| android:textSize="14dp" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" | |||||
| android:gravity="center_vertical" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="温度:低值" /> | |||||
| <EditText | |||||
| android:id="@+id/etTempMin" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="36.0" | |||||
| android:inputType="numberDecimal" | |||||
| android:maxLength="4" | |||||
| android:textSize="14dp" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="高值" /> | |||||
| <EditText | |||||
| android:id="@+id/etTempMax" | |||||
| android:layout_width="0dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_weight="1" | |||||
| android:gravity="center" | |||||
| android:hint="38.0" | |||||
| android:inputType="numberDecimal" | |||||
| android:maxLength="4" | |||||
| android:textSize="14dp" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetThreshold" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_gravity="center" | |||||
| android:layout_marginStart="10dp" | |||||
| android:layout_marginEnd="10dp" | |||||
| android:text="设置阈值" /> | |||||
| </LinearLayout> | |||||
| <ListView | |||||
| android:id="@+id/log_list" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_marginTop="10dp" /> | |||||
| </LinearLayout> |
| android:id="@+id/et_type" | android:id="@+id/et_type" | ||||
| android:layout_width="200dp" | android:layout_width="200dp" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:hint="透传数据" | |||||
| android:hint="A7 payload数据" | |||||
| android:text="01" | android:text="01" | ||||
| android:digits="0123456789abcdefABCDEF" | android:digits="0123456789abcdefABCDEF" | ||||
| /> | /> | ||||
| android:text="set_unit" | android:text="set_unit" | ||||
| /> | /> | ||||
| <Button | |||||
| android:id="@+id/btnPause" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="暂停" | |||||
| /> | |||||
| <Button | |||||
| android:id="@+id/btnClearShakeHands" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="解除握手加密" | |||||
| /> | |||||
| </LinearLayout> | </LinearLayout> | ||||
| </LinearLayout> | </LinearLayout> | ||||
| </ScrollView> | </ScrollView> |
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="清空" /> | android:text="清空" /> | ||||
| <Button | |||||
| android:id="@+id/btnPause" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="暂停" /> | |||||
| </LinearLayout> | </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"> | |||||
| <RadioGroup | |||||
| android:id="@+id/unit" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:layout_below="@+id/edit_Userid" | |||||
| android:orientation="horizontal"> | |||||
| <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> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="年龄:" /> | |||||
| <EditText | |||||
| android:id="@+id/et_age" | |||||
| android:layout_width="100dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:inputType="number" | |||||
| android:text="34" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="性别(女=0,男=1):" /> | |||||
| <EditText | |||||
| android:id="@+id/et_sex" | |||||
| android:layout_width="100dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:inputType="number" | |||||
| android:text="1" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="身高(CM):" /> | |||||
| <EditText | |||||
| android:id="@+id/et_height" | |||||
| android:layout_width="100dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:inputType="number" | |||||
| android:text="178" /> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="体重(kg):" /> | |||||
| <EditText | |||||
| android:id="@+id/et_weight" | |||||
| android:layout_width="100dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:inputType="number" | |||||
| android:text="78" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:orientation="horizontal" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/support_unit" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="查询支持单位" /> | |||||
| <Button | |||||
| android:id="@+id/btn_clear_log" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="清空log" /> | |||||
| </LinearLayout> | |||||
| <Button | |||||
| android:id="@+id/test_bodyfit" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="计算体脂数据" /> | |||||
| <ListView | |||||
| android:id="@+id/log_list" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="match_parent" | |||||
| android:layout_below="@id/unit" | |||||
| android:layout_marginTop="20dp"> | |||||
| </ListView> | |||||
| </LinearLayout> |
| <?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" | |||||
| 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" | |||||
| android:padding="5dp"> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnGetCurInfo" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="实时信息" /> | |||||
| <Button | |||||
| android:id="@+id/btnSyncTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="同步时间" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnGetCO2Density" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="CO2报警浓度" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetCODensity" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="CO报警浓度" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetO2Density" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="O2报警浓度" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnGetCO2Interval" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="CO2间隔" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetCOInterval" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="CO间隔" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetHistoryInterval" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="历史记录间隔" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnGetCO2Switch" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="CO2开关" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetCOSwitch" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="CO开关" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetSoundSwitch" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="声音开关" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetShakeSwitch" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="震动开关" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnGetTempUnit" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="温度单位" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetPressureUnit" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="气压单位" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetScreenOffTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="息屏时间" /> | |||||
| <Button | |||||
| android:id="@+id/btnGetShutdownTime" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="关机时间" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnGetHistory" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="历史记录" /> | |||||
| <Button | |||||
| android:id="@+id/btnClearHistory" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="清空历史记录" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <EditText | |||||
| android:id="@+id/etDensity" | |||||
| android:layout_width="160dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:hint="报警浓度(单位ppm)" | |||||
| android:inputType="number" | |||||
| android:textSize="14dp" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetCo2Density" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="设置Co2浓度" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetO2Density" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="设置O2浓度" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <EditText | |||||
| android:id="@+id/etInterval" | |||||
| android:layout_width="160dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:hint="间隔(min)0代表一直" | |||||
| android:inputType="number" | |||||
| android:textSize="14dp" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetCo2Interval" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="设置CO2间隔" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetCoInterval" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="设置CO间隔" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <EditText | |||||
| android:id="@+id/etHpa" | |||||
| android:layout_width="120dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:hint="气压(hPa,0-9999)" | |||||
| android:inputType="number" | |||||
| android:textSize="14dp" /> | |||||
| <EditText | |||||
| android:id="@+id/etInHg" | |||||
| android:layout_width="120dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:hint="气压(hPa,0-9999)" | |||||
| android:inputType="number" | |||||
| android:textSize="14dp" /> | |||||
| <Button | |||||
| android:id="@+id/btnSetPressureCali" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:onClick="onClick" | |||||
| android:text="气压校准" /> | |||||
| </LinearLayout> | |||||
| </LinearLayout> | |||||
| </ScrollView> | |||||
| <ListView | |||||
| android:id="@+id/list_view" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="0dp" | |||||
| android:layout_weight="1" | |||||
| /> | |||||
| </androidx.appcompat.widget.LinearLayoutCompat> |
| android:text="回复测量完成" | android:text="回复测量完成" | ||||
| android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
| </LinearLayout> | </LinearLayout> | ||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content"> | |||||
| <Button | |||||
| android:id="@+id/btnPause" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="暂停" | |||||
| /> | |||||
| </LinearLayout> | |||||
| <ListView | <ListView | ||||
| android:id="@+id/listView" | android:id="@+id/listView" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" |
| android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
| android:orientation="vertical"> | android:orientation="vertical"> | ||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:gravity="center" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="搜索:" /> | |||||
| <EditText | |||||
| android:id="@+id/etSearch" | |||||
| android:layout_width="300dp" | |||||
| android:layout_height="50dp" | |||||
| android:hint=" 请输入关键字" /> | |||||
| <ImageView | |||||
| android:id="@+id/ivClear" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:src="@drawable/baseline_delete_24" /> | |||||
| </LinearLayout> | |||||
| <androidx.recyclerview.widget.RecyclerView | <androidx.recyclerview.widget.RecyclerView | ||||
| android:id="@+id/rv_list" | android:id="@+id/rv_list" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" |
| <?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:padding="10dp"> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal"> | |||||
| <Button | |||||
| android:id="@+id/btnClearShakeHands" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="清空" /> | |||||
| <TextView | |||||
| android:id="@+id/tvDeviceList" | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="当前APPID:" /> | |||||
| <EditText | |||||
| android:id="@+id/etAppUserId" | |||||
| android:layout_width="80dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:text="1" /> | |||||
| <Button | |||||
| android:id="@+id/btnConnectMqtt" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="连接MQTT" /> | |||||
| <Button | |||||
| android:id="@+id/btnDisconnectMqtt" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="断开MQTT" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:orientation="horizontal"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="设备ID:" /> | |||||
| <EditText | |||||
| android:id="@+id/etDeviceId" | |||||
| android:layout_width="80dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:hint="请输入设备ID" | |||||
| android:text="1" /> | |||||
| <Button | |||||
| android:id="@+id/btnAddDevice" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="添加设备" /> | |||||
| <Button | |||||
| android:id="@+id/btnRemoveDevice" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="移除设备" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:orientation="horizontal" | |||||
| android:layout_height="wrap_content"> | |||||
| <TextView | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="设备ID:" | |||||
| /> | |||||
| <EditText | |||||
| android:id="@+id/etSendDataDeviceId" | |||||
| android:layout_width="80dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| /> | |||||
| <EditText | |||||
| android:id="@+id/etSendData" | |||||
| android:layout_width="0dp" | |||||
| android:layout_weight="1" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="" | |||||
| android:hint="请输入要发送的数据" | |||||
| android:textSize="12dp" | |||||
| android:digits="0123456789abcdefABCDEF" | |||||
| /> | |||||
| <Button | |||||
| android:id="@+id/btnSendData" | |||||
| 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> |
| android:id="@+id/et_cid" | android:id="@+id/et_cid" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="match_parent" | android:layout_height="match_parent" | ||||
| android:digits="-0123456789" | |||||
| android:hint="CID(decimal)" /> | |||||
| android:digits="-0123456789abcdefABCDEF" | |||||
| android:hint="CID" /> | |||||
| </LinearLayout> | </LinearLayout> |
| android:text="Battery" /> | android:text="Battery" /> | ||||
| <Button | <Button | ||||
| android:id="@+id/btnClear" | |||||
| android:id="@+id/btnClearShakeHands" | |||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="清空" /> | android:text="清空" /> |
| android:id="@+id/et_cmd" | android:id="@+id/et_cmd" | ||||
| android:layout_width="180dp" | android:layout_width="180dp" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:hint="透传数据" | |||||
| android:text="4" /> | |||||
| android:digits="0123456789ABCDEFabcdef" | |||||
| android:hint="16进制数据(hex)" | |||||
| android:text="04" /> | |||||
| <Button | <Button | ||||
| android:id="@+id/btn1" | android:id="@+id/btn1" | ||||
| android:id="@+id/et_time" | android:id="@+id/et_time" | ||||
| android:layout_width="100dp" | android:layout_width="100dp" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:digits="0123456789-" | |||||
| android:hint="发送间隔" | android:hint="发送间隔" | ||||
| android:maxLines="1" | android:maxLines="1" | ||||
| android:digits="0123456789-" | |||||
| android:text="1000" /> | |||||
| android:text="100" /> | |||||
| <Button | <Button | ||||
| android:id="@+id/btn_time" | android:id="@+id/btn_time" | ||||
| </LinearLayout> | </LinearLayout> | ||||
| <LinearLayout | |||||
| android:layout_width="match_parent" | |||||
| android:layout_height="wrap_content" | |||||
| android:paddingStart="10dp" | |||||
| android:paddingEnd="5dp"> | |||||
| <EditText | |||||
| android:id="@+id/etIncrementNumber" | |||||
| android:layout_width="100dp" | |||||
| android:layout_height="wrap_content" | |||||
| android:digits="0123456789" | |||||
| android:hint="递增数" | |||||
| android:maxLines="1" | |||||
| android:text="517" /> | |||||
| <Button | |||||
| android:id="@+id/btnIncrementSend" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="递增发送:N" /> | |||||
| </LinearLayout> | |||||
| <LinearLayout | <LinearLayout | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| <TextView | <TextView | ||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="发送:" | |||||
| android:layout_marginStart="50dp" | android:layout_marginStart="50dp" | ||||
| android:text="发送:" | |||||
| android:textSize="18dp" /> | android:textSize="18dp" /> | ||||
| <TextView | <TextView |
| android:id="@+id/tv_device_info" | android:id="@+id/tv_device_info" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:textColor="@color/colorAccent" | |||||
| /> | /> | ||||
| <LinearLayout | <LinearLayout | ||||
| android:id="@+id/bt_clear" | android:id="@+id/bt_clear" | ||||
| 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/bt_clear_log" | android:id="@+id/bt_clear_log" | ||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:text="清空log" /> | android:text="清空log" /> | ||||
| <Button | |||||
| android:id="@+id/btPause" | |||||
| android:layout_width="wrap_content" | |||||
| android:layout_height="wrap_content" | |||||
| android:text="暂停" /> | |||||
| </LinearLayout> | </LinearLayout> |
| android:layout_marginStart="16dp" | android:layout_marginStart="16dp" | ||||
| android:layout_marginEnd="16dp" | android:layout_marginEnd="16dp" | ||||
| android:layout_marginBottom="10dp" | android:layout_marginBottom="10dp" | ||||
| app:cardBackgroundColor="@color/white" | |||||
| app:cardBackgroundColor="@color/colorPrimary" | |||||
| app:cardCornerRadius="8dp" | app:cardCornerRadius="8dp" | ||||
| android:foreground="?attr/selectableItemBackground" | android:foreground="?attr/selectableItemBackground" | ||||
| app:cardElevation="0dp" | app:cardElevation="0dp" | ||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:gravity="center" | android:gravity="center" | ||||
| android:textColor="@color/black" | |||||
| android:textColor="@color/white" | |||||
| android:textSize="18dp" | android:textSize="18dp" | ||||
| tools:text="item" /> | tools:text="item" /> | ||||
| <resources> | <resources> | ||||
| <string name="app_name" translatable="false">AILink联调工具</string> | |||||
| <string name="app_name" translatable="false">AILinkSDKDemo</string> | |||||
| <string name="clear">Vide</string> | <string name="clear">Vide</string> | ||||
| <string name="handshake">serrer la main</string> | <string name="handshake">serrer la main</string> | ||||
| <string name="check_version">version:</string> | <string name="check_version">version:</string> | ||||
| <string name="upgrade_controller">Contrôleur de mise à niveau</string> | <string name="upgrade_controller">Contrôleur de mise à niveau</string> | ||||
| <string name="upgrade_watch">Mettre à niveau l\'instrument</string> | <string name="upgrade_watch">Mettre à niveau l\'instrument</string> | ||||
| <string name="gas_detector">Détecteur de gaz</string> | |||||
| </resources> | </resources> |
| <string name="connecting_wifi">正在连接wifi...</string> | <string name="connecting_wifi">正在连接wifi...</string> | ||||
| <string name="cancel">取消</string> | <string name="cancel">取消</string> | ||||
| <string name="select_wifi">选择WIFI</string> | <string name="select_wifi">选择WIFI</string> | ||||
| <string name="item_ble_general_settings">Ble通用设置</string> | <string name="item_ble_general_settings">Ble通用设置</string> | ||||
| <string name="item_ble_universal_distribution_network">BLE通用配网</string> | <string name="item_ble_universal_distribution_network">BLE通用配网</string> | ||||
| <string name="item_ble_test">Ble test</string> | <string name="item_ble_test">Ble test</string> | ||||
| <string name="item_ble_connect_test">Ble connect test</string> | <string name="item_ble_connect_test">Ble connect test</string> | ||||
| <string name="item_ota">OTA通用</string> | <string name="item_ota">OTA通用</string> | ||||
| <string name="item_mqtt">MQTT通用</string> | |||||
| <string name="item_penetrate">透传</string> | <string name="item_penetrate">透传</string> | ||||
| <string name="item_body_fat_scale_broadcast">广播秤</string> | <string name="item_body_fat_scale_broadcast">广播秤</string> | ||||
| <string name="item_body_fat_scale_ble">Ble体脂秤</string> | <string name="item_body_fat_scale_ble">Ble体脂秤</string> | ||||
| <string name="item_body_fat_scale_4g">4G体脂秤</string> | <string name="item_body_fat_scale_4g">4G体脂秤</string> | ||||
| <string name="item_body_fat_scale_wifi_ble">WiFi+Ble体脂秤</string> | <string name="item_body_fat_scale_wifi_ble">WiFi+Ble体脂秤</string> | ||||
| <string name="item_body_fat_scale_eight">八极秤</string> | |||||
| <string name="item_body_fat_scale_eight">八极秤(单频)APP</string> | |||||
| <string name="item_body_fat_scale_eight_mcu">八极秤(单频)MCU</string> | |||||
| <string name="item_body_fat_scale_eight_dual_band">八极秤(双频)APP</string> | |||||
| <string name="item_body_fat_scale_eight_dual_band_mcu">八极秤(双频)MCU</string> | |||||
| <string name="item_body_fat_scale_aidi">艾迪体脂秤</string> | <string name="item_body_fat_scale_aidi">艾迪体脂秤</string> | ||||
| <string name="item_baby_scale">婴儿秤</string> | <string name="item_baby_scale">婴儿秤</string> | ||||
| <string name="item_baby_body_fat_scale">婴儿体脂两用秤</string> | <string name="item_baby_body_fat_scale">婴儿体脂两用秤</string> | ||||
| <string name="about_us">关于我们</string> | <string name="about_us">关于我们</string> | ||||
| <string name="share">分享</string> | <string name="share">分享</string> | ||||
| <string name="wifi_ble_ota_tool">WIFI+BLE OTA工具</string> | <string name="wifi_ble_ota_tool">WIFI+BLE OTA工具</string> | ||||
| <string name="item_bw05_watch">BW05手表</string> | |||||
| <string name="gas_detector">气体检测仪</string> | |||||
| </resources> | </resources> |
| <color name="colorAccent">#D81B60</color> | <color name="colorAccent">#D81B60</color> | ||||
| <color name="public_white">#FFFFFF</color> | <color name="public_white">#FFFFFF</color> | ||||
| <color name="public_press_bg">#dcdcdc</color> | <color name="public_press_bg">#dcdcdc</color> | ||||
| <color name="black">#FF000000</color> | |||||
| <color name="white">#FFFFFFFF</color> | |||||
| <color name="black">#000000</color> | |||||
| <color name="white">#FFFFFF</color> | |||||
| </resources> | </resources> |
| <string name="baby_hold">锁定</string> | <string name="baby_hold">锁定</string> | ||||
| <string name="rtk_dfu_progress_state_origin"> ready to upgrade </string> | <string name="rtk_dfu_progress_state_origin"> ready to upgrade </string> | ||||
| <string name="rtk_dfu_state_abort_processing">waiting for cancellation...</string> | <string name="rtk_dfu_state_abort_processing">waiting for cancellation...</string> | ||||
| <string name="rtk_dfu_state_aborted"> has been cancelled</string> | <string name="rtk_dfu_state_aborted"> has been cancelled</string> | ||||
| <string name="upgrade_controller">Upgrade controller</string> | <string name="upgrade_controller">Upgrade controller</string> | ||||
| <string name="upgrade_watch">Upgrade instrument</string> | <string name="upgrade_watch">Upgrade instrument</string> | ||||
| <!-- wifi+ble体脂秤 --> | |||||
| <!-- wifi+ble体脂秤 --> | |||||
| <string name="check_wifi_status">Check wifi status</string> | <string name="check_wifi_status">Check wifi status</string> | ||||
| <string name="search_wifi_hotspots">Search wifi hotspots</string> | <string name="search_wifi_hotspots">Search wifi hotspots</string> | ||||
| <string name="select_wifi_serial_number">Select wifi serial number</string> | <string name="select_wifi_serial_number">Select wifi serial number</string> | ||||
| <string name="item_ble_test">Ble test</string> | <string name="item_ble_test">Ble test</string> | ||||
| <string name="item_ble_connect_test">Ble connect test</string> | <string name="item_ble_connect_test">Ble connect test</string> | ||||
| <string name="item_ota">OTA</string> | <string name="item_ota">OTA</string> | ||||
| <string name="item_mqtt">MQTT</string> | |||||
| <string name="item_penetrate">Penetrate</string> | <string name="item_penetrate">Penetrate</string> | ||||
| <string name="item_body_fat_scale_broadcast">Body fat scale (Broadcast)</string> | <string name="item_body_fat_scale_broadcast">Body fat scale (Broadcast)</string> | ||||
| <string name="item_body_fat_scale_ble">Body fat scale (Ble)</string> | <string name="item_body_fat_scale_ble">Body fat scale (Ble)</string> | ||||
| <string name="item_body_fat_scale_4g">Body fat scale (4G)</string> | <string name="item_body_fat_scale_4g">Body fat scale (4G)</string> | ||||
| <string name="item_body_fat_scale_wifi_ble">Body fat scale (WiFi+Ble)</string> | <string name="item_body_fat_scale_wifi_ble">Body fat scale (WiFi+Ble)</string> | ||||
| <string name="item_body_fat_scale_eight">Eight-electrode body fat scale</string> | |||||
| <string name="item_body_fat_scale_eight">Eight-electrode body fat scale app</string> | |||||
| <string name="item_body_fat_scale_eight_mcu">Eight-electrode body fat scale MCU</string> | |||||
| <string name="item_body_fat_scale_eight_dual_band">Eight-electrode body fat scale(dual band)APP</string> | |||||
| <string name="item_body_fat_scale_eight_dual_band_mcu">Eight-electrode body fat scale(dual band)MCU</string> | |||||
| <string name="item_body_fat_scale_aidi">Body fat scale (Aidi)</string> | <string name="item_body_fat_scale_aidi">Body fat scale (Aidi)</string> | ||||
| <string name="item_baby_scale">Baby scale</string> | <string name="item_baby_scale">Baby scale</string> | ||||
| <string name="item_baby_body_fat_scale">Baby body fat scale</string> | <string name="item_baby_body_fat_scale">Baby body fat scale</string> | ||||
| <string name="item_wifi_config">WIFI config</string> | <string name="item_wifi_config">WIFI config</string> | ||||
| <string name="about_us">About us</string> | <string name="about_us">About us</string> | ||||
| <string name="share">Share</string> | <string name="share">Share</string> | ||||
| <string name="wifi_ble_ota_tool">WIFI+BLE OTA工具</string> | |||||
| <string name="wifi_ble_ota_tool">WIFI+BLE OTA Tools</string> | |||||
| <string name="item_bw05_watch">BW05 WATCH</string> | |||||
| <string name="item_nutritional_scale_ble_nutrient">Bluetooth Nutrition Scale-Nutrients</string> | |||||
| <string name="gas_detector">Gas detector</string> | |||||
| </resources> | </resources> |
| repositories { | repositories { | ||||
| google() | google() | ||||
| mavenCentral() | mavenCentral() | ||||
| jcenter() | |||||
| maven { url 'https://jitpack.io' } | maven { url 'https://jitpack.io' } | ||||
| jcenter() | |||||
| } | } | ||||
| dependencies { | dependencies { | ||||
| classpath 'com.android.tools.build:gradle:7.1.2' | classpath 'com.android.tools.build:gradle:7.1.2' | ||||
| repositories { | repositories { | ||||
| google() | google() | ||||
| mavenCentral() | mavenCentral() | ||||
| jcenter() | |||||
| maven { url 'https://jitpack.io' } | maven { url 'https://jitpack.io' } | ||||
| jcenter() | |||||
| } | } | ||||
| } | } | ||||