You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Possible Bug The method BleUuidParser.number should handle numbers greater than 0xFFFF and less than 0x10000, but the current implementation only allows numbers between 0x0100 and 0xFFFF. This might exclude valid 16-bit UUIDs like 0x0001.
Error Handling The method BleUuidParser.string might throw a FormatException for valid UUIDs that are exactly 32 characters long without dashes. This scenario is not handled correctly in the current implementation.
Add a check for hexadecimal validity in UUID strings
Consider adding a check for hexadecimal validity in the string method to ensure that the UUID string contains only hexadecimal characters before processing it. This can prevent runtime errors or unexpected behavior due to invalid input.
static String string(String uuid) {
if (uuid.length < 4) {
throw const FormatException('Invalid UUID');
}
+ final hexRegex = RegExp(r'^[0-9a-fA-F]+$');+ if (!hexRegex.hasMatch(uuid.replaceAll('-', ''))) {+ throw const FormatException('UUID must contain only hexadecimal characters');+ }
...
}
Suggestion importance[1-10]: 9
Why: This suggestion adds a crucial validation step to ensure that the UUID string contains only hexadecimal characters, which can prevent runtime errors and unexpected behavior due to invalid input.
9
Adjust the range check in the number method to support 32-bit UUIDs
Refactor the number method to handle the full range of valid 16-bit and 32-bit UUIDs by adjusting the conditional check to allow values up to 0xFFFFFFFF.
static String number(int short) {
- if (short <= 0xFF || short > 0xFFFF) {+ if (short < 0 || short > 0xFFFFFFFF) {
throw const FormatException('Invalid UUID');
}
- return string(short.toRadixString(16).padLeft(4, '0'));+ return string(short.toRadixString(16).padLeft(8, '0'));
}
Apply this suggestion
Suggestion importance[1-10]: 8
Why: This suggestion correctly expands the range check to include the full range of valid 32-bit UUIDs, enhancing the method's functionality and ensuring it handles a broader range of inputs.
8
Bug fix
Ensure correct formatting of UUIDs starting with '0x' in the string method
In the string method, ensure that UUIDs starting with '0x' are properly formatted after removing the prefix to avoid incorrect UUID formats.
Why: This suggestion addresses a potential formatting issue with UUIDs starting with '0x', ensuring they are correctly formatted after removing the prefix. However, the existing code already handles this well, so the improvement is minor.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR Type
Enhancement, Tests
Description
BleUuid
toBleUuidParser
for better clarity and functionality.BleUuidParser
methods.BleUuid
class.BleUuidParser
.Changes walkthrough 📝
6 files
ble_service.dart
Update UUID parsing method in BleService and BleCharacteristic
lib/src/models/ble_service.dart
BleUuid.parse
toBleUuidParser.string
for UUID parsing.ble_uuid_parser.dart
Refactor and enhance UUID parsing utility
lib/src/models/ble_uuid_parser.dart
BleUuid
toBleUuidParser
.model_exports.dart
Update export statement for BleUuidParser
lib/src/models/model_exports.dart
BleUuidParser
class name.universal_ble.dart
Update UUID parsing method in UniversalBle class
lib/src/universal_ble.dart
BleUuid.parse
toBleUuidParser.string
for UUID parsing inmultiple methods.
universal_ble_pigeon_channel.dart
Update UUID parsing method in UniversalBleScanResult extension
lib/src/universal_ble_pigeon/universal_ble_pigeon_channel.dart
BleUuid.parse
toBleUuidParser.string
for UUID parsing inextension method.
universal_ble_platform_interface.dart
Update UUID parsing method in UniversalBlePlatform interface
lib/src/universal_ble_platform_interface.dart
BleUuid.parse
toBleUuidParser.string
for UUID parsing inupdateCharacteristicValue
method.3 files
ble_uuid_parser_test.dart
Add tests for BleUuidParser methods
test/ble_uuid_parser_test.dart
BleUuidParser
methods.universal_ble_test.dart
Remove outdated tests for BleUuid class
test/universal_ble_test.dart
BleUuid
class.text_ble_uuid.yml
Add GitHub Actions workflow for BleUuidParser tests
.github/workflows/text_ble_uuid.yml
BleUuidParser
.2 files
CHANGELOG.md
Update changelog for BleUuid utility methods
CHANGELOG.md
BleUuid
utility methods.README.md
Update README for BleUuidParser methods
README.md
BleUuidParser
methods.