title: Flutter Blue Writing Automatically
body: <p>I have used Flutter Blue for a college work, where I need to create an application to fetch and pass information to an equipment. The passing of this data must be automatic, as in any application (after all the end user should not look for the services and characteristics necessary to carry out the process). The problem is that I am not being able to perform the data passing soon after connecting with the device.</p>
  
  <p>I'm using the App example I downloaded at <a href="https://github.com/pauldemarco/flutter_blue" rel="nofollow noreferrer">https://github.com/pauldemarco/flutter_blue</a>, so the basic idea is that as soon as I connect to my bluetooth device I send a message to a certain device. There is already an answered question that has the interest of setting notifications when connecting at <a href="https://stackoverflow.com/questions/52879548/flutter-blue-setting-notifications">Flutter Blue Setting Notifications</a>
  I followed the same example but instead of using _setNotification (c) I used the _writeCharacteristic (c), but it does not work.</p>
  
  <pre><code>  _connect(BluetoothDevice d) async {
      device = d;
  // Connect to device
      deviceConnection = _flutterBlue
          .connect(device, timeout: const Duration(seconds: 4))
          .listen(
        null,
        onDone: _disconnect,
      );
  
  // Update the connection state immediately
      device.state.then((s) {
        setState(() {
          deviceState = s;
        });
      });
  
  // Subscribe to connection changes
      deviceStateSubscription = device.onStateChanged().listen((s) {
        setState(() {
          deviceState = s;
        });
        if (s == BluetoothDeviceState.connected) {
  
          device.discoverServices().then((s) {
  
            services = s;
  
            for(BluetoothService service in services) {
              for(BluetoothCharacteristic c in service.characteristics) {
                if(c.uuid == new Guid("06d1e5e7-79ad-4a71-8faa-373789f7d93c")) {
                  _writeCharacteristic(c);
                } else {
                  print("Nope");
                }
              }
            }
            setState(() {
              services = s;
            });
          });
        }
      });
    }
  </code></pre>
  
  <p>I have changed the original code so that it prints me the notifications as soon as I perform the writing method. The notifications should show me a standard message that is in the firmware of the device, but instead it is printing me the Local Name of the bluetooth chip, being that if I select the service and characteristic manually the return is the correct message.</p>