setNotify method

Future<bool> setNotify(
  1. String serviceUuid,
  2. String characteristicUuid,
  3. bool isEnable
)

设置对应的notify特征值的通知 返回true代表设置成功,false代表设置失败

Implementation

Future<bool> setNotify(
    String serviceUuid, String characteristicUuid, bool isEnable) async {
  bool result = false;
  if (_state != DeviceState.destroyed && _state == DeviceState.connected) {
    //已连接才能去设置notify的通知
    await FlutterBlueElves.instance._channel.invokeMethod('setNotify', {
      "id": _id,
      "serviceUuid": serviceUuid,
      "characteristicUuid": characteristicUuid,
      "isEnable": isEnable
    }).then((value) => result = value); //去设置notify
  }
  return result;
}