How can I send data to STM32 CARD using flutter?


This Content is from Stack Overflow. Question asked by syrine

actually I want to send data via bluetooth to an STM 32 card. I could connect with it But now I have no idea about sending data to this card. I created a simple form to write text at first time but I don’t have solution for sending the data(text, float,…).
My question is finding some way to send any data to the STM32 card.
This is the code that connect and showing some informations about the card :

    }).then((data) async {
      if (returnValue == null) {
        debugPrint('connection successful');
        print('start discover service');
        List<BluetoothService> bleServices =
            await widget.device.discoverServices();
        setState(() {
          bluetoothService = bleServices;
        for (BluetoothService service in bleServices) {
          print('Service UUID: ${service.uuid}');
          for (BluetoothCharacteristic c in service.characteristics) {
            print('tcharacteristic UUID: ${c.uuid.toString()}');
            print('ttwrite: ${}');
            print('ttread: ${}');
            print('ttnotify: ${}');
            print('ttisNotifying: ${c.isNotifying}');
                'ttwriteWithoutResponse: ${}');
            print('ttindicate: ${}');

            if ( && c.descriptors.isNotEmpty) {
              for (BluetoothDescriptor d in c.descriptors) {
                print('BluetoothDescriptor uuid ${d.uuid}');
                if (d.uuid == BluetoothDescriptor.cccd) {
                  print('d.lastValue: ${d.lastValue}');

              if (!c.isNotifying) {
                try {
                  await c.setNotifyValue(true);
                  notifyDatas[c.uuid.toString()] = List.empty();
                  c.value.listen((value) {
                    print('${c.uuid}: $value');
                    setState(() {
                      notifyDatas[c.uuid.toString()] = value;

                  await Future.delayed(const Duration(milliseconds: 500));
                } catch (e) {
                  print('error ${c.uuid} $e');
        returnValue = Future.value(true);

    return returnValue ?? Future.value(false);

  void disconnect() {
    try {
      setState(() {
        stateText = 'Disconnecting';
    } catch (e) {}

I know that I have to send data using the uuid of the card but I don’t know how to create the code.
I would be very thankful if you can help me by giving me some ideas.


This question is not yet answered, be the first one who answer using the comment. Later the confirmed answer will be published as the solution.

This Question and Answer are collected from stackoverflow and tested by JTuto community, is licensed under the terms of CC BY-SA 2.5. - CC BY-SA 3.0. - CC BY-SA 4.0.

people found this article helpful. What about you?