0

I am developing an app for humidity sensor. the sensor will send data to the app continuously every second. I need to show it on multiple textviews with an update every second.

Currently, My receiving part code is

@Override
public void onCharacteristicRead(BluetoothGatt gatt,
    BluetoothGattCharacteristic characteristic, int status) {
    if (status == BluetoothGatt.GATT_SUCCESS) if (BleUuid.READ_TIME
        .equalsIgnoreCase(characteristic.getUuid().toString())) {
        final String names = characteristic.getStringValue(0);
        Textview1.setText(names);
    }
}
kgangadhar
  • 4,886
  • 5
  • 36
  • 54
Mr Robot
  • 1,747
  • 6
  • 35
  • 67
  • There's an [Android Open Source Project](https://github.com/googlesamples/android-BluetoothLeGatt) example that show how to get data from a BLE device, that will be easier if you start with this ! – Fakher Jul 30 '15 at 13:34
  • my code is based on that sample. but it doesn't shows how to receive data continuously in android app. – Mr Robot Jul 31 '15 at 04:37
  • what's the version of android do you test on ?? you should use 5.0.1 or above cuz the method onCharacteristicChange doesn't fire in previous version of android so you can't get data continuously !! – Fakher Jul 31 '15 at 08:44
  • no. mine is Moto E android 4.4.4. with ble support. – Mr Robot Jul 31 '15 at 10:41
  • Okay.then is there any way to send some uuids continuous after small time interval and receive the data for each uuid(bcos we can send only 1 uuid at a time. if we send more , last uuid will be receive at the ble.) – Mr Robot Jul 31 '15 at 10:44
  • i tried using 'for loop' to send readcharacteristics .but it also the phone reads only one reading. – Mr Robot Jul 31 '15 at 10:46
  • you must implement a method to do reading, and then call it periodically (don't forget to add a wait () after each call) and you should try to debug on a 5.0.1 device! using debugging may show you some problems that you didn't know about them ;) – Fakher Aug 01 '15 at 11:11

0 Answers0