wjc
2026-03-24 c4ae4589c6c001329ebb731589b209e8ddcbf7ca
app/src/main/java/com/hdl/photovoltaic/utils/BleWifiConfiguratorUtils.java
@@ -325,8 +325,8 @@
        if (bluetoothGatt != null) {
            bluetoothGatt.disconnect();  // 先断开连接
//            bluetoothGatt.close();
//            bluetoothGatt = null;
            bluetoothGatt.close();
            bluetoothGatt = null;
            Log.d(TAG, "Connecting to 先断开旧蓝牙连接");
        }
        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(deviceAddress);
@@ -370,10 +370,10 @@
                gatt.discoverServices();
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                isConnected = false;
                if (bluetoothGatt != null) {
                    bluetoothGatt.close();
                    bluetoothGatt = null;
                }
//                if (bluetoothGatt != null) {
//                    bluetoothGatt.close();
//                    bluetoothGatt = null;
//                }
                if (connectListener != null) {
                    callbackHandler.post(() -> connectListener.onDisconnected());
                }
@@ -429,7 +429,7 @@
                }
                return;
            }
            Log.e(TAG, "onCharacteristicWrite: 写入成功回复");
            Log.d(TAG, "onCharacteristicWrite: 写入成功回复");
            if (characteristic.getUuid().equals(charUuid)) {
                //写入成功
                if (writeListener != null) {
@@ -441,7 +441,7 @@
        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
            Log.e(TAG, "onCharacteristicChanged: " + characteristic.getUuid());
            Log.d(TAG, "onCharacteristicChanged: " + characteristic.getUuid());
            //收到蓝牙回复的数
            if (characteristic.getUuid().equals(notifyCharUuid) && writeListener != null) {
                byte[] value = characteristic.getValue();