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

(iOS) Not able to discover GATT Characteristics #36

Closed
IvanTorres21 opened this issue Jan 12, 2024 · 7 comments · Fixed by #37 or #38
Closed

(iOS) Not able to discover GATT Characteristics #36

IvanTorres21 opened this issue Jan 12, 2024 · 7 comments · Fixed by #37 or #38
Assignees
Labels
bug Something isn't working

Comments

@IvanTorres21
Copy link

Hi!

I've compiled the example project (Version 5.0.0), it works on Android and Windows, but when compiling for iOS it never discovers the services and GATT characteristics.

Steps to reproduce:

  1. Download the example project
  2. Run flutter pub get
  3. Run flutter run
  4. Scan devices
  5. Connect to device

And the Services list will never get values.

@yanshouwang
Copy link
Owner

yanshouwang commented Jan 12, 2024

I tested on macOS(My apple developer account was unregistered so I can't test on my iPhone device right now) and connect the Gatt server on my Android device, can't reproduce this issue, but iOS and macOS use the same code, can you run the GattServer on a Android device and test again to see if this issue still exists? and provide the log messages on the console will be helpful.
截屏2024-01-12 23 36 46

======= Edit
I found some unexpected logs caused by the incorrect copy on write, will fix this later. But this should not block the GATT discovery.

@yanshouwang yanshouwang self-assigned this Jan 12, 2024
@yanshouwang yanshouwang added the question Further information is requested label Jan 12, 2024
@yanshouwang
Copy link
Owner

Tested on iPhone but can't reproduce this issue.

@yanshouwang yanshouwang linked a pull request Jan 15, 2024 that will close this issue
@IvanTorres21
Copy link
Author

Sorry for the delay, I didn't have access to the project during the weekend.

Here is the iPhone log.

App crached.

PlatformException(illegalArgument, MyError, Stacktrace: ["0   bluetooth_low_energy_darwin         0x00000001051b2f0c $s27bluetooth_low_energy_darwin9wrapError33_67DD5082666B3ED7A98ED592AD08C18CLLySayypSgGypF + 1300", "1   bluetooth_low_energy_darwin         0x00000001051bc8ac $s27bluetooth_low_energy_darwin28MyCentralManagerHostApiSetupC5setUp15binaryMessenger3apiySo013FlutterBinaryN0_p_AA0efghI0_pSgtFZyypSg_yAJctcfU8_ys6ResultOySayAA0E18GattDescriptorArgsVGs5Error_pGcfU_ + 384", "2   bluetooth_low_energy_darwin         0x00000001051d3ae4 $s27bluetooth_low_energy_darwin16MyCentralManagerC19discoverDescriptors8uuidArgs08hashCodeK010completionySS_s5Int64Vys6ResultOySayAA0e14GattDescriptorK0VGs5Error_pGctF + 1020", "3   bluetooth_low_energy_darwin         0x00000001051e0588 $s27bluetooth_low_energy_darwin16MyCentralManagerCAA0efG7HostApiA2aDP19discoverDescriptors8uuidArgs08hashCodeM010completionySS_s5Int64Vys6ResultOySayAA0e14GattDescriptorM0VGs5Error_pGctFTW + 28", "4   bluetooth_low_energy_darwin         0x00000001051bc704 $s27bluetooth_low_energy_darwin28MyCentralManagerHostApiSetupC5setUp15binaryMessenger3apiySo013FlutterBinaryN0_p_AA0efghI0_pSgtFZyypSg_yAJctcfU8_ + 1240", "5   bluetooth_low_energy_darwin         0x00000001051b9ed4 $sypSgAAIegn_Iegng_yXlSgABIeyBy_IeyByy_TR + 236", "6   Flutter                             0x0000000108547914 __48-[FlutterBasicMessageChannel setMessageHandler:]_block_invoke + 160", "7   Flutter                             0x0000000107fa1644 ___ZN7flutter25PlatformMessageHandlerIos21HandlePlatformMessageENSt21_LIBCPP_ABI_NAMESPACE10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE_block_invoke + 116", "8   libdispatch.dylib                   0x00000001c86207a8 30AB7A30-04BC-3C9C-AE24-8DE17D9D2AF2 + 407464", "9   libdispatch.dylib                   0x00000001c8621780 30AB7A30-04BC-3C9C-AE24-8DE17D9D2AF2 + 411520", "10  libdispatch.dylib                   0x00000001c85cdbdc 30AB7A30-04BC-3C9C-AE24-8DE17D9D2AF2 + 68572", "11  libdispatch.dylib                   0x00000001c85cd82c 30AB7A30-04BC-3C9C-AE24-8DE17D9D2AF2 + 67628", "12  CoreFoundation                      0x00000001c19059ac 06CFD2AC-08FA-3879-8894-C29869F8CD97 + 596396", "13  CoreFoundation                      0x00000001c18e9648 06CFD2AC-08FA-3879-8894-C29869F8CD97 + 480840", "14  CoreFoundation                      0x00000001c18edd20 CFRunLoopRunSpecific + 584", "15  GraphicsServices                    0x00000001f8478998 GSEventRunModal + 160", "16  UIKitCore                           0x00000001c3b7f80c 11874256-4FD7-3E33-8914-E04D909E9387 + 3610636", "17  UIKitCore                           0x00000001c3b7f484 UIApplicationMain + 312", "18  Runner                              0x0000000104f7459c main + 64", "19  dyld                                0x00000001df098344 9808DB40-10F3-3EC8-8E14-3A370A6619E7 + 82756"], null)

#0      MyCentralManagerHostApi.discoverDescriptors (package:bluetooth_low_energy_darwin/src/my_api.g.dart:548:7)
<asynchronous suspension>
#1      MyCentralManager.discoverGATT.<anonymous closure> (package:bluetooth_low_energy_darwin/src/my_central_manager.dart:127:19)
<asynchronous suspension>
#2      MyCentralManager.discoverGATT (package:bluetooth_low_energy_darwin/src/my_central_manager.dart:125:33)
<asynchronous suspension>
#3      _PeripheralViewState.buildAppBar.<anonymous closure>.<anonymous closure> (package:bluetooth_low_energy_example/main.dart:489:23)
<asynchronous suspension>

The app is still open and I can move between the scan and connect menu without problem, but the services won't show (though the logs kind of look like it was able to read some?)

Also opened the Android version to show you that it's not a problem with the device here is screenshot.

Screenshot_20240115_113909

@yanshouwang
Copy link
Owner

yanshouwang commented Jan 15, 2024

@IvanTorres21 Can you provide the pubspec.yaml and pubspec.lock of the example in your project? I guess this may be a wrong dependency problem.

@yanshouwang yanshouwang reopened this Jan 15, 2024
@IvanTorres21
Copy link
Author

Here they are.

Pubseck.yaml

name: bluetooth_low_energy_example
description: Demonstrates how to use the bluetooth_low_energy plugin.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
​
environment:
  sdk: '>=3.0.0 <4.0.0'
​
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
  flutter:
    sdk: flutter
​
  bluetooth_low_energy: ^5.0.1
​
  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  convert: ^3.1.1
  intl: ^0.19.0
​
dev_dependencies:
  integration_test:
    sdk: flutter
  flutter_test:
    sdk: flutter
​
  # The "flutter_lints" package below contains a set of recommended lints to
  # encourage good coding practices. The lint set provided by the package is
  # activated in the `analysis_options.yaml` file located at the root of your
  # package. See that file for information about deactivating specific lint
  # rules and activating additional ones.
  flutter_lints: ^3.0.0
​
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
​
# The following section is specific to Flutter packages.
flutter:
​
  # The following line ensures that the Material Icons font is
  # included with your application, so that you can use the icons in
  # the material Icons class.
  uses-material-design: true
​
  # To add assets to your application, add an assets section, like this:
  # assets:
  #   - images/a_dot_burr.jpeg
  #   - images/a_dot_ham.jpeg
​
  # An image asset can refer to one or more resolution-specific "variants", see
  # https://flutter.dev/assets-and-images/#resolution-aware
​
  # For details regarding adding assets from package dependencies, see
  # https://flutter.dev/assets-and-images/#from-packages
​
  # To add custom fonts to your application, add a fonts section here,
  # in this "flutter" section. Each entry in this list should have a
  # "family" key with the font family name, and a "fonts" key with a
  # list giving the asset and other descriptors for the font. For
  # example:
  # fonts:
  #   - family: Schyler
  #     fonts:
  #       - asset: fonts/Schyler-Regular.ttf
  #       - asset: fonts/Schyler-Italic.ttf
  #         style: italic
  #   - family: Trajan Pro
  #     fonts:
  #       - asset: fonts/TrajanPro.ttf
  #       - asset: fonts/TrajanPro_Bold.ttf
  #         weight: 700
  #
  # For details regarding fonts from package dependencies,
  # see https://flutter.dev/custom-fonts/#from-packages

Pubseck.lock

# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  args:
    dependency: transitive
    description:
      name: args
      sha256: eef6c46b622e0494a36c5a12d10d77fb4e855501a91c1b9ef9339326e58f0596
      url: "https://pub.dev"
    source: hosted
    version: "2.4.2"
  async:
    dependency: transitive
    description:
      name: async
      sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
      url: "https://pub.dev"
    source: hosted
    version: "2.11.0"
  bluetooth_low_energy:
    dependency: "direct main"
    description:
      name: bluetooth_low_energy
      sha256: "144b644bca609131226166777e99e9012c62e81ed20544e1b4bab47049f1c285"
      url: "https://pub.dev"
    source: hosted
    version: "5.0.1"
  bluetooth_low_energy_android:
    dependency: transitive
    description:
      name: bluetooth_low_energy_android
      sha256: "502382b2bc6d0bf9e7aa635bafa28057cb8538d6f2dd9c2eceb6d0111bcee94a"
      url: "https://pub.dev"
    source: hosted
    version: "5.0.0"
  bluetooth_low_energy_darwin:
    dependency: transitive
    description:
      name: bluetooth_low_energy_darwin
      sha256: "8cbb1a9ac97a217f6f45dca58510df457e8b70f861c36d3bf8cf2640c669e1cd"
      url: "https://pub.dev"
    source: hosted
    version: "5.0.1"
  bluetooth_low_energy_linux:
    dependency: transitive
    description:
      name: bluetooth_low_energy_linux
      sha256: "100dc824a9b409442e7018994de74d56d65faa95b8c6fbbf5a8c0ae70cd58286"
      url: "https://pub.dev"
    source: hosted
    version: "5.0.0"
  bluetooth_low_energy_platform_interface:
    dependency: transitive
    description:
      name: bluetooth_low_energy_platform_interface
      sha256: "54f92ab2d7746fb6f2b4a40a48cd7eb8e3bf772f3ee89e1979d4d7b741fb2a05"
      url: "https://pub.dev"
    source: hosted
    version: "5.0.0"
  bluetooth_low_energy_windows:
    dependency: transitive
    description:
      name: bluetooth_low_energy_windows
      sha256: "1a4382a1c3d480a35b4de5b7065b00e739cf44129108006c2a3ed8f3ca99fd3d"
      url: "https://pub.dev"
    source: hosted
    version: "5.0.0"
  bluez:
    dependency: transitive
    description:
      name: bluez
      sha256: bfd004c81e3de0f06dce8580bc39a4600e4a6efe465a866b31d4d954c9f356aa
      url: "https://pub.dev"
    source: hosted
    version: "0.8.1"
  boolean_selector:
    dependency: transitive
    description:
      name: boolean_selector
      sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.1"
  characters:
    dependency: transitive
    description:
      name: characters
      sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
      url: "https://pub.dev"
    source: hosted
    version: "1.3.0"
  clock:
    dependency: transitive
    description:
      name: clock
      sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
      url: "https://pub.dev"
    source: hosted
    version: "1.1.1"
  collection:
    dependency: transitive
    description:
      name: collection
      sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
      url: "https://pub.dev"
    source: hosted
    version: "1.18.0"
  convert:
    dependency: "direct main"
    description:
      name: convert
      sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
      url: "https://pub.dev"
    source: hosted
    version: "3.1.1"
  cupertino_icons:
    dependency: "direct main"
    description:
      name: cupertino_icons
      sha256: d57953e10f9f8327ce64a508a355f0b1ec902193f66288e8cb5070e7c47eeb2d
      url: "https://pub.dev"
    source: hosted
    version: "1.0.6"
  dbus:
    dependency: transitive
    description:
      name: dbus
      sha256: "365c771ac3b0e58845f39ec6deebc76e3276aa9922b0cc60840712094d9047ac"
      url: "https://pub.dev"
    source: hosted
    version: "0.7.10"
  fake_async:
    dependency: transitive
    description:
      name: fake_async
      sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
      url: "https://pub.dev"
    source: hosted
    version: "1.3.1"
  ffi:
    dependency: transitive
    description:
      name: ffi
      sha256: "7bf0adc28a23d395f19f3f1eb21dd7cfd1dd9f8e1c50051c069122e6853bc878"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.0"
  file:
    dependency: transitive
    description:
      name: file
      sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
      url: "https://pub.dev"
    source: hosted
    version: "6.1.4"
  flutter:
    dependency: "direct main"
    description: flutter
    source: sdk
    version: "0.0.0"
  flutter_driver:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.0"
  flutter_lints:
    dependency: "direct dev"
    description:
      name: flutter_lints
      sha256: e2a421b7e59244faef694ba7b30562e489c2b489866e505074eb005cd7060db7
      url: "https://pub.dev"
    source: hosted
    version: "3.0.1"
  flutter_test:
    dependency: "direct dev"
    description: flutter
    source: sdk
    version: "0.0.0"
  fuchsia_remote_debug_protocol:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.0"
  integration_test:
    dependency: "direct dev"
    description: flutter
    source: sdk
    version: "0.0.0"
  intl:
    dependency: "direct main"
    description:
      name: intl
      sha256: d6f56758b7d3014a48af9701c085700aac781a92a87a62b1333b46d8879661cf
      url: "https://pub.dev"
    source: hosted
    version: "0.19.0"
  lints:
    dependency: transitive
    description:
      name: lints
      sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
      url: "https://pub.dev"
    source: hosted
    version: "3.0.0"
  log_service:
    dependency: transitive
    description:
      name: log_service
      sha256: "21124936899e227d1779268077921d46d57456e2592d1562e455be273594e2e4"
      url: "https://pub.dev"
    source: hosted
    version: "1.0.0"
  logging:
    dependency: transitive
    description:
      name: logging
      sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  matcher:
    dependency: transitive
    description:
      name: matcher
      sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e"
      url: "https://pub.dev"
    source: hosted
    version: "0.12.16"
  material_color_utilities:
    dependency: transitive
    description:
      name: material_color_utilities
      sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
      url: "https://pub.dev"
    source: hosted
    version: "0.5.0"
  meta:
    dependency: transitive
    description:
      name: meta
      sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
      url: "https://pub.dev"
    source: hosted
    version: "1.10.0"
  path:
    dependency: transitive
    description:
      name: path
      sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
      url: "https://pub.dev"
    source: hosted
    version: "1.8.3"
  petitparser:
    dependency: transitive
    description:
      name: petitparser
      sha256: c15605cd28af66339f8eb6fbe0e541bfe2d1b72d5825efc6598f3e0a31b9ad27
      url: "https://pub.dev"
    source: hosted
    version: "6.0.2"
  platform:
    dependency: transitive
    description:
      name: platform
      sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
      url: "https://pub.dev"
    source: hosted
    version: "3.1.2"
  plugin_platform_interface:
    dependency: transitive
    description:
      name: plugin_platform_interface
      sha256: f4f88d4a900933e7267e2b353594774fc0d07fb072b47eedcd5b54e1ea3269f8
      url: "https://pub.dev"
    source: hosted
    version: "2.1.7"
  process:
    dependency: transitive
    description:
      name: process
      sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
      url: "https://pub.dev"
    source: hosted
    version: "4.2.4"
  sky_engine:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.99"
  source_span:
    dependency: transitive
    description:
      name: source_span
      sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
      url: "https://pub.dev"
    source: hosted
    version: "1.10.0"
  stack_trace:
    dependency: transitive
    description:
      name: stack_trace
      sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
      url: "https://pub.dev"
    source: hosted
    version: "1.11.1"
  stream_channel:
    dependency: transitive
    description:
      name: stream_channel
      sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
      url: "https://pub.dev"
    source: hosted
    version: "2.1.2"
  string_scanner:
    dependency: transitive
    description:
      name: string_scanner
      sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  sync_http:
    dependency: transitive
    description:
      name: sync_http
      sha256: "7f0cd72eca000d2e026bcd6f990b81d0ca06022ef4e32fb257b30d3d1014a961"
      url: "https://pub.dev"
    source: hosted
    version: "0.3.1"
  term_glyph:
    dependency: transitive
    description:
      name: term_glyph
      sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
      url: "https://pub.dev"
    source: hosted
    version: "1.2.1"
  test_api:
    dependency: transitive
    description:
      name: test_api
      sha256: "5c2f730018264d276c20e4f1503fd1308dfbbae39ec8ee63c5236311ac06954b"
      url: "https://pub.dev"
    source: hosted
    version: "0.6.1"
  typed_data:
    dependency: transitive
    description:
      name: typed_data
      sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
      url: "https://pub.dev"
    source: hosted
    version: "1.3.2"
  vector_math:
    dependency: transitive
    description:
      name: vector_math
      sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.4"
  vm_service:
    dependency: transitive
    description:
      name: vm_service
      sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
      url: "https://pub.dev"
    source: hosted
    version: "11.10.0"
  web:
    dependency: transitive
    description:
      name: web
      sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
      url: "https://pub.dev"
    source: hosted
    version: "0.3.0"
  webdriver:
    dependency: transitive
    description:
      name: webdriver
      sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
      url: "https://pub.dev"
    source: hosted
    version: "3.0.2"
  xml:
    dependency: transitive
    description:
      name: xml
      sha256: b015a8ad1c488f66851d762d3090a21c600e479dc75e68328c52774040cf9226
      url: "https://pub.dev"
    source: hosted
    version: "6.5.0"
sdks:
  dart: ">=3.2.0 <4.0.0"
  flutter: ">=3.3.0"

@yanshouwang
Copy link
Owner

The pubspec is right, but I think I have known the reason of this issue, wait a moment, I will fix this right now, thanks for this feedback.

@yanshouwang yanshouwang added bug Something isn't working and removed question Further information is requested labels Jan 16, 2024
@yanshouwang yanshouwang linked a pull request Jan 16, 2024 that will close this issue
@yanshouwang
Copy link
Owner

@IvanTorres21 Pull the latest code and try again, this issue should be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants