This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
I have posted this a few times - with no response - I am able to turn on Keypress, get battery level etc but not able to turn on the acceleromter on Keyfob CC2541 using Android. Can somebody review the code and let me know what may be incorrect.
I have replicating what I believe the BLE device monitor is doing...Thanks.
private static final UUID ACCEL_SERVICE_UUID = UUID.fromString("0000FFA0-0000-1000-8000-00805f9b34fb"); private static final UUID ACCEL_ENABLE_UUID = UUID.fromString("0000FFA1-0000-1000-8000-00805f9b34fb"); private static final UUID X_ENABLE_UUID = UUID.fromString("0000FFA3-0000-1000-8000-00805f9b34fb"); private static final UUID X_ENABLE_UUID_DESC = UUID.fromString("00002902-0000-1000-8000-00805f9b34fb"); public void EnableAccel(boolean enable) { if(mBluetoothGatt != null) return; BluetoothGattService keyService = mBluetoothGatt.getService(ACCEL_SERVICE_UUID); if(keyService == null) { Log.d(TAG, "Acceleration service not found!"); return; } BluetoothGattCharacteristic enableAcceleration = keyService.getCharacteristic(ACCEL_ENABLE_UUID); if(enableAcceleration == null) { Log.d(TAG, "Acceleration Enable charateristic not found!"); return; } setCharacteristicNotification(enableAcceleration, enable); BluetoothGattCharacteristic enableX = keyService.getCharacteristic(X_ENABLE_UUID); if(enableX == null) { Log.e(TAG, "Enable X charateristic not found!"); } else { BluetoothGattDescriptor gatDesc = enableX.getDescriptor(X_ENABLE_UUID_DESC); if(gatDesc == null) { Log.e(TAG, "Enable X BluetoothGattDescriptor not found!"); return; } setDescriptorNotification(gatDesc, enable); } } public void setDescriptorNotification(BluetoothGattDescriptor descriptor, boolean enabled) { Log.i(TAG, "setDescriptorNotification " + descriptor.getUuid().toString()); byte[] val = enabled ? BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE : BluetoothGattDescriptor.DISABLE_NOTIFICATION_VALUE; descriptor.setValue(val); mBluetoothGatt.writeDescriptor(descriptor); }