You are not logged in.

#1 Re: Any Questions » Can I send sensor value to smart phone via BLE? » 2016-12-05 03:59:22

Hi admin,

Thank you for reply. But, cc debugger is required to customize BLE113 firmware right?

#2 Any Questions » Can I send sensor value to smart phone via BLE? » 2016-12-02 15:52:08

tk35
Replies: 6

Hi Guvalif,

I'm trying to send sensor's data to my android app via BLE, but is it possible?

In PLEN's firmware:

void loop()
{
    if (PLEN2::System::BLESerial().available())
    {
        PLEN2::System::BLESerial().write("From Plen");
    }
}

And in android, i tried to read value of BLE_SHIELD_RX (BLE_SHIELD_TX return error)

 if (isConnected) {
            BluetoothGattService bluetoothGattService = gatt.getService(UUID.fromString(GATTAttributes.BLE_SHIELD_SERVICE));
            if (bluetoothGattService == null) {
                Log.e(TAG, "Can't get a BluetoothGattService");
                return false;
            }
            BluetoothGattCharacteristic characteristic = bluetoothGattService.getCharacteristic(UUID.fromString(GATTAttributes.BLE_SHIELD_RX));
            if (characteristic == null) {
                Log.e(TAG, "Can't get a BluetoothGattCharacteristic");
                return false;
            }
            gatt.readCharacteristic(characteristic); //return true
}

but in onCharacteristicRead, result is an array of 0. So i tried:

 if (isConnected) {
            BluetoothGattService bluetoothGattService = gatt.getService(UUID.fromString(GATTAttributes.BLE_SHIELD_SERVICE));
            if (bluetoothGattService == null) {
                Log.e(TAG, "Can't get a BluetoothGattService");
                return false;
            }
            BluetoothGattCharacteristic characteristic = bluetoothGattService.getCharacteristic(UUID.fromString(GATTAttributes.BLE_SHIELD_RX));
            if (characteristic == null) {
                Log.e(TAG, "Can't get a BluetoothGattCharacteristic");
                return false;
            }
            gatt.setCharacteristicNotification(characteristic, true);
            BluetoothGattDescriptor descriptor = characteristic.getDescriptor(UUID.fromString(GATTAttributes.CLIENT_CHARACTERISTIC_CONFIG));
            descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
            gatt.writeDescriptor(descriptor); //return true and onWriteDescriptor is called
}

but onCharacteristicChanged not called.

Am i miss something? Thank you!

Board footer

Powered by FluxBB