2016-06-09 19 views
0

Bluegiga BLE113 모듈과 Android 앱이 포함 된 프로젝트에서 작업하고 있습니다. Bluegiga 모듈에서는 몇 가지 특성을 설정했습니다. 한 특성에 대해 clie enter code here NT 알림을 활성화하는 설명자를 정의했습니다 (내 경우 클라이언트는 Android 앱 임). BLE113 모듈의 특성 정의는 다음과 같습니다Android BLE onCharacteristicChanged()가 호출되지 않았습니다.

나는 안드로이드 블루투스 로우 에너지 가이드에 따라 onServicesDiscovered (...) 콜백 내에서 알림을 설정 한 안드로이드 측면에서
<characteristic uuid="dcfa2671-974d-4e4a-96cd-6221afeabb62"  id="ez1_flow_data_out"> 
    <!-- org.bluetooth.descriptor.gatt.characteristic_user_description --> 
    <description>Data to transmit to Android device</description> 
    <properties write="true" read="true" /> 
    <value variable_length="true" length="255" type="hex" /> 
    <!-- org.bluetooth.descriptor.gatt.client_characteristic_configuration --> 
    <descriptor uuid="2902"> 
    <properties write="true" read="true" const="false" /> 
    <!-- Bit 0 = 1: Notifications enabled --> 
    <value type="hex">0001</value> 
    </descriptor> 


    </characteristic> 

:

characteristic=gatt.getService(BLEuuids.DATAFLOW_SERVICE).getCharacteristic(BLEuuids.DATAFLOW_OUT_CHARACT); 
//Enable local notifications 
gatt.setCharacteristicNotification(characteristic, true); 
//Enabled remote notifications 
BluetoothGattDescriptor desc = characteristic.getDescriptor(BLEuuids.DATAFLOW_OUT_DESCRIPT); 
boolean test; 
test = desc.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); // return value = true 
test = gatt.readDescriptor(desc); // return value = true 
test = gatt.writeDescriptor(desc); // return value = true 

그러나 Bluegiga 모듈의 직렬 인터페이스를 사용하여 DATAFLOW_OUT_CHARACT 특성 UUID의 값을 변경하면 내 Android 앱에서 의도 한 콜백 onCharacteristicChanged (...)가 실행되지 않습니다.

설명자를 올바르게 설정했거나 안드로이드 코드에서 오류가 있습니까?

답변

0

지금 등록 ENABLE_NOTIFICATION_VALUE 및 ENABLE_INDICATION_VALUE

Log.d(TAG, "setCharacteristicNotification"); 
     if (mBluetoothAdapter == null || customBluetoothGatt == null) { 
      Log.d(TAG, "BluetoothAdapter not initialized"); 
      return; 
     }cx 
     customBluetoothGatt.setCharacteristicNotification(characteristic, enabled); 

     BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(SampleGattAttributes.CLIENT_CHARACTERISTIC_CONFIG)); 
     descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE); 
     descriptor.setValue(BluetoothGattDescriptor.ENABLE_INDICATION_VALUE); 
     boolean success = customBluetoothGatt.writeDescriptor(descriptor); 
을 onCharactersticsChanged을 (콜백) 및 설정 알림을 사용
관련 문제