deokgyuhan / flutter_ble_peripheral_central

MIT License
9 stars 8 forks source link

Different UUIDs #1

Open marcotrumpet opened 1 year ago

marcotrumpet commented 1 year ago

Hay, thanks for this package, it helped me a lot to understand a little bit better the peripheral/central suff. One question, is there any reason why uuids for services and characteristics are in native and not parameters from Flutter?

deokgyuhan commented 1 year ago

Hi, marcotrumpet . The initial goal of this project was to create a Flutter plugin to enable data exchange between apps cross-platform. During the development of this plugin, I also worked on flutter_nfc_hce concurrently. In the initial version, I hard-coded the UUIDs for services and characteristics in the native code and deployed it.

However, for future updates, I plan to allow passing UUIDs for services and characteristics as parameters in Flutter functions. While working on both plugin projects and studying BLE and NFC HCE, I realized that I initially hardcoded these values for deployment.

I appreciate your interest in my project, and I plan to proceed with the updates soon. When the updates are complete and published on pub.dev, I will inform you through comments on the issue tracker.

Thank you once again for your interest in my project, and I wish you the best of luck.

marcotrumpet commented 1 year ago

Thanks for the quick reply.. While playing around with your package I fixed an issue with advertising on ios but I'm still not able to connect to the peripheral.. if you want I can do a PR if I can solve it

deokgyuhan commented 1 year ago

Thank you, marcotrumpet. I just found out that you are the developer behind the flutter_security and flutter_mapbox_navigation plugins. I'm really grateful for sharing these great plugins. I've been using flutter_mapbox_navigation in my app for the past month, and I want to express my thanks once again.

Also, I appreciate your help with the issues in the flutter_ble_central_peripheral plugin. It's truly an honor for me.

In fact, I've been working with Flutter for about 6 months now, and I have a different profession outside of development. Coding is my hobby, and I've been coding in Java for about 10 years before starting to develop apps with Flutter. It's been around 3 months since I started publishing plugins on pub.dev, and I'm not very familiar with GitHub and Pull Requests. A few weeks ago, there was a Pull Request for flutter_nfc_hce, and I applied the changes you made to my source code because I wasn't familiar with the process.

But this time, I want to try creating a Pull Request after reading GitHub documentation and collaborate with you, marcotrumpet, on coding. It's a great honor and joy for me to be able to collaborate in coding with a current software engineer. I'll spend about a day preparing and then provide comments on the issue.

I'll also provide links to the plugins I've created just in case:

I will contact you after creating the PR. Thank you.

deokgyuhan commented 1 year ago

Hello marcotrumpet. I was reading the Github documentation yesterday and I understood the concept and principles of Pull Requests. If you could send me a PR for the issue at hand, I would greatly appreciate it. After that, I will review the code and update the README to acknowledge the contributor marcotrumpet. Thank you for your assistance, and I'll be looking forward to your PR. Have a great day and stay strong!

marcotrumpet commented 1 year ago

I wasn't able to solve the issues yet, sorry

deokgyuhan commented 1 year ago

While working on updating functions that pass parameters for UUID and similar tasks, I'll look into the issues occurring on iOS. Feel free to submit a PR anytime you find a solution. Thank you for the prompt response, and have a great time!

bbm-design commented 1 year ago

Thanks for the quick reply.. While playing around with your package I fixed an issue with advertising on ios but I'm still not able to connect to the peripheral.. if you want I can do a PR if I can solve it

Concerning the ios issue, if you deploy the ios version of the base code https://github.com/alexanderlavrushko/BLEProof-collection, everything starts working, it made me think it was an issue with the authorizations, but it isn't.

deokgyuhan commented 1 year ago

Thanks for the quick reply.. While playing around with your package I fixed an issue with advertising on ios but I'm still not able to connect to the peripheral.. if you want I can do a PR if I can solve it

Concerning the ios issue, if you deploy the ios version of the base code https://github.com/alexanderlavrushko/BLEProof-collection, everything starts working, it made me think it was an issue with the authorizations, but it isn't.

Hi bbm-design!!! When I tested the plugin, I did it on iOS version 16, and when I built the source code from the original author and tested the plugin on both sides, I didn't encounter any issues. Could you please let me know which iOS version you are currently testing with? Also, thank you for your interest in the plugin.

bbm-design commented 1 year ago

The test i did was on ios 17, and i did the test on 3 devices now (all under ios 17). When i try to use the flutter example as peripheral, the broadcasting works, but i can't connect to it using the central view (tried it with multiple apps).

When i put the native app as peripheral, it works fine When i put try the flutter app on android, it works fine

i got the flutter peripheral work once or twice after starting and stopping the native app and doing random things

i will redo some testing and get back to you

Edit : The peripheral view doesn't show the bluetooth status (screenshot attached) IMG_23E1D5619D6B-1

bbm-design commented 1 year ago

Tested on an iphone 7 running IOS 15.7.9 and an iphone 13 mini on 17.0.3 and got the same issue, please find the details bellow

Dart 3.1.3 Flutter 3.13.6

freshly downloaded package

1/ got the error :

The current Dart SDK version is 3.1.3.
Because flutter_ble_peripheral_central_example requires SDK version >=3.2.0-8.0.dev <4.0.0, version solving failed.
You can try the following suggestion to make the pubspec resolve:
* Try using the Flutter SDK version: 3.16.0-0.3.pre. 

=> Swapping (sdk: '>=3.2.0-8.0.dev <4.0.0') to (sdk: '>=3.1.3 <4.0.0')

2/ Console is showing

