tester-gatt.c 132 KB

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