Skip to content
Snippets Groups Projects
Commit 334b7721 authored by Kihong Seong's avatar Kihong Seong Committed by Gerrit Code Review
Browse files

Merge "Throw error when notification is larger than max attribute value" into main

parents 1434d775 59c19fa4
No related branches found
No related tags found
No related merge requests found
......@@ -68,6 +68,8 @@ public final class BluetoothGattServer implements BluetoothProfile {
private List<BluetoothGattService> mServices;
private static final int CALLBACK_REG_TIMEOUT = 10000;
// Max length of an attribute value, defined in gatt_api.h
private static final int GATT_MAX_ATTR_LEN = 512;
/**
* Bluetooth GATT interface callbacks
......@@ -829,6 +831,10 @@ public final class BluetoothGattServer implements BluetoothProfile {
if (device == null) {
throw new IllegalArgumentException("device must not be null");
}
if (value.length > GATT_MAX_ATTR_LEN) {
throw new IllegalArgumentException(
"notification should not be longer than max length of an attribute value");
}
BluetoothGattService service = characteristic.getService();
if (service == null) {
throw new IllegalArgumentException("Characteristic must have a non-null service");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment