wjc
2026-03-20 905f88c976c27c8d30e14871e916be62b1c46efe
app/src/main/java/com/hdl/photovoltaic/utils/BleWifiConfiguratorUtils.java
@@ -372,6 +372,7 @@
                if (connectListener != null) {
                    callbackHandler.post(() -> connectListener.onDisconnected());
                }
                Log.d(TAG, "Connected to GATT server, onDisconnected");
            }//
        }
@@ -520,7 +521,7 @@
                // 第 4 步:写入描述符到设备
                //↑ 只有写入成功后,告诉设备端,设备才会开始发送通知,
                bluetoothGatt.writeDescriptor(descriptor);
                Log.e(TAG, "writeDescriptor success");
                Log.d(TAG, "writeDescriptor success");
            }
        }
    }
@@ -542,7 +543,7 @@
     */
    @RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
    public void writeCredentials(String data, WriteListener listener) {
        Log.e(TAG, "writeCredentials :准备写入");
        Log.d(TAG, "writeCredentials :准备写入");
        this.writeListener = listener;
        if (!isConnected || characteristic == null) {
            if (listener != null) {
@@ -556,7 +557,7 @@
    @RequiresPermission(Manifest.permission.BLUETOOTH_CONNECT)
    private void writeCharacteristic(BluetoothGattCharacteristic characteristic, String value) {
        Log.e(TAG, "writeCharacteristic :开始写入");
        Log.d(TAG, "writeCharacteristic :开始写入");
        if (!this.getMissingPermissions().isEmpty()) {
            callbackHandler.post(() -> this.writeListener.onWriteFailed(-2)); // 没有权限
            return;
@@ -564,7 +565,7 @@
        characteristic.setValue(value.getBytes(StandardCharsets.UTF_8));
        characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT);
        bluetoothGatt.writeCharacteristic(characteristic);
        Log.e(TAG, "writeCharacteristic :开始完成");
        Log.d(TAG, "writeCharacteristic :开始完成");
    }
    // ==================== 工具方法 ====================