summaryrefslogtreecommitdiff
path: root/android/tester-main.c
diff options
context:
space:
mode:
authorMarcin Kraglak <marcin.kraglak@tieto.com>2014-10-02 14:34:07 +0200
committerSzymon Janc <szymon.janc@tieto.com>2014-10-02 15:25:16 +0200
commitc9889f54f063c251eae575a36ec271834c4578c0 (patch)
tree985dc91043ebb59c4edc0278227a4c058c7822fd /android/tester-main.c
parentee83025c5e7639d93e8332c3528d1f531c4024f0 (diff)
downloadbluez-c9889f54f063c251eae575a36ec271834c4578c0.tar.gz
android/tester: Add support for GATT Notification in tester
Service register_for_notification and notification callbacks.
Diffstat (limited to 'android/tester-main.c')
-rw-r--r--android/tester-main.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/android/tester-main.c b/android/tester-main.c
index 5517973c4..fe452f841 100644
--- a/android/tester-main.c
+++ b/android/tester-main.c
@@ -718,6 +718,21 @@ static bool match_data(struct step *step)
tester_debug("Gatt write_param doesn't match");
return false;
}
+
+ if (exp->callback_result.notification_registered !=
+ step->callback_result.notification_registered) {
+ tester_debug("Gatt registered flag mismatch");
+ return false;
+ }
+
+ if (exp->callback_result.notify_params) {
+ if (memcmp(step->callback_result.notify_params,
+ exp->callback_result.notify_params,
+ sizeof(btgatt_notify_params_t))) {
+ tester_debug("Gatt notify_param doesn't match");
+ return false;
+ }
+ }
}
return true;
@@ -820,6 +835,9 @@ static void destroy_callback_step(void *data)
if (step->callback_result.write_params)
free(step->callback_result.write_params);
+ if (step->callback_result.notify_params)
+ free(step->callback_result.notify_params);
+
g_free(step);
g_atomic_int_dec_and_test(&scheduled_cbacks_num);
}
@@ -1360,6 +1378,35 @@ static void gattc_write_descriptor_cb(int conn_id, int status,
schedule_callback_call(step);
}
+static void gattc_register_for_notification_cb(int conn_id, int registered,
+ int status,
+ btgatt_srvc_id_t *srvc_id,
+ btgatt_gatt_id_t *char_id)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_GATTC_REGISTER_FOR_NOTIFICATION;
+ step->callback_result.status = status;
+ step->callback_result.conn_id = conn_id;
+ step->callback_result.service = g_memdup(srvc_id, sizeof(*srvc_id));
+ step->callback_result.characteristic = g_memdup(char_id,
+ sizeof(*char_id));
+ step->callback_result.notification_registered = registered;
+
+ schedule_callback_call(step);
+}
+
+static void gattc_notif_cb(int conn_id, btgatt_notify_params_t *p_data)
+{
+ struct step *step = g_new0(struct step, 1);
+
+ step->callback = CB_GATTC_NOTIFY;
+ step->callback_result.conn_id = conn_id;
+ step->callback_result.notify_params = g_memdup(p_data, sizeof(*p_data));
+
+ schedule_callback_call(step);
+}
+
static void gatts_register_server_cb(int status, int server_if,
bt_uuid_t *app_uuid)
{
@@ -1481,8 +1528,8 @@ static const btgatt_client_callbacks_t btgatt_client_callbacks = {
.get_characteristic_cb = gattc_get_characteristic_cb,
.get_descriptor_cb = gattc_get_descriptor_cb,
.get_included_service_cb = gattc_get_included_service_cb,
- .register_for_notification_cb = NULL,
- .notify_cb = NULL,
+ .register_for_notification_cb = gattc_register_for_notification_cb,
+ .notify_cb = gattc_notif_cb,
.read_characteristic_cb = gattc_read_characteristic_cb,
.write_characteristic_cb = gattc_write_characteristic_cb,
.read_descriptor_cb = gattc_read_descriptor_cb,