sendNotification method

Future<void> sendNotification(
  1. String characteristicUuid,
  2. List<int> value, {
  3. String? clientId,
})

Sends bytes to subscribers without changing the stored readable value. Omitting clientId targets all subscribers; with none, nothing is sent. Never automatically retries or fragments messages. Payload must fit the target's negotiated limit; completion is not an application-level receipt.

Implementation

Future<void> sendNotification(
  String characteristicUuid,
  List<int> value, {
  String? clientId,
}) {
  final bytes = bleBytes(value);
  return _enqueue(() async {
    final field = _field(characteristicUuid);
    if (!field.access.contains(BleProperty.notify)) {
      throw StateError('Field does not support notifications');
    }
    field.validateBytes(bytes);
    if (clientId == null) {
      await _platform.notify(field.uuid, bytes);
    } else {
      await _platform.notifyClient(field.uuid, bytes, clientId);
    }
  });
}