无法连接蓝牙Welch Allyn(数字血压计)

时间:2018-10-26 16:06:15

标签: android bluetooth-lowenergy android-bluetooth bluetooth-gatt

无法将我的应用程序与Welch Allyn血压计连接。 How can i enable characteristics as per documentations

enter image description here

这些是我的回电

 private final BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
    @Override
    public void onDescriptorWrite(BluetoothGatt gatt, BluetoothGattDescriptor descriptor, int status) {
       Log.d("TAG_DESC_WR",status+"::");
        super.onDescriptorWrite(gatt, descriptor, status);
    }

    @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) {
        Log.d("TAG_CHAR_READ", " ");
        if (status == BluetoothGatt.GATT_SUCCESS) {
            broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
        }

    }

    @Override
    public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
        Log.d("TAG_BP_S", "" + status);
        Log.d("TAG_BP_M", "" + characteristic.getUuid());
        setCharacteristicNotification(characteristic.getService().getCharacteristic(UUID.fromString(SampleGattAttributes.MEASUREMENTS_BP_DEVICE_TRANSFER)), true);
        setCharacteristicNotification(characteristic.getService().getCharacteristic(UUID.fromString(SampleGattAttributes.INFO_TRANSFER_BP_DEVICE)), true);
    }

    @Override
    public void onCharacteristicChanged(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic) {
        Log.d("TAG_CHAR_CHANGE", characteristic.getUuid().toString());
        broadcastUpdate(ACTION_DATA_AVAILABLE, characteristic);
    }

    @Override
    public void onReliableWriteCompleted(BluetoothGatt gatt, int status) {
        super.onReliableWriteCompleted(gatt, status);
    }
};

这是编写通知的方法

public void setCharacteristicNotification(BluetoothGattCharacteristic characteristic, boolean enabled) {
    if (mBluetoothAdapter == null || mBluetoothGatt == null) {
        Log.w(TAG, "BluetoothAdapter not initialized");
        return;
    }
    mBluetoothGatt.setCharacteristicNotification(characteristic, enabled);
    for (BluetoothGattDescriptor descriptor : characteristic.getDescriptors()) {
        Log.d("TAG_DESC", descriptor.getUuid().toString());
        descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE);
        mBluetoothGatt.writeDescriptor(descriptor);
    }

我面临的问题是,根据文档,我正在编写一个charatic 8a81并指示两个特性8a82和8a92,但是onCharacteristicsChange中没有任何反应,我正试图从一个星期的时间开始使其与设备配对有BLE android的任何人都可以帮助我! 这是完整文档的链接。 enter link description here

0 个答案:

没有答案