diff --git a/CHANGELOG.md b/CHANGELOG.md index 765e846..f802ddb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.14.0 +* BREAKING CHANGE: `bleDevice.name` now filters out non-printable characters +* Add `bleDevice.rawName` + ## 0.13.0 * BREAKING CHANGE: `scanFilter` filters are now in OR relation * BREAKING CHANGE: `manufacturerDataHead` is removed from `BleDevice` diff --git a/example/lib/home/widgets/scanned_item_widget.dart b/example/lib/home/widgets/scanned_item_widget.dart index 32e79ac..0ce70c6 100644 --- a/example/lib/home/widgets/scanned_item_widget.dart +++ b/example/lib/home/widgets/scanned_item_widget.dart @@ -14,7 +14,7 @@ class ScannedItemWidget extends StatelessWidget { if (rawManufacturerData.isNotEmpty) { manufacturerData = rawManufacturerData.first; } - if (name == null || name.isEmpty) name = 'NA'; + if (name == null || name.isEmpty) name = 'N/A'; return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: Card( diff --git a/lib/src/models/ble_device.dart b/lib/src/models/ble_device.dart index 0232803..b471861 100644 --- a/lib/src/models/ble_device.dart +++ b/lib/src/models/ble_device.dart @@ -5,6 +5,7 @@ import 'package:universal_ble/universal_ble.dart'; class BleDevice { String deviceId; String? name; + String? rawName; int? rssi; bool? isPaired; List services; @@ -29,13 +30,16 @@ class BleDevice { BleDevice({ required this.deviceId, - required this.name, + required String? name, this.rssi, this.isPaired, this.services = const [], this.isSystemDevice, this.manufacturerDataList = const [], - }); + }) { + rawName = name; + this.name = name?.replaceAll(RegExp(r'[^ -~]'), '').trim(); + } @override String toString() { diff --git a/pubspec.yaml b/pubspec.yaml index 4fd5116..55528ef 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,6 +1,6 @@ name: universal_ble description: A cross-platform (Android/iOS/macOS/Windows/Linux/Web) Bluetooth Low Energy (BLE) plugin for Flutter -version: 0.13.0 +version: 0.14.0 homepage: https://navideck.com repository: https://github.com/Navideck/universal_ble issue_tracker: https://github.com/Navideck/universal_ble/issues