# Class BluetoothUuid

java.lang.Object
com.codename1.bluetooth.BluetoothUuid

public final class BluetoothUuid extends Object

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

  Fields
  Modifier and Type
  Field
  Description
  `static final BluetoothUuid`
  `BASE`
  The Bluetooth Base UUID, `00000000-0000-1000-8000-00805f9b34fb`.
  `static final BluetoothUuid`
  `CCCD`
  The Client Characteristic Configuration descriptor (`0x2902`) written by the stack when enabling notifications/indications.
  `static final BluetoothUuid`
  `SPP`
  The classic Serial Port Profile service (`0x1101`) used as the default UUID for RFCOMM connections.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BluetoothUuid(long mostSigBits, long leastSigBits)`
  Creates a UUID from its raw 64-bit halves, mirroring `java.util.UUID(long, long)`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `boolean`
  `equals(Object o)`
  Indicates whether some other object is "equal to" this one.
  `static BluetoothUuid`
  `fromShort(int assignedNumber)`
  Expands a 16 or 32-bit Bluetooth SIG assigned number over the Bluetooth Base UUID, e.g.
  `static BluetoothUuid`
  `fromString(String uuid)`
  Parses a UUID string.
  `long`
  `getLeastSignificantBits()`
  The least significant 64 bits, mirroring `java.util.UUID.getLeastSignificantBits()`.
  `long`
  `getMostSignificantBits()`
  The most significant 64 bits, mirroring `java.util.UUID.getMostSignificantBits()`.
  `int`
  `getShortValue()`
  The 16/32-bit SIG assigned number of a Base-UUID derivation.
  `int`
  `hashCode()`
  Returns a hash code value for the object.
  `boolean`
  `isShortUuid()`
  `true` when this UUID is a Bluetooth Base UUID derivation, i.e.
  `String`
  `toString()`
  Canonical lowercase 36 character form, e.g.

  ### Methods inherited from class Object

  `clone, getClass, notify, notifyAll, wait, wait, wait`

- ## Field Details

  - ### BASE

    public static final BluetoothUuid BASE
    The Bluetooth Base UUID, `00000000-0000-1000-8000-00805f9b34fb`. All 16/32-bit SIG assigned numbers are derivations of it.

  - ### CCCD

    public static final BluetoothUuid CCCD
    The Client Characteristic Configuration descriptor (`0x2902`) written by the stack when enabling notifications/indications.

  - ### SPP

    public static final BluetoothUuid 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, mirroring `java.util.UUID(long, long)`.

- ## Method Details

  - ### fromString

    public static BluetoothUuid fromString(String uuid)
    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. Throws `IllegalArgumentException` on malformed input.

  - ### fromShort

    public static BluetoothUuid fromShort(int assignedNumber)
    Expands a 16 or 32-bit Bluetooth SIG assigned number over the Bluetooth Base UUID, e.g. `fromShort(0x180D)` yields `0000180d-0000-1000-8000-00805f9b34fb` (the Heart Rate service).

  - ### getMostSignificantBits

    public long getMostSignificantBits()
    The most significant 64 bits, mirroring `java.util.UUID.getMostSignificantBits()`.

  - ### getLeastSignificantBits

    public long getLeastSignificantBits()
    The least significant 64 bits, mirroring `java.util.UUID.getLeastSignificantBits()`.

  - ### isShortUuid

    public boolean isShortUuid()
    `true` when this UUID is a Bluetooth Base UUID derivation, i.e. a 16/32-bit SIG assigned number expanded via `fromShort(int)` or an equivalent string form. When `true`, `getShortValue()` returns the assigned number.

  - ### getShortValue

    public int getShortValue()
    The 16/32-bit SIG assigned number of a Base-UUID derivation. Throws `IllegalStateException` when `isShortUuid()` is `false`.

  - ### toString

    public String toString()
    Canonical lowercase 36 character form, e.g. `0000180d-0000-1000-8000-00805f9b34fb`.
    Overrides:
      `toString` in class `Object`

  - ### equals

    public boolean equals(Object o)
    Description copied from class: `Object`
    Indicates 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).
    Overrides:
      `equals` in class `Object`

  - ### hashCode

    public int hashCode()
    Description copied from class: `Object`
    Returns 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.)
    Overrides:
      `hashCode` in class `Object`