Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth low energy data reading #1

Open
paxsipornax opened this issue May 26, 2021 · 2 comments
Open

Bluetooth low energy data reading #1

paxsipornax opened this issue May 26, 2021 · 2 comments

Comments

@paxsipornax
Copy link

paxsipornax commented May 26, 2021

I used the bluetooth low energy app for esp32, but I can't read data from esp32, sending data from esp32. however, the application cannot catch it. Can you help me?

@viktorvano
Copy link
Owner

First of all, you have to find out what service and characteristic UUID is used to read and write.
Then...:
In BluetoothLeService.java change your UUID:
`

public void writeCharacteristic(String input) { try { BluetoothGattService Service = mBluetoothGatt.getService(UUID.fromString("0000ffe0-0000-1000-8000-00805f9b34fb")); BluetoothGattCharacteristic charac = Service.getCharacteristic(UUID.fromString("0000ffe1-0000-1000-8000-00805f9b34fb")); charac.setValue(input); mBluetoothGatt.writeCharacteristic(charac); }catch (IllegalStateException | NullPointerException e) { Log.e(TAG, "Wrong device, does not contain service/characteristic 0000fee1-0000-1000-8000-00805f9b34fb"); } }

`

And in your DeviceControlActivuty.java also change your UUID:
`

//custom code if(uuid.equals("0000ffe1-0000-1000-8000-00805f9b34fb") && mNotifyCharacteristic == null) { mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true); mNotifyCharacteristic = gattCharacteristic; }

`

@paxsipornax
Copy link
Author

First of all, you have to find out what service and characteristic UUID is used to read and write.
Then...:
In BluetoothLeService.java change your UUID:
`

public void writeCharacteristic(String input) { try { BluetoothGattService Service = mBluetoothGatt.getService(UUID.fromString("0000ffe0-0000-1000-8000-00805f9b34fb")); BluetoothGattCharacteristic charac = Service.getCharacteristic(UUID.fromString("0000ffe1-0000-1000-8000-00805f9b34fb")); charac.setValue(input); mBluetoothGatt.writeCharacteristic(charac); }catch (IllegalStateException | NullPointerException e) { Log.e(TAG, "Wrong device, does not contain service/characteristic 0000fee1-0000-1000-8000-00805f9b34fb"); } }
`

And in your DeviceControlActivuty.java also change your UUID:
`

//custom code if(uuid.equals("0000ffe1-0000-1000-8000-00805f9b34fb") && mNotifyCharacteristic == null) { mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true); mNotifyCharacteristic = gattCharacteristic; }
`

#define SERVICE_UUID "6E400001-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_RX "6E400002-B5A3-F393-E0A9-E50E24DCCA9E"
#define CHARACTERISTIC_UUID_TX "6E400003-B5A3-F393-E0A9-E50E24DCCA9E"

BluetoothGattService Service = mBluetoothGatt.getService(UUID.fromString("6E400001-B5A3-F393-E0A9-E50E24DCCA9E"));
BluetoothGattCharacteristic charac = Service.getCharacteristic(UUID.fromString("6E400002-B5A3-F393-E0A9E50E24DCCA9E"));
charac.setValue(input);
mBluetoothGatt.writeCharacteristic(charac);
if(uuid.equals("6E400003-B5A3-F393-E0A9-E50E24DCCA9E") && mNotifyCharacteristic == null) {
mBluetoothLeService.setCharacteristicNotification(gattCharacteristic, true);
mNotifyCharacteristic = gattCharacteristic;
}

The uuids I use, the uuids I change in the application, but the reading process is happening.
Can write data to esp32 via aqq

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants