Example usage for android.bluetooth BluetoothClass getDeviceClass

List of usage examples for android.bluetooth BluetoothClass getDeviceClass

Introduction

In this page you can find the example usage for android.bluetooth BluetoothClass getDeviceClass.

Prototype

public int getDeviceClass() 

Source Link

Document

Return the (major and minor) device class component of this BluetoothClass .

Usage

From source file:uk.ac.horizon.ubihelper.service.channel.BluetoothDiscoveryChannel.java

protected synchronized void handlePollComplete() {
    if (pollInProgress)
        pollComplete();/*w ww.j  ava  2  s  .c om*/
    try {
        JSONObject value = new JSONObject();
        value.put(KEY_TIME, System.currentTimeMillis());
        String btname = bluetooth.getName();
        String btaddress = bluetooth.getAddress();
        if (btname != null)
            value.put(KEY_NAME, btname);
        if (btaddress != null)
            value.put(KEY_ADDRESS, btaddress);
        JSONArray ds = new JSONArray();
        value.put(KEY_DEVICES, ds);
        for (BluetoothDevice device : this.devices.values()) {
            JSONObject d = new JSONObject();
            d.put(KEY_ADDRESS, device.getAddress());
            BluetoothClass btclass = device.getBluetoothClass();
            if (btclass != null)
                d.put(KEY_CLASS, btclass.getDeviceClass());
            String name = device.getName();
            if (name != null)
                d.put(KEY_NAME, name);
            d.put(KEY_BOND, device.getBondState());
            ds.put(d);
        }
        onNewValue(value);
    } catch (JSONException e) {
        // shouldn't
    }
}