문제
여러 Bluetooth LE 장치 (심박수 모니터)를 Android 장치에 연결하려고합니다. 스캔하고 연결할 수 있습니다. 그것들은 단지 괜찮 았습니다. 단지 알림을 출력 할 때 센서의 데이터 사이를 점프합니다.Bluetooth LE를 통해 여러 장치를 Android 장치에 연결하려고 시도했습니다.
기본적으로이 프로젝트의 대부분은 this GitHub 소스 코드를 사용했습니다. 프로젝트에서 그들은 하나의 서비스 (BluetoothLeService)를 사용합니다. 내 프로젝트에서는 하나의 사용자에 대해 하나의 핸들을 처리하고 다른 사용자에게는 다른 하나를 처리하는 것을 제외하고는 두 개의 서비스를 만들었습니다.
나는 콘솔에이 출력을 받고 있어요 :
07-27 21 : 14 : 01.786 9062-9062/com.example.android.aware의 D/BluetoothGatt : setCharacteristicNotification() - UUID : 00002a37 -0000-1000-8000-00805f9b34fb 사용 : true
07-27 21 : 14 : 01.786 9062-9062/com.example.android.aware D/BluetoothLeService2 : 연결에 기존 mBluetoothGatt를 사용하려고합니다. 이 오류는 BLS2에서 발생합니다.
07-27 21 : 14 : 01.796 9062-10009/com.example.android.aware D/BluetoothGatt : onClientConnectionState() - status = 133 clientIf = 7 device = E3 : 64 : 43 : 37 : D2 : AA
07-27 21 : 14 : 01.796 9062-10009/com.example.android.aware I/BluetoothLeService2 : GATT 서버와의 연결이 끊어졌습니다. 14 :
07-27 21 01.796 9062-9062/com.example.android.aware의 D/BluetoothGatt : setCharacteristicNotification() - UUID는 : 인 에이블 00002a37-0000-1000-8000-00805f9b34fb : 참
07 -27 21 : 14 : 01.816 9062-9062/com.example.android.aware D/BluetoothLeService : 연결에 기존 mBluetoothGatt를 사용하려고합니다. 이 오류는 BLS1에서 발생합니다.
07-27 21 : 14 : 01.826 9062-10009/com.example.android.aware D/BluetoothGatt : onClientConnectionState() - status = 133 clientIf = 6 device = 00 : 22 : D0 : 41 : CA : B6
07-27 21 : 14 : 01.826 9062-10009/com.example.android.aware I/BluetoothLeService : GATT 서버와의 연결이 끊어졌습니다.
시도 나는 새로운 CLIENT_CHARACTERISTIC_CONFIG를 추가하려고했습니다
는 SampleGattAttributes 클래스의 문자열 (이 CLIENT_CHARACTERISTIC_CONFIG2라고도 함),이에서 (다음 코드 조각에서 재생 온다 서비스 클래스) :
BluetoothGattDescriptor descriptor = characteristic
.getDescriptor(UUID
.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG));
콘솔과 마찬가지로이 문제는 mBluetoothGatt (BluetoothGatt 유형 객체)라는 두 서비스의 변수와 관련이 있다고 생각합니다. 내 생각은 다음과 같습니다 :
두 개의 서비스가 동 기적으로 실행되는 경우 각각에 두 개의 서로 다른 BluetoothGatt 개체를 만드는 경우 왜 동일한 BluetoothGatt 개체가 사용된다고 들었습니까?
실제로 두 장치를 독립적으로 처리 할 수 있어야한다고 생각 하겠지만, 신뢰할 수있는 유일한 방법은 여러 주변 장치의 코드를 동기화하여 단일 시스템에 대한 단일 요청 만 제공한다는 것입니다. 한 번에 주변 장치. 시작이 고통스럽게 느려집니다. – Ifor