diff --git a/unit/test-gatt.c b/unit/test-gatt.c
index 7bc2168..69574b6 100644
--- a/unit/test-gatt.c
+++ b/unit/test-gatt.c
#define SECONDARY_DISC_SMALL_DB \
raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x01, 0x28), \
- raw_pdu(0x11, 0x06, 0x01, 0x00, 0x0F, 0x00, 0x0a, 0x18),\
- raw_pdu(0x10, 0x10, 0x00, 0xff, 0xff, 0x01, 0x28), \
- raw_pdu(0x01, 0x10, 0x10, 0x00, 0x0a)
+ raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x0a, 0x18),\
+ raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x01, 0x28), \
+ raw_pdu(0x01, 0x10, 0x11, 0x00, 0x0a)
+
+#define INCLUDE_DISC_SMALL_DB \
+ raw_pdu(0x08, 0x10, 0xf0, 0x17, 0xf0, 0x02, 0x28), \
+ raw_pdu(0x09, 0x08, 0x11, 0xf0, 0x01, 0x00, 0x0f, 0x00, \
+ 0x0a, 0x18), \
+ raw_pdu(0x08, 0x12, 0xf0, 0x17, 0xf0, 0x02, 0x28), \
+ raw_pdu(0x01, 0x08, 0x12, 0xf0, 0x0a), \
+ raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28), \
+ raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a)
+
+#define CHARACTERISTIC_DISC_SMALL_DB \
+ raw_pdu(0x08, 0x10, 0xf0, 0x17, 0xf0, 0x03, 0x28), \
+ raw_pdu(0x09, 0x07, 0x12, 0xf0, 0x02, 0x13, 0xf0, 0x00, \
+ 0x2a), \
+ raw_pdu(0x08, 0x13, 0xf0, 0x17, 0xf0, 0x03, 0x28), \
+ raw_pdu(0x09, 0x15, 0x14, 0xf0, 0x02, 0x15, 0xf0, 0xef, \
+ 0xcd, 0xab, 0x89, 0x67, 0x45, 0x23, 0x01, 0x00, \
+ 0x00, 0x00, 0x00, 0x09, 0xB0, 0x00, 0x00), \
+ raw_pdu(0x08, 0x15, 0xf0, 0x17, 0xf0, 0x03, 0x28), \
+ raw_pdu(0x09, 0x07, 0x16, 0xf0, 0x02, 0x17, 0xf0, 0x01, \
+ 0x2a), \
+ raw_pdu(0x08, 0x17, 0xf0, 0x17, 0xf0, 0x03, 0x28), \
+ raw_pdu(0x01, 0x08, 0x17, 0xf0, 0x0a), \
+ raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28), \
+ raw_pdu(0x09, 0x07, 0x02, 0x00, 0x12, 0x03, 0x00, 0x29, \
+ 0x2a), \
+ raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28), \
+ raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a)
+
+#define DESCRIPTOR_DISC_SMALL_DB \
+ raw_pdu(0x04, 0x04, 0x00, 0x10, 0x00), \
+ raw_pdu(0x05, 0x01, 0x04, 0x00, 0x02, 0x29, 0x05, 0x00, \
+ 0x01, 0x29), \
+ raw_pdu(0x04, 0x06, 0x00, 0x10, 0x00), \
+ raw_pdu(0x01, 0x04, 0x06, 0x00, 0x0a)
+
+#define SMALL_DB_DISCOVERY_PDUS \
+ PRIMARY_DISC_SMALL_DB, \
+ SECONDARY_DISC_SMALL_DB, \
+ INCLUDE_DISC_SMALL_DB, \
+ CHARACTERISTIC_DISC_SMALL_DB, \
+ DESCRIPTOR_DISC_SMALL_DB
+
#define SERVER_MTU_EXCHANGE_PDU raw_pdu(0x02, 0x17, 0x00)
SECONDARY_SERVICE(0x0001, DEVICE_INFORMATION_UUID, 16),
CHARACTERISTIC_STR(GATT_CHARAC_MANUFACTURER_NAME_STRING,
BT_ATT_PERM_READ,
- BT_GATT_CHRC_PROP_READ,
+ BT_GATT_CHRC_PROP_READ |
+ BT_GATT_CHRC_PROP_NOTIFY,
"BlueZ"),
- DESCRIPTOR(GATT_CLIENT_CHARAC_CFG_UUID, BT_ATT_PERM_READ, 0x00,
- 0x00),
+ DESCRIPTOR(GATT_CLIENT_CHARAC_CFG_UUID, BT_ATT_PERM_READ |
+ BT_ATT_PERM_WRITE, 0x00, 0x00),
DESCRIPTOR_STR(GATT_CHARAC_USER_DESC_UUID, BT_ATT_PERM_READ,
"Manufacturer Name"),
PRIMARY_SERVICE(0xF010, GAP_UUID, 8),
.expected_att_ecode = 0x0c
};
+static void notification_cb(uint16_t value_handle, const uint8_t *value,
+ uint16_t length, void *user_data)
+{
+ struct context *context = user_data;
+ const struct test_step *step = context->data->step;
+
+ if (value_handle == step->handle) {
+ g_assert_cmpint(length, ==, step->length);
+
+ g_assert(memcmp(value, step->value, length) == 0);
+
+ context_quit(context);
+ }
+}
+
+static void notification_register_cb(uint16_t att_ecode, void *user_data)
+{
+ g_assert(!att_ecode);
+}
+
+static void test_notification(struct context *context)
+{
+ const struct test_step *step = context->data->step;
+
+ g_assert(bt_gatt_client_register_notify(context->client, step->handle,
+ notification_register_cb,
+ notification_cb, context,
+ NULL));
+}
+
+static const struct test_step test_notification_1 = {
+ .handle = 0x0003,
+ .func = test_notification,
+ .value = read_data_1,
+ .length = 0x03,
+};
+
int main(int argc, char *argv[])
{
struct gatt_db *service_db_1, *ts_small_db, *ts_large_db_1;
ts_small_db, NULL,
raw_pdu(0x03, 0x00, 0x02),
raw_pdu(0x08, 0x01, 0x00, 0x0f, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x29,
+ raw_pdu(0x09, 0x07, 0x02, 0x00, 0x12, 0x03, 0x00, 0x29,
0x2a),
raw_pdu(0x08, 0x03, 0x00, 0x0f, 0x00, 0x03, 0x28),
raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a));
ts_small_db, NULL,
raw_pdu(0x03, 0x00, 0x02),
raw_pdu(0x08, 0x01, 0x00, 0x0f, 0x00, 0x03, 0x28),
- raw_pdu(0x09, 0x07, 0x02, 0x00, 0x02, 0x03, 0x00, 0x29,
+ raw_pdu(0x09, 0x07, 0x02, 0x00, 0x12, 0x03, 0x00, 0x29,
0x2a),
raw_pdu(0x08, 0x03, 0x00, 0x0f, 0x00, 0x03, 0x28),
raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a));
raw_pdu(0x0C, 0xF0, 0x0F, 0x00, 0x00),
raw_pdu(0x01, 0x0C, 0xF0, 0x0F, 0x01));
+ define_test_client("/TP/GAN/CL/BV-01-C", test_client, ts_small_db,
+ &test_notification_1,
+ MTU_EXCHANGE_CLIENT_PDUS,
+ SMALL_DB_DISCOVERY_PDUS,
+ raw_pdu(0x12, 0x04, 0x00, 0x01, 0x00),
+ raw_pdu(0x13),
+ raw_pdu(),
+ raw_pdu(0x1B, 0x03, 0x00, 0x01, 0x02, 0x03));
+
return g_test_run();
}