wjc
2026-03-20 0efa4dfdfad5647abb73d38deb3e8ab5f444e5cb
app/src/main/java/com/hdl/photovoltaic/utils/BleWifiConfiguratorUtils.java
@@ -325,8 +325,9 @@
        if (bluetoothGatt != null) {
            bluetoothGatt.disconnect();  // 先断开连接
            bluetoothGatt.close();
            bluetoothGatt = null;
//            bluetoothGatt.close();
//            bluetoothGatt = null;
            Log.d(TAG, "Connecting to 先断开旧蓝牙连接");
        }
        BluetoothDevice device = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(deviceAddress);
        // 自动连接 = false,避免系统缓存连接
@@ -369,9 +370,14 @@
                gatt.discoverServices();
            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                isConnected = false;
                if (bluetoothGatt != null) {
                    bluetoothGatt.close();
                    bluetoothGatt = null;
                }
                if (connectListener != null) {
                    callbackHandler.post(() -> connectListener.onDisconnected());
                }
                Log.d(TAG, "Connected to GATT server, onDisconnected");
            }//
        }
@@ -458,6 +464,7 @@
                }
            }
        }
        @Override
        public void onMtuChanged(BluetoothGatt gatt, int mtu, int status) {
            //todo 后面兼用mtc分包的,目前默认设置512字节