Class BluetoothUuid
java.lang.Object
com.codename1.bluetooth.BluetoothUuid
Immutable 128-bit Bluetooth UUID value type used throughout the
com.codename1.bluetooth API for services, characteristics and
descriptors. The Codename One core has no java.util.UUID, so this class
fills that role and adds Bluetooth-specific conveniences: 16/32-bit SIG
assigned numbers are expanded over the Bluetooth Base UUID via
fromShort(int) and recognized by isShortUuid().
BluetoothUuid heartRate = BluetoothUuid.fromShort(0x180D);
BluetoothUuid custom = BluetoothUuid.fromString(
"5f47a3c0-1234-4e6b-9d00-000000000001");
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final BluetoothUuidThe Bluetooth Base UUID,00000000-0000-1000-8000-00805f9b34fb.static final BluetoothUuidThe Client Characteristic Configuration descriptor (0x2902) written by the stack when enabling notifications/indications.static final BluetoothUuidThe classic Serial Port Profile service (0x1101) used as the default UUID for RFCOMM connections. -
Constructor Summary
ConstructorsConstructorDescriptionBluetoothUuid(long mostSigBits, long leastSigBits) Creates a UUID from its raw 64-bit halves, mirroringjava.util.UUID(long, long). -
Method Summary
Modifier and TypeMethodDescriptionbooleanIndicates whether some other object is "equal to" this one.static BluetoothUuidfromShort(int assignedNumber) Expands a 16 or 32-bit Bluetooth SIG assigned number over the Bluetooth Base UUID, e.g.static BluetoothUuidfromString(String uuid) Parses a UUID string.longThe least significant 64 bits, mirroringjava.util.UUID.getLeastSignificantBits().longThe most significant 64 bits, mirroringjava.util.UUID.getMostSignificantBits().intThe 16/32-bit SIG assigned number of a Base-UUID derivation.inthashCode()Returns a hash code value for the object.booleantruewhen this UUID is a Bluetooth Base UUID derivation, i.e.toString()Canonical lowercase 36 character form, e.g.
-
Field Details
-
BASE
The Bluetooth Base UUID,00000000-0000-1000-8000-00805f9b34fb. All 16/32-bit SIG assigned numbers are derivations of it. -
CCCD
The Client Characteristic Configuration descriptor (0x2902) written by the stack when enabling notifications/indications. -
SPP
The classic Serial Port Profile service (0x1101) used as the default UUID for RFCOMM connections.
-
-
Constructor Details
-
BluetoothUuid
public BluetoothUuid(long mostSigBits, long leastSigBits) Creates a UUID from its raw 64-bit halves, mirroringjava.util.UUID(long, long).
-
-
Method Details
-
fromString
Parses a UUID string. Accepts the full canonical 36 character form (0000180d-0000-1000-8000-00805f9b34fb), an 8 hex digit 32-bit SIG assigned number (0000180D) or a 4 hex digit 16-bit one (180D); the short forms are expanded over the Bluetooth Base UUID. Case insensitive. ThrowsIllegalArgumentExceptionon malformed input. -
fromShort
Expands a 16 or 32-bit Bluetooth SIG assigned number over the Bluetooth Base UUID, e.g.fromShort(0x180D)yields0000180d-0000-1000-8000-00805f9b34fb(the Heart Rate service). -
getMostSignificantBits
public long getMostSignificantBits()The most significant 64 bits, mirroringjava.util.UUID.getMostSignificantBits(). -
getLeastSignificantBits
public long getLeastSignificantBits()The least significant 64 bits, mirroringjava.util.UUID.getLeastSignificantBits(). -
isShortUuid
public boolean isShortUuid()truewhen this UUID is a Bluetooth Base UUID derivation, i.e. a 16/32-bit SIG assigned number expanded viafromShort(int)or an equivalent string form. Whentrue,getShortValue()returns the assigned number. -
getShortValue
public int getShortValue()The 16/32-bit SIG assigned number of a Base-UUID derivation. ThrowsIllegalStateExceptionwhenisShortUuid()isfalse. -
toString
-
equals
Description copied from class:ObjectIndicates whether some other object is "equal to" this one. The equals method implements an equivalence relation: It is reflexive: for any reference value x, x.equals(x) should return true. It is symmetric: for any reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true. It is transitive: for any reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true. It is consistent: for any reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the object is modified. For any non-null reference value x, x.equals(null) should return false. The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any reference values x and y, this method returns true if and only if x and y refer to the same object (x==y has the value true). -
hashCode
public int hashCode()Description copied from class:ObjectReturns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable. The general contract of hashCode is: Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application. If two objects are equal according to the equals(Object) method, then calling the hashCode method on each of the two objects must produce the same integer result. It is not required that if two objects are unequal according to the equals(java.lang.Object) method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hashtables. As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)
-