Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking with BLE Android 4.3 how to write characteristics?
    primarykey
    data
    text
    <p>I am working on a BLE project (Android application) using Android 4.3 API, i have used sample BLE app it is only reading characteristics in DeviceControlActivity.activity, but i want to write characteristics and send it to BLE chip on clicking a button. How can I write data on chip cc2540 .. Basically i don't know the step by step procedure to write characteristics. </p> <p>write i can only see the name and id of device with following piece of code in DeviceControlActivity</p> <pre><code> private final ExpandableListView.OnChildClickListener servicesListClickListner = new ExpandableListView.OnChildClickListener() { @Override public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) { if (mGattCharacteristics != null) { final BluetoothGattCharacteristic characteristic = mGattCharacteristics.get(groupPosition).get(childPosition); final int charaProp = characteristic.getProperties(); if ((charaProp | BluetoothGattCharacteristic.PROPERTY_READ) &gt; 0) { // If there is an active notification on a characteristic, clear // it first so it doesn't update the data field on the user interface. if (mNotifyCharacteristic != null) { mBluetoothLeService.setCharacteristicNotification( mNotifyCharacteristic, false); mNotifyCharacteristic = null; } mBluetoothLeService.readCharacteristic(characteristic); showDialog("reading"); } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_WRITE) &gt; 0) { // If there is an active notification on a characteristic, clear // it first so it doesn't update the data field on the user interface. if (mNotifyCharacteristic != null) { mBluetoothLeService.setCharacteristicNotification( mNotifyCharacteristic, false); mNotifyCharacteristic = null; } mBluetoothLeService.writeCharacteristic(characteristic); showDialog("writing"); //characteristic.setValue(bytes); //characteristic.setValue("testing"); //characteristic.setWriteType(BluetoothGattCharacteristic.PERMISSION_WRITE); } if ((charaProp | BluetoothGattCharacteristic.PROPERTY_NOTIFY) &gt; 0) { mNotifyCharacteristic = characteristic; mBluetoothLeService.setCharacteristicNotification( characteristic, true); } byte[] value = {0x00, (byte) (0xB9) , 0x0D, (byte) (0x90), 0x2F}; if(!characteristic.setValue(value)) { Log.w(TAG, "Couldn't set characteristic's local value"); //return; } characteristic.setWriteType(BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE); /*if(!writeCharacteristic.writeCharacteristic(characteristic)) { Log.w(TAG, "Couldn't write characteristic"); }*/ return true; } return false; } }; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload