Upgrade bluez5_37 :Merge the code from private
[platform/upstream/bluez.git] / android / tester-gatt.c
1 /*
2  * Copyright (C) 2014 Intel Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 #include <stdbool.h>
19
20 #include "emulator/bthost.h"
21 #include "lib/bluetooth.h"
22 #include "src/shared/util.h"
23 #include "src/shared/tester.h"
24 #include "src/shared/queue.h"
25 #include "tester-main.h"
26
27 #define ATT_HANDLE_SIZE 2
28
29 #define L2CAP_ATT_ERROR                 0x01
30 #define L2CAP_ATT_EXCHANGE_MTU_REQ      0x02
31 #define L2CAP_ATT_EXCHANGE_MTU_RSP      0x03
32 #define L2CAP_ATT_FIND_BY_TYPE_REQ      0x06
33 #define L2CAP_ATT_READ_REQ              0x0a
34 #define L2CAP_ATT_READ_RSP              0x0b
35 #define L2CAP_ATT_WRITE_REQ             0x12
36 #define L2CAP_ATT_WRITE_RSP             0x13
37 #define L2CAP_ATT_HANDLE_VALUE_NOTIFY   0x1b
38 #define L2CAP_ATT_HANDLE_VALUE_IND      0x1d
39
40 #define GATT_STATUS_SUCCESS     0x00000000
41 #define GATT_STATUS_FAILURE     0x00000101
42 #define GATT_STATUS_INS_AUTH    0x08
43
44 #define GATT_ERR_INVAL_ATTR_VALUE_LEN   0x0D
45
46 #define GATT_SERVER_DISCONNECTED        0
47 #define GATT_SERVER_CONNECTED           1
48
49 #define APP1_ID 1
50 #define APP2_ID 2
51
52 #define CONN1_ID        1
53 #define CONN2_ID        2
54
55 #define TRANS1_ID       1
56
57 #define BT_TRANSPORT_UNKNOWN            0x00
58
59 #define GATT_SERVER_TRANSPORT_LE                0x01
60 #define GATT_SERVER_TRANSPORT_BREDR             0x02
61 #define GATT_SERVER_TRANSPORT_LE_BREDR          (0x01 | 0x02)
62
63 #define GATT_WRITE_TYPE_NO_RESPONSE     0x01
64 #define GATT_WRITE_TYPE_DEFAULT         0x02
65 #define GATT_WRITE_TYPE_PREPARE         0x03
66 #define GATT_WRITE_TYPE_SIGNED          0x04
67
68 #define CHAR_PROP_BROADCAST                     0x01
69 #define CHAR_PROP_READ                          0x02
70 #define CHAR_PROP_WRITE_WITHOUT_RESPONSE        0x04
71 #define CHAR_PROP_WRITE                         0x08
72 #define CHAR_PROP_NOTIFY                        0x10
73 #define CHAR_PROP_INDICATE                      0x20
74 #define CHAR_PROP_AUTHENTICATED_SIGNED_WRITES   0x40
75 #define CHAR_PROP_EXTENDED_PROPERTIES           0x80
76
77 #define CHAR_PERM_READ                  0x0001
78 #define CHAR_PERM_READ_ENCRYPTED        0x0002
79 #define CHAR_PERM_READ_ENCRYPTED_MITM   0x0004
80 #define CHAR_PERM_WRITE                 0x0010
81 #define CHAR_PERM_WRITE_ENCRYPTED       0x0020
82 #define CHAR_PERM_WRITE_ENCRYPTED_MITM  0x0040
83 #define CHAR_PERM_WRITE_SIGNED          0x0080
84 #define CHAR_PERM_WRITE_SIGNED_MITM     0x0100
85
86 static struct queue *list; /* List of gatt test cases */
87
88 static uint16_t srvc1_handle;
89 static uint16_t inc_srvc1_handle;
90 static uint16_t char1_handle;
91
92 static struct iovec char1_handle_v = {
93         .iov_base = &char1_handle,
94         .iov_len = sizeof(char1_handle),
95 };
96
97 struct set_att_data {
98         char *to;
99         char *from;
100         int len;
101 };
102
103 struct att_write_req_data {
104         uint16_t *attr_handle;
105         uint8_t *value;
106 };
107
108 static bt_uuid_t app1_uuid = {
109         .uu = { 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
110                                 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01 },
111 };
112
113 static bt_uuid_t app2_uuid = {
114         .uu = { 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
115                                 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02 },
116 };
117
118 static uint8_t value_1[] = {0x01};
119
120 static uint8_t att_write_req_value_1[] = {0x00, 0x01, 0x02, 0x03};
121 static struct iovec att_write_req_value_1_v = {
122         .iov_base = att_write_req_value_1,
123         .iov_len = sizeof(att_write_req_value_1),
124 };
125
126 struct gatt_connect_data {
127         const int app_id;
128         const int conn_id;
129 };
130
131 struct gatt_search_service_data {
132         const int conn_id;
133         bt_uuid_t *filter_uuid;
134 };
135
136 struct get_char_data {
137         const int conn_id;
138         btgatt_srvc_id_t *service;
139 };
140
141 struct get_desc_data {
142         const int conn_id;
143         btgatt_srvc_id_t *service;
144         btgatt_gatt_id_t *characteristic;
145         btgatt_gatt_id_t *desc;
146 };
147
148 struct get_incl_data {
149         const int conn_id;
150         btgatt_srvc_id_t *service;
151         btgatt_srvc_id_t *start_service;
152 };
153
154 struct read_char_data {
155         const int conn_id;
156         btgatt_srvc_id_t *service;
157         btgatt_gatt_id_t *characteristic;
158         int auth_req;
159 };
160
161 struct read_desc_data {
162         const int conn_id;
163         btgatt_srvc_id_t *service;
164         btgatt_gatt_id_t *characteristic;
165         btgatt_gatt_id_t *descriptor;
166         int auth_req;
167 };
168
169 struct write_char_data {
170         int conn_id;
171         btgatt_srvc_id_t *service;
172         btgatt_gatt_id_t *characteristic;
173         int write_type;
174         int len;
175         int auth_req;
176         char *p_value;
177 };
178
179 struct write_desc_data {
180         int conn_id;
181         btgatt_srvc_id_t *service;
182         btgatt_gatt_id_t *characteristic;
183         btgatt_gatt_id_t *descriptor;
184         int write_type;
185         int len;
186         int auth_req;
187         char *p_value;
188 };
189
190 struct notif_data {
191         int conn_id;
192         const bt_bdaddr_t *bdaddr;
193         btgatt_srvc_id_t *service;
194         btgatt_gatt_id_t *charac;
195 };
196
197 struct add_service_data {
198         int app_id;
199         btgatt_srvc_id_t *service;
200         int num_handles;
201 };
202
203 struct add_included_service_data {
204         int app_id;
205         uint16_t *inc_srvc_handle;
206         uint16_t *srvc_handle;
207 };
208 struct add_char_data {
209         int app_id;
210         uint16_t *srvc_handle;
211         bt_uuid_t *uuid;
212         int properties;
213         int permissions;
214 };
215
216 struct add_desc_data {
217         int app_id;
218         uint16_t *srvc_handle;
219         bt_uuid_t *uuid;
220         int permissions;
221 };
222
223 struct start_srvc_data {
224         int app_id;
225         uint16_t *srvc_handle;
226         int transport;
227 };
228
229 struct stop_srvc_data {
230         int app_id;
231         uint16_t *srvc_handle;
232 };
233
234 struct delete_srvc_data {
235         int app_id;
236         uint16_t *srvc_handle;
237 };
238
239 struct send_indication_data {
240         int app_id;
241         uint16_t *attr_handle;
242         int conn_id;
243         int len;
244         int confirm;
245         char *p_value;
246 };
247
248 struct send_resp_data {
249         int conn_id;
250         int trans_id;
251         int status;
252         btgatt_response_t *response;
253 };
254
255 static bt_bdaddr_t emu_remote_bdaddr_val = {
256         .address = { 0x00, 0xaa, 0x01, 0x01, 0x00, 0x00 },
257 };
258 static bt_device_type_t emu_remote_ble_device_type = BT_DEVICE_DEVTYPE_BLE;
259
260 static bt_property_t prop_emu_remotes_default_set[] = {
261         { BT_PROPERTY_BDADDR, sizeof(emu_remote_bdaddr_val),
262                                                 &emu_remote_bdaddr_val },
263 };
264 static bt_property_t prop_emu_remotes_default_le_set[] = {
265         { BT_PROPERTY_BDADDR, sizeof(emu_remote_bdaddr_val),
266                                                 &emu_remote_bdaddr_val },
267         { BT_PROPERTY_TYPE_OF_DEVICE, sizeof(bt_device_type_t),
268                                                 &emu_remote_ble_device_type },
269 };
270
271 static struct bt_action_data prop_test_remote_ble_bdaddr_req = {
272         .addr = &emu_remote_bdaddr_val,
273         .prop_type = BT_PROPERTY_BDADDR,
274         .prop = &prop_emu_remotes_default_set[0],
275 };
276
277 static bt_scan_mode_t setprop_scan_mode_conn_val =
278                                         BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE;
279
280 static bt_property_t prop_test_scan_mode_conn = {
281         .type = BT_PROPERTY_ADAPTER_SCAN_MODE,
282         .val = &setprop_scan_mode_conn_val,
283         .len = sizeof(setprop_scan_mode_conn_val),
284 };
285
286 static struct emu_l2cap_cid_data cid_data;
287
288 static struct gatt_connect_data app1_conn_req = {
289         .app_id = APP1_ID,
290         .conn_id = CONN1_ID,
291 };
292
293 static struct gatt_connect_data app1_conn2_req = {
294         .app_id = APP1_ID,
295         .conn_id = CONN2_ID,
296 };
297
298 static struct gatt_connect_data app2_conn_req = {
299         .app_id = APP2_ID,
300         .conn_id = CONN2_ID,
301 };
302
303 static struct gatt_search_service_data search_services_1 = {
304         .conn_id = CONN1_ID,
305         .filter_uuid = NULL,
306 };
307
308 static const struct iovec exchange_mtu_req_pdu = raw_pdu(0x02, 0xa0, 0x02);
309 static const struct iovec exchange_mtu_resp_pdu = raw_pdu(0x03, 0xa0, 0x02);
310
311 static struct bt_action_data bearer_type = {
312         .bearer_type = BDADDR_LE_PUBLIC,
313 };
314
315 static btgatt_srvc_id_t service_1 = {
316         .is_primary = true,
317         .id = {
318                 .inst_id = 0,
319                 .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
320                         0x00, 0x10, 0x00, 0x00,  0x00, 0x18, 0x00, 0x00}
321         }
322 };
323
324 static btgatt_srvc_id_t service_2 = {
325         .is_primary = true,
326         .id = {
327                 .inst_id = 1,
328                 .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
329                         0x00, 0x10, 0x00, 0x00,  0x01, 0x18, 0x00, 0x00},
330         }
331 };
332
333 static btgatt_srvc_id_t service_add_1 = {
334         .is_primary = true,
335         .id = {
336                 .inst_id = 0,
337                 .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
338                         0x00, 0x10, 0x00, 0x00, 0xFF, 0xEF, 0x00, 0x00},
339         }
340 };
341
342 static btgatt_srvc_id_t service_add_2 = {
343         .is_primary = true,
344         .id = {
345                 .inst_id = 1,
346                 .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
347                         0x00, 0x10, 0x00, 0x00, 0xFF, 0xDF, 0x00, 0x00},
348         }
349 };
350
351 static btgatt_srvc_id_t service_add_3 = {
352         .is_primary = true,
353         .id = {
354                 .inst_id = 2,
355                 .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
356                         0x00, 0x10, 0x00, 0x00, 0xFF, 0xCF, 0x00, 0x00},
357         }
358 };
359
360 static btgatt_srvc_id_t included_1 = {
361         .is_primary = false,
362         .id = {
363                 .inst_id = 1,
364                 .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
365                         0x00, 0x10, 0x00, 0x00,  0xff, 0xfe, 0x00, 0x00},
366         }
367 };
368
369 static btgatt_srvc_id_t included_2 = {
370         .is_primary = false,
371         .id = {
372                 .inst_id = 1,
373                 .uuid.uu = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
374                                 0x08, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10},
375         }
376 };
377
378 static btgatt_gatt_id_t characteristic_1 = {
379         .inst_id = 1,
380         .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
381                         0x00, 0x10, 0x00, 0x00,  0x19, 0x00, 0x00, 0x00}
382 };
383
384 static btgatt_gatt_id_t desc_1 = {
385         .inst_id = 1,
386         .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
387                         0x00, 0x10, 0x00, 0x00,  0x00, 0x29, 0x00, 0x00}
388 };
389
390 static btgatt_gatt_id_t desc_2 = {
391         .inst_id = 2,
392         .uuid.uu = {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
393                         0x00, 0x10, 0x00, 0x00,  0x01, 0x29, 0x00, 0x00}
394 };
395
396 static btgatt_read_params_t read_params_1;
397 static btgatt_write_params_t write_params_1;
398 static btgatt_notify_params_t notify_params_1;
399
400 static struct get_char_data get_char_data_1 = {
401         .conn_id = CONN1_ID,
402         .service = &service_1
403 };
404
405 static struct get_char_data get_char_data_2 = {
406         .conn_id = CONN1_ID,
407         .service = &service_2
408 };
409
410 static struct get_desc_data get_desc_data_1 = {
411         .conn_id = CONN1_ID,
412         .service = &service_1,
413         .characteristic = &characteristic_1,
414 };
415
416 static struct get_desc_data get_desc_data_2 = {
417         .conn_id = CONN1_ID,
418         .service = &service_1,
419         .characteristic = &characteristic_1,
420         .desc = &desc_1,
421 };
422
423 static struct read_char_data read_char_data_1 = {
424         .conn_id = CONN1_ID,
425         .service = &service_1,
426         .characteristic = &characteristic_1,
427 };
428
429 static struct read_char_data read_char_data_2 = {
430         .conn_id = CONN1_ID,
431         .service = &service_2,
432         .characteristic = &characteristic_1,
433 };
434
435 static struct read_desc_data read_desc_data_1 = {
436         .conn_id = CONN1_ID,
437         .service = &service_1,
438         .characteristic = &characteristic_1,
439         .descriptor = &desc_1,
440 };
441
442 static struct read_desc_data read_desc_data_2 = {
443         .conn_id = CONN1_ID,
444         .service = &service_1,
445         .characteristic = &characteristic_1,
446         .descriptor = &desc_2,
447 };
448
449 static struct get_incl_data get_incl_data_1 = {
450         .conn_id = CONN1_ID,
451         .service = &service_1
452 };
453
454 static char value_2[] = {0x00, 0x01, 0x02, 0x03};
455
456 static struct write_char_data write_char_data_1 = {
457         .conn_id = CONN1_ID,
458         .service = &service_1,
459         .characteristic = &characteristic_1,
460         .write_type = GATT_WRITE_TYPE_NO_RESPONSE,
461         .len = sizeof(value_2),
462         .p_value = value_2,
463         .auth_req = 0
464 };
465
466 static struct write_char_data write_char_data_2 = {
467         .conn_id = CONN1_ID,
468         .service = &service_1,
469         .characteristic = &characteristic_1,
470         .write_type = GATT_WRITE_TYPE_DEFAULT,
471         .len = sizeof(value_2),
472         .p_value = value_2,
473         .auth_req = 0
474 };
475
476 static struct write_desc_data write_desc_data_1 = {
477         .conn_id = CONN1_ID,
478         .service = &service_1,
479         .characteristic = &characteristic_1,
480         .descriptor = &desc_1,
481         .write_type = 2,
482         .len = sizeof(value_2),
483         .auth_req = 0,
484         .p_value = value_2,
485 };
486
487 static struct write_desc_data write_desc_data_2 = {
488         .conn_id = CONN1_ID,
489         .service = &service_1,
490         .characteristic = &characteristic_1,
491         .descriptor = &desc_2,
492         .write_type = 2,
493         .len = sizeof(value_2),
494         .auth_req = 0,
495         .p_value = value_2,
496 };
497
498 static struct notif_data notif_data_1 = {
499         .conn_id = CONN1_ID,
500         .service = &service_1,
501         .charac = &characteristic_1,
502         .bdaddr = &emu_remote_bdaddr_val,
503 };
504
505 static struct add_service_data add_service_data_1 = {
506         .app_id = APP1_ID,
507         .service = &service_add_1,
508         .num_handles = 1
509 };
510
511 static struct add_service_data add_service_data_2 = {
512         .app_id = APP1_ID,
513         .service = &service_add_2,
514         .num_handles = 1
515 };
516
517 static struct add_service_data add_service_data_3 = {
518         .app_id = APP1_ID,
519         .service = &service_add_3,
520         .num_handles = 1
521 };
522
523 static struct add_service_data add_service_data_4 = {
524         .app_id = APP1_ID,
525         .service = &service_add_1,
526         .num_handles = 2
527 };
528
529 static struct add_service_data add_service_data_5 = {
530         .app_id = APP1_ID,
531         .service = &service_add_1,
532         .num_handles = 3
533 };
534
535 static struct add_service_data add_service_data_6 = {
536         .app_id = APP1_ID,
537         .service = &service_add_1,
538         .num_handles = 4
539 };
540
541 static struct add_service_data add_bad_service_data_1 = {
542         .app_id = APP1_ID,
543         .service = &service_add_1,
544         .num_handles = 0
545 };
546
547 static struct add_service_data add_sec_service_data_1 = {
548         .app_id = APP1_ID,
549         .service = &included_1,
550         .num_handles = 1
551 };
552
553 static uint16_t srvc_bad_handle = 0xffff;
554
555 static struct add_included_service_data add_inc_service_data_1 = {
556         .app_id = APP1_ID,
557         .inc_srvc_handle = &inc_srvc1_handle,
558         .srvc_handle = &srvc1_handle
559 };
560
561 static struct add_included_service_data add_bad_inc_service_data_1 = {
562         .app_id = APP1_ID,
563         .inc_srvc_handle = &srvc_bad_handle,
564         .srvc_handle = &srvc1_handle
565 };
566
567 static struct add_char_data add_char_data_1 = {
568         .app_id = APP1_ID,
569         .srvc_handle = &srvc1_handle,
570         .uuid = &app1_uuid,
571         .properties = 0,
572         .permissions = 0
573 };
574
575 static struct add_char_data add_char_data_2 = {
576         .app_id = APP1_ID,
577         .srvc_handle = &srvc1_handle,
578         .uuid = &app1_uuid,
579         .properties = CHAR_PROP_WRITE,
580         .permissions = CHAR_PERM_WRITE
581 };
582
583 static struct add_char_data add_bad_char_data_1 = {
584         .app_id = APP1_ID,
585         .srvc_handle = &srvc_bad_handle,
586         .uuid = &app1_uuid,
587         .properties = 0,
588         .permissions = 0
589 };
590
591 static struct add_desc_data add_bad_desc_data_1 = {
592         .app_id = APP1_ID,
593         .srvc_handle = &srvc_bad_handle,
594         .uuid = &app2_uuid,
595         .permissions = 0
596 };
597
598 static struct add_desc_data add_bad_desc_data_2 = {
599         .app_id = APP2_ID,
600         .srvc_handle = &srvc1_handle,
601         .uuid = &app2_uuid,
602         .permissions = 0
603 };
604
605 static struct add_desc_data add_desc_data_1 = {
606         .app_id = APP1_ID,
607         .srvc_handle = &srvc1_handle,
608         .uuid = &app2_uuid,
609         .permissions = 0
610 };
611
612 static struct start_srvc_data start_srvc_data_1 = {
613         .app_id = APP1_ID,
614         .srvc_handle = &srvc1_handle,
615         .transport = GATT_SERVER_TRANSPORT_LE_BREDR
616 };
617
618 static struct start_srvc_data start_srvc_data_2 = {
619         .app_id = APP1_ID,
620         .srvc_handle = &srvc1_handle,
621         .transport = GATT_SERVER_TRANSPORT_LE
622 };
623
624 static struct start_srvc_data start_bad_srvc_data_1 = {
625         .app_id = APP1_ID,
626         .srvc_handle = &srvc_bad_handle,
627         .transport = GATT_SERVER_TRANSPORT_LE
628 };
629
630 static struct start_srvc_data start_bad_srvc_data_2 = {
631         .app_id = APP1_ID,
632         .srvc_handle = &srvc1_handle,
633         .transport = 0
634 };
635
636 static struct stop_srvc_data stop_srvc_data_1 = {
637         .app_id = APP1_ID,
638         .srvc_handle = &srvc1_handle
639 };
640
641 static struct stop_srvc_data stop_bad_srvc_data_1 = {
642         .app_id = APP1_ID,
643         .srvc_handle = &srvc_bad_handle
644 };
645
646 static struct delete_srvc_data delete_srvc_data_1 = {
647         .app_id = APP1_ID,
648         .srvc_handle = &srvc1_handle
649 };
650
651 static struct delete_srvc_data delete_bad_srvc_data_1 = {
652         .app_id = APP1_ID,
653         .srvc_handle = &srvc_bad_handle
654 };
655
656 static uint16_t srvc_indication_handle_1 = 0x01;
657
658 static struct send_indication_data send_indication_data_1 = {
659         .app_id = APP1_ID,
660         .attr_handle = &srvc_indication_handle_1,
661         .conn_id = CONN1_ID,
662         .len = sizeof(value_2),
663         .p_value = value_2,
664         .confirm = 1
665 };
666
667 static struct send_indication_data send_indication_data_2 = {
668         .app_id = APP1_ID,
669         .attr_handle = &srvc_indication_handle_1,
670         .conn_id = CONN1_ID,
671         .len = sizeof(value_2),
672         .p_value = value_2,
673         .confirm = 0
674 };
675
676 static struct send_indication_data send_bad_indication_data_1 = {
677         .app_id = APP1_ID,
678         .attr_handle = &srvc_indication_handle_1,
679         .conn_id = CONN2_ID,
680         .len = sizeof(value_2),
681         .p_value = value_2,
682         .confirm = 0
683 };
684
685 struct set_read_params {
686         btgatt_read_params_t *params;
687         btgatt_srvc_id_t *srvc_id;
688         btgatt_gatt_id_t *char_id;
689         btgatt_gatt_id_t *descr_id;
690         uint8_t *value;
691         uint16_t len;
692         uint16_t value_type;
693         uint8_t status;
694 };
695
696 struct set_write_params {
697         btgatt_write_params_t *params;
698         btgatt_srvc_id_t *srvc_id;
699         btgatt_gatt_id_t *char_id;
700         btgatt_gatt_id_t *descr_id;
701         uint8_t status;
702 };
703
704 struct set_notify_params {
705         btgatt_notify_params_t *params;
706         uint8_t *value;
707         uint16_t len;
708         uint8_t is_notify;
709         btgatt_srvc_id_t *srvc_id;
710         btgatt_gatt_id_t *char_id;
711         bt_bdaddr_t *bdaddr;
712 };
713
714 static struct set_read_params set_read_param_1 = {
715         .params = &read_params_1,
716         .srvc_id = &service_1,
717         .char_id = &characteristic_1,
718         .value = value_1,
719         .len = sizeof(value_1),
720         .status = BT_STATUS_SUCCESS
721 };
722
723 static struct set_read_params set_read_param_2 = {
724         .params = &read_params_1,
725         .srvc_id = &service_1,
726         .char_id = &characteristic_1,
727         .status = GATT_STATUS_INS_AUTH
728 };
729
730 static struct set_read_params set_read_param_3 = {
731         .params = &read_params_1,
732         .srvc_id = &service_2,
733         .char_id = &characteristic_1,
734         .status = BT_STATUS_FAIL
735 };
736
737 static struct set_read_params set_read_param_4 = {
738         .params = &read_params_1,
739         .srvc_id = &service_1,
740         .char_id = &characteristic_1,
741         .descr_id = &desc_1,
742         .value = value_1,
743         .len = sizeof(value_1),
744         .status = BT_STATUS_SUCCESS
745 };
746
747 static struct set_read_params set_read_param_5 = {
748         .params = &read_params_1,
749         .srvc_id = &service_1,
750         .char_id = &characteristic_1,
751         .descr_id = &desc_1,
752         .status = GATT_STATUS_INS_AUTH
753 };
754
755 static struct set_read_params set_read_param_6 = {
756         .params = &read_params_1,
757         .srvc_id = &service_1,
758         .char_id = &characteristic_1,
759         .descr_id = &desc_2,
760         .status = BT_STATUS_FAIL
761 };
762
763 static struct set_write_params set_write_param_1 = {
764         .params = &write_params_1,
765         .srvc_id = &service_1,
766         .char_id = &characteristic_1,
767         .status = BT_STATUS_SUCCESS
768 };
769
770 static struct set_write_params set_write_param_2 = {
771         .params = &write_params_1,
772         .srvc_id = &service_1,
773         .char_id = &characteristic_1,
774         .status = GATT_STATUS_INS_AUTH
775 };
776
777 static struct set_write_params set_write_param_3 = {
778         .params = &write_params_1,
779         .srvc_id = &service_1,
780         .char_id = &characteristic_1,
781         .status = BT_STATUS_FAIL
782 };
783
784 static struct set_write_params set_write_param_4 = {
785         .params = &write_params_1,
786         .srvc_id = &service_1,
787         .char_id = &characteristic_1,
788         .descr_id = &desc_1,
789         .status = BT_STATUS_SUCCESS
790 };
791
792 static struct set_write_params set_write_param_5 = {
793         .params = &write_params_1,
794         .srvc_id = &service_1,
795         .char_id = &characteristic_1,
796         .descr_id = &desc_2,
797         .status = BT_STATUS_FAIL
798 };
799
800 static struct set_write_params set_write_param_6 = {
801         .params = &write_params_1,
802         .srvc_id = &service_1,
803         .char_id = &characteristic_1,
804         .descr_id = &desc_1,
805         .status = GATT_STATUS_INS_AUTH
806 };
807
808 static struct set_notify_params set_notify_param_1 = {
809         .params = &notify_params_1,
810         .value = value_1,
811         .len = sizeof(value_1),
812         .is_notify = 0,
813         .srvc_id = &service_1,
814         .char_id = &characteristic_1,
815         .bdaddr = &emu_remote_bdaddr_val
816 };
817
818 static struct set_notify_params set_notify_param_2 = {
819         .params = &notify_params_1,
820         .value = value_1,
821         .len = sizeof(value_1),
822         .is_notify = 1,
823         .srvc_id = &service_1,
824         .char_id = &characteristic_1,
825         .bdaddr = &emu_remote_bdaddr_val
826 };
827
828 static btgatt_response_t response_1 = {
829         .handle = 0x1c,
830         .attr_value.auth_req = 0,
831         .attr_value.handle = 0x1d,
832         .attr_value.len = 0,
833         .attr_value.offset = 0,
834 };
835
836 static btgatt_response_t response_2 = {
837         .handle = 0x1c,
838         .attr_value.auth_req = 0,
839         .attr_value.handle = 0x1d,
840         .attr_value.len = sizeof(att_write_req_value_1),
841         .attr_value.offset = 0,
842 };
843
844 static struct send_resp_data send_resp_data_1 = {
845         .conn_id = CONN1_ID,
846         .trans_id = TRANS1_ID,
847         .status = BT_STATUS_SUCCESS,
848         .response = &response_1,
849 };
850
851 static struct send_resp_data send_resp_data_2 = {
852         .conn_id = CONN1_ID,
853         .trans_id = TRANS1_ID,
854         .status = BT_STATUS_SUCCESS,
855         .response = &response_2,
856 };
857
858 static struct send_resp_data send_resp_data_2_error = {
859         .conn_id = CONN1_ID,
860         .trans_id = TRANS1_ID,
861         .status = GATT_ERR_INVAL_ATTR_VALUE_LEN,
862         .response = &response_2,
863 };
864
865 #define SEARCH_SERVICE_SINGLE_SUCCESS_PDUS                              \
866         raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),              \
867         raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),        \
868         raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),              \
869         raw_pdu(0x01, 0x10, 0x11, 0x00, 0x0a)
870
871 #define READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS                         \
872         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),              \
873         raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),  \
874         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),              \
875         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a)
876
877 static struct iovec search_service[] = {
878         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
879         end_pdu
880 };
881
882 static struct iovec search_service_2[] = {
883         raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
884         raw_pdu(0x11, 0x06, 0x01, 0x00, 0x10, 0x00, 0x00, 0x18),
885         raw_pdu(0x10, 0x11, 0x00, 0xff, 0xff, 0x00, 0x28),
886         raw_pdu(0x11, 0x06, 0x11, 0x00, 0x20, 0x00, 0x01, 0x18),
887         raw_pdu(0x10, 0x21, 0x00, 0xff, 0xff, 0x00, 0x28),
888         raw_pdu(0x01, 0x10, 0x21, 0x00, 0x0a),
889         end_pdu
890 };
891
892 static struct iovec search_service_3[] = {
893         raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
894         raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
895         end_pdu
896 };
897
898 static struct iovec search_service_4[] = {
899         raw_pdu(0x10, 0x01, 0x00, 0xff, 0xff, 0x00, 0x28),
900         raw_pdu(0x11, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x18),
901         end_pdu
902 };
903
904 static struct iovec get_characteristic_1[] = {
905         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
906         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
907         end_pdu
908 };
909
910 static struct iovec get_characteristic_2[] = {
911         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
912         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
913         raw_pdu(0x09, 0x07, 0x00, 0x00, 0x04, 0x00, 0x00, 0x19, 0x00),
914         end_pdu
915 };
916
917 static struct iovec get_descriptor_0[] = {
918         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
919         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
920         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
921         raw_pdu(0x05, 0x01, 0x00, 0x00, 0x00, 0x29),
922         end_pdu
923 };
924
925 static struct iovec get_descriptor_1[] = {
926         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
927         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
928         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
929         raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29),
930         raw_pdu(0x04, 0x05, 0x00, 0x10, 0x00),
931         raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
932         end_pdu
933 };
934
935 static struct iovec get_descriptor_2[] = {
936         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
937         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
938         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
939         raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29, 0x05, 0x00, 0x01, 0x29),
940         raw_pdu(0x04, 0x06, 0x00, 0x10, 0x00),
941         raw_pdu(0x01, 0x04, 0x06, 0x00, 0x0a),
942         end_pdu
943 };
944
945 static struct iovec get_descriptor_3[] = {
946         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
947         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
948         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
949         raw_pdu(0x01, 0x04, 0x01, 0x00, 0x0a),
950         end_pdu
951 };
952
953 static struct iovec get_included_0[] = {
954         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
955         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
956         raw_pdu(0x09, 0x08, 0x00, 0x00, 0x15, 0x00, 0x19, 0x00, 0xff, 0xfe),
957         end_pdu
958 };
959
960 static struct iovec get_included_1[] = {
961         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
962         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
963         raw_pdu(0x09, 0x08, 0x02, 0x00, 0x15, 0x00, 0x19, 0x00, 0xff, 0xfe),
964         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x02, 0x28),
965         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
966         end_pdu
967 };
968
969 static struct iovec get_included_2[] = {
970         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
971         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
972         raw_pdu(0x09, 0x06, 0x02, 0x00, 0x15, 0x00, 0x19, 0x00),
973         raw_pdu(0x0a, 0x15, 0x00),
974         raw_pdu(0x0b, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08,
975                                 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, 0x10),
976         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x02, 0x28),
977         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
978         end_pdu
979 };
980
981 static struct iovec get_included_3[] = {
982         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
983         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x02, 0x28),
984         raw_pdu(0x01, 0x08, 0x01, 0x00, 0x0a),
985         end_pdu
986 };
987
988 static struct iovec read_characteristic_1[] = {
989         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
990         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
991         raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
992         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
993         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
994         raw_pdu(0x0a, 0x03, 0x00),
995         raw_pdu(0x0b, 0x01),
996         end_pdu
997 };
998
999 static struct iovec read_characteristic_2[] = {
1000         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1001         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
1002         raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
1003         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
1004         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
1005         raw_pdu(0x0a, 0x03, 0x00),
1006         raw_pdu(0x01, 0x0a, 0x03, 0x00, 0x08),
1007         end_pdu
1008 };
1009
1010 static struct iovec read_descriptor_1[] = {
1011         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1012         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1013         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
1014         raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29),
1015         raw_pdu(0x04, 0x05, 0x00, 0x10, 0x00),
1016         raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
1017         raw_pdu(0x0a, 0x04, 0x00),
1018         raw_pdu(0x0b, 0x01),
1019         end_pdu
1020 };
1021
1022 static struct iovec read_descriptor_2[] = {
1023         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1024         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1025         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
1026         raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29),
1027         raw_pdu(0x04, 0x05, 0x00, 0x10, 0x00),
1028         raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
1029         raw_pdu(0x0a, 0x04, 0x00),
1030         raw_pdu(0x01, 0x0a, 0x04, 0x00, 0x08),
1031         end_pdu
1032 };
1033
1034 static struct iovec write_characteristic_1[] = {
1035         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1036         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
1037         raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
1038         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
1039         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
1040         raw_pdu(0x52, 0x03, 0x00, 0x00, 0x01, 0x02, 0x03),
1041         end_pdu
1042 };
1043
1044 static struct iovec write_characteristic_2[] = {
1045         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1046         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
1047         raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
1048         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
1049         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
1050         raw_pdu(0x12, 0x03, 0x00, 0x00, 0x01, 0x02, 0x03),
1051         raw_pdu(0x13),
1052         end_pdu
1053 };
1054
1055 static struct iovec write_characteristic_3[] = {
1056         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1057         raw_pdu(0x08, 0x01, 0x00, 0x10, 0x00, 0x03, 0x28),
1058         raw_pdu(0x09, 0x07, 0x02, 0x00, 0x04, 0x03, 0x00, 0x19, 0x00),
1059         raw_pdu(0x08, 0x03, 0x00, 0x10, 0x00, 0x03, 0x28),
1060         raw_pdu(0x01, 0x08, 0x03, 0x00, 0x0a),
1061         raw_pdu(0x12, 0x03, 0x00, 0x00, 0x01, 0x02, 0x03),
1062         raw_pdu(0x01, 0x12, 0x03, 0x00, 0x08),
1063         end_pdu
1064 };
1065
1066 static struct iovec write_descriptor_1[] = {
1067         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1068         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1069         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
1070         raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29),
1071         raw_pdu(0x04, 0x05, 0x00, 0x10, 0x00),
1072         raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
1073         raw_pdu(0x12, 0x04, 0x00, 0x00, 0x01, 0x02, 0x03),
1074         raw_pdu(0x13),
1075         end_pdu
1076 };
1077
1078 static struct iovec write_descriptor_2[] = {
1079         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1080         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1081         raw_pdu(0x04, 0x01, 0x00, 0x10, 0x00),
1082         raw_pdu(0x05, 0x01, 0x04, 0x00, 0x00, 0x29),
1083         raw_pdu(0x04, 0x05, 0x00, 0x10, 0x00),
1084         raw_pdu(0x01, 0x04, 0x05, 0x00, 0x0a),
1085         raw_pdu(0x12, 0x04, 0x00, 0x00, 0x01, 0x02, 0x03),
1086         raw_pdu(0x01, 0x12, 0x04, 0x00, 0x08),
1087         end_pdu
1088 };
1089
1090 static struct iovec notification_1[] = {
1091         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1092         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1093         end_pdu
1094 };
1095
1096 static struct iovec notification_2[] = {
1097         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1098         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1099         raw_pdu(0x1d, 0x03, 0x00, 0x01),
1100         raw_pdu(0x1e),
1101         end_pdu
1102 };
1103
1104 static struct iovec notification_3[] = {
1105         SEARCH_SERVICE_SINGLE_SUCCESS_PDUS,
1106         READ_BY_TYPE_SINGLE_CHARACTERISTIC_PDUS,
1107         raw_pdu(0x1b, 0x03, 0x00, 0x01),
1108         end_pdu
1109 };
1110
1111 static struct iovec send_indication_1[] = {
1112         raw_pdu(0x1d, 0x01, 0x00, 0x00, 0x01, 0x02, 0x03),
1113         raw_pdu(0x1e),
1114         end_pdu
1115 };
1116
1117 static struct iovec send_notification_1[] = {
1118         raw_pdu(0x1b, 0x01, 0x00, 0x00, 0x01, 0x02, 0x03),
1119         end_pdu
1120 };
1121
1122 static struct iovec search_range_1[] = {
1123         raw_pdu(0x01, 0xff, 0xff, 0xff),
1124         end_pdu
1125 };
1126
1127 static struct iovec primary_type = raw_pdu(0x00, 0x28);
1128
1129 /* att commands define raw pdus */
1130 static struct iovec att_read_req_op_v = raw_pdu(L2CAP_ATT_READ_REQ);
1131 static struct iovec att_write_req_op_v = raw_pdu(L2CAP_ATT_WRITE_REQ);
1132 static struct iovec att_find_by_type_req_op_v =
1133                                         raw_pdu(L2CAP_ATT_FIND_BY_TYPE_REQ);
1134
1135 static struct iovec svc_change_ccc_handle_v = raw_pdu(0x1c, 0x00);
1136 static struct iovec svc_change_ccc_value_v = raw_pdu(0x00, 0x01);
1137
1138 static void gatt_client_register_action(void)
1139 {
1140         struct test_data *data = tester_get_data();
1141         struct step *current_data_step = queue_peek_head(data->steps);
1142         bt_uuid_t *app_uuid = current_data_step->set_data;
1143         struct step *step = g_new0(struct step, 1);
1144
1145         if (!app_uuid) {
1146                 tester_warn("No app uuid provided for register action.");
1147                 return;
1148         }
1149
1150         step->action_status = data->if_gatt->client->register_client(app_uuid);
1151
1152         schedule_action_verification(step);
1153 }
1154
1155 static void gatt_client_unregister_action(void)
1156 {
1157         struct test_data *data = tester_get_data();
1158         struct step *current_data_step = queue_peek_head(data->steps);
1159         int32_t cl_id = PTR_TO_INT(current_data_step->set_data);
1160         struct step *step = g_new0(struct step, 1);
1161
1162         step->action_status = data->if_gatt->client->unregister_client(cl_id);
1163
1164         schedule_action_verification(step);
1165 }
1166
1167 static void gatt_client_start_scan_action(void)
1168 {
1169         struct test_data *data = tester_get_data();
1170         struct step *step = g_new0(struct step, 1);
1171
1172         step->action_status = data->if_gatt->client->scan(TRUE);
1173
1174         schedule_action_verification(step);
1175 }
1176
1177 static void gatt_client_stop_scan_action(void)
1178 {
1179         struct test_data *data = tester_get_data();
1180         struct step *step = g_new0(struct step, 1);
1181
1182         step->action_status = data->if_gatt->client->scan(FALSE);
1183
1184         schedule_action_verification(step);
1185 }
1186
1187 static void gatt_client_connect_action(void)
1188 {
1189         struct test_data *data = tester_get_data();
1190         struct step *current_data_step = queue_peek_head(data->steps);
1191         struct gatt_connect_data *conn_data = current_data_step->set_data;
1192         struct step *step = g_new0(struct step, 1);
1193
1194         step->action_status = data->if_gatt->client->connect(
1195                                                 conn_data->app_id,
1196                                                 &emu_remote_bdaddr_val, 0,
1197                                                 BT_TRANSPORT_UNKNOWN);
1198
1199         schedule_action_verification(step);
1200 }
1201
1202 static void gatt_client_disconnect_action(void)
1203 {
1204         struct test_data *data = tester_get_data();
1205         struct step *current_data_step = queue_peek_head(data->steps);
1206         struct gatt_connect_data *conn_data = current_data_step->set_data;
1207         struct step *step = g_new0(struct step, 1);
1208
1209         step->action_status = data->if_gatt->client->disconnect(
1210                                                         conn_data->app_id,
1211                                                         &emu_remote_bdaddr_val,
1212                                                         conn_data->conn_id);
1213
1214         schedule_action_verification(step);
1215 }
1216
1217 static void gatt_client_do_listen_action(void)
1218 {
1219         struct test_data *data = tester_get_data();
1220         struct step *current_data_step = queue_peek_head(data->steps);
1221         struct gatt_connect_data *conn_data = current_data_step->set_data;
1222         struct step *step = g_new0(struct step, 1);
1223
1224         step->action_status = data->if_gatt->client->listen(
1225                                                         conn_data->app_id,
1226                                                         1);
1227
1228         schedule_action_verification(step);
1229 }
1230
1231 static void gatt_client_stop_listen_action(void)
1232 {
1233         struct test_data *data = tester_get_data();
1234         struct step *current_data_step = queue_peek_head(data->steps);
1235         struct gatt_connect_data *conn_data = current_data_step->set_data;
1236         struct step *step = g_new0(struct step, 1);
1237
1238         step->action_status = data->if_gatt->client->listen(
1239                                                         conn_data->app_id,
1240                                                         0);
1241
1242         schedule_action_verification(step);
1243 }
1244
1245 static void gatt_client_get_characteristic_action(void)
1246 {
1247         struct test_data *data = tester_get_data();
1248         struct step *current_data_step = queue_peek_head(data->steps);
1249         struct get_char_data *get_char = current_data_step->set_data;
1250         const btgatt_client_interface_t *client = data->if_gatt->client;
1251         struct step *step = g_new0(struct step, 1);
1252         int status;
1253
1254         status = client->get_characteristic(get_char->conn_id,
1255                                                 get_char->service, NULL);
1256         step->action_status = status;
1257
1258         schedule_action_verification(step);
1259 }
1260
1261 static void gatt_client_get_descriptor_action(void)
1262 {
1263         struct test_data *data = tester_get_data();
1264         struct step *current_data_step = queue_peek_head(data->steps);
1265         struct get_desc_data *get_desc = current_data_step->set_data;
1266         const btgatt_client_interface_t *client = data->if_gatt->client;
1267         struct step *step = g_new0(struct step, 1);
1268         int status;
1269
1270         status = client->get_descriptor(get_desc->conn_id, get_desc->service,
1271                                                 get_desc->characteristic,
1272                                                 get_desc->desc);
1273         step->action_status = status;
1274
1275         schedule_action_verification(step);
1276 }
1277
1278 static void gatt_client_get_included_action(void)
1279 {
1280         struct test_data *data = tester_get_data();
1281         struct step *current_data_step = queue_peek_head(data->steps);
1282         struct get_incl_data *get_incl = current_data_step->set_data;
1283         const btgatt_client_interface_t *client = data->if_gatt->client;
1284         struct step *step = g_new0(struct step, 1);
1285         int status;
1286
1287         status = client->get_included_service(get_incl->conn_id,
1288                                 get_incl->service, get_incl->start_service);
1289
1290         step->action_status = status;
1291
1292         schedule_action_verification(step);
1293 }
1294
1295 static void gatt_client_read_characteristic_action(void)
1296 {
1297         struct test_data *data = tester_get_data();
1298         struct step *current_data_step = queue_peek_head(data->steps);
1299         struct read_char_data *read_char_data = current_data_step->set_data;
1300         const btgatt_client_interface_t *client = data->if_gatt->client;
1301         struct step *step = g_new0(struct step, 1);
1302         int status;
1303
1304         status = client->read_characteristic(read_char_data->conn_id,
1305                         read_char_data->service, read_char_data->characteristic,
1306                         read_char_data->auth_req);
1307
1308         step->action_status = status;
1309
1310         schedule_action_verification(step);
1311 }
1312
1313 static void gatt_client_read_descriptor_action(void)
1314 {
1315         struct test_data *data = tester_get_data();
1316         struct step *current_data_step = queue_peek_head(data->steps);
1317         struct read_desc_data *read_desc_data = current_data_step->set_data;
1318         const btgatt_client_interface_t *client = data->if_gatt->client;
1319         struct step *step = g_new0(struct step, 1);
1320         int status;
1321
1322         status = client->read_descriptor(read_desc_data->conn_id,
1323                         read_desc_data->service, read_desc_data->characteristic,
1324                         read_desc_data->descriptor,
1325                         read_desc_data->auth_req);
1326
1327         step->action_status = status;
1328
1329         schedule_action_verification(step);
1330 }
1331
1332 static void gatt_client_write_characteristic_action(void)
1333 {
1334         struct test_data *data = tester_get_data();
1335         struct step *current_data_step = queue_peek_head(data->steps);
1336         struct write_char_data *write_char_data = current_data_step->set_data;
1337         const btgatt_client_interface_t *client = data->if_gatt->client;
1338         struct step *step = g_new0(struct step, 1);
1339         int status;
1340
1341         status = client->write_characteristic(write_char_data->conn_id,
1342                                                 write_char_data->service,
1343                                                 write_char_data->characteristic,
1344                                                 write_char_data->write_type,
1345                                                 write_char_data->len,
1346                                                 write_char_data->auth_req,
1347                                                 write_char_data->p_value);
1348
1349         step->action_status = status;
1350
1351         schedule_action_verification(step);
1352 }
1353
1354 static void gatt_client_register_for_notification_action(void)
1355 {
1356         struct test_data *data = tester_get_data();
1357         struct step *current_data_step = queue_peek_head(data->steps);
1358         struct notif_data *notif_data = current_data_step->set_data;
1359         const btgatt_client_interface_t *client = data->if_gatt->client;
1360         struct step *step = g_new0(struct step, 1);
1361         int status;
1362
1363         status = client->register_for_notification(notif_data->conn_id,
1364                                                         notif_data->bdaddr,
1365                                                         notif_data->service,
1366                                                         notif_data->charac);
1367         step->action_status = status;
1368
1369         schedule_action_verification(step);
1370 }
1371
1372 static void gatt_client_deregister_for_notification_action(void)
1373 {
1374         struct test_data *data = tester_get_data();
1375         struct step *current_data_step = queue_peek_head(data->steps);
1376         struct notif_data *notif_data = current_data_step->set_data;
1377         const btgatt_client_interface_t *client = data->if_gatt->client;
1378         struct step *step = g_new0(struct step, 1);
1379         int status;
1380
1381         status = client->deregister_for_notification(notif_data->conn_id,
1382                                                         notif_data->bdaddr,
1383                                                         notif_data->service,
1384                                                         notif_data->charac);
1385         step->action_status = status;
1386
1387         schedule_action_verification(step);
1388 }
1389
1390 static void gatt_server_register_action(void)
1391 {
1392         struct test_data *data = tester_get_data();
1393         struct step *current_data_step = queue_peek_head(data->steps);
1394         bt_uuid_t *app_uuid = current_data_step->set_data;
1395         struct step *step = g_new0(struct step, 1);
1396
1397         if (!app_uuid) {
1398                 tester_warn("No app uuid provided for register action.");
1399                 return;
1400         }
1401
1402         step->action_status = data->if_gatt->server->register_server(app_uuid);
1403
1404         schedule_action_verification(step);
1405 }
1406
1407 static void gatt_server_unregister_action(void)
1408 {
1409         struct test_data *data = tester_get_data();
1410         struct step *current_data_step = queue_peek_head(data->steps);
1411         int32_t sr_id = PTR_TO_INT(current_data_step->set_data);
1412         struct step *step = g_new0(struct step, 1);
1413
1414         step->action_status = data->if_gatt->server->unregister_server(sr_id);
1415
1416         schedule_action_verification(step);
1417 }
1418
1419 static void gatt_server_connect_action(void)
1420 {
1421         struct test_data *data = tester_get_data();
1422         struct step *current_data_step = queue_peek_head(data->steps);
1423         struct gatt_connect_data *conn_data = current_data_step->set_data;
1424         struct step *step = g_new0(struct step, 1);
1425
1426         step->action_status = data->if_gatt->server->connect(
1427                                                 conn_data->app_id,
1428                                                 &emu_remote_bdaddr_val, 0,
1429                                                 BT_TRANSPORT_UNKNOWN);
1430
1431         schedule_action_verification(step);
1432 }
1433
1434 static void gatt_server_disconnect_action(void)
1435 {
1436         struct test_data *data = tester_get_data();
1437         struct step *current_data_step = queue_peek_head(data->steps);
1438         struct gatt_connect_data *conn_data = current_data_step->set_data;
1439         struct step *step = g_new0(struct step, 1);
1440
1441         step->action_status = data->if_gatt->server->disconnect(
1442                                                         conn_data->app_id,
1443                                                         &emu_remote_bdaddr_val,
1444                                                         conn_data->conn_id);
1445
1446         schedule_action_verification(step);
1447 }
1448
1449 static void gatt_server_add_service_action(void)
1450 {
1451         struct test_data *data = tester_get_data();
1452         struct step *current_data_step = queue_peek_head(data->steps);
1453         struct add_service_data *add_srvc_data = current_data_step->set_data;
1454         struct step *step = g_new0(struct step, 1);
1455
1456         step->action_status = data->if_gatt->server->add_service(
1457                                                 add_srvc_data->app_id,
1458                                                 add_srvc_data->service,
1459                                                 add_srvc_data->num_handles);
1460
1461         schedule_action_verification(step);
1462 }
1463
1464 static void gatt_server_add_inc_service_action(void)
1465 {
1466         struct test_data *data = tester_get_data();
1467         struct step *current_data_step = queue_peek_head(data->steps);
1468         struct add_included_service_data *add_inc_srvc_data =
1469                                                 current_data_step->set_data;
1470         struct step *step = g_new0(struct step, 1);
1471
1472         step->action_status = data->if_gatt->server->add_included_service(
1473                                         add_inc_srvc_data->app_id,
1474                                         *add_inc_srvc_data->srvc_handle,
1475                                         *add_inc_srvc_data->inc_srvc_handle);
1476
1477         schedule_action_verification(step);
1478 }
1479
1480 static void gatt_server_add_char_action(void)
1481 {
1482         struct test_data *data = tester_get_data();
1483         struct step *current_data_step = queue_peek_head(data->steps);
1484         struct add_char_data *add_char_data = current_data_step->set_data;
1485         struct step *step = g_new0(struct step, 1);
1486
1487         step->action_status = data->if_gatt->server->add_characteristic(
1488                                                 add_char_data->app_id,
1489                                                 *add_char_data->srvc_handle,
1490                                                 add_char_data->uuid,
1491                                                 add_char_data->properties,
1492                                                 add_char_data->permissions);
1493
1494         schedule_action_verification(step);
1495 }
1496
1497 static void gatt_server_add_desc_action(void)
1498 {
1499         struct test_data *data = tester_get_data();
1500         struct step *current_data_step = queue_peek_head(data->steps);
1501         struct add_desc_data *add_desc_data = current_data_step->set_data;
1502         struct step *step = g_new0(struct step, 1);
1503
1504         step->action_status = data->if_gatt->server->add_descriptor(
1505                                                 add_desc_data->app_id,
1506                                                 *add_desc_data->srvc_handle,
1507                                                 add_desc_data->uuid,
1508                                                 add_desc_data->permissions);
1509
1510         schedule_action_verification(step);
1511 }
1512
1513 static void gatt_client_write_descriptor_action(void)
1514 {
1515         struct test_data *data = tester_get_data();
1516         struct step *current_data_step = queue_peek_head(data->steps);
1517         struct write_desc_data *write_desc_data = current_data_step->set_data;
1518         const btgatt_client_interface_t *client = data->if_gatt->client;
1519         struct step *step = g_new0(struct step, 1);
1520         int status;
1521
1522         status = client->write_descriptor(write_desc_data->conn_id,
1523                                                 write_desc_data->service,
1524                                                 write_desc_data->characteristic,
1525                                                 write_desc_data->descriptor,
1526                                                 write_desc_data->write_type,
1527                                                 write_desc_data->len,
1528                                                 write_desc_data->auth_req,
1529                                                 write_desc_data->p_value);
1530
1531         step->action_status = status;
1532
1533         schedule_action_verification(step);
1534 }
1535
1536 static void gatt_server_start_srvc_action(void)
1537 {
1538         struct test_data *data = tester_get_data();
1539         struct step *current_data_step = queue_peek_head(data->steps);
1540         struct start_srvc_data *start_srvc_data = current_data_step->set_data;
1541         struct step *step = g_new0(struct step, 1);
1542
1543         step->action_status = data->if_gatt->server->start_service(
1544                                                 start_srvc_data->app_id,
1545                                                 *start_srvc_data->srvc_handle,
1546                                                 start_srvc_data->transport);
1547
1548         schedule_action_verification(step);
1549 }
1550
1551 static void gatt_server_stop_srvc_action(void)
1552 {
1553         struct test_data *data = tester_get_data();
1554         struct step *current_data_step = queue_peek_head(data->steps);
1555         struct stop_srvc_data *stop_srvc_data = current_data_step->set_data;
1556         struct step *step = g_new0(struct step, 1);
1557
1558         step->action_status = data->if_gatt->server->stop_service(
1559                                                 stop_srvc_data->app_id,
1560                                                 *stop_srvc_data->srvc_handle);
1561
1562         schedule_action_verification(step);
1563 }
1564
1565 static void gatt_server_delete_srvc_action(void)
1566 {
1567         struct test_data *data = tester_get_data();
1568         struct step *current_data_step = queue_peek_head(data->steps);
1569         struct delete_srvc_data *delete_srvc_data = current_data_step->set_data;
1570         struct step *step = g_new0(struct step, 1);
1571
1572         step->action_status = data->if_gatt->server->delete_service(
1573                                                 delete_srvc_data->app_id,
1574                                                 *delete_srvc_data->srvc_handle);
1575
1576         schedule_action_verification(step);
1577 }
1578
1579 static void gatt_server_send_indication_action(void)
1580 {
1581         struct test_data *data = tester_get_data();
1582         struct step *current_data_step = queue_peek_head(data->steps);
1583         struct send_indication_data *send_indication_data =
1584                                                 current_data_step->set_data;
1585         struct step *step = g_new0(struct step, 1);
1586
1587         step->action_status = data->if_gatt->server->send_indication(
1588                                         send_indication_data->app_id,
1589                                         *send_indication_data->attr_handle,
1590                                         send_indication_data->conn_id,
1591                                         send_indication_data->len,
1592                                         send_indication_data->confirm,
1593                                         send_indication_data->p_value);
1594
1595         schedule_action_verification(step);
1596 }
1597
1598 static void gatt_server_send_response_action(void)
1599 {
1600         struct test_data *data = tester_get_data();
1601         struct step *current_data_step = queue_peek_head(data->steps);
1602         struct send_resp_data *send_resp_data = current_data_step->set_data;
1603         struct step *step = g_new0(struct step, 1);
1604
1605         step->action_status = data->if_gatt->server->send_response(
1606                                                 send_resp_data->conn_id,
1607                                                 send_resp_data->trans_id,
1608                                                 send_resp_data->status,
1609                                                 send_resp_data->response);
1610
1611         schedule_action_verification(step);
1612 }
1613
1614 static void gatt_cid_hook_cb(const void *data, uint16_t len, void *user_data)
1615 {
1616         struct test_data *t_data = tester_get_data();
1617         struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
1618         struct emu_l2cap_cid_data *cid_data = user_data;
1619         const uint8_t *pdu = data;
1620         struct iovec *gatt_pdu = queue_peek_head(t_data->pdus);
1621         struct step *step;
1622
1623         tester_debug("Received att pdu with opcode 0x%02x", pdu[0]);
1624
1625         switch (pdu[0]) {
1626         case L2CAP_ATT_ERROR:
1627                 step = g_new0(struct step, 1);
1628
1629                 step->callback = CB_EMU_ATT_ERROR;
1630                 step->callback_result.error = pdu[4];
1631
1632                 schedule_callback_verification(step);
1633                 break;
1634         case L2CAP_ATT_EXCHANGE_MTU_REQ:
1635                 tester_print("Exchange MTU request received.");
1636
1637                 if (!memcmp(exchange_mtu_req_pdu.iov_base, pdu, len))
1638                         bthost_send_cid_v(bthost, cid_data->handle,
1639                                                 cid_data->cid,
1640                                                 &exchange_mtu_resp_pdu, 1);
1641
1642                 break;
1643         case L2CAP_ATT_EXCHANGE_MTU_RSP:
1644                 tester_print("Exchange MTU response received.");
1645
1646                 break;
1647         case L2CAP_ATT_HANDLE_VALUE_IND:
1648                 step = g_new0(struct step, 1);
1649
1650                 step->callback = CB_EMU_VALUE_INDICATION;
1651
1652                 schedule_callback_verification(step);
1653                 goto respond;
1654         case L2CAP_ATT_HANDLE_VALUE_NOTIFY:
1655                 step = g_new0(struct step, 1);
1656
1657                 step->callback = CB_EMU_VALUE_NOTIFICATION;
1658
1659                 schedule_callback_verification(step);
1660                 break;
1661         case L2CAP_ATT_READ_RSP:
1662                 /* TODO - More complicated cases should also verify pdu data */
1663                 step = g_new0(struct step, 1);
1664
1665                 step->callback = CB_EMU_READ_RESPONSE;
1666
1667                 schedule_callback_verification(step);
1668                 break;
1669         case L2CAP_ATT_WRITE_RSP:
1670                 /* TODO - More complicated cases should also verify pdu data */
1671                 step = g_new0(struct step, 1);
1672
1673                 step->callback = CB_EMU_WRITE_RESPONSE;
1674
1675                 schedule_callback_verification(step);
1676                 break;
1677         default:
1678                 if (!gatt_pdu || !gatt_pdu->iov_base) {
1679                         tester_print("Unknown ATT packet.");
1680                         break;
1681                 }
1682
1683                 if (gatt_pdu->iov_len != len) {
1684                         tester_print("Size of incoming frame is not valid");
1685                         tester_print("Expected size = %zd incoming size = %d",
1686                                                         gatt_pdu->iov_len, len);
1687                         break;
1688                 }
1689
1690 respond:
1691                 if (memcmp(gatt_pdu->iov_base, data, len)) {
1692                         tester_print("Incoming data mismatch");
1693                         break;
1694                 }
1695                 queue_pop_head(t_data->pdus);
1696                 gatt_pdu = queue_pop_head(t_data->pdus);
1697                 if (!gatt_pdu || !gatt_pdu->iov_base)
1698                         break;
1699
1700                 bthost_send_cid_v(bthost, cid_data->handle, cid_data->cid,
1701                                                                 gatt_pdu, 1);
1702
1703                 break;
1704         }
1705 }
1706
1707 static void gatt_remote_send_frame_action(void)
1708 {
1709         struct test_data *t_data = tester_get_data();
1710         struct bthost *bthost = hciemu_client_get_host(t_data->hciemu);
1711         struct iovec *gatt_pdu = queue_pop_head(t_data->pdus);
1712         struct step *step = g_new0(struct step, 1);
1713
1714         if (!gatt_pdu) {
1715                 tester_print("No frame to send");
1716                 step->action_status = BT_STATUS_FAIL;
1717         } else {
1718                 bthost_send_cid_v(bthost, cid_data.handle, cid_data.cid,
1719                                                                 gatt_pdu, 1);
1720                 step->action_status = BT_STATUS_SUCCESS;
1721         }
1722
1723         schedule_action_verification(step);
1724 }
1725
1726 static void gatt_remote_send_raw_pdu_action(void)
1727 {
1728         struct test_data *data = tester_get_data();
1729         struct bthost *bthost = hciemu_client_get_host(data->hciemu);
1730         struct step *current_data_step = queue_peek_head(data->steps);
1731         struct iovec *pdu = current_data_step->set_data;
1732         struct iovec *pdu2 = current_data_step->set_data_2;
1733         struct iovec *pdu3 = current_data_step->set_data_3;
1734         struct step *step = g_new0(struct step, 1);
1735
1736         if (cid_data.handle && cid_data.cid) {
1737                 struct iovec rsp[3];
1738                 size_t len = 0;
1739
1740                 if (!pdu) {
1741                         step->action_status = BT_STATUS_FAIL;
1742                         goto done;
1743                 }
1744
1745                 rsp[0].iov_base = pdu->iov_base;
1746                 rsp[0].iov_len = pdu->iov_len;
1747                 len++;
1748
1749                 if (pdu2) {
1750                         rsp[1].iov_base = pdu2->iov_base;
1751                         rsp[1].iov_len = pdu2->iov_len;
1752                         len++;
1753                 }
1754
1755                 if (pdu3) {
1756                         rsp[2].iov_base = pdu3->iov_base;
1757                         rsp[2].iov_len = pdu3->iov_len;
1758                         len++;
1759                 }
1760
1761                 bthost_send_cid_v(bthost, cid_data.handle, cid_data.cid, rsp,
1762                                                                         len);
1763                 step->action_status = BT_STATUS_SUCCESS;
1764         } else {
1765                 tester_debug("No connection set up");
1766                 step->action_status = BT_STATUS_FAIL;
1767         }
1768
1769 done:
1770         schedule_action_verification(step);
1771 }
1772
1773 static void gatt_conn_cb(uint16_t handle, void *user_data)
1774 {
1775         struct test_data *data = tester_get_data();
1776         struct bthost *bthost = hciemu_client_get_host(data->hciemu);
1777
1778         tester_print("New connection with handle 0x%04x", handle);
1779
1780         if (data->hciemu_type == HCIEMU_TYPE_BREDR) {
1781                 tester_warn("Not handled device type.");
1782                 return;
1783         }
1784
1785         cid_data.cid = 0x0004;
1786         cid_data.handle = handle;
1787
1788         bthost_add_cid_hook(bthost, handle, cid_data.cid, gatt_cid_hook_cb,
1789                                                                 &cid_data);
1790 }
1791
1792 static void gatt_client_search_services(void)
1793 {
1794         struct test_data *data = tester_get_data();
1795         struct step *current_data_step = queue_peek_head(data->steps);
1796         struct step *step = g_new0(struct step, 1);
1797         struct gatt_search_service_data *search_data;
1798         int status;
1799
1800         search_data = current_data_step->set_data;
1801
1802         status = data->if_gatt->client->search_service(search_data->conn_id,
1803                                                 search_data->filter_uuid);
1804         step->action_status = status;
1805
1806         schedule_action_verification(step);
1807 }
1808
1809 static void init_pdus(void)
1810 {
1811         struct test_data *data = tester_get_data();
1812         struct step *current_data_step = queue_peek_head(data->steps);
1813         struct step *step = g_new0(struct step, 1);
1814         struct iovec *pdu = current_data_step->set_data;
1815
1816         while (pdu->iov_base) {
1817                 queue_push_tail(data->pdus, pdu);
1818                 pdu++;
1819         }
1820
1821         step->action_status = BT_STATUS_SUCCESS;
1822
1823         schedule_action_verification(step);
1824 }
1825
1826 static void init_read_params_action(void)
1827 {
1828         struct test_data *data = tester_get_data();
1829         struct step *current_data_step = queue_peek_head(data->steps);
1830         struct step *step = g_new0(struct step, 1);
1831         struct set_read_params *set_param_data = current_data_step->set_data;
1832         btgatt_read_params_t *param = set_param_data->params;
1833
1834         memset(param, 0, sizeof(*param));
1835
1836         if (set_param_data->srvc_id)
1837                 memcpy(&param->srvc_id, set_param_data->srvc_id,
1838                                                 sizeof(btgatt_srvc_id_t));
1839
1840         if (set_param_data->char_id)
1841                 memcpy(&param->char_id, set_param_data->char_id,
1842                                                 sizeof(btgatt_gatt_id_t));
1843
1844         if (set_param_data->descr_id)
1845                 memcpy(&param->descr_id, set_param_data->descr_id,
1846                                                 sizeof(btgatt_gatt_id_t));
1847
1848         param->value_type = set_param_data->value_type;
1849         param->status = set_param_data->status;
1850         param->value.len = set_param_data->len;
1851
1852         if (param->value.len != 0)
1853                 memcpy(&param->value.value, set_param_data->value,
1854                                                         param->value.len);
1855
1856         step->action_status = BT_STATUS_SUCCESS;
1857
1858         schedule_action_verification(step);
1859 }
1860
1861 static void init_write_params_action(void)
1862 {
1863         struct test_data *data = tester_get_data();
1864         struct step *current_data_step = queue_peek_head(data->steps);
1865         struct step *step = g_new0(struct step, 1);
1866         struct set_write_params *set_param_data = current_data_step->set_data;
1867         btgatt_write_params_t *param = set_param_data->params;
1868
1869         memset(param, 0, sizeof(*param));
1870
1871         if (set_param_data->srvc_id)
1872                 memcpy(&param->srvc_id, set_param_data->srvc_id,
1873                                                 sizeof(btgatt_srvc_id_t));
1874
1875         if (set_param_data->char_id)
1876                 memcpy(&param->char_id, set_param_data->char_id,
1877                                                 sizeof(btgatt_gatt_id_t));
1878
1879         if (set_param_data->descr_id)
1880                 memcpy(&param->descr_id, set_param_data->descr_id,
1881                                                 sizeof(btgatt_gatt_id_t));
1882
1883         param->status = set_param_data->status;
1884
1885         step->action_status = BT_STATUS_SUCCESS;
1886
1887         schedule_action_verification(step);
1888 }
1889
1890 static void init_notify_params_action(void)
1891 {
1892         struct test_data *data = tester_get_data();
1893         struct step *current_data_step = queue_peek_head(data->steps);
1894         struct step *step = g_new0(struct step, 1);
1895         struct set_notify_params *set_param_data = current_data_step->set_data;
1896         btgatt_notify_params_t *param = set_param_data->params;
1897
1898         memset(param, 0, sizeof(*param));
1899
1900         if (set_param_data->srvc_id)
1901                 memcpy(&param->srvc_id, set_param_data->srvc_id,
1902                                                 sizeof(btgatt_srvc_id_t));
1903
1904         if (set_param_data->char_id)
1905                 memcpy(&param->char_id, set_param_data->char_id,
1906                                                 sizeof(btgatt_gatt_id_t));
1907
1908         param->len = set_param_data->len;
1909         param->is_notify = set_param_data->is_notify;
1910
1911         memcpy(&param->bda, set_param_data->bdaddr, sizeof(bt_bdaddr_t));
1912         if (param->len != 0)
1913                 memcpy(&param->value, set_param_data->value, param->len);
1914
1915         step->action_status = BT_STATUS_SUCCESS;
1916
1917         schedule_action_verification(step);
1918 }
1919
1920 static struct test_case test_cases[] = {
1921         TEST_CASE_BREDRLE("Gatt Init",
1922                 ACTION_SUCCESS(dummy_action, NULL),
1923         ),
1924         TEST_CASE_BREDRLE("Gatt Client - Register",
1925                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
1926                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
1927         ),
1928         TEST_CASE_BREDRLE("Gatt Client - Unregister",
1929                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
1930                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
1931                 ACTION_SUCCESS(gatt_client_unregister_action,
1932                                                         INT_TO_PTR(APP1_ID)),
1933                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
1934                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
1935         ),
1936         TEST_CASE_BREDRLE("Gatt Client - Scan",
1937                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
1938                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
1939                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
1940                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
1941                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
1942                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
1943                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
1944                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
1945                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
1946                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
1947                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
1948                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
1949         ),
1950         TEST_CASE_BREDRLE("Gatt Client - LE Connect",
1951                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
1952                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
1953                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
1954                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
1955                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
1956                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
1957                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
1958                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
1959                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
1960                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
1961                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
1962                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
1963                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
1964                                                 prop_emu_remotes_default_set,
1965                                                 CONN1_ID, APP1_ID),
1966                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
1967                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
1968         ),
1969         TEST_CASE_BREDRLE("Gatt Client - LE Disconnect",
1970                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
1971                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
1972                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
1973                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
1974                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
1975                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
1976                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
1977                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
1978                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
1979                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
1980                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
1981                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
1982                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
1983                                                 prop_emu_remotes_default_set,
1984                                                 CONN1_ID, APP1_ID),
1985                 ACTION_SUCCESS(gatt_client_disconnect_action,
1986                                                         &app1_conn_req),
1987                 CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
1988                                                 prop_emu_remotes_default_set,
1989                                                 CONN1_ID, APP1_ID),
1990                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
1991                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
1992         ),
1993         TEST_CASE_BREDRLE("Gatt Client - LE Multiple Client Conn./Disc.",
1994                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
1995                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
1996                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
1997                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
1998                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
1999                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2000                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2001                 ACTION_SUCCESS(gatt_client_register_action, &app2_uuid),
2002                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2003                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2004                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2005                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2006                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2007                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2008                                                 prop_emu_remotes_default_set,
2009                                                 CONN1_ID, APP1_ID),
2010                 ACTION_SUCCESS(gatt_client_connect_action, &app2_conn_req),
2011                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2012                                                 prop_emu_remotes_default_set,
2013                                                 CONN2_ID, APP2_ID),
2014                 ACTION_SUCCESS(gatt_client_disconnect_action,
2015                                                         &app2_conn_req),
2016                 CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
2017                                                 prop_emu_remotes_default_set,
2018                                                 CONN2_ID, APP2_ID),
2019                 ACTION_SUCCESS(gatt_client_disconnect_action,
2020                                                         &app1_conn_req),
2021                 CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
2022                                                 prop_emu_remotes_default_set,
2023                                                 CONN1_ID, APP1_ID),
2024                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2025                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2026         ),
2027         TEST_CASE_BREDRLE("Gatt Client - Listen and Disconnect",
2028                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2029                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2030                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2031                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2032                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2033                 ACTION_SUCCESS(bt_set_property_action,
2034                                                 &prop_test_scan_mode_conn),
2035                 CALLBACK_ADAPTER_PROPS(&prop_test_scan_mode_conn, 1),
2036                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2037                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2038                 ACTION_SUCCESS(gatt_client_do_listen_action, &app1_conn_req),
2039                 CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
2040                 ACTION_SUCCESS(emu_remote_connect_hci_action, &bearer_type),
2041                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2042                                                 prop_emu_remotes_default_set,
2043                                                 CONN1_ID, APP1_ID),
2044                 ACTION_SUCCESS(gatt_client_stop_listen_action,
2045                                                         &app1_conn_req),
2046                 CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
2047                 ACTION_SUCCESS(gatt_client_disconnect_action,
2048                                                         &app1_conn_req),
2049                 CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
2050                                                 prop_emu_remotes_default_set,
2051                                                 CONN1_ID, APP1_ID),
2052                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2053                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2054         ),
2055         TEST_CASE_BREDRLE("Gatt Client - Double Listen",
2056                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2057                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2058                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2059                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2060                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2061                 ACTION_SUCCESS(bt_set_property_action,
2062                                                 &prop_test_scan_mode_conn),
2063                 CALLBACK_ADAPTER_PROPS(&prop_test_scan_mode_conn, 1),
2064                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2065                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2066                 ACTION_SUCCESS(gatt_client_do_listen_action, &app1_conn_req),
2067                 CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
2068                 ACTION_SUCCESS(emu_remote_connect_hci_action, &bearer_type),
2069                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2070                                                 prop_emu_remotes_default_set,
2071                                                 CONN1_ID, APP1_ID),
2072                 ACTION_SUCCESS(gatt_client_stop_listen_action,
2073                                                         &app1_conn_req),
2074                 CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
2075                 ACTION_SUCCESS(gatt_client_disconnect_action,
2076                                                         &app1_conn_req),
2077                 CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
2078                                                 prop_emu_remotes_default_set,
2079                                                 CONN1_ID, APP1_ID),
2080                 /* Close ACL on emulated remotes side so it can reconnect */
2081                 ACTION_SUCCESS(emu_remote_disconnect_hci_action,
2082                                                         &cid_data.handle),
2083                 CALLBACK_STATE(CB_BT_ACL_STATE_CHANGED,
2084                                                 BT_ACL_STATE_DISCONNECTED),
2085                 ACTION_SUCCESS(gatt_client_do_listen_action, &app1_conn_req),
2086                 CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
2087                 ACTION_SUCCESS(emu_remote_connect_hci_action, &bearer_type),
2088                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2089                                                 prop_emu_remotes_default_set,
2090                                                 CONN2_ID, APP1_ID),
2091                 ACTION_SUCCESS(gatt_client_disconnect_action,
2092                                                         &app1_conn2_req),
2093                 CALLBACK_GATTC_DISCONNECT(GATT_STATUS_SUCCESS,
2094                                                 prop_emu_remotes_default_set,
2095                                                 CONN2_ID, APP1_ID),
2096                 ACTION_SUCCESS(gatt_client_stop_listen_action,
2097                                                         &app1_conn_req),
2098                 CALLBACK_STATUS(CB_GATTC_LISTEN, GATT_STATUS_SUCCESS),
2099                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2100                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2101         ),
2102         TEST_CASE_BREDRLE("Gatt Client - Search Service - Single",
2103                 ACTION_SUCCESS(init_pdus, search_service),
2104                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2105                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2106                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2107                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2108                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2109                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2110                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2111                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2112                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2113                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2114                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2115                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2116                                                 prop_emu_remotes_default_set,
2117                                                 CONN1_ID, APP1_ID),
2118                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2119                 CALLBACK_GATTC_SEARCH_RESULT(CONN1_ID, &service_1),
2120                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2121                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2122                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2123         ),
2124         TEST_CASE_BREDRLE("Gatt Client - Search Service - Multiple",
2125                 ACTION_SUCCESS(init_pdus, search_service_2),
2126                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2127                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2128                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2129                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2130                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2131                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2132                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2133                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2134                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2135                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2136                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2137                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2138                                                 prop_emu_remotes_default_set,
2139                                                 CONN1_ID, APP1_ID),
2140                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2141                 CALLBACK_GATTC_SEARCH_RESULT(CONN1_ID, &service_1),
2142                 CALLBACK_GATTC_SEARCH_RESULT(CONN1_ID, &service_2),
2143                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2144                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2145                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2146         ),
2147         TEST_CASE_BREDRLE("Gatt Client - Search Service - None",
2148                 ACTION_SUCCESS(init_pdus, search_service_3),
2149                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2150                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2151                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2152                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2153                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2154                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2155                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2156                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2157                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2158                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2159                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2160                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2161                                                 prop_emu_remotes_default_set,
2162                                                 CONN1_ID, APP1_ID),
2163                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2164                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2165                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2166                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2167         ),
2168         TEST_CASE_BREDRLE("Gatt Client - Search Service - Incorrect rsp",
2169                 ACTION_SUCCESS(init_pdus, search_service_4),
2170                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2171                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2172                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2173                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2174                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2175                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2176                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2177                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2178                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2179                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2180                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2181                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2182                                                 prop_emu_remotes_default_set,
2183                                                 CONN1_ID, APP1_ID),
2184                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2185                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2186                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2187                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2188         ),
2189         TEST_CASE_BREDRLE("Gatt Client - Get Characteristic - Single",
2190                 ACTION_SUCCESS(init_pdus, get_characteristic_1),
2191                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2192                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2193                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2194                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2195                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2196                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2197                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2198                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2199                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2200                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2201                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2202                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2203                                                 prop_emu_remotes_default_set,
2204                                                 CONN1_ID, APP1_ID),
2205                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2206                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2207                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2208                                                         &get_char_data_1),
2209                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2210                                 CONN1_ID, &service_1, &characteristic_1, 4),
2211                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2212                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2213         ),
2214         TEST_CASE_BREDRLE("Gatt Client - Get Characteristic - Incorrect rsp",
2215                 ACTION_SUCCESS(init_pdus, get_characteristic_2),
2216                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2217                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2218                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2219                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2220                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2221                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2222                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2223                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2224                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2225                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2226                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2227                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2228                                                 prop_emu_remotes_default_set,
2229                                                 CONN1_ID, APP1_ID),
2230                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2231                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2232                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2233                                                         &get_char_data_1),
2234                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_FAILURE,
2235                                 CONN1_ID, &service_1, NULL, 0),
2236                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2237                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2238         ),
2239         TEST_CASE_BREDRLE("Gatt Client - Get Characteristic - None",
2240                 ACTION_SUCCESS(init_pdus, get_characteristic_1),
2241                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2242                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2243                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2244                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2245                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2246                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2247                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2248                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2249                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2250                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2251                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2252                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2253                                                 prop_emu_remotes_default_set,
2254                                                 CONN1_ID, APP1_ID),
2255                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2256                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2257                 ACTION_FAIL(gatt_client_get_characteristic_action,
2258                                                         &get_char_data_2),
2259                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_FAILURE,
2260                                                         CONN1_ID, &service_2,
2261                                                         NULL, 0),
2262                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2263                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2264         ),
2265         TEST_CASE_BREDRLE("Gatt Client - Get Descriptor - Incorrect rsp",
2266                 ACTION_SUCCESS(init_pdus, get_descriptor_0),
2267                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2268                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2269                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2270                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2271                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2272                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2273                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2274                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2275                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2276                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2277                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2278                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2279                                                 prop_emu_remotes_default_set,
2280                                                 CONN1_ID, APP1_ID),
2281                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2282                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2283                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2284                                                         &get_char_data_1),
2285                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2286                                 CONN1_ID, &service_1, &characteristic_1, 4),
2287                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2288                                                         &get_desc_data_1),
2289                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_FAILURE, CONN1_ID,
2290                                 &service_1, &characteristic_1, NULL),
2291                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2292                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2293         ),
2294         TEST_CASE_BREDRLE("Gatt Client - Get Descriptor - Single",
2295                 ACTION_SUCCESS(init_pdus, get_descriptor_1),
2296                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2297                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2298                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2299                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2300                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2301                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2302                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2303                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2304                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2305                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2306                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2307                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2308                                                 prop_emu_remotes_default_set,
2309                                                 CONN1_ID, APP1_ID),
2310                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2311                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2312                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2313                                                         &get_char_data_1),
2314                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2315                                 CONN1_ID, &service_1, &characteristic_1, 4),
2316                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2317                                                         &get_desc_data_1),
2318                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2319                                 &service_1, &characteristic_1, &desc_1),
2320                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2321                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2322         ),
2323         TEST_CASE_BREDRLE("Gatt Client - Get Descriptor - Multiple",
2324                 ACTION_SUCCESS(init_pdus, get_descriptor_2),
2325                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2326                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2327                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2328                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2329                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2330                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2331                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2332                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2333                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2334                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2335                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2336                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2337                                                 prop_emu_remotes_default_set,
2338                                                 CONN1_ID, APP1_ID),
2339                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2340                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2341                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2342                                                         &get_char_data_1),
2343                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2344                                                         CONN1_ID, &service_1,
2345                                                         &characteristic_1, 4),
2346                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2347                                                         &get_desc_data_1),
2348                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2349                                                 &service_1, &characteristic_1,
2350                                                 &desc_1),
2351                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2352                                                         &get_desc_data_2),
2353                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2354                                                 &service_1, &characteristic_1,
2355                                                 &desc_2),
2356                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2357                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2358         ),
2359         TEST_CASE_BREDRLE("Gatt Client - Get Descriptor - None",
2360                 ACTION_SUCCESS(init_pdus, get_descriptor_3),
2361                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2362                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2363                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2364                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2365                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2366                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2367                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2368                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2369                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2370                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2371                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2372                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2373                                                 prop_emu_remotes_default_set,
2374                                                 CONN1_ID, APP1_ID),
2375                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2376                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2377                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2378                                                         &get_char_data_1),
2379                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2380                                 CONN1_ID, &service_1, &characteristic_1, 4),
2381                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2382                                                         &get_desc_data_1),
2383                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_FAILURE, CONN1_ID,
2384                                 &service_1, &characteristic_1, NULL),
2385                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2386                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2387         ),
2388         TEST_CASE_BREDRLE("Gatt Client - Get Included Services - Incorrect rsp",
2389                 ACTION_SUCCESS(init_pdus, get_included_0),
2390                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2391                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2392                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2393                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2394                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2395                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2396                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2397                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2398                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2399                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2400                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2401                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2402                                                 prop_emu_remotes_default_set,
2403                                                 CONN1_ID, APP1_ID),
2404                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2405                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2406                 ACTION_SUCCESS(gatt_client_get_included_action,
2407                                                         &get_incl_data_1),
2408                 CALLBACK_GATTC_GET_INCLUDED(GATT_STATUS_FAILURE, CONN1_ID,
2409                                                         &service_1, NULL),
2410                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2411                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2412                 ),
2413         TEST_CASE_BREDRLE("Gatt Client - Get Included Service - 16 UUID",
2414                 ACTION_SUCCESS(init_pdus, get_included_1),
2415                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2416                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2417                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2418                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2419                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2420                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2421                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2422                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2423                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2424                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2425                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2426                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2427                                                 prop_emu_remotes_default_set,
2428                                                 CONN1_ID, APP1_ID),
2429                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2430                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2431                 ACTION_SUCCESS(gatt_client_get_included_action,
2432                                                         &get_incl_data_1),
2433                 CALLBACK_GATTC_GET_INCLUDED(GATT_STATUS_SUCCESS, CONN1_ID,
2434                                                 &service_1, &included_1),
2435                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2436                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2437         ),
2438         TEST_CASE_BREDRLE("Gatt Client - Get Included Service - 128 UUID",
2439                 ACTION_SUCCESS(init_pdus, get_included_2),
2440                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2441                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2442                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2443                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2444                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2445                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2446                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2447                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2448                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2449                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2450                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2451                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2452                                                 prop_emu_remotes_default_set,
2453                                                 CONN1_ID, APP1_ID),
2454                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2455                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2456                 ACTION_SUCCESS(gatt_client_get_included_action,
2457                                                         &get_incl_data_1),
2458                 CALLBACK_GATTC_GET_INCLUDED(GATT_STATUS_SUCCESS, CONN1_ID,
2459                                                 &service_1, &included_2),
2460                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2461                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2462         ),
2463         TEST_CASE_BREDRLE("Gatt Client - Get Included Service - None",
2464                 ACTION_SUCCESS(init_pdus, get_included_3),
2465                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2466                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2467                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2468                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2469                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2470                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2471                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2472                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2473                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2474                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2475                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2476                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2477                                                 prop_emu_remotes_default_set,
2478                                                 CONN1_ID, APP1_ID),
2479                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2480                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2481                 ACTION_SUCCESS(gatt_client_get_included_action,
2482                                                         &get_incl_data_1),
2483                 CALLBACK_GATTC_GET_INCLUDED(GATT_STATUS_FAILURE, CONN1_ID,
2484                                                         &service_1, NULL),
2485                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2486                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2487         ),
2488         TEST_CASE_BREDRLE("Gatt Client - Read Characteristic - Success",
2489                 ACTION_SUCCESS(init_pdus, read_characteristic_1),
2490                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2491                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2492                 ACTION_SUCCESS(init_read_params_action, &set_read_param_1),
2493                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2494                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2495                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2496                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2497                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2498                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2499                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2500                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2501                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2502                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2503                                                 prop_emu_remotes_default_set,
2504                                                 CONN1_ID, APP1_ID),
2505                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2506                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2507                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2508                                                         &get_char_data_1),
2509                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2510                                 CONN1_ID, &service_1, &characteristic_1, 4),
2511                 ACTION_SUCCESS(gatt_client_read_characteristic_action,
2512                                                         &read_char_data_1),
2513                 CALLBACK_GATTC_READ_CHARACTERISTIC(GATT_STATUS_SUCCESS,
2514                                                 CONN1_ID, &read_params_1),
2515                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2516                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2517         ),
2518
2519         TEST_CASE_BREDRLE("Gatt Client - Read Characteristic - Insuf. Auth.",
2520                 ACTION_SUCCESS(init_pdus, read_characteristic_2),
2521                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2522                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2523                 ACTION_SUCCESS(init_read_params_action, &set_read_param_2),
2524                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2525                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2526                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2527                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2528                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2529                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2530                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2531                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2532                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2533                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2534                                                 prop_emu_remotes_default_set,
2535                                                 CONN1_ID, APP1_ID),
2536                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2537                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2538                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2539                                                         &get_char_data_1),
2540                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2541                                 CONN1_ID, &service_1, &characteristic_1, 4),
2542                 ACTION_SUCCESS(gatt_client_read_characteristic_action,
2543                                                         &read_char_data_1),
2544                 CALLBACK_GATTC_READ_CHARACTERISTIC(GATT_STATUS_INS_AUTH,
2545                                                 CONN1_ID, &read_params_1),
2546                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2547                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2548         ),
2549         TEST_CASE_BREDRLE("Gatt Client - Read Characteristic - Wrong params",
2550                 ACTION_SUCCESS(init_pdus, read_characteristic_2),
2551                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2552                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2553                 ACTION_SUCCESS(init_read_params_action, &set_read_param_3),
2554                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2555                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2556                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2557                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2558                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2559                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2560                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2561                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2562                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2563                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2564                                                 prop_emu_remotes_default_set,
2565                                                 CONN1_ID, APP1_ID),
2566                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2567                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2568                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2569                                                         &get_char_data_1),
2570                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2571                                 CONN1_ID, &service_1, &characteristic_1, 4),
2572                 ACTION_FAIL(gatt_client_read_characteristic_action,
2573                                                         &read_char_data_2),
2574                 CALLBACK_GATTC_READ_CHARACTERISTIC(GATT_STATUS_FAILURE,
2575                                                 CONN1_ID, &read_params_1),
2576                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2577                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2578         ),
2579         TEST_CASE_BREDRLE("Gatt Client - Read Descriptor - Success",
2580                 ACTION_SUCCESS(init_pdus, read_descriptor_1),
2581                 ACTION_SUCCESS(init_read_params_action, &set_read_param_4),
2582                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2583                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2584                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2585                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2586                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2587                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2588                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2589                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2590                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2591                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2592                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2593                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2594                                                 prop_emu_remotes_default_set,
2595                                                 CONN1_ID, APP1_ID),
2596                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2597                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2598                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2599                                                         &get_char_data_1),
2600                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2601                                 CONN1_ID, &service_1, &characteristic_1, 4),
2602                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2603                                                         &get_desc_data_1),
2604                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2605                                 &service_1, &characteristic_1, &desc_1),
2606                 ACTION_SUCCESS(gatt_client_read_descriptor_action,
2607                                                         &read_desc_data_1),
2608                 CALLBACK_GATTC_READ_DESCRIPTOR(GATT_STATUS_SUCCESS,
2609                                                 CONN1_ID, &read_params_1),
2610                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2611                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2612         ),
2613         TEST_CASE_BREDRLE("Gatt Client - Read Descriptor - Insuf. Auth.",
2614                 ACTION_SUCCESS(init_pdus, read_descriptor_2),
2615                 ACTION_SUCCESS(init_read_params_action, &set_read_param_5),
2616                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2617                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2618                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2619                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2620                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2621                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2622                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2623                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2624                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2625                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2626                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2627                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2628                                                 prop_emu_remotes_default_set,
2629                                                 CONN1_ID, APP1_ID),
2630                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2631                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2632                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2633                                                         &get_char_data_1),
2634                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2635                                 CONN1_ID, &service_1, &characteristic_1, 4),
2636                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2637                                                         &get_desc_data_1),
2638                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2639                                 &service_1, &characteristic_1, &desc_1),
2640                 ACTION_SUCCESS(gatt_client_read_descriptor_action,
2641                                                         &read_desc_data_1),
2642                 CALLBACK_GATTC_READ_DESCRIPTOR(GATT_STATUS_INS_AUTH,
2643                                                 CONN1_ID, &read_params_1),
2644                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2645                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2646         ),
2647         TEST_CASE_BREDRLE("Gatt Client - Read Descriptor - Wrong params",
2648                 ACTION_SUCCESS(init_pdus, read_descriptor_2),
2649                 ACTION_SUCCESS(init_read_params_action, &set_read_param_6),
2650                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2651                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2652                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2653                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2654                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2655                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2656                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2657                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2658                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2659                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2660                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2661                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2662                                                 prop_emu_remotes_default_set,
2663                                                 CONN1_ID, APP1_ID),
2664                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2665                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2666                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2667                                                         &get_char_data_1),
2668                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2669                                 CONN1_ID, &service_1, &characteristic_1, 4),
2670                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2671                                                         &get_desc_data_1),
2672                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2673                                 &service_1, &characteristic_1, &desc_1),
2674                 ACTION_FAIL(gatt_client_read_descriptor_action,
2675                                                         &read_desc_data_2),
2676                 CALLBACK_GATTC_READ_DESCRIPTOR(GATT_STATUS_FAILURE,
2677                                                 CONN1_ID, &read_params_1),
2678                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2679                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2680         ),
2681         TEST_CASE_BREDRLE("Gatt Client - Write Characteristic Cmd - Success",
2682                 ACTION_SUCCESS(init_pdus, write_characteristic_1),
2683                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2684                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2685                 ACTION_SUCCESS(init_write_params_action, &set_write_param_1),
2686                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2687                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2688                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2689                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2690                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2691                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2692                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2693                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2694                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2695                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2696                                                 prop_emu_remotes_default_set,
2697                                                 CONN1_ID, APP1_ID),
2698                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2699                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2700                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2701                                                         &get_char_data_1),
2702                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2703                                 CONN1_ID, &service_1, &characteristic_1, 4),
2704                 ACTION_SUCCESS(gatt_client_write_characteristic_action,
2705                                                         &write_char_data_1),
2706                 CALLBACK_GATTC_WRITE_CHARACTERISTIC(GATT_STATUS_SUCCESS,
2707                                                 CONN1_ID, &write_params_1),
2708                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2709                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2710         ),
2711         TEST_CASE_BREDRLE("Gatt Client - Write Characteristic Req - Success",
2712                 ACTION_SUCCESS(init_pdus, write_characteristic_2),
2713                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2714                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2715                 ACTION_SUCCESS(init_write_params_action, &set_write_param_1),
2716                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2717                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2718                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2719                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2720                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2721                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2722                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2723                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2724                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2725                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2726                                                 prop_emu_remotes_default_set,
2727                                                 CONN1_ID, APP1_ID),
2728                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2729                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2730                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2731                                                         &get_char_data_1),
2732                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2733                                 CONN1_ID, &service_1, &characteristic_1, 4),
2734                 ACTION_SUCCESS(gatt_client_write_characteristic_action,
2735                                                         &write_char_data_2),
2736                 CALLBACK_GATTC_WRITE_CHARACTERISTIC(GATT_STATUS_SUCCESS,
2737                                                 CONN1_ID, &write_params_1),
2738                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2739                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2740         ),
2741         TEST_CASE_BREDRLE("Gatt Client - Write Characteristic - Insuf. Auth.",
2742                 ACTION_SUCCESS(init_pdus, write_characteristic_3),
2743                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2744                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2745                 ACTION_SUCCESS(init_write_params_action, &set_write_param_2),
2746                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2747                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2748                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2749                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2750                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2751                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2752                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2753                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2754                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2755                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2756                                                 prop_emu_remotes_default_set,
2757                                                 CONN1_ID, APP1_ID),
2758                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2759                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2760                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2761                                                         &get_char_data_1),
2762                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2763                                 CONN1_ID, &service_1, &characteristic_1, 4),
2764                 ACTION_SUCCESS(gatt_client_write_characteristic_action,
2765                                                         &write_char_data_2),
2766                 CALLBACK_GATTC_WRITE_CHARACTERISTIC(GATT_STATUS_INS_AUTH,
2767                                                 CONN1_ID, &write_params_1),
2768                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2769                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2770         ),
2771         TEST_CASE_BREDRLE("Gatt Client - Write Characteristic - Wrong Params",
2772                 ACTION_SUCCESS(init_pdus, write_characteristic_3),
2773                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2774                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2775                 ACTION_SUCCESS(init_write_params_action, &set_write_param_3),
2776                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2777                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2778                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2779                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2780                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2781                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2782                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2783                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2784                 ACTION_FAIL(gatt_client_write_characteristic_action,
2785                                                         &write_char_data_2),
2786                 CALLBACK_GATTC_WRITE_CHARACTERISTIC(GATT_STATUS_FAILURE,
2787                                                 CONN1_ID, &write_params_1),
2788                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2789                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2790         ),
2791         TEST_CASE_BREDRLE("Gatt Client - Register For Notification - Success",
2792                 ACTION_SUCCESS(init_pdus, notification_1),
2793                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2794                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2795                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2796                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2797                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2798                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2799                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2800                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2801                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2802                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2803                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2804                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2805                                                 prop_emu_remotes_default_set,
2806                                                 CONN1_ID, APP1_ID),
2807                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2808                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2809                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2810                                                         &get_char_data_1),
2811                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2812                                 CONN1_ID, &service_1, &characteristic_1, 4),
2813                 ACTION_SUCCESS(gatt_client_register_for_notification_action,
2814                                                                 &notif_data_1),
2815                 CALLBACK_GATTC_REGISTER_FOR_NOTIF(GATT_STATUS_SUCCESS, CONN1_ID,
2816                                                         &characteristic_1,
2817                                                         &service_1, 1),
2818                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2819                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2820         ),
2821         TEST_CASE_BREDRLE("Gatt Client - Deregister For Notification - Success",
2822                 ACTION_SUCCESS(init_pdus, notification_1),
2823                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2824                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2825                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2826                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2827                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2828                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2829                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2830                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2831                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2832                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2833                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2834                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2835                                                 prop_emu_remotes_default_set,
2836                                                 CONN1_ID, APP1_ID),
2837                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2838                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2839                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2840                                                         &get_char_data_1),
2841                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2842                                 CONN1_ID, &service_1, &characteristic_1, 4),
2843                 ACTION_SUCCESS(gatt_client_register_for_notification_action,
2844                                                                 &notif_data_1),
2845                 CALLBACK_GATTC_REGISTER_FOR_NOTIF(GATT_STATUS_SUCCESS, CONN1_ID,
2846                                                         &characteristic_1,
2847                                                         &service_1, 1),
2848                 ACTION_SUCCESS(gatt_client_deregister_for_notification_action,
2849                                                                 &notif_data_1),
2850                 CALLBACK_GATTC_REGISTER_FOR_NOTIF(GATT_STATUS_SUCCESS, CONN1_ID,
2851                                                         &characteristic_1,
2852                                                         &service_1, 0),
2853                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2854                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2855         ),
2856         TEST_CASE_BREDRLE("Gatt Client - Register For Notification - Indicate",
2857                 ACTION_SUCCESS(init_pdus, notification_2),
2858                 ACTION_SUCCESS(init_notify_params_action, &set_notify_param_1),
2859                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2860                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2861                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2862                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2863                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2864                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2865                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2866                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2867                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2868                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2869                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2870                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2871                                                 prop_emu_remotes_default_set,
2872                                                         CONN1_ID, APP1_ID),
2873                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2874                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2875                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2876                                                         &get_char_data_1),
2877                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2878                                 CONN1_ID, &service_1, &characteristic_1, 4),
2879                 ACTION_SUCCESS(gatt_client_register_for_notification_action,
2880                                                                 &notif_data_1),
2881                 CALLBACK_GATTC_REGISTER_FOR_NOTIF(GATT_STATUS_SUCCESS, CONN1_ID,
2882                                                         &characteristic_1,
2883                                                         &service_1, 1),
2884                 ACTION_SUCCESS(gatt_remote_send_frame_action, NULL),
2885                 CALLBACK_GATTC_NOTIFY(CONN1_ID, &notify_params_1),
2886                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2887                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2888         ),
2889         TEST_CASE_BREDRLE("Gatt Client - Register For Notification - Notify",
2890                 ACTION_SUCCESS(init_pdus, notification_3),
2891                 ACTION_SUCCESS(init_notify_params_action, &set_notify_param_2),
2892                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2893                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2894                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2895                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2896                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2897                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2898                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2899                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2900                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2901                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2902                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2903                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2904                                                 prop_emu_remotes_default_set,
2905                                                 CONN1_ID, APP1_ID),
2906                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2907                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2908                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2909                                                         &get_char_data_1),
2910                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2911                                 CONN1_ID, &service_1, &characteristic_1, 4),
2912                 ACTION_SUCCESS(gatt_client_register_for_notification_action,
2913                                                                 &notif_data_1),
2914                 CALLBACK_GATTC_REGISTER_FOR_NOTIF(GATT_STATUS_SUCCESS, CONN1_ID,
2915                                                         &characteristic_1,
2916                                                         &service_1, 1),
2917                 ACTION_SUCCESS(gatt_remote_send_frame_action, NULL),
2918                 CALLBACK_GATTC_NOTIFY(CONN1_ID, &notify_params_1),
2919                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2920                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2921         ),
2922         TEST_CASE_BREDRLE("Gatt Client - Write Descriptor - Success",
2923                 ACTION_SUCCESS(init_pdus, write_descriptor_1),
2924                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2925                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2926                 ACTION_SUCCESS(init_write_params_action, &set_write_param_4),
2927                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2928                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2929                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2930                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2931                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2932                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2933                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2934                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2935                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2936                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2937                                                 prop_emu_remotes_default_set,
2938                                                 CONN1_ID, APP1_ID),
2939                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2940                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2941                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2942                                                         &get_char_data_1),
2943                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2944                                 CONN1_ID, &service_1, &characteristic_1, 4),
2945                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2946                                                         &get_desc_data_1),
2947                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2948                                 &service_1, &characteristic_1, &desc_1),
2949                 ACTION_SUCCESS(gatt_client_write_descriptor_action,
2950                                                         &write_desc_data_1),
2951                 CALLBACK_GATTC_WRITE_DESCRIPTOR(GATT_STATUS_SUCCESS,
2952                                                 CONN1_ID, &write_params_1),
2953                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2954                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2955         ),
2956         TEST_CASE_BREDRLE("Gatt Client - Write Descriptor - Insuf. Auth.",
2957                 ACTION_SUCCESS(init_pdus, write_descriptor_2),
2958                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2959                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2960                 ACTION_SUCCESS(init_write_params_action, &set_write_param_6),
2961                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2962                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2963                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2964                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2965                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
2966                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
2967                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
2968                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
2969                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
2970                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
2971                                                 prop_emu_remotes_default_set,
2972                                                 CONN1_ID, APP1_ID),
2973                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
2974                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
2975                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
2976                                                         &get_char_data_1),
2977                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
2978                                 CONN1_ID, &service_1, &characteristic_1, 4),
2979                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
2980                                                         &get_desc_data_1),
2981                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
2982                                 &service_1, &characteristic_1, &desc_1),
2983                 ACTION_SUCCESS(gatt_client_write_descriptor_action,
2984                                                         &write_desc_data_1),
2985                 CALLBACK_GATTC_WRITE_DESCRIPTOR(GATT_STATUS_INS_AUTH,
2986                                                 CONN1_ID, &write_params_1),
2987                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
2988                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
2989         ),
2990         TEST_CASE_BREDRLE("Gatt Client - Write Descriptor - Wrong Param",
2991                 ACTION_SUCCESS(init_pdus, write_descriptor_1),
2992                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
2993                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
2994                 ACTION_SUCCESS(init_write_params_action, &set_write_param_5),
2995                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
2996                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
2997                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
2998                 ACTION_SUCCESS(gatt_client_register_action, &app1_uuid),
2999                 CALLBACK_STATUS(CB_GATTC_REGISTER_CLIENT, BT_STATUS_SUCCESS),
3000                 ACTION_SUCCESS(gatt_client_start_scan_action, NULL),
3001                 CLLBACK_GATTC_SCAN_RES(prop_emu_remotes_default_set, 1, TRUE),
3002                 ACTION_SUCCESS(gatt_client_stop_scan_action, NULL),
3003                 ACTION_SUCCESS(gatt_client_connect_action, &app1_conn_req),
3004                 CALLBACK_GATTC_CONNECT(GATT_STATUS_SUCCESS,
3005                                                 prop_emu_remotes_default_set,
3006                                                 CONN1_ID, APP1_ID),
3007                 ACTION_SUCCESS(gatt_client_search_services, &search_services_1),
3008                 CALLBACK_GATTC_SEARCH_COMPLETE(GATT_STATUS_SUCCESS, CONN1_ID),
3009                 ACTION_SUCCESS(gatt_client_get_characteristic_action,
3010                                                         &get_char_data_1),
3011                 CALLBACK_GATTC_GET_CHARACTERISTIC_CB(GATT_STATUS_SUCCESS,
3012                                 CONN1_ID, &service_1, &characteristic_1, 4),
3013                 ACTION_SUCCESS(gatt_client_get_descriptor_action,
3014                                                         &get_desc_data_1),
3015                 CALLBACK_GATTC_GET_DESCRIPTOR(GATT_STATUS_SUCCESS, CONN1_ID,
3016                                 &service_1, &characteristic_1, &desc_1),
3017                 ACTION_FAIL(gatt_client_write_descriptor_action,
3018                                                         &write_desc_data_2),
3019                 CALLBACK_GATTC_WRITE_DESCRIPTOR(GATT_STATUS_FAILURE,
3020                                                 CONN1_ID, &write_params_1),
3021                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3022                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3023         ),
3024         TEST_CASE_BREDRLE("Gatt Server - Register",
3025                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3026                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3027         ),
3028         TEST_CASE_BREDRLE("Gatt Server - Unregister",
3029                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3030                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3031                 ACTION_SUCCESS(gatt_server_unregister_action,
3032                                                         INT_TO_PTR(APP1_ID)),
3033                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3034                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3035         ),
3036         TEST_CASE_BREDRLE("Gatt Server - LE Connect",
3037                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3038                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3039                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3040                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3041                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3042                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3043                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3044                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3045                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3046                                                         BT_DISCOVERY_STARTED),
3047                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3048                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3049                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3050                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3051                                                 prop_emu_remotes_default_set,
3052                                                 CONN1_ID, APP1_ID),
3053                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3054                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3055         ),
3056         TEST_CASE_BREDRLE("Gatt Server - LE Disconnect",
3057                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3058                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3059                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3060                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3061                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3062                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3063                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3064                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3065                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3066                                                         BT_DISCOVERY_STARTED),
3067                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3068                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3069                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3070                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3071                                                 prop_emu_remotes_default_set,
3072                                                 CONN1_ID, APP1_ID),
3073                 ACTION_SUCCESS(gatt_server_disconnect_action,
3074                                                         &app1_conn_req),
3075                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_DISCONNECTED,
3076                                                 prop_emu_remotes_default_set,
3077                                                 CONN1_ID, APP1_ID),
3078                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3079                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3080         ),
3081         TEST_CASE_BREDRLE("Gatt Server - LE Multiple Server Conn./Disc",
3082                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3083                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3084                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3085                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3086                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3087                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3088                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3089                 ACTION_SUCCESS(gatt_server_register_action, &app2_uuid),
3090                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3091                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3092                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3093                                                         BT_DISCOVERY_STARTED),
3094                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3095                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3096                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3097                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3098                                                 prop_emu_remotes_default_set,
3099                                                 CONN1_ID, APP1_ID),
3100                 ACTION_SUCCESS(gatt_server_connect_action, &app2_conn_req),
3101                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3102                                                 prop_emu_remotes_default_set,
3103                                                 CONN2_ID, APP2_ID),
3104                 ACTION_SUCCESS(gatt_server_disconnect_action, &app2_conn_req),
3105                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_DISCONNECTED,
3106                                                 prop_emu_remotes_default_set,
3107                                                 CONN2_ID, APP2_ID),
3108                 ACTION_SUCCESS(gatt_server_disconnect_action, &app1_conn_req),
3109                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_DISCONNECTED,
3110                                                 prop_emu_remotes_default_set,
3111                                                 CONN1_ID, APP1_ID),
3112                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3113                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3114         ),
3115         TEST_CASE_BREDRLE("Gatt Server - Add Single Service Successful",
3116                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3117                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3118                 ACTION_SUCCESS(gatt_server_add_service_action,
3119                                                         &add_service_data_1),
3120                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3121                                                 &service_add_1, NULL, NULL),
3122         ),
3123         TEST_CASE_BREDRLE("Gatt Server - Add Multiple Services Successful",
3124                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3125                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3126                 ACTION_SUCCESS(gatt_server_add_service_action,
3127                                                         &add_service_data_1),
3128                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3129                                                 &service_add_1, NULL, NULL),
3130                 ACTION_SUCCESS(gatt_server_add_service_action,
3131                                                         &add_service_data_2),
3132                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3133                                                 &service_add_2, NULL, NULL),
3134                 ACTION_SUCCESS(gatt_server_add_service_action,
3135                                                         &add_service_data_3),
3136                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3137                                                 &service_add_3, NULL, NULL),
3138         ),
3139         TEST_CASE_BREDRLE("Gatt Server - Add Service with 0 handles",
3140                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3141                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3142                 ACTION_FAIL(gatt_server_add_service_action,
3143                                                 &add_bad_service_data_1),
3144                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_FAILURE, APP1_ID,
3145                                                 &service_add_1, NULL, NULL),
3146         ),
3147         TEST_CASE_BREDRLE("Gatt Server - Add Secondary Service",
3148                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3149                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3150                 ACTION_SUCCESS(gatt_server_add_service_action,
3151                                                 &add_sec_service_data_1),
3152                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3153                                                 &included_1, NULL, NULL),
3154         ),
3155         TEST_CASE_BREDRLE("Gatt Server - Add Included Service Successful",
3156                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3157                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3158                 ACTION_SUCCESS(gatt_server_add_service_action,
3159                                                         &add_service_data_4),
3160                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3161                                                         &service_add_1, NULL,
3162                                                         &srvc1_handle),
3163                 ACTION_SUCCESS(gatt_server_add_service_action,
3164                                                         &add_service_data_4),
3165                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3166                                                         &service_add_1, NULL,
3167                                                         &inc_srvc1_handle),
3168                 ACTION_SUCCESS(gatt_server_add_inc_service_action,
3169                                                 &add_inc_service_data_1),
3170                 CALLBACK_GATTS_INC_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3171                                                         &srvc1_handle, NULL),
3172         ),
3173         TEST_CASE_BREDRLE("Gatt Server - Add Inc. Service with wrong handle",
3174                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3175                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3176                 ACTION_SUCCESS(gatt_server_add_service_action,
3177                                                         &add_service_data_4),
3178                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3179                                                         &service_add_1, NULL,
3180                                                         &srvc1_handle),
3181                 ACTION_SUCCESS(gatt_server_add_service_action,
3182                                                         &add_service_data_4),
3183                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3184                                                 &service_add_1, NULL, NULL),
3185                 ACTION_FAIL(gatt_server_add_inc_service_action,
3186                                                 &add_bad_inc_service_data_1),
3187                 CALLBACK_GATTS_INC_SERVICE_ADDED(GATT_STATUS_FAILURE, APP1_ID,
3188                                                         &srvc1_handle, NULL),
3189         ),
3190         TEST_CASE_BREDRLE("Gatt Server - Add Single Characteristic Successful",
3191                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3192                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3193                 ACTION_SUCCESS(gatt_server_add_service_action,
3194                                                         &add_service_data_5),
3195                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3196                                                         &service_add_1, NULL,
3197                                                         &srvc1_handle),
3198                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_1),
3199                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3200                                                         APP1_ID, &app1_uuid,
3201                                                         &srvc1_handle, NULL,
3202                                                         NULL),
3203         ),
3204         TEST_CASE_BREDRLE("Gatt Server - Add Char. wrong service handle",
3205                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3206                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3207                 ACTION_SUCCESS(gatt_server_add_service_action,
3208                                                         &add_service_data_5),
3209                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3210                                                         &service_add_1, NULL,
3211                                                         &srvc1_handle),
3212                 ACTION_FAIL(gatt_server_add_char_action, &add_bad_char_data_1),
3213                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_FAILURE,
3214                                                         APP1_ID, &app1_uuid,
3215                                                         NULL, NULL, NULL),
3216         ),
3217         TEST_CASE_BREDRLE("Gatt Server - Add Single Descriptor Successful",
3218                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3219                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3220                 ACTION_SUCCESS(gatt_server_add_service_action,
3221                                                         &add_service_data_6),
3222                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3223                                                         &service_add_1, NULL,
3224                                                         &srvc1_handle),
3225                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_1),
3226                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3227                                                         APP1_ID, &app1_uuid,
3228                                                         &srvc1_handle, NULL,
3229                                                         NULL),
3230                 ACTION_SUCCESS(gatt_server_add_desc_action, &add_desc_data_1),
3231                 CALLBACK_GATTS_DESCRIPTOR_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3232                                                 &app2_uuid, &srvc1_handle,
3233                                                 NULL, NULL),
3234         ),
3235         TEST_CASE_BREDRLE("Gatt Server - Add Desc. wrong service handle",
3236                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3237                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3238                 ACTION_SUCCESS(gatt_server_add_service_action,
3239                                                         &add_service_data_6),
3240                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3241                                                         &service_add_1, NULL,
3242                                                         &srvc1_handle),
3243                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_1),
3244                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3245                                                         APP1_ID, &app1_uuid,
3246                                                         &srvc1_handle, NULL,
3247                                                         NULL),
3248                 ACTION_FAIL(gatt_server_add_desc_action, &add_bad_desc_data_1),
3249                 CALLBACK_GATTS_DESCRIPTOR_ADDED(GATT_STATUS_FAILURE, APP1_ID,
3250                                                 &app2_uuid, NULL, NULL, NULL),
3251         ),
3252         TEST_CASE_BREDRLE("Gatt Server - Add Desc. wrong app ID",
3253                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3254                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3255                 ACTION_SUCCESS(gatt_server_add_service_action,
3256                                                         &add_service_data_6),
3257                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3258                                                         &service_add_1, NULL,
3259                                                         &srvc1_handle),
3260                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_1),
3261                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3262                                                         APP1_ID, &app1_uuid,
3263                                                         &srvc1_handle, NULL,
3264                                                         NULL),
3265                 ACTION_FAIL(gatt_server_add_desc_action, &add_bad_desc_data_2),
3266                 CALLBACK_GATTS_DESCRIPTOR_ADDED(GATT_STATUS_FAILURE, APP2_ID,
3267                                                 &app2_uuid, NULL, NULL, NULL),
3268         ),
3269         TEST_CASE_BREDRLE("Gatt Server - Start Service Successful BREDRLE",
3270                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3271                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3272                 ACTION_SUCCESS(gatt_server_add_service_action,
3273                                                         &add_service_data_1),
3274                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3275                                                         &service_add_1, NULL,
3276                                                         &srvc1_handle),
3277                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3278                                                         &start_srvc_data_1),
3279                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3280                                                                 &srvc1_handle),
3281         ),
3282         TEST_CASE_BREDRLE("Gatt Server - Start Service Successful LE",
3283                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3284                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3285                 ACTION_SUCCESS(gatt_server_add_service_action,
3286                                                         &add_service_data_1),
3287                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3288                                                         &service_add_1, NULL,
3289                                                         &srvc1_handle),
3290                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3291                                                         &start_srvc_data_2),
3292                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3293                                                                 &srvc1_handle),
3294         ),
3295         TEST_CASE_BREDRLE("Gatt Server - Start Service wrong service handle",
3296                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3297                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3298                 ACTION_SUCCESS(gatt_server_add_service_action,
3299                                                         &add_service_data_1),
3300                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3301                                                 &service_add_1, NULL, NULL),
3302                 ACTION_FAIL(gatt_server_start_srvc_action,
3303                                                         &start_bad_srvc_data_1),
3304                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_FAILURE, APP1_ID,
3305                                                                         NULL),
3306         ),
3307         TEST_CASE_BREDRLE("Gatt Server - Start Service wrong server transport",
3308                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3309                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3310                 ACTION_SUCCESS(gatt_server_add_service_action,
3311                                                         &add_service_data_1),
3312                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3313                                                         &service_add_1, NULL,
3314                                                         &srvc1_handle),
3315                 ACTION_FAIL(gatt_server_start_srvc_action,
3316                                                         &start_bad_srvc_data_2),
3317                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_FAILURE, APP1_ID,
3318                                                                 &srvc1_handle),
3319         ),
3320         TEST_CASE_BREDRLE("Gatt Server - Stop Service Successful",
3321                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3322                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3323                 ACTION_SUCCESS(gatt_server_add_service_action,
3324                                                         &add_service_data_1),
3325                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3326                                                         &service_add_1, NULL,
3327                                                         &srvc1_handle),
3328                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3329                                                         &start_srvc_data_1),
3330                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3331                                                                 &srvc1_handle),
3332                 ACTION_SUCCESS(gatt_server_stop_srvc_action, &stop_srvc_data_1),
3333                 CALLBACK_GATTS_SERVICE_STOPPED(GATT_STATUS_SUCCESS, APP1_ID,
3334                                                                 &srvc1_handle),
3335         ),
3336         TEST_CASE_BREDRLE("Gatt Server - Stop Service wrong service handle",
3337                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3338                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3339                 ACTION_SUCCESS(gatt_server_add_service_action,
3340                                                         &add_service_data_1),
3341                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3342                                                         &service_add_1, NULL,
3343                                                         &srvc1_handle),
3344                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3345                                                         &start_srvc_data_1),
3346                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3347                                                                 &srvc1_handle),
3348                 ACTION_FAIL(gatt_server_stop_srvc_action,
3349                                                         &stop_bad_srvc_data_1),
3350                 CALLBACK_GATTS_SERVICE_STOPPED(GATT_STATUS_FAILURE, APP1_ID,
3351                                                                         NULL),
3352         ),
3353         TEST_CASE_BREDRLE("Gatt Server - Delete Service Successful",
3354                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3355                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3356                 ACTION_SUCCESS(gatt_server_add_service_action,
3357                                                         &add_service_data_1),
3358                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3359                                                         &service_add_1, NULL,
3360                                                         &srvc1_handle),
3361                 ACTION_SUCCESS(gatt_server_delete_srvc_action,
3362                                                         &delete_srvc_data_1),
3363                 CALLBACK_GATTS_SERVICE_DELETED(GATT_STATUS_SUCCESS, APP1_ID,
3364                                                                 &srvc1_handle),
3365         ),
3366         TEST_CASE_BREDRLE("Gatt Server - Delete Service wrong handle",
3367                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3368                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3369                 ACTION_SUCCESS(gatt_server_add_service_action,
3370                                                         &add_service_data_1),
3371                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3372                                                         &service_add_1, NULL,
3373                                                         &srvc1_handle),
3374                 ACTION_FAIL(gatt_server_delete_srvc_action,
3375                                                 &delete_bad_srvc_data_1),
3376                 CALLBACK_GATTS_SERVICE_DELETED(GATT_STATUS_FAILURE, APP1_ID,
3377                                                                         NULL),
3378         ),
3379         TEST_CASE_BREDRLE("Gatt Server - Send Indication",
3380                 ACTION_SUCCESS(init_pdus, send_indication_1),
3381                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3382                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3383                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3384                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3385                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3386                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3387                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3388                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3389                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3390                                                         BT_DISCOVERY_STARTED),
3391                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3392                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3393                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3394                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3395                                                 prop_emu_remotes_default_set,
3396                                                 CONN1_ID, APP1_ID),
3397                 ACTION_SUCCESS(gatt_server_send_indication_action,
3398                                                 &send_indication_data_1),
3399                 CALLBACK(CB_EMU_VALUE_INDICATION),
3400                 CALLBACK_GATTS_NOTIF_CONF(CONN1_ID, GATT_STATUS_SUCCESS),
3401                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3402                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3403         ),
3404         TEST_CASE_BREDRLE("Gatt Server - Send Notification",
3405                 ACTION_SUCCESS(init_pdus, send_notification_1),
3406                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3407                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3408                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3409                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3410                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3411                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3412                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3413                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3414                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3415                                                         BT_DISCOVERY_STARTED),
3416                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3417                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3418                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3419                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3420                                                 prop_emu_remotes_default_set,
3421                                                 CONN1_ID, APP1_ID),
3422                 ACTION_SUCCESS(gatt_server_send_indication_action,
3423                                                 &send_indication_data_2),
3424                 CALLBACK_GATTS_NOTIF_CONF(CONN1_ID, GATT_STATUS_SUCCESS),
3425                 CALLBACK(CB_EMU_VALUE_NOTIFICATION),
3426                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3427                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3428         ),
3429         TEST_CASE_BREDRLE("Gatt Server - Send Notification, wrong conn id",
3430                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3431                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3432                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3433                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3434                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3435                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3436                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3437                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3438                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3439                                                         BT_DISCOVERY_STARTED),
3440                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3441                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3442                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3443                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3444                                                 prop_emu_remotes_default_set,
3445                                                 CONN1_ID, APP1_ID),
3446                 ACTION_FAIL(gatt_server_send_indication_action,
3447                                                 &send_bad_indication_data_1),
3448                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3449                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3450         ),
3451         TEST_CASE_BREDRLE("Gatt Server - Send response to read char request",
3452                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3453                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3454                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3455                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3456                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3457                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3458                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3459                 ACTION_SUCCESS(gatt_server_add_service_action,
3460                                                         &add_service_data_5),
3461                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3462                                                         &service_add_1, NULL,
3463                                                         &srvc1_handle),
3464                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_1),
3465                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3466                                                         APP1_ID, &app1_uuid,
3467                                                         &srvc1_handle, NULL,
3468                                                         &char1_handle),
3469                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3470                                                         &start_srvc_data_2),
3471                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3472                                                                 &srvc1_handle),
3473                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3474                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3475                                                         BT_DISCOVERY_STARTED),
3476                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3477                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3478                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3479                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3480                                                 prop_emu_remotes_default_set,
3481                                                 CONN1_ID, APP1_ID),
3482                 PROCESS_DATA(GATT_STATUS_SUCCESS,
3483                                 gatt_remote_send_raw_pdu_action,
3484                                 &att_read_req_op_v, &char1_handle_v, NULL),
3485                 CALLBACK_GATTS_REQUEST_READ(CONN1_ID, TRANS1_ID,
3486                                                 prop_emu_remotes_default_set,
3487                                                 &char1_handle, 0, false),
3488                 ACTION_SUCCESS(gatt_server_send_response_action,
3489                                                         &send_resp_data_1),
3490                 CALLBACK(CB_EMU_READ_RESPONSE),
3491                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3492                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3493         ),
3494         TEST_CASE_BREDRLE("Gatt Server - Send response to write char request",
3495                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3496                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3497                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3498                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3499                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3500                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3501                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3502                 ACTION_SUCCESS(gatt_server_add_service_action,
3503                                                         &add_service_data_5),
3504                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3505                                                         &service_add_1, NULL,
3506                                                         &srvc1_handle),
3507                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_2),
3508                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3509                                                         APP1_ID, &app1_uuid,
3510                                                         &srvc1_handle, NULL,
3511                                                         &char1_handle),
3512                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3513                                                         &start_srvc_data_2),
3514                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3515                                                                 &srvc1_handle),
3516                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3517                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3518                                                         BT_DISCOVERY_STARTED),
3519                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3520                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3521                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3522                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3523                                                 prop_emu_remotes_default_set,
3524                                                 CONN1_ID, APP1_ID),
3525                 PROCESS_DATA(GATT_STATUS_SUCCESS,
3526                                         gatt_remote_send_raw_pdu_action,
3527                                         &att_write_req_op_v, &char1_handle_v,
3528                                         &att_write_req_value_1_v),
3529                 CALLBACK_GATTS_REQUEST_WRITE(CONN1_ID, TRANS1_ID,
3530                                                 prop_emu_remotes_default_set,
3531                                                 &char1_handle, 0,
3532                                                 sizeof(att_write_req_value_1),
3533                                                 true, false,
3534                                                 att_write_req_value_1),
3535                 ACTION_SUCCESS(gatt_server_send_response_action,
3536                                                         &send_resp_data_2),
3537                 CALLBACK(CB_EMU_WRITE_RESPONSE),
3538                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3539                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3540         ),
3541         TEST_CASE_BREDRLE("Gatt Server - Find By Type - Attribute not found",
3542                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3543                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3544                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3545                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3546                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3547                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3548                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3549                 ACTION_SUCCESS(gatt_server_add_service_action,
3550                                                         &add_service_data_5),
3551                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3552                                                         &service_add_1, NULL,
3553                                                         &srvc1_handle),
3554                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_2),
3555                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3556                                                         APP1_ID, &app1_uuid,
3557                                                         &srvc1_handle, NULL,
3558                                                         &char1_handle),
3559                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3560                                                         &start_srvc_data_2),
3561                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3562                                                                 &srvc1_handle),
3563                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3564                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3565                                                         BT_DISCOVERY_STARTED),
3566                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3567                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3568                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3569                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3570                                                 prop_emu_remotes_default_set,
3571                                                 CONN1_ID, APP1_ID),
3572                 PROCESS_DATA(GATT_STATUS_SUCCESS,
3573                                                 gatt_remote_send_raw_pdu_action,
3574                                                 &att_find_by_type_req_op_v,
3575                                                 &search_range_1,
3576                                                 &primary_type),
3577                 CALLBACK_ERROR(CB_EMU_ATT_ERROR, 0x0a),
3578                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3579                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3580         ),
3581         /* This tests embeded ccc */
3582         TEST_CASE_BREDRLE("Gatt Server - Srvc change write req. success",
3583                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3584                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3585                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3586                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3587                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3588                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3589                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3590                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3591                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3592                                                         BT_DISCOVERY_STARTED),
3593                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3594                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3595                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3596                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3597                                                 prop_emu_remotes_default_set,
3598                                                 CONN1_ID, APP1_ID),
3599                 /* For CCC we need to be bonded */
3600                 ACTION_SUCCESS(bt_create_bond_action,
3601                                         &prop_test_remote_ble_bdaddr_req),
3602                 CALLBACK_BOND_STATE(BT_BOND_STATE_BONDED,
3603                                         &prop_emu_remotes_default_set[0], 1),
3604                 /* Write and receive confirmation */
3605                 PROCESS_DATA(GATT_STATUS_SUCCESS,
3606                                 gatt_remote_send_raw_pdu_action,
3607                                 &att_write_req_op_v, &svc_change_ccc_handle_v,
3608                                 &svc_change_ccc_value_v),
3609                 CALLBACK(CB_EMU_WRITE_RESPONSE),
3610                 /* Shutdown */
3611                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3612                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3613         ),
3614         TEST_CASE_BREDRLE("Gatt Server - Send error resp to write char request",
3615                 ACTION_SUCCESS(bluetooth_enable_action, NULL),
3616                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_ON),
3617                 ACTION_SUCCESS(emu_setup_powered_remote_action, NULL),
3618                 ACTION_SUCCESS(emu_set_ssp_mode_action, NULL),
3619                 ACTION_SUCCESS(emu_set_connect_cb_action, gatt_conn_cb),
3620                 ACTION_SUCCESS(gatt_server_register_action, &app1_uuid),
3621                 CALLBACK_STATUS(CB_GATTS_REGISTER_SERVER, BT_STATUS_SUCCESS),
3622                 ACTION_SUCCESS(gatt_server_add_service_action,
3623                                                         &add_service_data_5),
3624                 CALLBACK_GATTS_SERVICE_ADDED(GATT_STATUS_SUCCESS, APP1_ID,
3625                                                         &service_add_1, NULL,
3626                                                         &srvc1_handle),
3627                 ACTION_SUCCESS(gatt_server_add_char_action, &add_char_data_2),
3628                 CALLBACK_GATTS_CHARACTERISTIC_ADDED(GATT_STATUS_SUCCESS,
3629                                                         APP1_ID, &app1_uuid,
3630                                                         &srvc1_handle, NULL,
3631                                                         &char1_handle),
3632                 ACTION_SUCCESS(gatt_server_start_srvc_action,
3633                                                         &start_srvc_data_2),
3634                 CALLBACK_GATTS_SERVICE_STARTED(GATT_STATUS_SUCCESS, APP1_ID,
3635                                                                 &srvc1_handle),
3636                 ACTION_SUCCESS(bt_start_discovery_action, NULL),
3637                 CALLBACK_STATE(CB_BT_DISCOVERY_STATE_CHANGED,
3638                                                         BT_DISCOVERY_STARTED),
3639                 CALLBACK_DEVICE_FOUND(prop_emu_remotes_default_le_set, 2),
3640                 ACTION_SUCCESS(bt_cancel_discovery_action, NULL),
3641                 ACTION_SUCCESS(gatt_server_connect_action, &app1_conn_req),
3642                 CALLBACK_GATTS_CONNECTION(GATT_SERVER_CONNECTED,
3643                                                 prop_emu_remotes_default_set,
3644                                                 CONN1_ID, APP1_ID),
3645                 PROCESS_DATA(GATT_STATUS_SUCCESS,
3646                                         gatt_remote_send_raw_pdu_action,
3647                                         &att_write_req_op_v, &char1_handle_v,
3648                                         &att_write_req_value_1_v),
3649                 CALLBACK_GATTS_REQUEST_WRITE(CONN1_ID, TRANS1_ID,
3650                                                 prop_emu_remotes_default_set,
3651                                                 &char1_handle, 0,
3652                                                 sizeof(att_write_req_value_1),
3653                                                 true, false,
3654                                                 att_write_req_value_1),
3655                 ACTION_SUCCESS(gatt_server_send_response_action,
3656                                                 &send_resp_data_2_error),
3657                 CALLBACK_ERROR(CB_EMU_ATT_ERROR, GATT_ERR_INVAL_ATTR_VALUE_LEN),
3658                 ACTION_SUCCESS(bluetooth_disable_action, NULL),
3659                 CALLBACK_STATE(CB_BT_ADAPTER_STATE_CHANGED, BT_STATE_OFF),
3660                 ),
3661 };
3662
3663 struct queue *get_gatt_tests(void)
3664 {
3665         uint16_t i = 0;
3666
3667         list = queue_new();
3668
3669         for (; i < sizeof(test_cases) / sizeof(test_cases[0]); ++i)
3670                 queue_push_tail(list, &test_cases[i]);
3671
3672         return list;
3673 }
3674
3675 void remove_gatt_tests(void)
3676 {
3677         queue_destroy(list, NULL);
3678 }