You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Flutter Reactive Ble连接iOS设备时遇无效deviceID问题求助

Flutter Reactive Ble iOS连接BLE设备报错:invalid "disconnectFromDevice" method call ("deviceID" is invalid)

我用Flutter Reactive Ble库和iOS设备建立BLE连接,扫描到目标设备后调用连接代码,Android上运行完全正常,但iOS端一连接就触发.listen()的onError回调。

连接代码如下:

void connect(Bike bike, BuildContext context) {
    String connectionId = ""; //foundDeviceId
    if (Platform.isIOS) {
      connectionId = bike.uuid; //On iOS the device ID is a UUID
    } else {
      connectionId = bike.mac; //On Android it is a MAC address
    }
    currentConnectionStream = bluetoothProvider.flutterReactiveBle
        .connectToDevice(
      id: connectionId,
      connectionTimeout: const Duration(seconds: 15),
    )
        .listen(
      (connectionState) {
        switch (connectionState.connectionState) {
          ...
        }
      },
      onError: (error) {
        cancelConnectionStream();
        log("ble_service error: " + (error as PlatformException).message!);
      },
    );
  }

iOS端报错日志:

Unhandled Exception: PlatformException(invalidMethodCall(method: "disconnectFromDevice", details: Optional("\"deviceID\" is invalid")), invalid "disconnectFromDevice" method call ("deviceID" is invalid), null, null)

我已经试过把connectionId硬编码成目标设备UUID的不同格式(大小写、带/不带短横线),但问题依然存在。有没有人遇到过同样的问题?

内容的提问来源于stack exchange,提问作者HCKRMVT

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.20 15:38:24