| applicationId "aicare.net.cn.sdk.ailinksdkdemoandroid" | applicationId "aicare.net.cn.sdk.ailinksdkdemoandroid" | ||||
| minSdkVersion 19 | minSdkVersion 19 | ||||
| targetSdkVersion 33 | targetSdkVersion 33 | ||||
| versionName "1.11.10" | |||||
| versionName "1.11.11" | |||||
| versionCode getVersionCodeNumber(versionName) | versionCode getVersionCodeNumber(versionName) | ||||
| testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||||
| } | } | ||||
| 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.3'//蓝牙核心库 | |||||
| implementation 'com.github.elinkthings:AILinkSDKRepositoryAndroid:1.14.5'//蓝牙核心库 | |||||
| // implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.1.4'//OTA库,需要依赖核心库 | // implementation 'com.github.elinkthings:AILinkSDKOtaLibraryAndroid:1.1.4'//OTA库,需要依赖核心库 | ||||
| implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.9.2'//蓝牙解析库 | |||||
| implementation 'com.github.elinkthings:AILinkSDKParsingLibraryAndroid:1.9.3'//蓝牙解析库 | |||||
| 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' |
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mDevice = ADWeightScaleDeviceData.getInstance(bleDevice); | mDevice = ADWeightScaleDeviceData.getInstance(bleDevice); | ||||
| mDevice.setOnNotifyData(this); | mDevice.setOnNotifyData(this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| mDevice.clear(); | mDevice.clear(); | ||||
| mDevice = null; | mDevice = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| logList.add(0,"绑定服务成功"); | logList.add(0,"绑定服务成功"); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| AilinkScooterBleData.init(bleDevice); | AilinkScooterBleData.init(bleDevice); | ||||
| AilinkScooterBleData.getInstance().setScooterListener(this); | AilinkScooterBleData.getInstance().setScooterListener(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| // BleLog.i(TAG, "服务与界面建立连接成功"); | // BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| BLDBodyFatBleUtilsData.init(bleDevice, this); | BLDBodyFatBleUtilsData.init(bleDevice, this); | ||||
| bodyFatBleUtilsData = BLDBodyFatBleUtilsData.getInstance(); | bodyFatBleUtilsData = BLDBodyFatBleUtilsData.getInstance(); | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| mlogList.add(0, "服务与界面建立断开连接成功"); | mlogList.add(0, "服务与界面建立断开连接成功"); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mDevice = BabyBodyFatDeviceData.getInstance(bleDevice); | mDevice = BabyBodyFatDeviceData.getInstance(bleDevice); | ||||
| mDevice.setOnNotifyData(this); | mDevice.setOnNotifyData(this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| mDevice.clear(); | mDevice.clear(); | ||||
| mDevice = null; | mDevice = null; | ||||
| } | } | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| babyDevice = BabyDeviceData.getInstance(bleDevice); | babyDevice = BabyDeviceData.getInstance(bleDevice); | ||||
| babyDevice.setOnNotifyData(new babyNotifyData()); | babyDevice.setOnNotifyData(new babyNotifyData()); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| addShowData("断开连接"); | addShowData("断开连接"); | ||||
| break; | break; | ||||
| case R.id.btnConnect: | case R.id.btnConnect: | ||||
| mBluetoothService.connectDevice(mAddress); | |||||
| mAILinkBleManager.connectDevice(mAddress); | |||||
| addShowData("连接设备"); | addShowData("连接设备"); | ||||
| break; | break; | ||||
| case R.id.btnClear: | case R.id.btnClear: | ||||
| addShowData("服务与界面建立连接成功"); | addShowData("服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mBluetoothService.deviceConnectListener(mAddress, true); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| mAILinkBleManager.deviceConnectListener(mAddress, true); | |||||
| connectSuccess(); | connectSuccess(); | ||||
| } | } | ||||
| private void connectSuccess() { | private void connectSuccess() { | ||||
| if (mBluetoothService != null) { | |||||
| mBleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (mBleDevice == null) { | if (mBleDevice == null) { | ||||
| BleLog.i(TAG, "mBleDevice==null"); | BleLog.i(TAG, "mBleDevice==null"); | ||||
| } | } | ||||
| }, 3000); | }, 3000); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| CallbackDisIm.getInstance().removeListener(this); | CallbackDisIm.getInstance().removeListener(this); | ||||
| mBluetoothService.disconnectAll(); | |||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mLogList.add(0, "绑定服务成功"); | mLogList.add(0, "绑定服务成功"); | ||||
| listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBloodGlucoseBleDeviceData = new BloodGlucoseBleDeviceData(bleDevice); | mBloodGlucoseBleDeviceData = new BloodGlucoseBleDeviceData(bleDevice); | ||||
| mBloodGlucoseBleDeviceData.setBloodGlucoseCallback(this); | mBloodGlucoseBleDeviceData.setBloodGlucoseCallback(this); |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| loglist.add(0, "连接设备成功"); | loglist.add(0, "连接设备成功"); | ||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| BleBloodOxygenDeviceData.init(bleDevice, this); | BleBloodOxygenDeviceData.init(bleDevice, this); | ||||
| mBleBloodOxygenDeviceData = BleBloodOxygenDeviceData.getInstance(); | mBleBloodOxygenDeviceData = BleBloodOxygenDeviceData.getInstance(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| break; | break; | ||||
| case R.id.open: | case R.id.open: | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.startScan(0, UUID.fromString("0000F0A0-0000-1000-8000-00805F9B34FB")); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.startScan(0, UUID.fromString("0000F0A0-0000-1000-8000-00805F9B34FB")); | |||||
| } | } | ||||
| break; | break; | ||||
| case R.id.stop: | case R.id.stop: | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| } | } | ||||
| break; | break; | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mDevice = BroadcastBloodOxygenDeviceData.getInstance(); | mDevice = BroadcastBloodOxygenDeviceData.getInstance(); | ||||
| mDevice.setOnNotifyData(this); | mDevice.setOnNotifyData(this); | ||||
| mBluetoothService.setOnScanFilterListener(this); | |||||
| mBluetoothService.startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
| mAILinkBleManager.setOnScanFilterListener(this); | |||||
| mAILinkBleManager.startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| 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); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| loglist.add(0, "绑定服务成功"); | loglist.add(0, "绑定服务成功"); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mEightBodyFatBleDeviceData = new EightBodyFatBleDeviceData(bleDevice); | mEightBodyFatBleDeviceData = new EightBodyFatBleDeviceData(bleDevice); | ||||
| mEightBodyFatBleDeviceData.setEightBodyFatCallback(this); | mEightBodyFatBleDeviceData.setEightBodyFatCallback(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = HeightDeviceData.getInstance(bleDevice); | mBleDevice = HeightDeviceData.getInstance(bleDevice); | ||||
| mBleDevice.setOnNotifyData(HeightCmdActivity.this); | mBleDevice.setOnNotifyData(HeightCmdActivity.this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| logList.add(0, "绑定服务成功"); | logList.add(0, "绑定服务成功"); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| HeightBodyFatBleData.init(bleDevice); | HeightBodyFatBleData.init(bleDevice); | ||||
| HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | HeightBodyFatBleData.getInstance().setOnHeightBodyFatDataCallback(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| btn.setOnClickListener(new View.OnClickListener() { | btn.setOnClickListener(new View.OnClickListener() { | ||||
| @Override | @Override | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| if (mBluetoothService != null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| BleLog.i(TAG, "搜索设备"); | BleLog.i(TAG, "搜索设备"); | ||||
| try { | try { | ||||
| String cidStr = et_cid.getText().toString().trim(); | String cidStr = et_cid.getText().toString().trim(); | ||||
| 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)); | ||||
| mBluetoothService.startScan(30 * 1000, list, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||||
| mAILinkBleManager.startScan(30 * 1000, list, BleConfig.UUID_SERVER_AILINK, SkateboardBleConfig.UUID_BROADCAST); | |||||
| } else { | } else { | ||||
| //0000FEE7=手表 | //0000FEE7=手表 | ||||
| mBluetoothService.startScan(30 * 1000, BleConfig.UUID_BROADCAST_AILINK, BleConfig.UUID_SERVER_BROADCAST_AILINK, UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||||
| mAILinkBleManager.startScan(30 * 1000, BleConfig.UUID_BROADCAST_AILINK, BleConfig.UUID_SERVER_BROADCAST_AILINK, UUID.fromString("0000FEE7-0000-1000-8000-00805F9B34FB"), SkateboardBleConfig.UUID_BROADCAST); | |||||
| } | } | ||||
| mBleValueList.clear(); | mBleValueList.clear(); | ||||
| listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
| btn1.setOnClickListener(new View.OnClickListener() { | btn1.setOnClickListener(new View.OnClickListener() { | ||||
| @Override | @Override | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(10000); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(10000); | |||||
| } | } | ||||
| } | } | ||||
| }); | }); | ||||
| clear.setOnClickListener(new View.OnClickListener() { | clear.setOnClickListener(new View.OnClickListener() { | ||||
| @Override | @Override | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| if (mBluetoothService != null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mBleValueList.clear(); | mBleValueList.clear(); | ||||
| listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
| } | } | ||||
| if (mType == BleDeviceConfig.CLEAR_SHAKE_HANDS) { | if (mType == BleDeviceConfig.CLEAR_SHAKE_HANDS) { | ||||
| //验证不握手,不加密的界面使用 | //验证不握手,不加密的界面使用 | ||||
| BleConfig.setHandshakeStatus(mac, false); | BleConfig.setHandshakeStatus(mac, false); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| mBluetoothService.connectDevice(new BleValueBean(mac, mCid, mVid, mPid)); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| mAILinkBleManager.connectDevice(new BleValueBean(mac, mCid, mVid, mPid)); | |||||
| showLoading(); | showLoading(); | ||||
| } | } | ||||
| } else if (BleDeviceConfig.TOOTHBRUSH_WIFI_BLE == mType) { | } else if (BleDeviceConfig.TOOTHBRUSH_WIFI_BLE == mType) { | ||||
| BleConfig.setHandshakeStatus(mac, true, mCid, mVid, mPid); | BleConfig.setHandshakeStatus(mac, true, mCid, mVid, mPid); | ||||
| mNoEncryptionMac = mac; | mNoEncryptionMac = mac; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| mBluetoothService.connectDevice(new BleValueBean(mac, mCid, mVid, mPid)); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| mAILinkBleManager.connectDevice(new BleValueBean(mac, mCid, mVid, mPid)); | |||||
| showLoading(); | showLoading(); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServicesDiscovered(@NonNull String mac) { | public void onServicesDiscovered(@NonNull String mac) { | ||||
| if (mac.equalsIgnoreCase(mNoEncryptionMac)) { | if (mac.equalsIgnoreCase(mNoEncryptionMac)) { | ||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mac); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mac); | |||||
| bleDevice.setA7Encryption(false); | bleDevice.setA7Encryption(false); | ||||
| mNoEncryptionMac = ""; | mNoEncryptionMac = ""; | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(ShowBleActivity.this); | |||||
| mBluetoothService.setOnScanFilterListener(ShowBleActivity.this); | |||||
| mBluetoothService.initForegroundService(1, R.mipmap.ic_launcher, "前台服务", MainActivity.class); | |||||
| mBluetoothService.startForegroundService();//启动前台服务 | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(ShowBleActivity.this); | |||||
| mAILinkBleManager.setOnScanFilterListener(ShowBleActivity.this); | |||||
| mAILinkBleManager.initForegroundService(1, R.mipmap.ic_launcher, "前台服务", MainActivity.class); | |||||
| mAILinkBleManager.startForegroundService();//启动前台服务 | |||||
| mHandler.sendEmptyMessage(BIND_SERVER_OK); | mHandler.sendEmptyMessage(BIND_SERVER_OK); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onResume() { | protected void onResume() { | ||||
| super.onResume(); | super.onResume(); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(ShowBleActivity.this); | |||||
| mBluetoothService.setOnScanFilterListener(ShowBleActivity.this); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(ShowBleActivity.this); | |||||
| mAILinkBleManager.setOnScanFilterListener(ShowBleActivity.this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| } | } | ||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mDevice = SmartMaskDeviceData.getInstance(bleDevice); | mDevice = SmartMaskDeviceData.getInstance(bleDevice); | ||||
| mDevice.setOnNotifyData(this); | mDevice.setOnNotifyData(this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = SphyDeviceData.getInstance(bleDevice); | mBleDevice = SphyDeviceData.getInstance(bleDevice); | ||||
| mBleDevice.setType(mCid); | mBleDevice.setType(mCid); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = TempDeviceData.getInstance(bleDevice); | mBleDevice = TempDeviceData.getInstance(bleDevice); | ||||
| mBleDevice.setOnNotifyData(new NotifyData()); | mBleDevice.setOnNotifyData(new NotifyData()); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = TempGunDeviceData.getInstance(bleDevice); | mBleDevice = TempGunDeviceData.getInstance(bleDevice); | ||||
| mBleDevice.setOnNotifyData(TempGunCmdActivity.this); | mBleDevice.setOnNotifyData(TempGunCmdActivity.this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| logList.add(0, "绑定服务成功"); | logList.add(0, "绑定服务成功"); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mBluetoothService.deviceConnectListener(mAddress, true); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| mAILinkBleManager.deviceConnectListener(mAddress, true); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| TempHumidityBleUtils.init(bleDevice); | TempHumidityBleUtils.init(bleDevice); | ||||
| TempHumidityBleUtils.getInstance().setBleDataCallBack(this); | TempHumidityBleUtils.getInstance().setBleDataCallBack(this); | ||||
| } else { | } else { | ||||
| mBluetoothService.disconnectAll(); | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| startScanBle(0); | startScanBle(0); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| public void onScanning(BleValueBean data) { | public void onScanning(BleValueBean data) { | ||||
| if (data.getMac().equalsIgnoreCase(mAddress)) { | if (data.getMac().equalsIgnoreCase(mAddress)) { | ||||
| stopScanBle(); | stopScanBle(); | ||||
| mBluetoothService.connectDevice(mAddress); | |||||
| mAILinkBleManager.connectDevice(mAddress); | |||||
| } | } | ||||
| if (mac.equalsIgnoreCase(mAddress)) { | if (mac.equalsIgnoreCase(mAddress)) { | ||||
| stopScanBle(); | stopScanBle(); | ||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| TempHumidityBleUtils.init(bleDevice); | TempHumidityBleUtils.init(bleDevice); | ||||
| TempHumidityBleUtils.getInstance().setBleDataCallBack(this); | TempHumidityBleUtils.getInstance().setBleDataCallBack(this); | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| mMHandler.removeMessages(HEART); | mMHandler.removeMessages(HEART); | ||||
| if (mBluetoothService != null) | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| } | } |
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mBleDevice.setOnBleOtherDataListener(this); | mBleDevice.setOnBleOtherDataListener(this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = TpmsDeviceData.getInstance(bleDevice); | mBleDevice = TpmsDeviceData.getInstance(bleDevice); | ||||
| mBleDevice.setOnNotifyData(TpmsConnectCmdActivity.this); | mBleDevice.setOnNotifyData(TpmsConnectCmdActivity.this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| // BleLog.i(TAG, "服务与界面建立连接成功"); | // BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| if (tv_device_info!=null) { | if (tv_device_info!=null) { | ||||
| tv_device_info.setText("MAC:"+bleDevice.getMac()); | tv_device_info.setText("MAC:"+bleDevice.getMac()); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| } | } | ||||
| } | } |
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| // BleLog.i(TAG, "服务与界面建立连接成功"); | // BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| BodyFatBleUtilsData.init(bleDevice, this, null); | |||||
| BodyFatBleUtilsData.init(bleDevice, this); | |||||
| bodyFatBleUtilsData = BodyFatBleUtilsData.getInstance(); | bodyFatBleUtilsData = BodyFatBleUtilsData.getInstance(); | ||||
| if (bodyFatBleUtilsData != null) { | if (bodyFatBleUtilsData != null) { | ||||
| bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().setWeightUnit(weighunit, BleDeviceConfig.WEIGHT_BODY_FAT_SCALE)); | bodyFatBleUtilsData.sendData(BodyFatDataUtil.getInstance().setWeightUnit(weighunit, BleDeviceConfig.WEIGHT_BODY_FAT_SCALE)); | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| mlogList.add(0, "服务与界面建立断开连接成功"); | mlogList.add(0, "服务与界面建立断开连接成功"); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public void onSetIpStatus(int status) { | |||||
| } | |||||
| @Override | |||||
| public void onSetPortStatus(int status) { | |||||
| } | |||||
| @Override | |||||
| public void onSetIpUrlStatus(int status) { | |||||
| } | |||||
| @Override | @Override | ||||
| public void onIpData(String ip) { | public void onIpData(String ip) { |
| private static String TAG = BleBaseActivity.class.getName(); | private static String TAG = BleBaseActivity.class.getName(); | ||||
| protected AILinkBleManager mBluetoothService; | |||||
| protected AILinkBleManager mAILinkBleManager; | |||||
| private Handler mHandler = new Handler(Looper.getMainLooper()); | private Handler mHandler = new Handler(Looper.getMainLooper()); | ||||
| @Override | @Override | ||||
| AILinkBleManager.getInstance().init(this, new AILinkBleManager.onInitListener() { | AILinkBleManager.getInstance().init(this, new AILinkBleManager.onInitListener() { | ||||
| @Override | @Override | ||||
| public void onInitSuccess() { | public void onInitSuccess() { | ||||
| mBluetoothService = AILinkBleManager.getInstance(); | |||||
| mAILinkBleManager = AILinkBleManager.getInstance(); | |||||
| onServiceSuccess(); | onServiceSuccess(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onInitFailure() { | public void onInitFailure() { | ||||
| AILinkBleManager.getInstance().clear(); | AILinkBleManager.getInstance().clear(); | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| onServiceErr(); | onServiceErr(); | ||||
| } | } | ||||
| }); | }); | ||||
| }else { | }else { | ||||
| mHandler.postDelayed(()->{ | mHandler.postDelayed(()->{ | ||||
| mBluetoothService = AILinkBleManager.getInstance(); | |||||
| mAILinkBleManager = AILinkBleManager.getInstance(); | |||||
| onServiceSuccess(); | onServiceSuccess(); | ||||
| },500); | },500); | ||||
| } | } |
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mFindDeviceData = FindDeviceData.getInstance(mBleDevice); | mFindDeviceData = FindDeviceData.getInstance(mBleDevice); | ||||
| mFindDeviceData.setOnNotifyData(this); | mFindDeviceData.setOnNotifyData(this); |
| mFindDeviceAdapter.notifyDataSetChanged(); | mFindDeviceAdapter.notifyDataSetChanged(); | ||||
| } | } | ||||
| mFindDeviceData.getConnectInfoList(); | mFindDeviceData.getConnectInfoList(); | ||||
| mBluetoothService.startScan(30 * 1000); | |||||
| mAILinkBleManager.startScan(30 * 1000); | |||||
| } | } | ||||
| break; | break; | ||||
| mac.deleteCharAt(mac.length() - 1); | mac.deleteCharAt(mac.length() - 1); | ||||
| } | } | ||||
| SP.getInstance().putFindDeviceMacList(mac.toString()); | SP.getInstance().putFindDeviceMacList(mac.toString()); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| // ------------------- 权限 ------------------ | // ------------------- 权限 ------------------ | ||||
| @Override | @Override | ||||
| protected void onPermissionsOk() { | protected void onPermissionsOk() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBluetoothService.setOnScanFilterListener(this); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| mAILinkBleManager.setOnScanFilterListener(this); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mFindDeviceData = FindDeviceData.getInstance(mBleDevice); | mFindDeviceData = FindDeviceData.getInstance(mBleDevice); | ||||
| mFindDeviceData.setOnNotifyData(this); | mFindDeviceData.setOnNotifyData(this); | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| if (mBluetoothService != null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| initPermissions(); | initPermissions(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null){ | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager !=null){ | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| mFindDeviceData = null; | mFindDeviceData = null; | ||||
| mBluetoothService=null; | |||||
| mAILinkBleManager =null; | |||||
| } | } | ||||
| @Override | @Override | ||||
| mMac = bleValueBean.getMac(); | mMac = bleValueBean.getMac(); | ||||
| } else if (bleValueBean.getMac().equalsIgnoreCase(mMac) && mFindDeviceData == null) { | } else if (bleValueBean.getMac().equalsIgnoreCase(mMac) && mFindDeviceData == null) { | ||||
| BleConfig.setHandshakeStatus(mMac, false); | BleConfig.setHandshakeStatus(mMac, false); | ||||
| mBluetoothService.stopScan(); | |||||
| mBluetoothService.connectDevice(mMac); | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mAILinkBleManager.stopScan(); | |||||
| mAILinkBleManager.connectDevice(mMac); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| } else if (bleValueBean.getName() == null || !bleValueBean.getName().trim().toUpperCase().startsWith(BLE_NAME_START.toUpperCase())) { | } else if (bleValueBean.getName() == null || !bleValueBean.getName().trim().toUpperCase().startsWith(BLE_NAME_START.toUpperCase())) { | ||||
| onNearbyDeviceInfo(bleValueBean.getMac(), bleValueBean.getRssi(), bleValueBean.getManufacturerData()); | onNearbyDeviceInfo(bleValueBean.getMac(), bleValueBean.getRssi(), bleValueBean.getManufacturerData()); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServicesDiscovered(String mac) { | public void onServicesDiscovered(String mac) { | ||||
| if (mac.equalsIgnoreCase(mMac)) { | if (mac.equalsIgnoreCase(mMac)) { | ||||
| mBluetoothService.stopScan(); | |||||
| mAILinkBleManager.stopScan(); | |||||
| onServiceSuccess(); | onServiceSuccess(); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void bleOpen() { | public void bleOpen() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| mList.add("正在扫描连接..."); | mList.add("正在扫描连接..."); | ||||
| if (tv_status != null) | if (tv_status != null) | ||||
| tv_status.setText("正在连接..."); | tv_status.setText("正在连接..."); | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| mBluetoothService.startScan(0, BleConfig.UUID_SERVER_AILINK); | |||||
| mAILinkBleManager.startScan(0, BleConfig.UUID_SERVER_AILINK); | |||||
| } | } | ||||
| } | } |
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| mList.add("服务与界面建立连接成功"); | mList.add("服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| mBleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mBleDevice.setOnBleVersionListener(PublicBleNetworkCmdActivity.this); | mBleDevice.setOnBleVersionListener(PublicBleNetworkCmdActivity.this); | ||||
| mBleDevice.setOnMcuParameterListener(PublicBleNetworkCmdActivity.this); | mBleDevice.setOnMcuParameterListener(PublicBleNetworkCmdActivity.this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| mList.add("服务与界面连接断开"); | mList.add("服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void getSelectWifiMac(String mac) { | |||||
| public void onConnectedWifiMac(String mac) { | |||||
| mList.add("获取到设置的wifi的mac地址 " + mac); | mList.add("获取到设置的wifi的mac地址 " + mac); | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void getSelectWifiPaw(String pwd) { | |||||
| public void onConnectedWifiPwd(String pwd) { | |||||
| mList.add("获取到设置的wifi的密码 " + pwd); | mList.add("获取到设置的wifi的密码 " + pwd); | ||||
| mHandler.sendEmptyMessage(REFRESH_DATA); | mHandler.sendEmptyMessage(REFRESH_DATA); | ||||
| } | } |
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = TempInstrumentDeviceData.getInstance(bleDevice); | mBleDevice = TempInstrumentDeviceData.getInstance(bleDevice); | ||||
| mBleDevice.setOnBleVersionListener(TempInstrumentActivity.this); | mBleDevice.setOnBleVersionListener(TempInstrumentActivity.this); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| @Override | @Override |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mAddress = getIntent().getStringExtra("mac"); | mAddress = getIntent().getStringExtra("mac"); | ||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| if (mAirDetectorWifeBleData == null) { | if (mAirDetectorWifeBleData == null) { | ||||
| AirDetectorWifeBleData.init(bleDevice); | AirDetectorWifeBleData.init(bleDevice); | ||||
| mAirDetectorWifeBleData = AirDetectorWifeBleData.getInstance(); | mAirDetectorWifeBleData = AirDetectorWifeBleData.getInstance(); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| if (mAirDetectorWifeBleData != null) { | if (mAirDetectorWifeBleData != null) { | ||||
| mAirDetectorWifeBleData = null; | mAirDetectorWifeBleData = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mAddress = getIntent().getStringExtra("mac"); | mAddress = getIntent().getStringExtra("mac"); | ||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice == null) { | if (bleDevice == null) { | ||||
| finish(); | finish(); | ||||
| return; | return; | ||||
| } | } | ||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| if (mAirDetectorWifeBleData == null) { | if (mAirDetectorWifeBleData == null) { | ||||
| // AirDetectorWifeBleData.init(bleDevice); | // AirDetectorWifeBleData.init(bleDevice); | ||||
| mAirDetectorWifeBleData = AirDetectorWifeBleData.getInstance(); | mAirDetectorWifeBleData = AirDetectorWifeBleData.getInstance(); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| Log.i(TAG, "unbindServices"); | Log.i(TAG, "unbindServices"); | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mBleNutritionData = new BleNutritionData(mBleDevice); | mBleNutritionData = new BleNutritionData(mBleDevice); | ||||
| mBleNutritionData.setBleNutritionCallback(this); | mBleNutritionData.setBleNutritionCallback(this); |
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mLogList.add(0, "绑定服务成功"); | mLogList.add(0, "绑定服务成功"); | ||||
| listAdapter.notifyDataSetChanged(); | listAdapter.notifyDataSetChanged(); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBloodGlucoseBleDeviceData = new BloodGlucoseBleDeviceData(bleDevice); | mBloodGlucoseBleDeviceData = new BloodGlucoseBleDeviceData(bleDevice); | ||||
| mBloodGlucoseBleDeviceData.setBloodGlucoseCallback(this); | mBloodGlucoseBleDeviceData.setBloodGlucoseCallback(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mBleDevice = new BloodGlucoseBleDeviceData(bleDevice); | mBleDevice = new BloodGlucoseBleDeviceData(bleDevice); | ||||
| mBleDevice.setBloodGlucoseCallback(this); | mBleDevice.setBloodGlucoseCallback(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mTransmissionDeviceData = new TransmissionDeviceData(mBleDevice); | mTransmissionDeviceData = new TransmissionDeviceData(mBleDevice); | ||||
| mTransmissionDeviceData.setMyBleCallback(this); | mTransmissionDeviceData.setMyBleCallback(this); |
| } | } | ||||
| // 权限都有了,OK | // 权限都有了,OK | ||||
| addText("权限都有,开始接收广播数据"); | addText("权限都有,开始接收广播数据"); | ||||
| if (mBluetoothService != null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mBroadCastHeightDeviceData = BroadCastHeightDeviceData.getInstance(); | mBroadCastHeightDeviceData = BroadCastHeightDeviceData.getInstance(); | ||||
| mBroadCastHeightDeviceData.setOnNotifyHeightData(this); | mBroadCastHeightDeviceData.setOnNotifyHeightData(this); | ||||
| mBluetoothService.setOnScanFilterListener(this); | |||||
| mBluetoothService.startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
| mAILinkBleManager.setOnScanFilterListener(this); | |||||
| mAILinkBleManager.startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
| } | } | ||||
| } | } | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| int id = v.getId(); | int id = v.getId(); | ||||
| if (id == R.id.btn_start) { | if (id == R.id.btn_start) { | ||||
| mBluetoothService.startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
| mAILinkBleManager.startScan(0, BleConfig.UUID_SERVER_BROADCAST_AILINK); | |||||
| } else if (id == R.id.btn_stop) { | } else if (id == R.id.btn_stop) { | ||||
| mBluetoothService.stopScan(); | |||||
| mAILinkBleManager.stopScan(); | |||||
| } else if (id == R.id.btn_clear) { | } else if (id == R.id.btn_clear) { | ||||
| clearText(); | clearText(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBluetoothService.setOnScanFilterListener(this); | |||||
| mAILinkBleManager.setOnScanFilterListener(this); | |||||
| } | } | ||||
| @Override | @Override |
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mCoffeeScaleData = new CoffeeScaleData(mBleDevice); | mCoffeeScaleData = new CoffeeScaleData(mBleDevice); | ||||
| mCoffeeScaleData.setCoffeeScaleCallback(this); | mCoffeeScaleData.setCoffeeScaleCallback(this); |
| mFasciaGunData.setFasciaGunCallback(null); | mFasciaGunData.setFasciaGunCallback(null); | ||||
| mFasciaGunData = null; | mFasciaGunData = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mFasciaGunData = new FasciaGunData(mBleDevice); | mFasciaGunData = new FasciaGunData(mBleDevice); | ||||
| mFasciaGunData.setFasciaGunCallback(this); | mFasciaGunData.setFasciaGunCallback(this); |
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mFoodTempData = new FoodTempData(mBleDevice); | mFoodTempData = new FoodTempData(mBleDevice); | ||||
| mFoodTempData.setFoodTempCallback(this); | mFoodTempData.setFoodTempCallback(this); |
| public void onClick(View v) { | public void onClick(View v) { | ||||
| int id = v.getId(); | int id = v.getId(); | ||||
| if (id == R.id.btn_start) { | if (id == R.id.btn_start) { | ||||
| mBluetoothService.startScan(0); | |||||
| mAILinkBleManager.startScan(0); | |||||
| } else if (id == R.id.btn_stop) { | } else if (id == R.id.btn_stop) { | ||||
| mBluetoothService.stopScan(); | |||||
| mAILinkBleManager.stopScan(); | |||||
| } else if (id == R.id.btn_clear) { | } else if (id == R.id.btn_clear) { | ||||
| clearText(); | clearText(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBluetoothService.setOnScanFilterListener(this); | |||||
| mAILinkBleManager.setOnScanFilterListener(this); | |||||
| } | } | ||||
| @Override | @Override |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| MeatProbeBleData.init(bleDevice); | MeatProbeBleData.init(bleDevice); | ||||
| mMeatProbeBleData = MeatProbeBleData.getInstance(); | mMeatProbeBleData = MeatProbeBleData.getInstance(); | ||||
| mMeatProbeBleData.addOnMeatProbeDataListener(this); | mMeatProbeBleData.addOnMeatProbeDataListener(this); | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| public void onServicesDiscovered(String mac) { | public void onServicesDiscovered(String mac) { | ||||
| //连接成功 | //连接成功 | ||||
| Log.e("ljl", "onServicesDiscovered: mac is " + mac); | Log.e("ljl", "onServicesDiscovered: mac is " + mac); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| MeatProbeBleData.init(bleDevice); | MeatProbeBleData.init(bleDevice); | ||||
| mMeatProbeBleData = MeatProbeBleData.getInstance(); | mMeatProbeBleData = MeatProbeBleData.getInstance(); | ||||
| mMeatProbeBleData.addOnMeatProbeDataListener(this); | mMeatProbeBleData.addOnMeatProbeDataListener(this); | ||||
| public void onClick(View v) { | public void onClick(View v) { | ||||
| switch (v.getId()) { | switch (v.getId()) { | ||||
| case R.id.btn_meat_probe_connect: | case R.id.btn_meat_probe_connect: | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.connectDevice(mMac); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.connectDevice(mMac); | |||||
| } | } | ||||
| break; | break; | ||||
| case R.id.btn_meat_probe_disconnect: | case R.id.btn_meat_probe_disconnect: | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnect(mMac); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnect(mMac); | |||||
| } | } | ||||
| break; | break; | ||||
| case R.id.btn_meat_probe_version: | case R.id.btn_meat_probe_version: | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnect(mMac); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnect(mMac); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| if (mMeatProbeChargerBleDevice == null) { | if (mMeatProbeChargerBleDevice == null) { | ||||
| Log.e("ljl", "onServiceSuccess: 绑定设备,设置监听"); | Log.e("ljl", "onServiceSuccess: 绑定设备,设置监听"); | ||||
| if (mMeatProbeChargerBleDevice != null) { | if (mMeatProbeChargerBleDevice != null) { | ||||
| mMeatProbeChargerBleDevice = null; | mMeatProbeChargerBleDevice = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| Log.e("ljl", "onServiceSuccess: 服务打开成功"); | Log.e("ljl", "onServiceSuccess: 服务打开成功"); | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| if (mNoiseMeterBle == null) { | if (mNoiseMeterBle == null) { | ||||
| Log.e("ljl", "NoiseMeterBleDevice绑定设备"); | Log.e("ljl", "NoiseMeterBleDevice绑定设备"); |
| if (mNoiseMeterBle != null) { | if (mNoiseMeterBle != null) { | ||||
| mNoiseMeterBle = null; | mNoiseMeterBle = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| if (mNoiseMeterBle == null) { | if (mNoiseMeterBle == null) { | ||||
| NoiseMeterWifiBleDevice.init(mBleDevice); | NoiseMeterWifiBleDevice.init(mBleDevice); |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| logList.add("绑定服务成功"); | logList.add("绑定服务成功"); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| RopeSkippingBleData.init(bleDevice); | RopeSkippingBleData.init(bleDevice); | ||||
| RopeSkippingBleData.getInstance().setOnRopeSkipCallBack(this); | RopeSkippingBleData.getInstance().setOnRopeSkipCallBack(this); | ||||
| if (mArrayAdapter != null && logList != null) { | if (mArrayAdapter != null && logList != null) { | ||||
| refreshLog("解除绑定服务"); | refreshLog("解除绑定服务"); | ||||
| } | } | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void finish() { | public void finish() { | ||||
| super.finish(); | super.finish(); | ||||
| if (mBluetoothService != null){ | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null){ | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| } | } | ||||
| } | } |
| case 1: | case 1: | ||||
| refreshLog("正在设置下一个..."); | refreshLog("正在设置下一个..."); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.startScan(0, BleConfig.UUID_BROADCAST_AILINK); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.startScan(0, BleConfig.UUID_BROADCAST_AILINK); | |||||
| } | } | ||||
| break; | break; | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| refreshLog("绑定服务成功"); | refreshLog("绑定服务成功"); | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| } | } | ||||
| if (mArrayAdapter != null && logList != null) { | if (mArrayAdapter != null && logList != null) { | ||||
| refreshLog("解除绑定服务"); | refreshLog("解除绑定服务"); | ||||
| } | } | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| et_set_mode.setEnabled(false); | et_set_mode.setEnabled(false); | ||||
| et_rssi.setEnabled(false); | et_rssi.setEnabled(false); | ||||
| mSetMode = true; | mSetMode = true; | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.startScan(0, BleConfig.UUID_BROADCAST_AILINK); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.startScan(0, BleConfig.UUID_BROADCAST_AILINK); | |||||
| } | } | ||||
| } else if (v.getId() == R.id.btn_start_read) { | } else if (v.getId() == R.id.btn_start_read) { | ||||
| //开始读取 | //开始读取 | ||||
| et_set_mode.setEnabled(true); | et_set_mode.setEnabled(true); | ||||
| et_rssi.setEnabled(true); | et_rssi.setEnabled(true); | ||||
| refreshLog("停止设置"); | refreshLog("停止设置"); | ||||
| mBluetoothService.stopScan(); | |||||
| mBluetoothService.disconnectAll(); | |||||
| mAILinkBleManager.stopScan(); | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onScanning(BleValueBean data) { | public void onScanning(BleValueBean data) { | ||||
| if (!mSet.contains(data.getMac()) && data.getCid() == 0x002F && Math.abs(mRssi) > Math.abs(data.getRssi())) { | if (!mSet.contains(data.getMac()) && data.getCid() == 0x002F && Math.abs(mRssi) > Math.abs(data.getRssi())) { | ||||
| mBluetoothService.stopScan(); | |||||
| mBluetoothService.connectDevice(data.getMac()); | |||||
| mAILinkBleManager.stopScan(); | |||||
| mAILinkBleManager.connectDevice(data.getMac()); | |||||
| refreshLog("正在连接:" + data.getMac()); | refreshLog("正在连接:" + data.getMac()); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServicesDiscovered(String mac) { | public void onServicesDiscovered(String mac) { | ||||
| if (mBluetoothService != null) { | |||||
| if (mAILinkBleManager != null) { | |||||
| mSet.add(mac); | mSet.add(mac); | ||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mac); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mac); | |||||
| bleDevice.setOnBleDeviceDataListener(this); | bleDevice.setOnBleDeviceDataListener(this); | ||||
| if (mSetMode) { | if (mSetMode) { | ||||
| setMode(bleDevice); | setMode(bleDevice); | ||||
| break; | break; | ||||
| } | } | ||||
| if (mBluetoothService!=null){ | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager !=null){ | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void finish() { | public void finish() { | ||||
| super.finish(); | super.finish(); | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| } | } |
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mShareChargerData = new ShareChargerData(mBleDevice); | mShareChargerData = new ShareChargerData(mBleDevice); | ||||
| mShareChargerData.setShareChargerCallback(this); | mShareChargerData.setShareChargerCallback(this); |
| mHandler.removeCallbacksAndMessages(null); | mHandler.removeCallbacksAndMessages(null); | ||||
| mHandler = null; | mHandler = null; | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mShareCondomData = new ShareCondomData(mBleDevice); | mShareCondomData = new ShareCondomData(mBleDevice); | ||||
| mShareCondomData.setShareCondomCallback(this); | mShareCondomData.setShareCondomCallback(this); |
| case MSG_TEST_START_SCAN: | case MSG_TEST_START_SCAN: | ||||
| // 开始扫描设备 | // 开始扫描设备 | ||||
| addText("准备重连,开始扫描设备:" + mMac); | addText("准备重连,开始扫描设备:" + mMac); | ||||
| mBluetoothService.startScan(0); | |||||
| mAILinkBleManager.startScan(0); | |||||
| break; | break; | ||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| protected void onDestroy() { | protected void onDestroy() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mBluetoothService.setOnScanFilterListener(this); | |||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| mAILinkBleManager.setOnScanFilterListener(this); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mShareSocketData = new ShareSocketData(mBleDevice); | mShareSocketData = new ShareSocketData(mBleDevice); | ||||
| mShareSocketData.setShareSocketCallback(this); | mShareSocketData.setShareSocketCallback(this); | ||||
| @Override | @Override | ||||
| public void onScanning(BleValueBean data) { | public void onScanning(BleValueBean data) { | ||||
| // 扫描到了设备 | // 扫描到了设备 | ||||
| if (mIsTest && !mBluetoothService.isConnectStatus()) { | |||||
| if (mIsTest && !mAILinkBleManager.isConnectStatus()) { | |||||
| // 开始连接设备 | // 开始连接设备 | ||||
| addText("扫描到设备,开始连接"); | addText("扫描到设备,开始连接"); | ||||
| mBluetoothService.connectDevice(mMac); | |||||
| mAILinkBleManager.connectDevice(mMac); | |||||
| // 停止扫描 | // 停止扫描 | ||||
| mBluetoothService.stopScan(); | |||||
| mAILinkBleManager.stopScan(); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService!=null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| if (mAILinkBleManager !=null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| } | } | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServicesDiscovered(String mac) { | public void onServicesDiscovered(String mac) { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mIsTest && mBleDevice != null) { | if (mIsTest && mBleDevice != null) { | ||||
| mTestConnectSuccessCount++; | mTestConnectSuccessCount++; | ||||
| addText("连接成功:" + mMac + ",查询剩余充电时间"); | addText("连接成功:" + mMac + ",查询剩余充电时间"); |
| mList.add(0, "服务与界面建立连接成功"); | mList.add(0, "服务与界面建立连接成功"); | ||||
| // mList.add(0, "搜索设备"); | // mList.add(0, "搜索设备"); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| mBluetoothService.startScan(30 * 1000); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| mAILinkBleManager.startScan(30 * 1000); | |||||
| } | } | ||||
| @Override | @Override | ||||
| public void unbindServices() { | public void unbindServices() { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.removeOnCallbackBle(this); | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.removeOnCallbackBle(this); | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| } | } | ||||
| public void onScanning(BleValueBean data) { | public void onScanning(BleValueBean data) { | ||||
| BleLog.i(TAG, "MAC=" + mAddress + "||CID=" + data.getCid() + "||VID=" + data.getVid() + "||PID=" + data.getPid()); | BleLog.i(TAG, "MAC=" + mAddress + "||CID=" + data.getCid() + "||VID=" + data.getVid() + "||PID=" + data.getPid()); | ||||
| if (data.getMac().equalsIgnoreCase(mAddress)) { | if (data.getMac().equalsIgnoreCase(mAddress)) { | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.stopScan(); | |||||
| mBluetoothService.connectDevice(data.getMac()); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.stopScan(); | |||||
| mAILinkBleManager.connectDevice(data.getMac()); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| public void onServicesDiscovered(String mac) { | public void onServicesDiscovered(String mac) { | ||||
| mList.add(0, "蓝牙已连接"); | mList.add(0, "蓝牙已连接"); | ||||
| mMHandler.sendEmptyMessage(ToRefreUi); | mMHandler.sendEmptyMessage(ToRefreUi); | ||||
| mBluetoothService.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| mAILinkBleManager.setOnCallbackBle(this); | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| ToothBrushWiFiBleUtilsData.init(bleDevice, this, this); | ToothBrushWiFiBleUtilsData.init(bleDevice, this, this); | ||||
| mToothBrushWiFiBleUtilsData = ToothBrushWiFiBleUtilsData.getInstance(); | mToothBrushWiFiBleUtilsData = ToothBrushWiFiBleUtilsData.getInstance(); |
| mHandler.removeCallbacksAndMessages(null); | mHandler.removeCallbacksAndMessages(null); | ||||
| mHandler = null; | mHandler = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } | ||||
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| mToothbrushTestData = new ToothbrushTestData(mBleDevice); | mToothbrushTestData = new ToothbrushTestData(mBleDevice); | ||||
| mToothbrushTestData.setBleToothbrushCallback(this); | mToothbrushTestData.setBleToothbrushCallback(this); |
| @Override | @Override | ||||
| public void onServiceSuccess() { | public void onServiceSuccess() { | ||||
| mBleDevice = mBluetoothService.getBleDevice(mMac); | |||||
| mBleDevice = mAILinkBleManager.getBleDevice(mMac); | |||||
| if (mBleDevice != null) { | if (mBleDevice != null) { | ||||
| if (mWeightScaleDevice == null) { | if (mWeightScaleDevice == null) { | ||||
| WeightScaleDevice.init(mBleDevice); | WeightScaleDevice.init(mBleDevice); | ||||
| if (mWeightScaleDevice != null) { | if (mWeightScaleDevice != null) { | ||||
| mWeightScaleDevice = null; | mWeightScaleDevice = null; | ||||
| } | } | ||||
| if (mBluetoothService != null) { | |||||
| mBluetoothService.disconnectAll(); | |||||
| if (mAILinkBleManager != null) { | |||||
| mAILinkBleManager.disconnectAll(); | |||||
| } | } | ||||
| super.onDestroy(); | super.onDestroy(); | ||||
| } | } |
| CallbackDisIm.getInstance().addListListener(this); | CallbackDisIm.getInstance().addListListener(this); | ||||
| BleLog.i(TAG, "服务与界面建立连接成功"); | BleLog.i(TAG, "服务与界面建立连接成功"); | ||||
| //与服务建立连接 | //与服务建立连接 | ||||
| if (mBluetoothService != null) { | |||||
| BleDevice bleDevice = mBluetoothService.getBleDevice(mAddress); | |||||
| if (mAILinkBleManager != null) { | |||||
| BleDevice bleDevice = mAILinkBleManager.getBleDevice(mAddress); | |||||
| if (bleDevice != null) { | if (bleDevice != null) { | ||||
| mSphyWifiBleDeviceData = SphyWifiBleDeviceData.getInstance(bleDevice); | mSphyWifiBleDeviceData = SphyWifiBleDeviceData.getInstance(bleDevice); | ||||
| mWifiBleDeviceData = mSphyWifiBleDeviceData.getWifiBleDeviceData(); | mWifiBleDeviceData = mSphyWifiBleDeviceData.getWifiBleDeviceData(); | ||||
| public void onServiceErr() { | public void onServiceErr() { | ||||
| BleLog.i(TAG, "服务与界面连接断开"); | BleLog.i(TAG, "服务与界面连接断开"); | ||||
| //与服务断开连接 | //与服务断开连接 | ||||
| mBluetoothService = null; | |||||
| mAILinkBleManager = null; | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| @Override | |||||
| public void onConnectWifiPwd(String pwd) { | |||||
| } | |||||
| @Override | @Override | ||||
| public void onWifiScanBean(WifiBleInfoBean wifiBleInfoBean) { | public void onWifiScanBean(WifiBleInfoBean wifiBleInfoBean) { | ||||
| L.i("扫描到的wifi信息:" + wifiBleInfoBean.toString()); | L.i("扫描到的wifi信息:" + wifiBleInfoBean.toString()); |
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:layout_marginStart="12dp" | android:layout_marginStart="12dp" | ||||
| android:layout_weight="1" | android:layout_weight="1" | ||||
| android:text="@string/search_wifi_hotspots" | |||||
| android:text="@string/distribution_network" | |||||
| android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
| <EditText | <EditText | ||||
| android:layout_marginEnd="10dp" | android:layout_marginEnd="10dp" | ||||
| android:layout_weight="1" | android:layout_weight="1" | ||||
| android:hint="@string/select_wifi_serial_number" | android:hint="@string/select_wifi_serial_number" | ||||
| android:visibility="gone" | |||||
| android:inputType="number" | android:inputType="number" | ||||
| android:textSize="14dp" /> | android:textSize="14dp" /> | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:layout_marginStart="13dp" | android:layout_marginStart="13dp" | ||||
| android:text="@string/initiate_connection" | android:text="@string/initiate_connection" | ||||
| android:visibility="gone" | |||||
| android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
| <Button | <Button | ||||
| android:text="8092" /> | android:text="8092" /> | ||||
| <EditText | <EditText | ||||
| android:id="@+id/et_url" | |||||
| android:id="@+id/et_path" | |||||
| android:layout_width="match_parent" | android:layout_width="match_parent" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:layout_marginStart="10dp" | android:layout_marginStart="10dp" | ||||
| android:orientation="horizontal"> | android:orientation="horizontal"> | ||||
| <Button | <Button | ||||
| android:id="@+id/check_url" | |||||
| android:id="@+id/check_path" | |||||
| android:layout_width="wrap_content" | android:layout_width="wrap_content" | ||||
| android:layout_height="wrap_content" | android:layout_height="wrap_content" | ||||
| android:layout_marginStart="9dp" | android:layout_marginStart="9dp" | ||||
| android:layout_marginTop="5dp" | android:layout_marginTop="5dp" | ||||
| android:text="@string/view_url" | |||||
| android:text="@string/view_path" | |||||
| android:textAllCaps="false" /> | android:textAllCaps="false" /> | ||||
| </LinearLayout> | </LinearLayout> |
| <string name="switch_environment">切换环境</string> | <string name="switch_environment">切换环境</string> | ||||
| <string name="view_ip">查看ip</string> | <string name="view_ip">查看ip</string> | ||||
| <string name="view_port">查看端口</string> | <string name="view_port">查看端口</string> | ||||
| <string name="view_url">查看url</string> | |||||
| <string name="view_path">查看地址</string> | |||||
| <string name="select_document">选择文件:</string> | <string name="select_document">选择文件:</string> | ||||
| <string name="real_time">实时</string> | <string name="real_time">实时</string> | ||||
| <string name="stable">稳定</string> | <string name="stable">稳定</string> | ||||
| <string name="set_environment_url_success">设置环境url成功</string> | <string name="set_environment_url_success">设置环境url成功</string> | ||||
| <string name="set_environment_url_failure">设置环境url失败</string> | <string name="set_environment_url_failure">设置环境url失败</string> | ||||
| <string name="password_format_err">密码格式不对</string> | <string name="password_format_err">密码格式不对</string> | ||||
| <string name="set_environment_ip">设置环境IP:</string> | |||||
| <string name="set_environment">设置环境:</string> | |||||
| <string name="view_environment_ip">查看环境ip</string> | <string name="view_environment_ip">查看环境ip</string> | ||||
| <string name="view_environment_port">查看环境端口</string> | <string name="view_environment_port">查看环境端口</string> | ||||
| <string name="view_environment_url">查看环境url</string> | |||||
| <string name="view_environment_path">查看环境地址</string> | |||||
| <string name="distribution_network">配网</string> | |||||
| <string name="connecting_wifi">正在连接wifi...</string> | |||||
| <string name="cancel">取消</string> | |||||
| <string name="select_wifi">选择WIFI</string> | |||||
| </resources> | </resources> |
| <string name="switch_environment">Switch environment</string> | <string name="switch_environment">Switch environment</string> | ||||
| <string name="view_ip">View IP</string> | <string name="view_ip">View IP</string> | ||||
| <string name="view_port">View port</string> | <string name="view_port">View port</string> | ||||
| <string name="view_url">View url</string> | |||||
| <string name="view_path">View Path</string> | |||||
| <string name="select_document">Select a document:</string> | <string name="select_document">Select a document:</string> | ||||
| <string name="real_time">Real-time data</string> | <string name="real_time">Real-time data</string> | ||||
| <string name="stable">Stable data</string> | <string name="stable">Stable data</string> | ||||
| <string name="set_environment_url_success">Set environment url successfully</string> | <string name="set_environment_url_success">Set environment url successfully</string> | ||||
| <string name="set_environment_url_failure">Failed to set environment url</string> | <string name="set_environment_url_failure">Failed to set environment url</string> | ||||
| <string name="password_format_err">Password format is wrong</string> | <string name="password_format_err">Password format is wrong</string> | ||||
| <string name="set_environment_ip">Set environment IP:</string> | |||||
| <string name="set_environment">Set environment IP:</string> | |||||
| <string name="view_environment_ip">View environment ip</string> | <string name="view_environment_ip">View environment ip</string> | ||||
| <string name="view_environment_port">View environment port</string> | <string name="view_environment_port">View environment port</string> | ||||
| <string name="view_environment_url">View environment url</string> | |||||
| <string name="view_environment_path">View environment path</string> | |||||
| <string name="distribution_network">Distribution network</string> | |||||
| <string name="connecting_wifi">Connecting to wifi...</string> | |||||
| <string name="cancel">Cancel</string> | |||||
| <string name="select_wifi">Select WIFI</string> | |||||
| </resources> | </resources> |