Android 安卓BLE传感器服务不可用

Android 安卓BLE传感器服务不可用,android,bluetooth-lowenergy,bluegiga,Android,Bluetooth Lowenergy,Bluegiga,我正在尝试为Android开发一个BLUEBluetooth(智能)应用程序,使用的是Bluegiga设备。我遵循android sdk示例中给出的BLE演示示例代码 这就是我的盖特Callback // Implements callback methods for GATT events that the app cares about. // For example, // connection status has changed, services are discovered,etc

我正在尝试为Android开发一个BLUEBluetooth(智能)应用程序,使用的是Bluegiga设备。我遵循android sdk示例中给出的BLE演示示例代码

这就是我的盖特Callback

// Implements callback methods for GATT events that the app cares about.
// For example,
// connection status has changed, services are discovered,etc...
private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    // Called when device has changed connection status and appropriate
    // broadcast with device address extra is sent
    // It can be either connected or disconnected state
    @Override
    public void onConnectionStateChange(final BluetoothGatt gatt,
            int status, int newState) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            // LogUtils.LOGI("BLE_STATUS", "SUCCESS");

            Log.i("BLE service", "onConnectionStateChange - status: "
                    + status + " - new state: " + newState);
            if (gatt.discoverServices())
                LogUtils.LOGI("DISCOVER_SERVC", "STARTED");
        } else
        // LogUtils.LOGI("DISCOVER_SERVC", "NOT_STARTED");

        if (newState == BluetoothProfile.STATE_CONNECTED) {
            LogUtils.LOGI("BLE_STATUS", "CON");

        } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {

        }

        Log.i("BLE service", "onConnectionStateChange - status: " + status
                + " - new state: " + newState);

    }

    // Called when services are discovered on remote device
    // If success broadcast with device address extra is sent
    @Override
    public void onServicesDiscovered(BluetoothGatt gatt, int status) {
        if (status == BluetoothGatt.GATT_SUCCESS) {
            LogUtils.LOGI("BLE_STATUS", "SUCCESS");
        }
        Log.i("BLE service", "onServicesDiscovered - status: " + status);
    }

    // Called when characteristic was read
    // Broadcast with characteristic uuid and status is sent
    @Override
    public void onCharacteristicRead(BluetoothGatt gatt,
            BluetoothGattCharacteristic characteristic, int status) {
        Log.i("BLE service", "onCharacteristicRead - status: " + status
                + "  - UUID: " + characteristic.getUuid());
    }

    // Called when characteristic was written
    // Broadcast with characteristic uuid and status is sent
    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt,
            BluetoothGattCharacteristic characteristic, int status) {
        Log.i("BLE service", "onCharacteristicWrite - status: " + status
                + "  - UUID: " + characteristic.getUuid());
    }

    // Called when remote device rssi was read
    // If success broadcast with device address extra is sent
    @Override
    public void onReadRemoteRssi(BluetoothGatt gatt, int rssi, int status) {
        if (status == BluetoothGatt.GATT_SUCCESS) {

        }
        Log.i("BLE service", "onReadRemoteRssi - status: " + status);
    }

    // Called when descriptor was written
    @Override
    public void onDescriptorWrite(BluetoothGatt gatt,
            BluetoothGattDescriptor descriptor, int status) {

        Log.i("BLE service", "onDescriptorWrite - status: " + status
                + "  - UUID: " + descriptor.getUuid());
    }

    // Called when notification has been sent from remote device
    // Broadcast with characteristic uuid is sent
    @Override
    public void onCharacteristicChanged(BluetoothGatt gatt,
            BluetoothGattCharacteristic characteristic) {
        Log.i("BLE service", "onCharacteristicChanged - status: "
                + "  - UUID: " + characteristic.getUuid());
    }
};
无论我做什么,我都得不到任何服务,也得不到BLE设备的特性 我在连接状态更改中收到的状态代码是133

已尝试解决方法:因为我已经知道该服务UUID我尝试获得该服务 对象,如下所示

BluetoothGattService gattService = gatt.getService(device);
if (gattService == null) {
LogUtils.LOGI("GATT SERVICE", "null :" + gattService);
} else {
LogUtils.LOGI("GATT SERVICE", "not null :" + gattService);
}
但是结果总是返回null

我应该如何获得Gattservices和charectrestics?