Skip to content

Codification of Bluetooth specifiers for manufacturer & service data.

License

Notifications You must be signed in to change notification settings

jeroen1602/bluetooth_identifiers

 
 

Repository files navigation

Pub License Code size Open Issues

Bluetooth Identifiers

Codification of some Assigned Numbers from Bluetooth.com which have been packaged into a Flutter package for your convenience!

Learn more at Bluetooth.com!


Usage

Usage of this package is dead simple as it is a neatly wrapped set of maps with int key type.

Direct Fetching

Direct fetching may be done either via raw integer, or hex literal.

final UUIDAllocation uuidServiceId = BluetoothIdentifiers.uuidServiceIdentifiers[64753];

print(uuidServiceID); // UUIDAllocation(type: '16-bit UUID for Members', registrant: 'Google LLC')


final String companyIdentifier = BluetoothIdentifiers.companyIdentifiers[0x00E0];

print(companyIdentifier); // 'Google'

Key Calculation

Regular calculation of keys

Calculating key from hex string example
final int key = int.parse('0x00E0', radix: 16);
Calculating key from byte list example
final int start = 0;
final Uint8List bytes = Uint8List.fromList([0, 224]);

final int key = bytes.buffer.asByteData().getUint16(start);

Instead of grinding away at calculating your own keys for the maps in order to follow general usage, the package exposes simple Map extension functions which may be used to reduce a lot of tedious boiler-plate.

Convenience extensions

final UUIDAllocation uuidServiceId = BluetoothIdentifiers.uuidServiceIdentifiers.elementForHex('0x00E0');

print(uuidServiceID); // UUIDAllocation(type: '16-bit UUID for Members', registrant: 'Google LLC')


final Uint8List bytes = Uint8List.fromList([0, 224]);
final String companyIdentifier = BluetoothIdentifiers.companyIdentifiers.elementForByteArray(bytes);

print(companyIdentifier); // 'Google'

What if I also need calculated key?

final MapEntry<int, UUIDAllocation> uuidServiceIDEntry = BluetoothIdentifiers.uuidServiceIdentifiers
  .entryForHex('0xFCF1');

print(uuidServiceIDEntry.key); // 64753
print(uuidServiceIDEntry.value); // UUIDAllocation(type: '16-bit UUID for Members', registrant: 'Google LLC')

final Uint8List bytes = Uint8List.fromList([0, 224]);
final MapEntry<int, String> companyIdentifierEntry = BluetoothIdentifiers.companyIdentifiers
  .entryForByteArray(bytes);

print(companyIdentifierEntry.key); // 224
print(companyIdentifierEntry.value); // 'Google'

Dart Versions

  • Dart 2: >= 2.12

Maintainers

Requests & Feedback

  • Due to the fact that the sources of this package are living documents, if this package becomes outdated an issue may be raised on the Github page and I will do my best to update date it quickly. Any other feedback may be sent to my personal contact.

About

Codification of Bluetooth specifiers for manufacturer & service data.

Resources

License

Stars

Watchers

Forks

Languages

  • Dart 83.7%
  • C++ 6.8%
  • CMake 5.9%
  • Python 1.1%
  • Ruby 0.9%
  • HTML 0.6%
  • Other 1.0%