Android BLE onCharacteristicChanged не вызывается - PullRequest
0 голосов
/ 04 апреля 2020

У меня есть следующие характеристики c Я хочу наблюдать, как только обнаружил

override fun onServicesDiscovered(gatt: BluetoothGatt?, status: Int) {
    super.onServicesDiscovered(gatt, status)

    if (gatt != null)
        for (bluetoothService: BluetoothGattService in gatt.services)
            for (bluetoothGattChar: BluetoothGattCharacteristic in bluetoothService.characteristics)
                when (bluetoothGattChar.uuid.toString()) {
                    GATT_REQ_UUID -> {
                        d("CellGattCallback", "GATT REQ UUID found")
                        requestCharacteristic = bluetoothGattChar
                    }
                    GATT_RESP_UUID -> {
                        d("CellGattCallback", "GATT RESP UUID found")
                        responseCharacteristic = bluetoothGattChar

                        bluetoothGattChar.descriptors[0].value = ENABLE_NOTIFICATION_VALUE
                        val writeStatus = gatt.writeDescriptor(bluetoothGattChar.descriptors[0])
                        val notifyStatus = gatt.setCharacteristicNotification(bluetoothGattChar, true)

                        d("CellGattCallback", "GATT RESP CHAR Write: $writeStatus")
                        d("CellGattCallback", "GATT RESP CHAR  Notify: $notifyStatus")
                    }
                }
}

И статус записи и уведомления возвращают true. При этом я никогда не уведомляюсь о характерных изменениях. Что я делаю неправильно?

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