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 :
setBleConnectionState(BluetoothDeviceState.disconnected);
}).then((data) async {
bluetoothService.clear();
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('============================================');
print('Service UUID: ${service.uuid}');
for (BluetoothCharacteristic c in service.characteristics) {
print('\tcharacteristic UUID: ${c.uuid.toString()}');
print('\t\twrite: ${c.properties.write}');
print('\t\tread: ${c.properties.read}');
print('\t\tnotify: ${c.properties.notify}');
print('\t\tisNotifying: ${c.isNotifying}');
print(
'\t\twriteWithoutResponse: ${c.properties.writeWithoutResponse}');
print('\t\tindicate: ${c.properties.indicate}');
if (c.properties.notify && 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';
});
widget.device.disconnect();
} 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.