蓝牙LE Cadence和速度传感器未在Android上发送通知

蓝牙LE Cadence和速度传感器未在Android上发送通知,android,bluetooth,bluetooth-lowenergy,Android,Bluetooth,Bluetooth Lowenergy,我有一个问题与蓝牙乐节奏和速度传感器(Wahoo SC)。我正在使用Android BluetoothGattLe示例应用程序,我已经为Cadence和Speed Sensor进行了调整 它与心率监视器配合使用效果良好。相关代码如下。随着心率的变化,心率监视器onCharacteristicChanged每秒触发一次。然而,当我连接Cadence和Speed传感器时,什么也没有发生。虽然我知道onConnectionStateChange在连接时被触发,但这个回调似乎并没有被触发 有什么想法吗

我有一个问题与蓝牙乐节奏和速度传感器(Wahoo SC)。我正在使用Android BluetoothGattLe示例应用程序,我已经为Cadence和Speed Sensor进行了调整

它与心率监视器配合使用效果良好。相关代码如下。随着心率的变化,心率监视器onCharacteristicChanged每秒触发一次。然而,当我连接Cadence和Speed传感器时,什么也没有发生。虽然我知道onConnectionStateChange在连接时被触发,但这个回调似乎并没有被触发

有什么想法吗

    /**
 * Service for managing connection and data communication with a GATT server hosted on a
 * given Bluetooth LE device.
 */
public class BluetoothLeService extends Service {
    private final static String TAG = BluetoothLeService.class.getSimpleName();

    private BluetoothManager mBluetoothManager;
    private BluetoothAdapter mBluetoothAdapter;
    private String mBluetoothDeviceAddress;
    private BluetoothGatt mBluetoothGatt;
    private int mConnectionState = STATE_DISCONNECTED;

    private static final int STATE_DISCONNECTED = 0;
    private static final int STATE_CONNECTING = 1;
    private static final int STATE_CONNECTED = 2;

    public final static String ACTION_GATT_CONNECTED =
            "com.example.bluetooth.le.ACTION_GATT_CONNECTED";
    public final static String ACTION_GATT_DISCONNECTED =
            "com.example.bluetooth.le.ACTION_GATT_DISCONNECTED";
    public final static String ACTION_GATT_SERVICES_DISCOVERED =
            "com.example.bluetooth.le.ACTION_GATT_SERVICES_DISCOVERED";
    public final static String ACTION_DATA_AVAILABLE =
            "com.example.bluetooth.le.ACTION_DATA_AVAILABLE";
    public final static String EXTRA_DATA =
            "com.example.bluetooth.le.EXTRA_DATA";

    public final static UUID UUID_HEART_RATE_MEASUREMENT =
            UUID.fromString(SampleGattAttributes.HEART_RATE_MEASUREMENT);
    public final static UUID UUID_CSC_MEASUREMENT =
            UUID.fromString(SampleGattAttributes.CSC_MEASUREMENT);

    // Implements callback methods for GATT events that the app cares about.  For example,
    // connection change and services discovered.
    private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
        @Override
        public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
            String intentAction;
            if (newState == BluetoothProfile.STATE_CONNECTED) {
                intentAction = ACTION_GATT_CONNECTED;
                mConnectionState = STATE_CONNECTED;
                broadcastUpdate(intentAction);
                Log.i(TAG, "Connected to GATT server.");
                // Attempts to discover services after successful connection.
                Log.i(TAG, "Attempting to start service discovery:" +
                        mBluetoothGatt.discoverServices());

            } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                intentAction = ACTION_GATT_DISCONNECTED;
                mConnectionState = STATE_DISCONNECTED;
                Log.i(TAG, "Disconnected from GATT server.");
                broadcastUpdate(intentAction);
            }
        }

        @Override
        public void onServicesDiscovered(BluetoothGatt gatt, int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_GATT_SERVICES_DISCOVERED);
            } else {
                Log.w(TAG, "onServicesDiscovered received: " + status);
            }
        }

        @Override
        public void onCharacteristicRead(BluetoothGatt gatt,
                                         BluetoothGattCharacteristic characteristic,
                                         int status) {
            if (status == BluetoothGatt.GATT_SUCCESS) {
                broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
            }
        }

        @Override
        public void onCharacteristicChanged(BluetoothGatt gatt,
                                            BluetoothGattCharacteristic characteristic) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }
    };

您是否将notify或indicate设置为true如果是,则检查setCharacteristicNotification()是否返回值。并检查您是否有阅读该特征的权限。还请打印onDescripterWrite回调方法的状态值

  for notification
http://developer.android.com/guide/topics/connectivity/bluetooth-le.html#notification

descriptor call back method javadoc

http://developer.android.com/reference/android/bluetooth/BluetoothGattCallback.html#onDescriptorWrite%28android.bluetooth.BluetoothGatt,%20android.bluetooth.BluetoothGattDescriptor,%20int%29