2023-10-21 00:41:20.129460+0100 Runner[499:9992] Metal API Validation Enabled
2023-10-21 00:41:20.275928+0100 Runner[499:9992] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend.
2023-10-21 00:41:20.296131+0100 Runner[499:9992] Warning: Unable to create restoration in progress marker file
2023-10-21 00:41:20.338973+0100 Runner[499:10213] fopen failed for data file: errno = 2 (No such file or directory)
2023-10-21 00:41:20.339118+0100 Runner[499:10213] Errors found! Invalidating cache...
2023-10-21 00:41:20.614403+0100 Runner[499:10235] flutter: The Dart VM service is listening on http://127.0.0.1:50147/yuqRxLoCiGQ=/
didUpdateState: poweredOn
central didUpdateState: poweredOn
state = disconnected
2023-10-21 00:46:53.815700+0100 Runner[499:9992] [Snapshotting] Snapshotting a view (0x13e8bac00, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
2023-10-21 00:47:26.782436+0100 Runner[499:9992] dnssd_clientstub read_all(11) DEFUNCT
2023-10-21 00:47:26.786963+0100 Runner[499:9992] [VERBOSE-2:FlutterDartVMServicePublisher.mm(152)] Could not register as server for FlutterDartVMServicePublisher. Check your network settings and relaunch the application.
2023-10-21 00:47:50.528108+0100 Runner[499:10212] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method stopBlePeripheralService on channel ble_peripheral/method)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7)
<asynchronous suspension>
#1      MethodChannelFlutterBlePeripheralCentral.stopBlePeripheralService (package:flutter_ble_peripheral_central/flutter_ble_peripheral_central_method_channel.dart:43:20)
<asynchronous suspension>
#2      _BLEPeripheralWidgetState._bleStopAdvertising (package:flutter_ble_peripheral_central_example/main.dart:435:5)
<asynchronous suspension>

=> (a bit after state = disconnected i went to the settings and when i switched back to the app i got the rest of the log)

BLE Peripheral is in fact broadcasting

Screenshot 2023-10-21 at 00 54 50

but the central devices are unable to connect (screenshot from bluetooth inspector / LightBlue {i tested to read and write, and things are working})

Edit : Same issue even with the beta

deokgyuhan commented 1 year ago

Tested on an iphone 7 running IOS 15.7.9 and an iphone 13 mini on 17.0.3 and got the same issue, please find the details bellow

Dart 3.1.3 Flutter 3.13.6

freshly downloaded package

1/ got the error :

The current Dart SDK version is 3.1.3.
Because flutter_ble_peripheral_central_example requires SDK version >=3.2.0-8.0.dev <4.0.0, version solving failed.
You can try the following suggestion to make the pubspec resolve:
* Try using the Flutter SDK version: 3.16.0-0.3.pre. 

=> Swapping (sdk: '>=3.2.0-8.0.dev <4.0.0') to (sdk: '>=3.1.3 <4.0.0')

2/ Console is showing

2023-10-21 00:41:20.129460+0100 Runner[499:9992] Metal API Validation Enabled
2023-10-21 00:41:20.275928+0100 Runner[499:9992] [VERBOSE-2:FlutterDarwinContextMetalImpeller.mm(37)] Using the Impeller rendering backend.
2023-10-21 00:41:20.296131+0100 Runner[499:9992] Warning: Unable to create restoration in progress marker file
2023-10-21 00:41:20.338973+0100 Runner[499:10213] fopen failed for data file: errno = 2 (No such file or directory)
2023-10-21 00:41:20.339118+0100 Runner[499:10213] Errors found! Invalidating cache...
2023-10-21 00:41:20.614403+0100 Runner[499:10235] flutter: The Dart VM service is listening on http://127.0.0.1:50147/yuqRxLoCiGQ=/
didUpdateState: poweredOn
central didUpdateState: poweredOn
state = disconnected
2023-10-21 00:46:53.815700+0100 Runner[499:9992] [Snapshotting] Snapshotting a view (0x13e8bac00, UIKeyboardImpl) that is not in a visible window requires afterScreenUpdates:YES.
2023-10-21 00:47:26.782436+0100 Runner[499:9992] dnssd_clientstub read_all(11) DEFUNCT
2023-10-21 00:47:26.786963+0100 Runner[499:9992] [VERBOSE-2:FlutterDartVMServicePublisher.mm(152)] Could not register as server for FlutterDartVMServicePublisher. Check your network settings and relaunch the application.
2023-10-21 00:47:50.528108+0100 Runner[499:10212] [VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation found for method stopBlePeripheralService on channel ble_peripheral/method)
#0      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:308:7)
<asynchronous suspension>
#1      MethodChannelFlutterBlePeripheralCentral.stopBlePeripheralService (package:flutter_ble_peripheral_central/flutter_ble_peripheral_central_method_channel.dart:43:20)
<asynchronous suspension>
#2      _BLEPeripheralWidgetState._bleStopAdvertising (package:flutter_ble_peripheral_central_example/main.dart:435:5)
<asynchronous suspension>

=> (a bit after state = disconnected i went to the settings and when i switched back to the app i got the rest of the log)

BLE Peripheral is in fact broadcasting Screenshot 2023-10-21 at 00 54 50

but the central devices are unable to connect (screenshot from bluetooth inspector / LightBlue {i tested to read and write, and things are working})

Edit : Same issue even with the beta

Hi bbm-design, and thank you for sharing the test results. I will also take a closer look at the Flutter app source code before I start working on it as the first plugin for areas where the connection isn't established in the central. I apologize for the late response. If there are any more issues that need to be addressed, please let me know. Thank you.

bbm-design commented 1 year ago

i will try to help you as much as possible too, as i really like the work you did, the plugin is really simple, well made and easy to maintain.