Невозможно подключить Bluetooth Welch Allyn (цифровой тонометр) - PullRequest
0 голосов
/ 26 октября 2018

Невозможно подключить мое приложение к монитору артериального давления Уэлча Аллина.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);
    }

Что ж, проблема, с которой я сталкиваюсь, заключается в том, что согласно документации я пишу характер 8a81 и указываю две характеристики 8a82 и 8a92, но в onCharacteristicsChange ничего не происходит, я пытаюсь от недели кСделайте это в паре с устройством любого, кто имеет опыт работы с BLE android HELP ME OUT!Это ссылка на полную документацию. введите описание ссылки здесь

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...