Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

characteristic.monitor().listen error while writeCharacteristic WithoutResponse as. my device is Notifiable #608

Open
philos3 opened this issue Aug 6, 2021 · 1 comment

Comments

@philos3
Copy link

philos3 commented Aug 6, 2021

characteristic.monitor().listen throw an exception

my device is writewithoutresponse and is notifible
──────────────────────────────────────────────────────────
flutter: dataCharacteristic:
flutter: uuid: XXXXXXXXXXX(as example)
flutter: isReadable: false
flutter: isWritableWithoutResponse: true
flutter: isWritableWithResponse: false
flutter: isIndicatable: false
flutter: isNotifiable: true
──────────────────────────────────────────────────────────

as i set true to peripheral.writeCharacteristic( , , , true, ), there is no error on Android but ios got an error while writeCharacteristic
if i set false to peripheral.writeCharacteristic( , , , false, ), both android and ios got an error while monitor
what is the correct way to monitor and writeCharacteristic?

here is the error message
#####################

Unhandled error happened: Connection error has occured: - subscription called from:

characteristic.monitor().listen onError =====error:BleError (Error code: 201, ATT error code: null, iOS error code: null, Android error code: null, reason: Unknown error., internal message: null, device ID: CECAF6DD-73C5-B04C-EDE0-20B401AEF08B, service UUID: null, characteristic UUID: null, descriptor UUID: null)

here is my code
########################################
streamSubscription = characteristic.monitor().listen((readValue) {
///....
},onError: (error) {
LogUtil.e("characteristic.monitor().listen onError =====error:${error.toString()}===============================",tag: getClassName());
catchCharacteristicError(error, null);
} );

peripheral
.writeCharacteristic(
YsBleUuids.uuidService,
YsBleUuids.clientCharacteristicWithNotifyAndWrite,
Uint8List.fromList(value),
false,///while my dataCharacteristic. isWritableWithoutResponse: true. so withResponse is false
// transactionId:transactionId
)

########################################
(base) philos:flutter_beauty zby0520$ flutter doctor -v
[✓] Flutter (Channel stable, 2.2.3, on macOS 11.3 20E232 darwin-x64, locale zh-Hans-CN)
• Flutter version 2.2.3 at /Users/zby0520/flutter/flutter
• Framework revision f4abaa0735 (5 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/zby0520/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_SDK_ROOT = /Users/zby0520/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)

[✓] IntelliJ IDEA Ultimate Edition (version 2020.1.3)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart

[✓] Connected device (2 available)
• XXXXX (mobile) • XXXXXX• ios • iOS 14.4
• Chrome (web) • chrome • web-javascript • Google Chrome 91.0.4472.114

• No issues found!

@sh3rlock97
Copy link

sh3rlock97 commented Sep 15, 2021

Hi

Were you able to fix your error? I'm also getting a 201-Error when listening to a Characteristic:

if (characteristic.isNotifiable) {
   print("Notifiable: ${characteristic.uuid}");
   characteristic.monitor().listen(
       (event) {
         print("listend and heared ${event}");
       },
       onError: (e) => print("Error monitoring disconnect $e"),
       onDone: () {
         print("Disconnect!");
         peripheral.disconnectOrCancelConnection();
       },
       cancelOnError: true);
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants