Improve BleUuid API and tests (#62)
* Improve tests * Fix tests * More improvements and ToDos * Final API changes Add tests * Update readme --------- Co-authored-by: Rohit Sangwan <rohitsangwan647@gmail.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
# Universal BLE
|
||||
# UniversalBLE
|
||||
|
||||
[](https://pub.dev/packages/universal_ble)
|
||||
|
||||
@@ -16,6 +16,9 @@ A cross-platform (Android/iOS/macOS/Windows/Linux/Web) Bluetooth Low Energy (BLE
|
||||
- [Bluetooth Availability](#bluetooth-availability)
|
||||
- [Command Queue](#command-queue)
|
||||
- [Timeout](#timeout)
|
||||
- [UUID Format Agnostic](#uuid-format-agnostic)
|
||||
|
||||
## Usage
|
||||
|
||||
### API Support Matrix
|
||||
|
||||
@@ -260,36 +263,37 @@ UniversalBle.timeout = const Duration(seconds: 10);
|
||||
UniversalBle.timeout = null;
|
||||
```
|
||||
|
||||
## UUID format
|
||||
## UUID Format Agnostic
|
||||
|
||||
All characteristic and service UUIDs will be returned in lowercase and in 128 bit format, across all platforms.
|
||||
e.g. `0000180a-0000-1000-8000-00805f9b34fb`
|
||||
UniversalBLE is agnostic to the UUID format of services and characteristics regardless of the platform the app runs on. When passing a UUID, you can pass it in any format (long/short) or character case (upper/lower case) you want. UniversalBLE will take care of necessary conversions, across all platforms, so that you don't need to worry about underlying platform differences.
|
||||
|
||||
When passing a UUID you can pass it in any character case or format (long/short) you want. The plugin will take care of conversions.
|
||||
For consistency, all characteristic and service UUIDs will be returned in **lowercase 128-bit format**, across all platforms, e.g. `0000180a-0000-1000-8000-00805f9b34fb`.
|
||||
|
||||
### Utility methods
|
||||
### Utility Methods
|
||||
|
||||
`BleUuid.parse()` converts a string to 128 bit UUID format:
|
||||
If you need to convert any UUIDs in your app you can use the following methods.
|
||||
|
||||
- `BleUuidParser.string()` converts a string to a 128-bit UUID formatted string:
|
||||
|
||||
```dart
|
||||
BleUuid.parse("180A"); // "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
BleUuidParser.string("180A"); // "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
|
||||
BleUuid.parse("0000180A-0000-1000-8000-00805F9B34FB"); // "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
BleUuidParser.string("0000180A-0000-1000-8000-00805F9B34FB"); // "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
```
|
||||
|
||||
`BleUuid.extend()` creates a 128 bit Bluetooth UUID from short (16 or 32 bit) format:
|
||||
- `BleUuidParser.number()` converts a number to a 128-bit UUID formatted string:
|
||||
|
||||
```dart
|
||||
BleUuid.extend(0x180A); // "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
BleUuidParser.number(0x180A); // "0000180a-0000-1000-8000-00805f9b34fb"
|
||||
```
|
||||
|
||||
`BleUuid.equals()` compares two UUIDs:
|
||||
- `BleUuidParser.compare()` compares two differently formatted UUIDs:
|
||||
|
||||
```dart
|
||||
BleUuid.equals("180a","0000180A-0000-1000-8000-00805F9B34FB"); // true
|
||||
BleUuidParser.compare("180a","0000180A-0000-1000-8000-00805F9B34FB"); // true
|
||||
```
|
||||
|
||||
## Platform-Specific Setup
|
||||
## Platform-specific Setup
|
||||
|
||||
### Android
|
||||
|
||||
|
||||
Reference in New Issue
Block a user