Giter Club home page Giter Club logo

Comments (5)

jeroen1602 avatar jeroen1602 commented on August 20, 2024

I think I found the problem.

The code adds an event for characteristicvaluechanged while it should be oncharacteristicvaluechanged.

If it works then the data should be received on the value stream

from flutter_web_bluetooth.

jeroen1602 avatar jeroen1602 commented on August 20, 2024

So I made a commit where the code also listens on oncharacteristicvaluechanged

But I'm not sure which one is correct since Google chrome samples uses characteristicvaluechanged.
While the Web api draft uses oncharacteristicvaluechanged.

I also haven't gotten the notifications to work locally using the devices I own. I got one that does support notifications and that also works in other apps, but the event doesn't seem to fire when using the web api.

Are you able to test this for me by either adding a git dependency to your own project using:

dependencies:
  flutter_web_bluetooth:
    git: https://github.com/jeroen1602/flutter_web_bluetooth.git

In your pubspec.yml. Source

Or checking out this project and testing it using the example project?

If you go the example project route you may need to change the logic in bluetooth_buesiness.dart to get it to find your devices.

try {
final device = await FlutterWebBluetooth.instance.requestDevice(
RequestOptionsBuilder.acceptAllDevices(
optionalServices: BluetoothDefaultServiceUUIDS.values
.map((final e) => e.uuid)
.toList(),
optionalManufacturerData: BluetoothDefaultManufacturerIdentifiers
.values
.map((final e) => e.identifier)
.toList(growable: false)));
debugPrint("Device got! ${device.name}, ${device.id}");

from flutter_web_bluetooth.

kolan51 avatar kolan51 commented on August 20, 2024

Hey, thanks for all the help.

Eventually I got it working by using this:

final List<BluetoothService> services = await device.discoverServices();

final BluetoothService service = services
    .firstWhere((BluetoothService service) => service.uuid == serviceId);

final BluetoothCharacteristic characteristic =
    await service.getCharacteristic(charId);

await characteristic.startNotifications();

characteristic.value.forEach((ByteData element) {
  final ByteBuffer buffer = element.buffer;
  final Uint8List received =
      buffer.asUint8List(element.offsetInBytes, element.lengthInBytes);}

all the data received is now in the list received. I provisioned the device using the return from this notifications so the data returned is correct.

from flutter_web_bluetooth.

jeroen1602 avatar jeroen1602 commented on August 20, 2024

Is this using the release on live on pub.dev or using the code in master?

from flutter_web_bluetooth.

kolan51 avatar kolan51 commented on August 20, 2024

Its from the release on pub.dev

from flutter_web_bluetooth.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.