Search code examples
bluetoothjava-me

Which are the int values of getMajorDeviceClass in J2ME?


I know that for detect the kind of device, DeviceClass is used:

void deviceDiscovered(RemoteDevice btDevice, DeviceClass cod)

I can use cod.getMajorDeviceClass() but I don't know which are the int values that corresponds to a "Computer", "Phone", ...


Solution

  • Major and Minor values are defined in Bluetooth specification. At this page you have an overall explanation of the values:

    The Major Device Class segment is the highest level of granularity for defining a Bluetooth device. A device's main function determines its Major Class assignment. There are 32 major classes.

    The values are well documented on Android's BluetoothClass.Device.Major. For example:

    public static final int COMPUTER = 0x100;
    public static final int PHONE = 0x200;
    

    You can copy these definitions to your Java ME code and use a simple comparison to check:

    if (cod.getMajorDeviceClass() == COMPUTER) {
      // ...
    } else if (cod.getMajorDeviceClass() == PHONE) {
      // ...
    }