hci.h 81 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789
  1. /* hci.h - Bluetooth Host Control Interface definitions */
  2. /*
  3. * Copyright (c) 2015-2016 Intel Corporation
  4. *
  5. * SPDX-License-Identifier: Apache-2.0
  6. */
  7. #ifndef ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_
  8. #define ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_
  9. #include <toolchain.h>
  10. #include <zephyr/types.h>
  11. #include <stdbool.h>
  12. #include <string.h>
  13. #include <sys/util.h>
  14. #include <net/buf.h>
  15. #include <bluetooth/addr.h>
  16. #include <bluetooth/hci_err.h>
  17. #include <bluetooth/conn.h>
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /* Special own address types for LL privacy (used in adv & scan parameters) */
  22. #define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC 0x02
  23. #define BT_HCI_OWN_ADDR_RPA_OR_RANDOM 0x03
  24. #define BT_HCI_OWN_ADDR_RPA_MASK 0x02
  25. #define BT_HCI_PEER_ADDR_RPA_UNRESOLVED 0xfe
  26. #define BT_HCI_PEER_ADDR_ANONYMOUS 0xff
  27. #define BT_ENC_KEY_SIZE_MIN 0x07
  28. #define BT_ENC_KEY_SIZE_MAX 0x10
  29. struct bt_hci_evt_hdr {
  30. uint8_t evt;
  31. uint8_t len;
  32. } __packed;
  33. #define BT_HCI_EVT_HDR_SIZE 2
  34. #define BT_ACL_START_NO_FLUSH 0x00
  35. #define BT_ACL_CONT 0x01
  36. #define BT_ACL_START 0x02
  37. #define BT_ACL_COMPLETE 0x03
  38. #define BT_ACL_POINT_TO_POINT 0x00
  39. #define BT_ACL_BROADCAST 0x01
  40. #define BT_ACL_HANDLE_MASK BIT_MASK(12)
  41. #define bt_acl_handle(h) ((h) & BT_ACL_HANDLE_MASK)
  42. #define bt_acl_flags(h) ((h) >> 12)
  43. #define bt_acl_flags_pb(f) ((f) & BIT_MASK(2))
  44. #define bt_acl_flags_bc(f) ((f) >> 2)
  45. #define bt_acl_handle_pack(h, f) ((h) | ((f) << 12))
  46. struct bt_hci_acl_hdr {
  47. uint16_t handle;
  48. uint16_t len;
  49. } __packed;
  50. #define BT_HCI_ACL_HDR_SIZE 4
  51. #define BT_ISO_START 0x00
  52. #define BT_ISO_CONT 0x01
  53. #define BT_ISO_SINGLE 0x02
  54. #define BT_ISO_END 0x03
  55. #define bt_iso_handle(h) ((h) & 0x0fff)
  56. #define bt_iso_flags(h) ((h) >> 12)
  57. #define bt_iso_flags_pb(f) ((f) & 0x0003)
  58. #define bt_iso_flags_ts(f) (((f) >> 2) & 0x0001)
  59. #define bt_iso_pack_flags(pb, ts) \
  60. (((pb) & 0x0003) | (((ts) & 0x0001) << 2))
  61. #define bt_iso_handle_pack(h, pb, ts) \
  62. ((h) | (bt_iso_pack_flags(pb, ts) << 12))
  63. #define BT_ISO_DATA_VALID 0x00
  64. #define BT_ISO_DATA_INVALID 0x01
  65. #define BT_ISO_DATA_NOP 0x02
  66. #define bt_iso_pkt_len(h) ((h) & 0x3fff)
  67. #define bt_iso_pkt_flags(h) ((h) >> 14)
  68. #define bt_iso_pkt_len_pack(h, f) ((h) | ((f) << 14))
  69. struct bt_hci_iso_data_hdr {
  70. uint16_t sn;
  71. uint16_t slen;
  72. } __packed;
  73. #define BT_HCI_ISO_DATA_HDR_SIZE 4
  74. struct bt_hci_iso_ts_data_hdr {
  75. uint32_t ts;
  76. struct bt_hci_iso_data_hdr data;
  77. } __packed;
  78. #define BT_HCI_ISO_TS_DATA_HDR_SIZE 8
  79. struct bt_hci_iso_hdr {
  80. uint16_t handle;
  81. uint16_t len;
  82. } __packed;
  83. #define BT_HCI_ISO_HDR_SIZE 4
  84. struct bt_hci_cmd_hdr {
  85. uint16_t opcode;
  86. uint8_t param_len;
  87. } __packed;
  88. #define BT_HCI_CMD_HDR_SIZE 3
  89. /* Supported Commands */
  90. #define BT_CMD_TEST(cmd, octet, bit) (cmd[octet] & BIT(bit))
  91. #define BT_CMD_LE_STATES(cmd) BT_CMD_TEST(cmd, 28, 3)
  92. #define BT_FEAT_TEST(feat, page, octet, bit) (feat[page][octet] & BIT(bit))
  93. #define BT_FEAT_BREDR(feat) !BT_FEAT_TEST(feat, 0, 4, 5)
  94. #define BT_FEAT_LE(feat) BT_FEAT_TEST(feat, 0, 4, 6)
  95. #define BT_FEAT_EXT_FEATURES(feat) BT_FEAT_TEST(feat, 0, 7, 7)
  96. #define BT_FEAT_HOST_SSP(feat) BT_FEAT_TEST(feat, 1, 0, 0)
  97. #define BT_FEAT_SC(feat) BT_FEAT_TEST(feat, 2, 1, 0)
  98. #define BT_FEAT_LMP_ESCO_CAPABLE(feat) BT_FEAT_TEST(feat, 0, 3, 7)
  99. #define BT_FEAT_HV2_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 4)
  100. #define BT_FEAT_HV3_PKT(feat) BT_FEAT_TEST(feat, 0, 1, 5)
  101. #define BT_FEAT_EV4_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 0)
  102. #define BT_FEAT_EV5_PKT(feat) BT_FEAT_TEST(feat, 0, 4, 1)
  103. #define BT_FEAT_2EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 5)
  104. #define BT_FEAT_3EV3_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 6)
  105. #define BT_FEAT_3SLOT_PKT(feat) BT_FEAT_TEST(feat, 0, 5, 7)
  106. /* LE features */
  107. #define BT_LE_FEAT_BIT_ENC 0
  108. #define BT_LE_FEAT_BIT_CONN_PARAM_REQ 1
  109. #define BT_LE_FEAT_BIT_EXT_REJ_IND 2
  110. #define BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG 3
  111. #define BT_LE_FEAT_BIT_PING 4
  112. #define BT_LE_FEAT_BIT_DLE 5
  113. #define BT_LE_FEAT_BIT_PRIVACY 6
  114. #define BT_LE_FEAT_BIT_EXT_SCAN 7
  115. #define BT_LE_FEAT_BIT_PHY_2M 8
  116. #define BT_LE_FEAT_BIT_SMI_TX 9
  117. #define BT_LE_FEAT_BIT_SMI_RX 10
  118. #define BT_LE_FEAT_BIT_PHY_CODED 11
  119. #define BT_LE_FEAT_BIT_EXT_ADV 12
  120. #define BT_LE_FEAT_BIT_PER_ADV 13
  121. #define BT_LE_FEAT_BIT_CHAN_SEL_ALGO_2 14
  122. #define BT_LE_FEAT_BIT_PWR_CLASS_1 15
  123. #define BT_LE_FEAT_BIT_MIN_USED_CHAN_PROC 16
  124. #define BT_LE_FEAT_BIT_CONN_CTE_REQ 17
  125. #define BT_LE_FEAT_BIT_CONN_CTE_RESP 18
  126. #define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX 19
  127. #define BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX 20
  128. #define BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD 21
  129. #define BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA 22
  130. #define BT_LE_FEAT_BIT_RX_CTE 23
  131. #define BT_LE_FEAT_BIT_PAST_SEND 24
  132. #define BT_LE_FEAT_BIT_PAST_RECV 25
  133. #define BT_LE_FEAT_BIT_SCA_UPDATE 26
  134. #define BT_LE_FEAT_BIT_REMOTE_PUB_KEY_VALIDATE 27
  135. #define BT_LE_FEAT_BIT_CIS_CENTRAL 28
  136. #define BT_LE_FEAT_BIT_CIS_PERIPHERAL 29
  137. #define BT_LE_FEAT_BIT_ISO_BROADCASTER 30
  138. #define BT_LE_FEAT_BIT_SYNC_RECEIVER 31
  139. #define BT_LE_FEAT_BIT_ISO_CHANNELS 32
  140. #define BT_LE_FEAT_BIT_PWR_CTRL_REQ 33
  141. #define BT_LE_FEAT_BIT_PWR_CHG_IND 34
  142. #define BT_LE_FEAT_BIT_PATH_LOSS_MONITOR 35
  143. #define BT_LE_FEAT_TEST(feat, n) (feat[(n) >> 3] & \
  144. BIT((n) & 7))
  145. #define BT_FEAT_LE_ENCR(feat) BT_LE_FEAT_TEST(feat, \
  146. BT_LE_FEAT_BIT_ENC)
  147. #define BT_FEAT_LE_CONN_PARAM_REQ_PROC(feat) BT_LE_FEAT_TEST(feat, \
  148. BT_LE_FEAT_BIT_CONN_PARAM_REQ)
  149. #define BT_FEAT_LE_PER_INIT_FEAT_XCHG(feat) BT_LE_FEAT_TEST(feat, \
  150. BT_LE_FEAT_BIT_PER_INIT_FEAT_XCHG)
  151. #define BT_FEAT_LE_DLE(feat) BT_LE_FEAT_TEST(feat, \
  152. BT_LE_FEAT_BIT_DLE)
  153. #define BT_FEAT_LE_PHY_2M(feat) BT_LE_FEAT_TEST(feat, \
  154. BT_LE_FEAT_BIT_PHY_2M)
  155. #define BT_FEAT_LE_PHY_CODED(feat) BT_LE_FEAT_TEST(feat, \
  156. BT_LE_FEAT_BIT_PHY_CODED)
  157. #define BT_FEAT_LE_PRIVACY(feat) BT_LE_FEAT_TEST(feat, \
  158. BT_LE_FEAT_BIT_PRIVACY)
  159. #define BT_FEAT_LE_EXT_ADV(feat) BT_LE_FEAT_TEST(feat, \
  160. BT_LE_FEAT_BIT_EXT_ADV)
  161. #define BT_FEAT_LE_EXT_PER_ADV(feat) BT_LE_FEAT_TEST(feat, \
  162. BT_LE_FEAT_BIT_PER_ADV)
  163. #define BT_FEAT_LE_CONNECTION_CTE_REQ(feat) BT_LE_FEAT_TEST(feat, \
  164. BT_LE_FEAT_BIT_CONN_CTE_REQ)
  165. #define BT_FEAT_LE_CONNECTION_CTE_RESP(feat) BT_LE_FEAT_TEST(feat, \
  166. BT_LE_FEAT_BIT_CONN_CTE_RESP)
  167. #define BT_FEAT_LE_CONNECTIONLESS_CTE_TX(feat) BT_LE_FEAT_TEST(feat, \
  168. BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_TX)
  169. #define BT_FEAT_LE_CONNECTIONLESS_CTE_RX(feat) BT_LE_FEAT_TEST(feat, \
  170. BT_LE_FEAT_BIT_CONNECTIONLESS_CTE_RX)
  171. #define BT_FEAT_LE_ANT_SWITCH_TX_AOD(feat) BT_LE_FEAT_TEST(feat, \
  172. BT_LE_FEAT_BIT_ANT_SWITCH_TX_AOD)
  173. #define BT_FEAT_LE_ANT_SWITCH_RX_AOA(feat) BT_LE_FEAT_TEST(feat, \
  174. BT_LE_FEAT_BIT_ANT_SWITCH_RX_AOA)
  175. #define BT_FEAT_LE_RX_CTE(feat) BT_LE_FEAT_TEST(feat, \
  176. BT_LE_FEAT_BIT_RX_CTE)
  177. #define BT_FEAT_LE_PAST_SEND(feat) BT_LE_FEAT_TEST(feat, \
  178. BT_LE_FEAT_BIT_PAST_SEND)
  179. #define BT_FEAT_LE_PAST_RECV(feat) BT_LE_FEAT_TEST(feat, \
  180. BT_LE_FEAT_BIT_PAST_RECV)
  181. #define BT_FEAT_LE_CIS_CENTRAL(feat) BT_LE_FEAT_TEST(feat, \
  182. BT_LE_FEAT_BIT_CIS_CENTRAL)
  183. #define BT_FEAT_LE_CIS_PERIPHERAL(feat) BT_LE_FEAT_TEST(feat, \
  184. BT_LE_FEAT_BIT_CIS_PERIPHERAL)
  185. #define BT_FEAT_LE_ISO_BROADCASTER(feat) BT_LE_FEAT_TEST(feat, \
  186. BT_LE_FEAT_BIT_ISO_BROADCASTER)
  187. #define BT_FEAT_LE_SYNC_RECEIVER(feat) BT_LE_FEAT_TEST(feat, \
  188. BT_LE_FEAT_BIT_SYNC_RECEIVER)
  189. #define BT_FEAT_LE_ISO_CHANNELS(feat) BT_LE_FEAT_TEST(feat, \
  190. BT_LE_FEAT_BIT_ISO_CHANNELS)
  191. #define BT_FEAT_LE_CIS(feat) (BT_FEAT_LE_CIS_CENTRAL(feat) | \
  192. BT_FEAT_LE_CIS_PERIPHERAL(feat))
  193. #define BT_FEAT_LE_BIS(feat) (BT_FEAT_LE_ISO_BROADCASTER(feat) | \
  194. BT_FEAT_LE_SYNC_RECEIVER(feat))
  195. #define BT_FEAT_LE_ISO(feat) (BT_FEAT_LE_CIS(feat) | \
  196. BT_FEAT_LE_BIS(feat))
  197. /* LE States */
  198. #define BT_LE_STATES_PER_CONN_ADV(states) (states & 0x0000004000000000)
  199. /* Bonding/authentication types */
  200. #define BT_HCI_NO_BONDING 0x00
  201. #define BT_HCI_NO_BONDING_MITM 0x01
  202. #define BT_HCI_DEDICATED_BONDING 0x02
  203. #define BT_HCI_DEDICATED_BONDING_MITM 0x03
  204. #define BT_HCI_GENERAL_BONDING 0x04
  205. #define BT_HCI_GENERAL_BONDING_MITM 0x05
  206. /*
  207. * MITM protection is enabled in SSP authentication requirements octet when
  208. * LSB bit is set.
  209. */
  210. #define BT_MITM 0x01
  211. /* I/O capabilities */
  212. #define BT_IO_DISPLAY_ONLY 0x00
  213. #define BT_IO_DISPLAY_YESNO 0x01
  214. #define BT_IO_KEYBOARD_ONLY 0x02
  215. #define BT_IO_NO_INPUT_OUTPUT 0x03
  216. /* SCO packet types */
  217. #define HCI_PKT_TYPE_HV1 0x0020
  218. #define HCI_PKT_TYPE_HV2 0x0040
  219. #define HCI_PKT_TYPE_HV3 0x0080
  220. /* eSCO packet types */
  221. #define HCI_PKT_TYPE_ESCO_HV1 0x0001
  222. #define HCI_PKT_TYPE_ESCO_HV2 0x0002
  223. #define HCI_PKT_TYPE_ESCO_HV3 0x0004
  224. #define HCI_PKT_TYPE_ESCO_EV3 0x0008
  225. #define HCI_PKT_TYPE_ESCO_EV4 0x0010
  226. #define HCI_PKT_TYPE_ESCO_EV5 0x0020
  227. #define HCI_PKT_TYPE_ESCO_2EV3 0x0040
  228. #define HCI_PKT_TYPE_ESCO_3EV3 0x0080
  229. #define HCI_PKT_TYPE_ESCO_2EV5 0x0100
  230. #define HCI_PKT_TYPE_ESCO_3EV5 0x0200
  231. #define ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_HV1 | \
  232. HCI_PKT_TYPE_ESCO_HV2 | \
  233. HCI_PKT_TYPE_ESCO_HV3)
  234. #define SCO_PKT_MASK (HCI_PKT_TYPE_HV1 | \
  235. HCI_PKT_TYPE_HV2 | \
  236. HCI_PKT_TYPE_HV3)
  237. #define EDR_ESCO_PKT_MASK (HCI_PKT_TYPE_ESCO_2EV3 | \
  238. HCI_PKT_TYPE_ESCO_3EV3 | \
  239. HCI_PKT_TYPE_ESCO_2EV5 | \
  240. HCI_PKT_TYPE_ESCO_3EV5)
  241. /* HCI BR/EDR link types */
  242. #define BT_HCI_SCO 0x00
  243. #define BT_HCI_ACL 0x01
  244. #define BT_HCI_ESCO 0x02
  245. /* OpCode Group Fields */
  246. #define BT_OGF_LINK_CTRL 0x01
  247. #define BT_OGF_BASEBAND 0x03
  248. #define BT_OGF_INFO 0x04
  249. #define BT_OGF_STATUS 0x05
  250. #define BT_OGF_LE 0x08
  251. #define BT_OGF_VS 0x3f
  252. /* Construct OpCode from OGF and OCF */
  253. #define BT_OP(ogf, ocf) ((ocf) | ((ogf) << 10))
  254. /* Invalid opcode */
  255. #define BT_OP_NOP 0x0000
  256. /* Obtain OGF from OpCode */
  257. #define BT_OGF(opcode) (((opcode) >> 10) & BIT_MASK(6))
  258. /* Obtain OCF from OpCode */
  259. #define BT_OCF(opcode) ((opcode) & BIT_MASK(10))
  260. #define BT_HCI_OP_INQUIRY BT_OP(BT_OGF_LINK_CTRL, 0x0001)
  261. struct bt_hci_op_inquiry {
  262. uint8_t lap[3];
  263. uint8_t length;
  264. uint8_t num_rsp;
  265. } __packed;
  266. #define BT_HCI_OP_INQUIRY_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0002)
  267. #define BT_HCI_OP_CONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0005)
  268. struct bt_hci_cp_connect {
  269. bt_addr_t bdaddr;
  270. uint16_t packet_type;
  271. uint8_t pscan_rep_mode;
  272. uint8_t reserved;
  273. uint16_t clock_offset;
  274. uint8_t allow_role_switch;
  275. } __packed;
  276. #define BT_HCI_OP_DISCONNECT BT_OP(BT_OGF_LINK_CTRL, 0x0006)
  277. struct bt_hci_cp_disconnect {
  278. uint16_t handle;
  279. uint8_t reason;
  280. } __packed;
  281. #define BT_HCI_OP_CONNECT_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x0008)
  282. struct bt_hci_cp_connect_cancel {
  283. bt_addr_t bdaddr;
  284. } __packed;
  285. struct bt_hci_rp_connect_cancel {
  286. uint8_t status;
  287. bt_addr_t bdaddr;
  288. } __packed;
  289. #define BT_HCI_OP_ACCEPT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0009)
  290. struct bt_hci_cp_accept_conn_req {
  291. bt_addr_t bdaddr;
  292. uint8_t role;
  293. } __packed;
  294. #define BT_HCI_OP_SETUP_SYNC_CONN BT_OP(BT_OGF_LINK_CTRL, 0x0028)
  295. struct bt_hci_cp_setup_sync_conn {
  296. uint16_t handle;
  297. uint32_t tx_bandwidth;
  298. uint32_t rx_bandwidth;
  299. uint16_t max_latency;
  300. uint16_t content_format;
  301. uint8_t retrans_effort;
  302. uint16_t pkt_type;
  303. } __packed;
  304. #define BT_HCI_OP_ACCEPT_SYNC_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x0029)
  305. struct bt_hci_cp_accept_sync_conn_req {
  306. bt_addr_t bdaddr;
  307. uint32_t tx_bandwidth;
  308. uint32_t rx_bandwidth;
  309. uint16_t max_latency;
  310. uint16_t content_format;
  311. uint8_t retrans_effort;
  312. uint16_t pkt_type;
  313. } __packed;
  314. #define BT_HCI_OP_REJECT_CONN_REQ BT_OP(BT_OGF_LINK_CTRL, 0x000a)
  315. struct bt_hci_cp_reject_conn_req {
  316. bt_addr_t bdaddr;
  317. uint8_t reason;
  318. } __packed;
  319. #define BT_HCI_OP_LINK_KEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000b)
  320. struct bt_hci_cp_link_key_reply {
  321. bt_addr_t bdaddr;
  322. uint8_t link_key[16];
  323. } __packed;
  324. #define BT_HCI_OP_LINK_KEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000c)
  325. struct bt_hci_cp_link_key_neg_reply {
  326. bt_addr_t bdaddr;
  327. } __packed;
  328. #define BT_HCI_OP_PIN_CODE_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000d)
  329. struct bt_hci_cp_pin_code_reply {
  330. bt_addr_t bdaddr;
  331. uint8_t pin_len;
  332. uint8_t pin_code[16];
  333. } __packed;
  334. struct bt_hci_rp_pin_code_reply {
  335. uint8_t status;
  336. bt_addr_t bdaddr;
  337. } __packed;
  338. #define BT_HCI_OP_PIN_CODE_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x000e)
  339. struct bt_hci_cp_pin_code_neg_reply {
  340. bt_addr_t bdaddr;
  341. } __packed;
  342. struct bt_hci_rp_pin_code_neg_reply {
  343. uint8_t status;
  344. bt_addr_t bdaddr;
  345. } __packed;
  346. #define BT_HCI_OP_AUTH_REQUESTED BT_OP(BT_OGF_LINK_CTRL, 0x0011)
  347. struct bt_hci_cp_auth_requested {
  348. uint16_t handle;
  349. } __packed;
  350. #define BT_HCI_OP_SET_CONN_ENCRYPT BT_OP(BT_OGF_LINK_CTRL, 0x0013)
  351. struct bt_hci_cp_set_conn_encrypt {
  352. uint16_t handle;
  353. uint8_t encrypt;
  354. } __packed;
  355. #define BT_HCI_OP_REMOTE_NAME_REQUEST BT_OP(BT_OGF_LINK_CTRL, 0x0019)
  356. struct bt_hci_cp_remote_name_request {
  357. bt_addr_t bdaddr;
  358. uint8_t pscan_rep_mode;
  359. uint8_t reserved;
  360. uint16_t clock_offset;
  361. } __packed;
  362. #define BT_HCI_OP_REMOTE_NAME_CANCEL BT_OP(BT_OGF_LINK_CTRL, 0x001a)
  363. struct bt_hci_cp_remote_name_cancel {
  364. bt_addr_t bdaddr;
  365. } __packed;
  366. struct bt_hci_rp_remote_name_cancel {
  367. uint8_t status;
  368. bt_addr_t bdaddr;
  369. } __packed;
  370. #define BT_HCI_OP_READ_REMOTE_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001b)
  371. struct bt_hci_cp_read_remote_features {
  372. uint16_t handle;
  373. } __packed;
  374. #define BT_HCI_OP_READ_REMOTE_EXT_FEATURES BT_OP(BT_OGF_LINK_CTRL, 0x001c)
  375. struct bt_hci_cp_read_remote_ext_features {
  376. uint16_t handle;
  377. uint8_t page;
  378. } __packed;
  379. #define BT_HCI_OP_READ_REMOTE_VERSION_INFO BT_OP(BT_OGF_LINK_CTRL, 0x001d)
  380. struct bt_hci_cp_read_remote_version_info {
  381. uint16_t handle;
  382. } __packed;
  383. #define BT_HCI_OP_IO_CAPABILITY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002b)
  384. struct bt_hci_cp_io_capability_reply {
  385. bt_addr_t bdaddr;
  386. uint8_t capability;
  387. uint8_t oob_data;
  388. uint8_t authentication;
  389. } __packed;
  390. #define BT_HCI_OP_USER_CONFIRM_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002c)
  391. #define BT_HCI_OP_USER_CONFIRM_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002d)
  392. struct bt_hci_cp_user_confirm_reply {
  393. bt_addr_t bdaddr;
  394. } __packed;
  395. struct bt_hci_rp_user_confirm_reply {
  396. uint8_t status;
  397. bt_addr_t bdaddr;
  398. } __packed;
  399. #define BT_HCI_OP_USER_PASSKEY_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002e)
  400. struct bt_hci_cp_user_passkey_reply {
  401. bt_addr_t bdaddr;
  402. uint32_t passkey;
  403. } __packed;
  404. #define BT_HCI_OP_USER_PASSKEY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x002f)
  405. struct bt_hci_cp_user_passkey_neg_reply {
  406. bt_addr_t bdaddr;
  407. } __packed;
  408. #define BT_HCI_OP_IO_CAPABILITY_NEG_REPLY BT_OP(BT_OGF_LINK_CTRL, 0x0034)
  409. struct bt_hci_cp_io_capability_neg_reply {
  410. bt_addr_t bdaddr;
  411. uint8_t reason;
  412. } __packed;
  413. #define BT_HCI_OP_SET_EVENT_MASK BT_OP(BT_OGF_BASEBAND, 0x0001)
  414. struct bt_hci_cp_set_event_mask {
  415. uint8_t events[8];
  416. } __packed;
  417. #define BT_HCI_OP_RESET BT_OP(BT_OGF_BASEBAND, 0x0003)
  418. #define BT_HCI_OP_WRITE_LOCAL_NAME BT_OP(BT_OGF_BASEBAND, 0x0013)
  419. struct bt_hci_write_local_name {
  420. uint8_t local_name[248];
  421. } __packed;
  422. #define BT_HCI_OP_WRITE_PAGE_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x0018)
  423. #define BT_HCI_OP_WRITE_SCAN_ENABLE BT_OP(BT_OGF_BASEBAND, 0x001a)
  424. #define BT_BREDR_SCAN_DISABLED 0x00
  425. #define BT_BREDR_SCAN_INQUIRY 0x01
  426. #define BT_BREDR_SCAN_PAGE 0x02
  427. #define BT_HCI_OP_WRITE_CLASS_OF_DEVICE BT_OP(BT_OGF_BASEBAND, 0x0024)
  428. struct bt_hci_cp_write_class_of_device {
  429. uint8_t class_of_device[3];
  430. } __packed;
  431. #define BT_TX_POWER_LEVEL_CURRENT 0x00
  432. #define BT_TX_POWER_LEVEL_MAX 0x01
  433. #define BT_HCI_OP_READ_TX_POWER_LEVEL BT_OP(BT_OGF_BASEBAND, 0x002d)
  434. struct bt_hci_cp_read_tx_power_level {
  435. uint16_t handle;
  436. uint8_t type;
  437. } __packed;
  438. struct bt_hci_rp_read_tx_power_level {
  439. uint8_t status;
  440. uint16_t handle;
  441. int8_t tx_power_level;
  442. } __packed;
  443. #define BT_HCI_CTL_TO_HOST_FLOW_DISABLE 0x00
  444. #define BT_HCI_CTL_TO_HOST_FLOW_ENABLE 0x01
  445. #define BT_HCI_OP_SET_CTL_TO_HOST_FLOW BT_OP(BT_OGF_BASEBAND, 0x0031)
  446. struct bt_hci_cp_set_ctl_to_host_flow {
  447. uint8_t flow_enable;
  448. } __packed;
  449. #define BT_HCI_OP_HOST_BUFFER_SIZE BT_OP(BT_OGF_BASEBAND, 0x0033)
  450. struct bt_hci_cp_host_buffer_size {
  451. uint16_t acl_mtu;
  452. uint8_t sco_mtu;
  453. uint16_t acl_pkts;
  454. uint16_t sco_pkts;
  455. } __packed;
  456. struct bt_hci_handle_count {
  457. uint16_t handle;
  458. uint16_t count;
  459. } __packed;
  460. #define BT_HCI_OP_HOST_NUM_COMPLETED_PACKETS BT_OP(BT_OGF_BASEBAND, 0x0035)
  461. struct bt_hci_cp_host_num_completed_packets {
  462. uint8_t num_handles;
  463. struct bt_hci_handle_count h[0];
  464. } __packed;
  465. #define BT_HCI_OP_WRITE_INQUIRY_MODE BT_OP(BT_OGF_BASEBAND, 0x0045)
  466. struct bt_hci_cp_write_inquiry_mode {
  467. uint8_t mode;
  468. } __packed;
  469. #define BT_HCI_OP_WRITE_SSP_MODE BT_OP(BT_OGF_BASEBAND, 0x0056)
  470. struct bt_hci_cp_write_ssp_mode {
  471. uint8_t mode;
  472. } __packed;
  473. #define BT_HCI_OP_SET_EVENT_MASK_PAGE_2 BT_OP(BT_OGF_BASEBAND, 0x0063)
  474. struct bt_hci_cp_set_event_mask_page_2 {
  475. uint8_t events_page_2[8];
  476. } __packed;
  477. #define BT_HCI_OP_LE_WRITE_LE_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x006d)
  478. struct bt_hci_cp_write_le_host_supp {
  479. uint8_t le;
  480. uint8_t simul;
  481. } __packed;
  482. #define BT_HCI_OP_WRITE_SC_HOST_SUPP BT_OP(BT_OGF_BASEBAND, 0x007a)
  483. struct bt_hci_cp_write_sc_host_supp {
  484. uint8_t sc_support;
  485. } __packed;
  486. #define BT_HCI_OP_READ_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007b)
  487. struct bt_hci_cp_read_auth_payload_timeout {
  488. uint16_t handle;
  489. } __packed;
  490. struct bt_hci_rp_read_auth_payload_timeout {
  491. uint8_t status;
  492. uint16_t handle;
  493. uint16_t auth_payload_timeout;
  494. } __packed;
  495. #define BT_HCI_OP_WRITE_AUTH_PAYLOAD_TIMEOUT BT_OP(BT_OGF_BASEBAND, 0x007c)
  496. struct bt_hci_cp_write_auth_payload_timeout {
  497. uint16_t handle;
  498. uint16_t auth_payload_timeout;
  499. } __packed;
  500. struct bt_hci_rp_write_auth_payload_timeout {
  501. uint8_t status;
  502. uint16_t handle;
  503. } __packed;
  504. #define BT_HCI_OP_CONFIGURE_DATA_PATH BT_OP(BT_OGF_BASEBAND, 0x0083)
  505. struct bt_hci_cp_configure_data_path {
  506. uint8_t data_path_dir;
  507. uint8_t data_path_id;
  508. uint8_t vs_config_len;
  509. uint8_t vs_config[0];
  510. } __packed;
  511. struct bt_hci_rp_configure_data_path {
  512. uint8_t status;
  513. } __packed;
  514. /* HCI version from Assigned Numbers */
  515. #define BT_HCI_VERSION_1_0B 0
  516. #define BT_HCI_VERSION_1_1 1
  517. #define BT_HCI_VERSION_1_2 2
  518. #define BT_HCI_VERSION_2_0 3
  519. #define BT_HCI_VERSION_2_1 4
  520. #define BT_HCI_VERSION_3_0 5
  521. #define BT_HCI_VERSION_4_0 6
  522. #define BT_HCI_VERSION_4_1 7
  523. #define BT_HCI_VERSION_4_2 8
  524. #define BT_HCI_VERSION_5_0 9
  525. #define BT_HCI_VERSION_5_1 10
  526. #define BT_HCI_VERSION_5_2 11
  527. #define BT_HCI_VERSION_5_3 12
  528. #define BT_HCI_OP_READ_LOCAL_VERSION_INFO BT_OP(BT_OGF_INFO, 0x0001)
  529. struct bt_hci_rp_read_local_version_info {
  530. uint8_t status;
  531. uint8_t hci_version;
  532. uint16_t hci_revision;
  533. uint8_t lmp_version;
  534. uint16_t manufacturer;
  535. uint16_t lmp_subversion;
  536. } __packed;
  537. #define BT_HCI_OP_READ_SUPPORTED_COMMANDS BT_OP(BT_OGF_INFO, 0x0002)
  538. struct bt_hci_rp_read_supported_commands {
  539. uint8_t status;
  540. uint8_t commands[64];
  541. } __packed;
  542. #define BT_HCI_OP_READ_LOCAL_EXT_FEATURES BT_OP(BT_OGF_INFO, 0x0004)
  543. struct bt_hci_cp_read_local_ext_features {
  544. uint8_t page;
  545. };
  546. struct bt_hci_rp_read_local_ext_features {
  547. uint8_t status;
  548. uint8_t page;
  549. uint8_t max_page;
  550. uint8_t ext_features[8];
  551. } __packed;
  552. #define BT_HCI_OP_READ_LOCAL_FEATURES BT_OP(BT_OGF_INFO, 0x0003)
  553. struct bt_hci_rp_read_local_features {
  554. uint8_t status;
  555. uint8_t features[8];
  556. } __packed;
  557. #define BT_HCI_OP_READ_BUFFER_SIZE BT_OP(BT_OGF_INFO, 0x0005)
  558. struct bt_hci_rp_read_buffer_size {
  559. uint8_t status;
  560. uint16_t acl_max_len;
  561. uint8_t sco_max_len;
  562. uint16_t acl_max_num;
  563. uint16_t sco_max_num;
  564. } __packed;
  565. #define BT_HCI_OP_READ_BD_ADDR BT_OP(BT_OGF_INFO, 0x0009)
  566. struct bt_hci_rp_read_bd_addr {
  567. uint8_t status;
  568. bt_addr_t bdaddr;
  569. } __packed;
  570. /* logic transport type bits as returned when reading supported codecs */
  571. #define BT_HCI_CODEC_TRANSPORT_MASK_BREDR_ACL BIT(0)
  572. #define BT_HCI_CODEC_TRANSPORT_MASK_BREDR_SCO BIT(1)
  573. #define BT_HCI_CODEC_TRANSPORT_MASK_LE_CIS BIT(2)
  574. #define BT_HCI_CODEC_TRANSPORT_MASK_LE_BIS BIT(3)
  575. /* logic transport types for reading codec capabilities and controller delays */
  576. #define BT_HCI_LOGICAL_TRANSPORT_TYPE_BREDR_ACL 0x00
  577. #define BT_HCI_LOGICAL_TRANSPORT_TYPE_BREDR_SCO 0x01
  578. #define BT_HCI_LOGICAL_TRANSPORT_TYPE_LE_CIS 0x02
  579. #define BT_HCI_LOGICAL_TRANSPORT_TYPE_LE_BIS 0x03
  580. /* audio datapath directions */
  581. #define BT_HCI_DATAPATH_DIR_HOST_TO_CTLR 0x00
  582. #define BT_HCI_DATAPATH_DIR_CTLR_TO_HOST 0x01
  583. /* audio datapath IDs */
  584. #define BT_HCI_DATAPATH_ID_HCI 0x00
  585. #define BT_HCI_DATAPATH_ID_VS 0x01
  586. #define BT_HCI_DATAPATH_ID_VS_END 0xfe
  587. #define BT_HCI_DATAPATH_ID_DISABLED 0xff
  588. /* coding format assigned numbers, used for codec IDs */
  589. #define BT_HCI_CODING_FORMAT_ULAW_LOG 0x00
  590. #define BT_HCI_CODING_FORMAT_ALAW_LOG 0x01
  591. #define BT_HCI_CODING_FORMAT_CVSD 0x02
  592. #define BT_HCI_CODING_FORMAT_TRANSPARENT 0x03
  593. #define BT_HCI_CODING_FORMAT_LINEAR_PCM 0x04
  594. #define BT_HCI_CODING_FORMAT_MSBC 0x05
  595. #define BT_HCI_CODING_FORMAT_VS 0xFF
  596. #define BT_HCI_OP_READ_CODECS BT_OP(BT_OGF_INFO, 0x000b)
  597. struct bt_hci_std_codec_info {
  598. uint8_t codec_id;
  599. } __packed;
  600. struct bt_hci_std_codecs {
  601. uint8_t num_codecs;
  602. struct bt_hci_std_codec_info codec_info[0];
  603. } __packed;
  604. struct bt_hci_vs_codec_info {
  605. uint16_t company_id;
  606. uint16_t codec_id;
  607. } __packed;
  608. struct bt_hci_vs_codecs {
  609. uint8_t num_codecs;
  610. struct bt_hci_vs_codec_info codec_info[0];
  611. } __packed;
  612. struct bt_hci_rp_read_codecs {
  613. uint8_t status;
  614. /* other fields filled in dynamically */
  615. uint8_t codecs[0];
  616. } __packed;
  617. #define BT_HCI_OP_READ_CODECS_V2 BT_OP(BT_OGF_INFO, 0x000d)
  618. struct bt_hci_std_codec_info_v2 {
  619. uint8_t codec_id;
  620. uint8_t transports; /* bitmap */
  621. } __packed;
  622. struct bt_hci_std_codecs_v2 {
  623. uint8_t num_codecs;
  624. struct bt_hci_std_codec_info_v2 codec_info[0];
  625. } __packed;
  626. struct bt_hci_vs_codec_info_v2 {
  627. uint16_t company_id;
  628. uint16_t codec_id;
  629. uint8_t transports; /* bitmap */
  630. } __packed;
  631. struct bt_hci_vs_codecs_v2 {
  632. uint8_t num_codecs;
  633. struct bt_hci_vs_codec_info_v2 codec_info[0];
  634. } __packed;
  635. struct bt_hci_rp_read_codecs_v2 {
  636. uint8_t status;
  637. /* other fields filled in dynamically */
  638. uint8_t codecs[0];
  639. } __packed;
  640. struct bt_hci_cp_codec_id {
  641. uint8_t coding_format;
  642. uint16_t company_id;
  643. uint16_t vs_codec_id;
  644. } __packed;
  645. #define BT_HCI_OP_READ_CODEC_CAPABILITIES BT_OP(BT_OGF_INFO, 0x000e)
  646. struct bt_hci_cp_read_codec_capabilities {
  647. struct bt_hci_cp_codec_id codec_id;
  648. uint8_t transport;
  649. uint8_t direction;
  650. } __packed;
  651. struct bt_hci_codec_capability_info {
  652. uint8_t length;
  653. uint8_t data[0];
  654. } __packed;
  655. struct bt_hci_rp_read_codec_capabilities {
  656. uint8_t status;
  657. uint8_t num_capabilities;
  658. /* other fields filled in dynamically */
  659. uint8_t capabilities[0];
  660. } __packed;
  661. #define BT_HCI_OP_READ_CTLR_DELAY BT_OP(BT_OGF_INFO, 0x000f)
  662. struct bt_hci_cp_read_ctlr_delay {
  663. struct bt_hci_cp_codec_id codec_id;
  664. uint8_t transport;
  665. uint8_t direction;
  666. uint8_t codec_config_len;
  667. uint8_t codec_config[0];
  668. } __packed;
  669. struct bt_hci_rp_read_ctlr_delay {
  670. uint8_t status;
  671. uint8_t min_ctlr_delay[3];
  672. uint8_t max_ctlr_delay[3];
  673. } __packed;
  674. #define BT_HCI_OP_READ_RSSI BT_OP(BT_OGF_STATUS, 0x0005)
  675. struct bt_hci_cp_read_rssi {
  676. uint16_t handle;
  677. } __packed;
  678. struct bt_hci_rp_read_rssi {
  679. uint8_t status;
  680. uint16_t handle;
  681. int8_t rssi;
  682. } __packed;
  683. #define BT_HCI_ENCRYPTION_KEY_SIZE_MIN 7
  684. #define BT_HCI_ENCRYPTION_KEY_SIZE_MAX 16
  685. #define BT_HCI_OP_READ_ENCRYPTION_KEY_SIZE BT_OP(BT_OGF_STATUS, 0x0008)
  686. struct bt_hci_cp_read_encryption_key_size {
  687. uint16_t handle;
  688. } __packed;
  689. struct bt_hci_rp_read_encryption_key_size {
  690. uint8_t status;
  691. uint16_t handle;
  692. uint8_t key_size;
  693. } __packed;
  694. /* BLE */
  695. #define BT_HCI_OP_LE_SET_EVENT_MASK BT_OP(BT_OGF_LE, 0x0001)
  696. struct bt_hci_cp_le_set_event_mask {
  697. uint8_t events[8];
  698. } __packed;
  699. #define BT_HCI_OP_LE_READ_BUFFER_SIZE BT_OP(BT_OGF_LE, 0x0002)
  700. struct bt_hci_rp_le_read_buffer_size {
  701. uint8_t status;
  702. uint16_t le_max_len;
  703. uint8_t le_max_num;
  704. } __packed;
  705. #define BT_HCI_OP_LE_READ_LOCAL_FEATURES BT_OP(BT_OGF_LE, 0x0003)
  706. struct bt_hci_rp_le_read_local_features {
  707. uint8_t status;
  708. uint8_t features[8];
  709. } __packed;
  710. #define BT_HCI_OP_LE_SET_RANDOM_ADDRESS BT_OP(BT_OGF_LE, 0x0005)
  711. struct bt_hci_cp_le_set_random_address {
  712. bt_addr_t bdaddr;
  713. } __packed;
  714. #define BT_HCI_ADV_IND 0x00
  715. #define BT_HCI_ADV_DIRECT_IND 0x01
  716. #define BT_HCI_ADV_SCAN_IND 0x02
  717. #define BT_HCI_ADV_NONCONN_IND 0x03
  718. #define BT_HCI_ADV_DIRECT_IND_LOW_DUTY 0x04
  719. #define BT_HCI_ADV_SCAN_RSP 0x04
  720. #define BT_LE_ADV_INTERVAL_MIN 0x0020
  721. #define BT_LE_ADV_INTERVAL_MAX 0x4000
  722. #define BT_LE_ADV_INTERVAL_DEFAULT 0x0800
  723. #define BT_LE_ADV_CHAN_MAP_CHAN_37 0x01
  724. #define BT_LE_ADV_CHAN_MAP_CHAN_38 0x02
  725. #define BT_LE_ADV_CHAN_MAP_CHAN_39 0x04
  726. #define BT_LE_ADV_CHAN_MAP_ALL 0x07
  727. #define BT_LE_ADV_FP_NO_FILTER 0x00
  728. #define BT_LE_ADV_FP_FILTER_SCAN_REQ 0x01
  729. #define BT_LE_ADV_FP_FILTER_CONN_IND 0x02
  730. #define BT_LE_ADV_FP_FILTER_BOTH 0x03
  731. #define BT_HCI_OP_LE_SET_ADV_PARAM BT_OP(BT_OGF_LE, 0x0006)
  732. struct bt_hci_cp_le_set_adv_param {
  733. uint16_t min_interval;
  734. uint16_t max_interval;
  735. uint8_t type;
  736. uint8_t own_addr_type;
  737. bt_addr_le_t direct_addr;
  738. uint8_t channel_map;
  739. uint8_t filter_policy;
  740. } __packed;
  741. #define BT_HCI_OP_LE_READ_ADV_CHAN_TX_POWER BT_OP(BT_OGF_LE, 0x0007)
  742. struct bt_hci_rp_le_read_chan_tx_power {
  743. uint8_t status;
  744. int8_t tx_power_level;
  745. } __packed;
  746. #define BT_HCI_OP_LE_SET_ADV_DATA BT_OP(BT_OGF_LE, 0x0008)
  747. struct bt_hci_cp_le_set_adv_data {
  748. uint8_t len;
  749. uint8_t data[31];
  750. } __packed;
  751. #define BT_HCI_OP_LE_SET_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0009)
  752. struct bt_hci_cp_le_set_scan_rsp_data {
  753. uint8_t len;
  754. uint8_t data[31];
  755. } __packed;
  756. #define BT_HCI_LE_ADV_DISABLE 0x00
  757. #define BT_HCI_LE_ADV_ENABLE 0x01
  758. #define BT_HCI_OP_LE_SET_ADV_ENABLE BT_OP(BT_OGF_LE, 0x000a)
  759. struct bt_hci_cp_le_set_adv_enable {
  760. uint8_t enable;
  761. } __packed;
  762. /* Scan types */
  763. #define BT_HCI_OP_LE_SET_SCAN_PARAM BT_OP(BT_OGF_LE, 0x000b)
  764. #define BT_HCI_LE_SCAN_PASSIVE 0x00
  765. #define BT_HCI_LE_SCAN_ACTIVE 0x01
  766. #define BT_HCI_LE_SCAN_FP_BASIC_NO_FILTER 0x00
  767. #define BT_HCI_LE_SCAN_FP_BASIC_FILTER 0x01
  768. #define BT_HCI_LE_SCAN_FP_EXT_NO_FILTER 0x02
  769. #define BT_HCI_LE_SCAN_FP_EXT_FILTER 0x03
  770. struct bt_hci_cp_le_set_scan_param {
  771. uint8_t scan_type;
  772. uint16_t interval;
  773. uint16_t window;
  774. uint8_t addr_type;
  775. uint8_t filter_policy;
  776. } __packed;
  777. #define BT_HCI_OP_LE_SET_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x000c)
  778. #define BT_HCI_LE_SCAN_DISABLE 0x00
  779. #define BT_HCI_LE_SCAN_ENABLE 0x01
  780. #define BT_HCI_LE_SCAN_FILTER_DUP_DISABLE 0x00
  781. #define BT_HCI_LE_SCAN_FILTER_DUP_ENABLE 0x01
  782. struct bt_hci_cp_le_set_scan_enable {
  783. uint8_t enable;
  784. uint8_t filter_dup;
  785. } __packed;
  786. #define BT_HCI_OP_LE_CREATE_CONN BT_OP(BT_OGF_LE, 0x000d)
  787. #define BT_HCI_LE_CREATE_CONN_FP_NO_FILTER 0x00
  788. #define BT_HCI_LE_CREATE_CONN_FP_FILTER 0x01
  789. struct bt_hci_cp_le_create_conn {
  790. uint16_t scan_interval;
  791. uint16_t scan_window;
  792. uint8_t filter_policy;
  793. bt_addr_le_t peer_addr;
  794. uint8_t own_addr_type;
  795. uint16_t conn_interval_min;
  796. uint16_t conn_interval_max;
  797. uint16_t conn_latency;
  798. uint16_t supervision_timeout;
  799. uint16_t min_ce_len;
  800. uint16_t max_ce_len;
  801. } __packed;
  802. #define BT_HCI_OP_LE_CREATE_CONN_CANCEL BT_OP(BT_OGF_LE, 0x000e)
  803. #define BT_HCI_OP_LE_READ_FAL_SIZE BT_OP(BT_OGF_LE, 0x000f)
  804. struct bt_hci_rp_le_read_fal_size {
  805. uint8_t status;
  806. uint8_t fal_size;
  807. } __packed;
  808. #define BT_HCI_OP_LE_CLEAR_FAL BT_OP(BT_OGF_LE, 0x0010)
  809. #define BT_HCI_OP_LE_ADD_DEV_TO_FAL BT_OP(BT_OGF_LE, 0x0011)
  810. struct bt_hci_cp_le_add_dev_to_fal {
  811. bt_addr_le_t addr;
  812. } __packed;
  813. #define BT_HCI_OP_LE_REM_DEV_FROM_FAL BT_OP(BT_OGF_LE, 0x0012)
  814. struct bt_hci_cp_le_rem_dev_from_fal {
  815. bt_addr_le_t addr;
  816. } __packed;
  817. #define BT_HCI_OP_LE_CONN_UPDATE BT_OP(BT_OGF_LE, 0x0013)
  818. struct hci_cp_le_conn_update {
  819. uint16_t handle;
  820. uint16_t conn_interval_min;
  821. uint16_t conn_interval_max;
  822. uint16_t conn_latency;
  823. uint16_t supervision_timeout;
  824. uint16_t min_ce_len;
  825. uint16_t max_ce_len;
  826. } __packed;
  827. #define BT_HCI_OP_LE_SET_HOST_CHAN_CLASSIF BT_OP(BT_OGF_LE, 0x0014)
  828. struct bt_hci_cp_le_set_host_chan_classif {
  829. uint8_t ch_map[5];
  830. } __packed;
  831. #define BT_HCI_OP_LE_READ_CHAN_MAP BT_OP(BT_OGF_LE, 0x0015)
  832. struct bt_hci_cp_le_read_chan_map {
  833. uint16_t handle;
  834. } __packed;
  835. struct bt_hci_rp_le_read_chan_map {
  836. uint8_t status;
  837. uint16_t handle;
  838. uint8_t ch_map[5];
  839. } __packed;
  840. #define BT_HCI_OP_LE_READ_REMOTE_FEATURES BT_OP(BT_OGF_LE, 0x0016)
  841. struct bt_hci_cp_le_read_remote_features {
  842. uint16_t handle;
  843. } __packed;
  844. #define BT_HCI_OP_LE_ENCRYPT BT_OP(BT_OGF_LE, 0x0017)
  845. struct bt_hci_cp_le_encrypt {
  846. uint8_t key[16];
  847. uint8_t plaintext[16];
  848. } __packed;
  849. struct bt_hci_rp_le_encrypt {
  850. uint8_t status;
  851. uint8_t enc_data[16];
  852. } __packed;
  853. #define BT_HCI_OP_LE_RAND BT_OP(BT_OGF_LE, 0x0018)
  854. struct bt_hci_rp_le_rand {
  855. uint8_t status;
  856. uint8_t rand[8];
  857. } __packed;
  858. #define BT_HCI_OP_LE_START_ENCRYPTION BT_OP(BT_OGF_LE, 0x0019)
  859. struct bt_hci_cp_le_start_encryption {
  860. uint16_t handle;
  861. uint64_t rand;
  862. uint16_t ediv;
  863. uint8_t ltk[16];
  864. } __packed;
  865. #define BT_HCI_OP_LE_LTK_REQ_REPLY BT_OP(BT_OGF_LE, 0x001a)
  866. struct bt_hci_cp_le_ltk_req_reply {
  867. uint16_t handle;
  868. uint8_t ltk[16];
  869. } __packed;
  870. struct bt_hci_rp_le_ltk_req_reply {
  871. uint8_t status;
  872. uint16_t handle;
  873. } __packed;
  874. #define BT_HCI_OP_LE_LTK_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x001b)
  875. struct bt_hci_cp_le_ltk_req_neg_reply {
  876. uint16_t handle;
  877. } __packed;
  878. struct bt_hci_rp_le_ltk_req_neg_reply {
  879. uint8_t status;
  880. uint16_t handle;
  881. } __packed;
  882. #define BT_HCI_OP_LE_READ_SUPP_STATES BT_OP(BT_OGF_LE, 0x001c)
  883. struct bt_hci_rp_le_read_supp_states {
  884. uint8_t status;
  885. uint8_t le_states[8];
  886. } __packed;
  887. #define BT_HCI_OP_LE_RX_TEST BT_OP(BT_OGF_LE, 0x001d)
  888. struct bt_hci_cp_le_rx_test {
  889. uint8_t rx_ch;
  890. } __packed;
  891. #define BT_HCI_OP_LE_TX_TEST BT_OP(BT_OGF_LE, 0x001e)
  892. struct bt_hci_cp_le_tx_test {
  893. uint8_t tx_ch;
  894. uint8_t test_data_len;
  895. uint8_t pkt_payload;
  896. } __packed;
  897. #define BT_HCI_OP_LE_TEST_END BT_OP(BT_OGF_LE, 0x001f)
  898. struct bt_hci_rp_le_test_end {
  899. uint8_t status;
  900. uint16_t rx_pkt_count;
  901. } __packed;
  902. #define BT_HCI_OP_LE_CONN_PARAM_REQ_REPLY BT_OP(BT_OGF_LE, 0x0020)
  903. struct bt_hci_cp_le_conn_param_req_reply {
  904. uint16_t handle;
  905. uint16_t interval_min;
  906. uint16_t interval_max;
  907. uint16_t latency;
  908. uint16_t timeout;
  909. uint16_t min_ce_len;
  910. uint16_t max_ce_len;
  911. } __packed;
  912. struct bt_hci_rp_le_conn_param_req_reply {
  913. uint8_t status;
  914. uint16_t handle;
  915. } __packed;
  916. #define BT_HCI_OP_LE_CONN_PARAM_REQ_NEG_REPLY BT_OP(BT_OGF_LE, 0x0021)
  917. struct bt_hci_cp_le_conn_param_req_neg_reply {
  918. uint16_t handle;
  919. uint8_t reason;
  920. } __packed;
  921. struct bt_hci_rp_le_conn_param_req_neg_reply {
  922. uint8_t status;
  923. uint16_t handle;
  924. } __packed;
  925. #define BT_HCI_OP_LE_SET_DATA_LEN BT_OP(BT_OGF_LE, 0x0022)
  926. struct bt_hci_cp_le_set_data_len {
  927. uint16_t handle;
  928. uint16_t tx_octets;
  929. uint16_t tx_time;
  930. } __packed;
  931. struct bt_hci_rp_le_set_data_len {
  932. uint8_t status;
  933. uint16_t handle;
  934. } __packed;
  935. #define BT_HCI_OP_LE_READ_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0023)
  936. struct bt_hci_rp_le_read_default_data_len {
  937. uint8_t status;
  938. uint16_t max_tx_octets;
  939. uint16_t max_tx_time;
  940. } __packed;
  941. #define BT_HCI_OP_LE_WRITE_DEFAULT_DATA_LEN BT_OP(BT_OGF_LE, 0x0024)
  942. struct bt_hci_cp_le_write_default_data_len {
  943. uint16_t max_tx_octets;
  944. uint16_t max_tx_time;
  945. } __packed;
  946. #define BT_HCI_OP_LE_P256_PUBLIC_KEY BT_OP(BT_OGF_LE, 0x0025)
  947. #define BT_HCI_OP_LE_GENERATE_DHKEY BT_OP(BT_OGF_LE, 0x0026)
  948. struct bt_hci_cp_le_generate_dhkey {
  949. uint8_t key[64];
  950. } __packed;
  951. #define BT_HCI_OP_LE_GENERATE_DHKEY_V2 BT_OP(BT_OGF_LE, 0x005e)
  952. #define BT_HCI_LE_KEY_TYPE_GENERATED 0x00
  953. #define BT_HCI_LE_KEY_TYPE_DEBUG 0x01
  954. struct bt_hci_cp_le_generate_dhkey_v2 {
  955. uint8_t key[64];
  956. uint8_t key_type;
  957. } __packed;
  958. #define BT_HCI_OP_LE_ADD_DEV_TO_RL BT_OP(BT_OGF_LE, 0x0027)
  959. struct bt_hci_cp_le_add_dev_to_rl {
  960. bt_addr_le_t peer_id_addr;
  961. uint8_t peer_irk[16];
  962. uint8_t local_irk[16];
  963. } __packed;
  964. #define BT_HCI_OP_LE_REM_DEV_FROM_RL BT_OP(BT_OGF_LE, 0x0028)
  965. struct bt_hci_cp_le_rem_dev_from_rl {
  966. bt_addr_le_t peer_id_addr;
  967. } __packed;
  968. #define BT_HCI_OP_LE_CLEAR_RL BT_OP(BT_OGF_LE, 0x0029)
  969. #define BT_HCI_OP_LE_READ_RL_SIZE BT_OP(BT_OGF_LE, 0x002a)
  970. struct bt_hci_rp_le_read_rl_size {
  971. uint8_t status;
  972. uint8_t rl_size;
  973. } __packed;
  974. #define BT_HCI_OP_LE_READ_PEER_RPA BT_OP(BT_OGF_LE, 0x002b)
  975. struct bt_hci_cp_le_read_peer_rpa {
  976. bt_addr_le_t peer_id_addr;
  977. } __packed;
  978. struct bt_hci_rp_le_read_peer_rpa {
  979. uint8_t status;
  980. bt_addr_t peer_rpa;
  981. } __packed;
  982. #define BT_HCI_OP_LE_READ_LOCAL_RPA BT_OP(BT_OGF_LE, 0x002c)
  983. struct bt_hci_cp_le_read_local_rpa {
  984. bt_addr_le_t peer_id_addr;
  985. } __packed;
  986. struct bt_hci_rp_le_read_local_rpa {
  987. uint8_t status;
  988. bt_addr_t local_rpa;
  989. } __packed;
  990. #define BT_HCI_ADDR_RES_DISABLE 0x00
  991. #define BT_HCI_ADDR_RES_ENABLE 0x01
  992. #define BT_HCI_OP_LE_SET_ADDR_RES_ENABLE BT_OP(BT_OGF_LE, 0x002d)
  993. struct bt_hci_cp_le_set_addr_res_enable {
  994. uint8_t enable;
  995. } __packed;
  996. #define BT_HCI_OP_LE_SET_RPA_TIMEOUT BT_OP(BT_OGF_LE, 0x002e)
  997. struct bt_hci_cp_le_set_rpa_timeout {
  998. uint16_t rpa_timeout;
  999. } __packed;
  1000. #define BT_HCI_OP_LE_READ_MAX_DATA_LEN BT_OP(BT_OGF_LE, 0x002f)
  1001. struct bt_hci_rp_le_read_max_data_len {
  1002. uint8_t status;
  1003. uint16_t max_tx_octets;
  1004. uint16_t max_tx_time;
  1005. uint16_t max_rx_octets;
  1006. uint16_t max_rx_time;
  1007. } __packed;
  1008. #define BT_HCI_LE_PHY_1M 0x01
  1009. #define BT_HCI_LE_PHY_2M 0x02
  1010. #define BT_HCI_LE_PHY_CODED 0x03
  1011. #define BT_HCI_OP_LE_READ_PHY BT_OP(BT_OGF_LE, 0x0030)
  1012. struct bt_hci_cp_le_read_phy {
  1013. uint16_t handle;
  1014. } __packed;
  1015. struct bt_hci_rp_le_read_phy {
  1016. uint8_t status;
  1017. uint16_t handle;
  1018. uint8_t tx_phy;
  1019. uint8_t rx_phy;
  1020. } __packed;
  1021. #define BT_HCI_LE_PHY_TX_ANY BIT(0)
  1022. #define BT_HCI_LE_PHY_RX_ANY BIT(1)
  1023. #define BT_HCI_LE_PHY_PREFER_1M BIT(0)
  1024. #define BT_HCI_LE_PHY_PREFER_2M BIT(1)
  1025. #define BT_HCI_LE_PHY_PREFER_CODED BIT(2)
  1026. #define BT_HCI_OP_LE_SET_DEFAULT_PHY BT_OP(BT_OGF_LE, 0x0031)
  1027. struct bt_hci_cp_le_set_default_phy {
  1028. uint8_t all_phys;
  1029. uint8_t tx_phys;
  1030. uint8_t rx_phys;
  1031. } __packed;
  1032. #define BT_HCI_LE_PHY_CODED_ANY 0x00
  1033. #define BT_HCI_LE_PHY_CODED_S2 0x01
  1034. #define BT_HCI_LE_PHY_CODED_S8 0x02
  1035. #define BT_HCI_OP_LE_SET_PHY BT_OP(BT_OGF_LE, 0x0032)
  1036. struct bt_hci_cp_le_set_phy {
  1037. uint16_t handle;
  1038. uint8_t all_phys;
  1039. uint8_t tx_phys;
  1040. uint8_t rx_phys;
  1041. uint16_t phy_opts;
  1042. } __packed;
  1043. #define BT_HCI_LE_MOD_INDEX_STANDARD 0x00
  1044. #define BT_HCI_LE_MOD_INDEX_STABLE 0x01
  1045. #define BT_HCI_OP_LE_ENH_RX_TEST BT_OP(BT_OGF_LE, 0x0033)
  1046. struct bt_hci_cp_le_enh_rx_test {
  1047. uint8_t rx_ch;
  1048. uint8_t phy;
  1049. uint8_t mod_index;
  1050. } __packed;
  1051. /* Extends BT_HCI_LE_PHY */
  1052. #define BT_HCI_LE_TX_PHY_CODED_S8 0x03
  1053. #define BT_HCI_LE_TX_PHY_CODED_S2 0x04
  1054. #define BT_HCI_OP_LE_ENH_TX_TEST BT_OP(BT_OGF_LE, 0x0034)
  1055. struct bt_hci_cp_le_enh_tx_test {
  1056. uint8_t tx_ch;
  1057. uint8_t test_data_len;
  1058. uint8_t pkt_payload;
  1059. uint8_t phy;
  1060. } __packed;
  1061. #define BT_HCI_OP_LE_SET_ADV_SET_RANDOM_ADDR BT_OP(BT_OGF_LE, 0x0035)
  1062. struct bt_hci_cp_le_set_adv_set_random_addr {
  1063. uint8_t handle;
  1064. bt_addr_t bdaddr;
  1065. } __packed;
  1066. #define BT_HCI_LE_ADV_PROP_CONN BIT(0)
  1067. #define BT_HCI_LE_ADV_PROP_SCAN BIT(1)
  1068. #define BT_HCI_LE_ADV_PROP_DIRECT BIT(2)
  1069. #define BT_HCI_LE_ADV_PROP_HI_DC_CONN BIT(3)
  1070. #define BT_HCI_LE_ADV_PROP_LEGACY BIT(4)
  1071. #define BT_HCI_LE_ADV_PROP_ANON BIT(5)
  1072. #define BT_HCI_LE_ADV_PROP_TX_POWER BIT(6)
  1073. #define BT_HCI_LE_ADV_SCAN_REQ_ENABLE 1
  1074. #define BT_HCI_LE_ADV_SCAN_REQ_DISABLE 0
  1075. #define BT_HCI_LE_ADV_TX_POWER_NO_PREF 0x7F
  1076. #define BT_HCI_LE_ADV_HANDLE_MAX 0xEF
  1077. #define BT_HCI_LE_EXT_ADV_SID_INVALID 0xFF
  1078. #define BT_HCI_OP_LE_SET_EXT_ADV_PARAM BT_OP(BT_OGF_LE, 0x0036)
  1079. struct bt_hci_cp_le_set_ext_adv_param {
  1080. uint8_t handle;
  1081. uint16_t props;
  1082. uint8_t prim_min_interval[3];
  1083. uint8_t prim_max_interval[3];
  1084. uint8_t prim_channel_map;
  1085. uint8_t own_addr_type;
  1086. bt_addr_le_t peer_addr;
  1087. uint8_t filter_policy;
  1088. int8_t tx_power;
  1089. uint8_t prim_adv_phy;
  1090. uint8_t sec_adv_max_skip;
  1091. uint8_t sec_adv_phy;
  1092. uint8_t sid;
  1093. uint8_t scan_req_notify_enable;
  1094. } __packed;
  1095. struct bt_hci_rp_le_set_ext_adv_param {
  1096. uint8_t status;
  1097. int8_t tx_power;
  1098. } __packed;
  1099. #define BT_HCI_LE_EXT_ADV_OP_INTERM_FRAG 0x00
  1100. #define BT_HCI_LE_EXT_ADV_OP_FIRST_FRAG 0x01
  1101. #define BT_HCI_LE_EXT_ADV_OP_LAST_FRAG 0x02
  1102. #define BT_HCI_LE_EXT_ADV_OP_COMPLETE_DATA 0x03
  1103. #define BT_HCI_LE_EXT_ADV_OP_UNCHANGED_DATA 0x04
  1104. #define BT_HCI_LE_EXT_ADV_FRAG_ENABLED 0x00
  1105. #define BT_HCI_LE_EXT_ADV_FRAG_DISABLED 0x01
  1106. #define BT_HCI_LE_EXT_ADV_FRAG_MAX_LEN 251
  1107. #define BT_HCI_OP_LE_SET_EXT_ADV_DATA BT_OP(BT_OGF_LE, 0x0037)
  1108. struct bt_hci_cp_le_set_ext_adv_data {
  1109. uint8_t handle;
  1110. uint8_t op;
  1111. uint8_t frag_pref;
  1112. uint8_t len;
  1113. uint8_t data[251];
  1114. } __packed;
  1115. #define BT_HCI_OP_LE_SET_EXT_SCAN_RSP_DATA BT_OP(BT_OGF_LE, 0x0038)
  1116. struct bt_hci_cp_le_set_ext_scan_rsp_data {
  1117. uint8_t handle;
  1118. uint8_t op;
  1119. uint8_t frag_pref;
  1120. uint8_t len;
  1121. uint8_t data[251];
  1122. } __packed;
  1123. #define BT_HCI_OP_LE_SET_EXT_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0039)
  1124. struct bt_hci_ext_adv_set {
  1125. uint8_t handle;
  1126. uint16_t duration;
  1127. uint8_t max_ext_adv_evts;
  1128. } __packed;
  1129. struct bt_hci_cp_le_set_ext_adv_enable {
  1130. uint8_t enable;
  1131. uint8_t set_num;
  1132. struct bt_hci_ext_adv_set s[0];
  1133. } __packed;
  1134. #define BT_HCI_OP_LE_READ_MAX_ADV_DATA_LEN BT_OP(BT_OGF_LE, 0x003a)
  1135. struct bt_hci_rp_le_read_max_adv_data_len {
  1136. uint8_t status;
  1137. uint16_t max_adv_data_len;
  1138. } __packed;
  1139. #define BT_HCI_OP_LE_READ_NUM_ADV_SETS BT_OP(BT_OGF_LE, 0x003b)
  1140. struct bt_hci_rp_le_read_num_adv_sets {
  1141. uint8_t status;
  1142. uint8_t num_sets;
  1143. } __packed;
  1144. #define BT_HCI_OP_LE_REMOVE_ADV_SET BT_OP(BT_OGF_LE, 0x003c)
  1145. struct bt_hci_cp_le_remove_adv_set {
  1146. uint8_t handle;
  1147. } __packed;
  1148. #define BT_HCI_OP_CLEAR_ADV_SETS BT_OP(BT_OGF_LE, 0x003d)
  1149. #define BT_HCI_OP_LE_SET_PER_ADV_PARAM BT_OP(BT_OGF_LE, 0x003e)
  1150. struct bt_hci_cp_le_set_per_adv_param {
  1151. uint8_t handle;
  1152. uint16_t min_interval;
  1153. uint16_t max_interval;
  1154. uint16_t props;
  1155. } __packed;
  1156. #define BT_HCI_LE_PER_ADV_OP_INTERM_FRAG 0x00
  1157. #define BT_HCI_LE_PER_ADV_OP_FIRST_FRAG 0x01
  1158. #define BT_HCI_LE_PER_ADV_OP_LAST_FRAG 0x02
  1159. #define BT_HCI_LE_PER_ADV_OP_COMPLETE_DATA 0x03
  1160. #define BT_HCI_LE_PER_ADV_FRAG_MAX_LEN 252
  1161. #define BT_HCI_OP_LE_SET_PER_ADV_DATA BT_OP(BT_OGF_LE, 0x003f)
  1162. struct bt_hci_cp_le_set_per_adv_data {
  1163. uint8_t handle;
  1164. uint8_t op;
  1165. uint8_t len;
  1166. uint8_t data[251];
  1167. } __packed;
  1168. #define BT_HCI_OP_LE_SET_PER_ADV_ENABLE BT_OP(BT_OGF_LE, 0x0040)
  1169. struct bt_hci_cp_le_set_per_adv_enable {
  1170. uint8_t enable;
  1171. uint8_t handle;
  1172. } __packed;
  1173. #define BT_HCI_OP_LE_SET_EXT_SCAN_PARAM BT_OP(BT_OGF_LE, 0x0041)
  1174. struct bt_hci_ext_scan_phy {
  1175. uint8_t type;
  1176. uint16_t interval;
  1177. uint16_t window;
  1178. } __packed;
  1179. #define BT_HCI_LE_EXT_SCAN_PHY_1M BIT(0)
  1180. #define BT_HCI_LE_EXT_SCAN_PHY_2M BIT(1)
  1181. #define BT_HCI_LE_EXT_SCAN_PHY_CODED BIT(2)
  1182. struct bt_hci_cp_le_set_ext_scan_param {
  1183. uint8_t own_addr_type;
  1184. uint8_t filter_policy;
  1185. uint8_t phys;
  1186. struct bt_hci_ext_scan_phy p[0];
  1187. } __packed;
  1188. /* Extends BT_HCI_LE_SCAN_FILTER_DUP */
  1189. #define BT_HCI_LE_EXT_SCAN_FILTER_DUP_ENABLE_RESET 0x02
  1190. #define BT_HCI_OP_LE_SET_EXT_SCAN_ENABLE BT_OP(BT_OGF_LE, 0x0042)
  1191. struct bt_hci_cp_le_set_ext_scan_enable {
  1192. uint8_t enable;
  1193. uint8_t filter_dup;
  1194. uint16_t duration;
  1195. uint16_t period;
  1196. } __packed;
  1197. #define BT_HCI_OP_LE_EXT_CREATE_CONN BT_OP(BT_OGF_LE, 0x0043)
  1198. struct bt_hci_ext_conn_phy {
  1199. uint16_t scan_interval;
  1200. uint16_t scan_window;
  1201. uint16_t conn_interval_min;
  1202. uint16_t conn_interval_max;
  1203. uint16_t conn_latency;
  1204. uint16_t supervision_timeout;
  1205. uint16_t min_ce_len;
  1206. uint16_t max_ce_len;
  1207. } __packed;
  1208. struct bt_hci_cp_le_ext_create_conn {
  1209. uint8_t filter_policy;
  1210. uint8_t own_addr_type;
  1211. bt_addr_le_t peer_addr;
  1212. uint8_t phys;
  1213. struct bt_hci_ext_conn_phy p[0];
  1214. } __packed;
  1215. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_USE_LIST BIT(0)
  1216. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_FP_REPORTS_DISABLED BIT(1)
  1217. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_FILTERING 0
  1218. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOA BIT(0)
  1219. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_1US BIT(1)
  1220. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_AOD_2US BIT(2)
  1221. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_NO_CTE BIT(3)
  1222. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ONLY_CTE BIT(4)
  1223. /* Constants to check correctness of CTE type */
  1224. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ALLOWED_BITS 5
  1225. #define BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_INVALID_VALUE \
  1226. (~BIT_MASK(BT_HCI_LE_PER_ADV_CREATE_SYNC_CTE_TYPE_ALLOWED_BITS))
  1227. #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC BT_OP(BT_OGF_LE, 0x0044)
  1228. struct bt_hci_cp_le_per_adv_create_sync {
  1229. uint8_t options;
  1230. uint8_t sid;
  1231. bt_addr_le_t addr;
  1232. uint16_t skip;
  1233. uint16_t sync_timeout;
  1234. uint8_t cte_type;
  1235. } __packed;
  1236. #define BT_HCI_OP_LE_PER_ADV_CREATE_SYNC_CANCEL BT_OP(BT_OGF_LE, 0x0045)
  1237. #define BT_HCI_OP_LE_PER_ADV_TERMINATE_SYNC BT_OP(BT_OGF_LE, 0x0046)
  1238. struct bt_hci_cp_le_per_adv_terminate_sync {
  1239. uint16_t handle;
  1240. } __packed;
  1241. #define BT_HCI_OP_LE_ADD_DEV_TO_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0047)
  1242. struct bt_hci_cp_le_add_dev_to_per_adv_list {
  1243. bt_addr_le_t addr;
  1244. uint8_t sid;
  1245. } __packed;
  1246. #define BT_HCI_OP_LE_REM_DEV_FROM_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0048)
  1247. struct bt_hci_cp_le_rem_dev_from_per_adv_list {
  1248. bt_addr_le_t addr;
  1249. uint8_t sid;
  1250. } __packed;
  1251. #define BT_HCI_OP_LE_CLEAR_PER_ADV_LIST BT_OP(BT_OGF_LE, 0x0049)
  1252. #define BT_HCI_OP_LE_READ_PER_ADV_LIST_SIZE BT_OP(BT_OGF_LE, 0x004a)
  1253. struct bt_hci_rp_le_read_per_adv_list_size {
  1254. uint8_t status;
  1255. uint8_t list_size;
  1256. } __packed;
  1257. #define BT_HCI_OP_LE_READ_TX_POWER BT_OP(BT_OGF_LE, 0x004b)
  1258. struct bt_hci_rp_le_read_tx_power {
  1259. uint8_t status;
  1260. int8_t min_tx_power;
  1261. int8_t max_tx_power;
  1262. } __packed;
  1263. #define BT_HCI_OP_LE_READ_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004c)
  1264. struct bt_hci_rp_le_read_rf_path_comp {
  1265. uint8_t status;
  1266. int16_t tx_path_comp;
  1267. int16_t rx_path_comp;
  1268. } __packed;
  1269. #define BT_HCI_OP_LE_WRITE_RF_PATH_COMP BT_OP(BT_OGF_LE, 0x004d)
  1270. struct bt_hci_cp_le_write_rf_path_comp {
  1271. int16_t tx_path_comp;
  1272. int16_t rx_path_comp;
  1273. } __packed;
  1274. #define BT_HCI_LE_PRIVACY_MODE_NETWORK 0x00
  1275. #define BT_HCI_LE_PRIVACY_MODE_DEVICE 0x01
  1276. #define BT_HCI_OP_LE_SET_PRIVACY_MODE BT_OP(BT_OGF_LE, 0x004e)
  1277. struct bt_hci_cp_le_set_privacy_mode {
  1278. bt_addr_le_t id_addr;
  1279. uint8_t mode;
  1280. } __packed;
  1281. /* Min and max Constant Tone Extension length in 8us units */
  1282. #define BT_HCI_LE_CTE_LEN_MIN 0x2
  1283. #define BT_HCI_LE_CTE_LEN_MAX 0x14
  1284. #define BT_HCI_LE_AOA_CTE 0x0
  1285. #define BT_HCI_LE_AOD_CTE_1US 0x1
  1286. #define BT_HCI_LE_AOD_CTE_2US 0x2
  1287. #define BT_HCI_LE_NO_CTE 0xFF
  1288. #define BT_HCI_LE_CTE_COUNT_MIN 0x1
  1289. #define BT_HCI_LE_CTE_COUNT_MAX 0x10
  1290. #define BT_HCI_OP_LE_SET_CL_CTE_TX_PARAMS BT_OP(BT_OGF_LE, 0x0051)
  1291. struct bt_hci_cp_le_set_cl_cte_tx_params {
  1292. uint8_t handle;
  1293. uint8_t cte_len;
  1294. uint8_t cte_type;
  1295. uint8_t cte_count;
  1296. uint8_t switch_pattern_len;
  1297. uint8_t ant_ids[0];
  1298. } __packed;
  1299. #define BT_HCI_OP_LE_SET_CL_CTE_TX_ENABLE BT_OP(BT_OGF_LE, 0x0052)
  1300. struct bt_hci_cp_le_set_cl_cte_tx_enable {
  1301. uint8_t handle;
  1302. uint8_t cte_enable;
  1303. } __packed;
  1304. #define BT_HCI_LE_ANTENNA_SWITCHING_SLOT_1US 0x1
  1305. #define BT_HCI_LE_ANTENNA_SWITCHING_SLOT_2US 0x2
  1306. #define BT_HCI_LE_SAMPLE_CTE_ALL 0x0
  1307. #define BT_HCI_LE_SAMPLE_CTE_COUNT_MIN 0x1
  1308. #define BT_HCI_LE_SAMPLE_CTE_COUNT_MAX 0x10
  1309. #define BT_HCI_OP_LE_SET_CL_CTE_SAMPLING_ENABLE BT_OP(BT_OGF_LE, 0x0053)
  1310. struct bt_hci_cp_le_set_cl_cte_sampling_enable {
  1311. uint16_t sync_handle;
  1312. uint8_t sampling_enable;
  1313. uint8_t slot_durations;
  1314. uint8_t max_sampled_cte;
  1315. uint8_t switch_pattern_len;
  1316. uint8_t ant_ids[0];
  1317. } __packed;
  1318. struct bt_hci_rp_le_set_cl_cte_sampling_enable {
  1319. uint8_t status;
  1320. uint16_t sync_handle;
  1321. } __packed;
  1322. #define BT_HCI_OP_LE_SET_CONN_CTE_RX_PARAMS BT_OP(BT_OGF_LE, 0x0054)
  1323. struct bt_hci_cp_le_set_conn_cte_rx_params {
  1324. uint16_t handle;
  1325. uint8_t sampling_enable;
  1326. uint8_t slot_durations;
  1327. uint8_t switch_pattern_len;
  1328. uint8_t ant_ids[0];
  1329. } __packed;
  1330. struct bt_hci_rp_le_set_conn_cte_rx_params {
  1331. uint8_t status;
  1332. uint16_t handle;
  1333. } __packed;
  1334. #define BT_HCI_LE_AOA_CTE_RSP BIT(0)
  1335. #define BT_HCI_LE_AOD_CTE_RSP_1US BIT(1)
  1336. #define BT_HCI_LE_AOD_CTE_RSP_2US BIT(2)
  1337. #define BT_HCI_LE_SWITCH_PATTERN_LEN_MIN 0x2
  1338. #define BT_HCI_LE_SWITCH_PATTERN_LEN_MAX 0x4B
  1339. #define BT_HCI_OP_LE_SET_CONN_CTE_TX_PARAMS BT_OP(BT_OGF_LE, 0x0055)
  1340. struct bt_hci_cp_le_set_conn_cte_tx_params {
  1341. uint16_t handle;
  1342. uint8_t cte_types;
  1343. uint8_t switch_pattern_len;
  1344. uint8_t ant_ids[0];
  1345. } __packed;
  1346. struct bt_hci_rp_le_set_conn_cte_tx_params {
  1347. uint8_t status;
  1348. uint16_t handle;
  1349. } __packed;
  1350. /* Interval between consecutive CTE request procedure starts in number of connection events. */
  1351. #define BT_HCI_REQUEST_CTE_ONCE 0x0
  1352. #define BT_HCI_REQUEST_CTE_INTERVAL_MIN 0x1
  1353. #define BT_HCI_REQUEST_CTE_INTERVAL_MAX 0xFFFF
  1354. #define BT_HCI_OP_LE_CONN_CTE_REQ_ENABLE BT_OP(BT_OGF_LE, 0x0056)
  1355. struct bt_hci_cp_le_conn_cte_req_enable {
  1356. uint16_t handle;
  1357. uint8_t enable;
  1358. uint8_t cte_request_interval;
  1359. uint8_t requested_cte_length;
  1360. uint8_t requested_cte_type;
  1361. } __packed;
  1362. struct bt_hci_rp_le_conn_cte_req_enable {
  1363. uint8_t status;
  1364. uint16_t handle;
  1365. } __packed;
  1366. #define BT_HCI_OP_LE_CONN_CTE_RSP_ENABLE BT_OP(BT_OGF_LE, 0x0057)
  1367. struct bt_hci_cp_le_conn_cte_rsp_enable {
  1368. uint16_t handle;
  1369. uint8_t enable;
  1370. } __packed;
  1371. struct bt_hci_rp_le_conn_cte_rsp_enable {
  1372. uint8_t status;
  1373. uint16_t handle;
  1374. } __packed;
  1375. #define BT_HCI_LE_1US_AOD_TX BIT(0)
  1376. #define BT_HCI_LE_1US_AOD_RX BIT(1)
  1377. #define BT_HCI_LE_1US_AOA_RX BIT(2)
  1378. #define BT_HCI_LE_NUM_ANT_MIN 0x1
  1379. #define BT_HCI_LE_NUM_ANT_MAX 0x4B
  1380. #define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MIN 0x2
  1381. #define BT_HCI_LE_MAX_SWITCH_PATTERN_LEN_MAX 0x4B
  1382. #define BT_HCI_LE_MAX_CTE_LEN_MIN 0x2
  1383. #define BT_HCI_LE_MAX_CTE_LEN_MAX 0x14
  1384. #define BT_HCI_OP_LE_READ_ANT_INFO BT_OP(BT_OGF_LE, 0x0058)
  1385. struct bt_hci_rp_le_read_ant_info {
  1386. uint8_t status;
  1387. uint8_t switch_sample_rates;
  1388. uint8_t num_ant;
  1389. uint8_t max_switch_pattern_len;
  1390. uint8_t max_cte_len;
  1391. };
  1392. #define BT_HCI_OP_LE_SET_PER_ADV_RECV_ENABLE BT_OP(BT_OGF_LE, 0x0059)
  1393. struct bt_hci_cp_le_set_per_adv_recv_enable {
  1394. uint16_t handle;
  1395. uint8_t enable;
  1396. } __packed;
  1397. #define BT_HCI_OP_LE_PER_ADV_SYNC_TRANSFER BT_OP(BT_OGF_LE, 0x005a)
  1398. struct bt_hci_cp_le_per_adv_sync_transfer {
  1399. uint16_t conn_handle;
  1400. uint16_t service_data;
  1401. uint16_t sync_handle;
  1402. } __packed;
  1403. struct bt_hci_rp_le_per_adv_sync_transfer {
  1404. uint8_t status;
  1405. uint16_t conn_handle;
  1406. } __packed;
  1407. #define BT_HCI_OP_LE_PER_ADV_SET_INFO_TRANSFER BT_OP(BT_OGF_LE, 0x005b)
  1408. struct bt_hci_cp_le_per_adv_set_info_transfer {
  1409. uint16_t conn_handle;
  1410. uint16_t service_data;
  1411. uint8_t adv_handle;
  1412. } __packed;
  1413. struct bt_hci_rp_le_per_adv_set_info_transfer {
  1414. uint8_t status;
  1415. uint16_t conn_handle;
  1416. } __packed;
  1417. #define BT_HCI_LE_PAST_MODE_NO_SYNC 0x00
  1418. #define BT_HCI_LE_PAST_MODE_NO_REPORTS 0x01
  1419. #define BT_HCI_LE_PAST_MODE_SYNC 0x02
  1420. #define BT_HCI_LE_PAST_CTE_TYPE_NO_AOA BIT(0)
  1421. #define BT_HCI_LE_PAST_CTE_TYPE_NO_AOD_1US BIT(1)
  1422. #define BT_HCI_LE_PAST_CTE_TYPE_NO_AOD_2US BIT(2)
  1423. #define BT_HCI_LE_PAST_CTE_TYPE_NO_CTE BIT(3)
  1424. #define BT_HCI_LE_PAST_CTE_TYPE_ONLY_CTE BIT(4)
  1425. #define BT_HCI_OP_LE_PAST_PARAM BT_OP(BT_OGF_LE, 0x005c)
  1426. struct bt_hci_cp_le_past_param {
  1427. uint16_t conn_handle;
  1428. uint8_t mode;
  1429. uint16_t skip;
  1430. uint16_t timeout;
  1431. uint8_t cte_type;
  1432. } __packed;
  1433. struct bt_hci_rp_le_past_param {
  1434. uint8_t status;
  1435. uint16_t conn_handle;
  1436. } __packed;
  1437. #define BT_HCI_OP_LE_DEFAULT_PAST_PARAM BT_OP(BT_OGF_LE, 0x005d)
  1438. struct bt_hci_cp_le_default_past_param {
  1439. uint8_t mode;
  1440. uint16_t skip;
  1441. uint16_t timeout;
  1442. uint8_t cte_type;
  1443. } __packed;
  1444. struct bt_hci_rp_le_default_past_param {
  1445. uint8_t status;
  1446. } __packed;
  1447. #define BT_HCI_OP_LE_READ_BUFFER_SIZE_V2 BT_OP(BT_OGF_LE, 0x0060)
  1448. struct bt_hci_rp_le_read_buffer_size_v2 {
  1449. uint8_t status;
  1450. uint16_t acl_max_len;
  1451. uint8_t acl_max_num;
  1452. uint16_t iso_max_len;
  1453. uint8_t iso_max_num;
  1454. } __packed;
  1455. #define BT_HCI_OP_LE_READ_ISO_TX_SYNC BT_OP(BT_OGF_LE, 0x0061)
  1456. struct bt_hci_cp_le_read_iso_tx_sync {
  1457. uint16_t handle;
  1458. } __packed;
  1459. struct bt_hci_rp_le_read_iso_tx_sync {
  1460. uint8_t status;
  1461. uint16_t handle;
  1462. uint16_t seq;
  1463. uint32_t timestamp;
  1464. uint8_t offset[3];
  1465. } __packed;
  1466. #define BT_HCI_OP_LE_SET_CIG_PARAMS BT_OP(BT_OGF_LE, 0x0062)
  1467. struct bt_hci_cis_params {
  1468. uint8_t cis_id;
  1469. uint16_t c_sdu;
  1470. uint16_t p_sdu;
  1471. uint8_t c_phy;
  1472. uint8_t p_phy;
  1473. uint8_t c_rtn;
  1474. uint8_t p_rtn;
  1475. } __packed;
  1476. struct bt_hci_cp_le_set_cig_params {
  1477. uint8_t cig_id;
  1478. uint8_t c_interval[3];
  1479. uint8_t p_interval[3];
  1480. uint8_t sca;
  1481. uint8_t packing;
  1482. uint8_t framing;
  1483. uint16_t c_latency;
  1484. uint16_t p_latency;
  1485. uint8_t num_cis;
  1486. struct bt_hci_cis_params cis[0];
  1487. } __packed;
  1488. struct bt_hci_rp_le_set_cig_params {
  1489. uint8_t status;
  1490. uint8_t cig_id;
  1491. uint8_t num_handles;
  1492. uint16_t handle[0];
  1493. } __packed;
  1494. #define BT_HCI_OP_LE_SET_CIG_PARAMS_TEST BT_OP(BT_OGF_LE, 0x0063)
  1495. struct bt_hci_cis_params_test {
  1496. uint8_t cis_id;
  1497. uint8_t nse;
  1498. uint16_t c_sdu;
  1499. uint16_t p_sdu;
  1500. uint16_t c_pdu;
  1501. uint16_t p_pdu;
  1502. uint8_t c_phy;
  1503. uint8_t p_phy;
  1504. uint8_t c_bn;
  1505. uint8_t p_bn;
  1506. } __packed;
  1507. struct bt_hci_cp_le_set_cig_params_test {
  1508. uint8_t cig_id;
  1509. uint8_t c_interval[3];
  1510. uint8_t p_interval[3];
  1511. uint8_t c_ft;
  1512. uint8_t p_ft;
  1513. uint16_t iso_interval;
  1514. uint8_t sca;
  1515. uint8_t packing;
  1516. uint8_t framing;
  1517. uint8_t num_cis;
  1518. struct bt_hci_cis_params_test cis[0];
  1519. } __packed;
  1520. struct bt_hci_rp_le_set_cig_params_test {
  1521. uint8_t status;
  1522. uint8_t cig_id;
  1523. uint8_t num_handles;
  1524. uint16_t handle[0];
  1525. } __packed;
  1526. #define BT_HCI_OP_LE_CREATE_CIS BT_OP(BT_OGF_LE, 0x0064)
  1527. struct bt_hci_cis {
  1528. uint16_t cis_handle;
  1529. uint16_t acl_handle;
  1530. } __packed;
  1531. struct bt_hci_cp_le_create_cis {
  1532. uint8_t num_cis;
  1533. struct bt_hci_cis cis[0];
  1534. } __packed;
  1535. #define BT_HCI_OP_LE_REMOVE_CIG BT_OP(BT_OGF_LE, 0x0065)
  1536. struct bt_hci_cp_le_remove_cig {
  1537. uint8_t cig_id;
  1538. } __packed;
  1539. struct bt_hci_rp_le_remove_cig {
  1540. uint8_t status;
  1541. uint8_t cig_id;
  1542. } __packed;
  1543. #define BT_HCI_OP_LE_ACCEPT_CIS BT_OP(BT_OGF_LE, 0x0066)
  1544. struct bt_hci_cp_le_accept_cis {
  1545. uint16_t handle;
  1546. } __packed;
  1547. #define BT_HCI_OP_LE_REJECT_CIS BT_OP(BT_OGF_LE, 0x0067)
  1548. struct bt_hci_cp_le_reject_cis {
  1549. uint16_t handle;
  1550. uint8_t reason;
  1551. } __packed;
  1552. struct bt_hci_rp_le_reject_cis {
  1553. uint8_t status;
  1554. uint16_t handle;
  1555. } __packed;
  1556. #define BT_HCI_OP_LE_CREATE_BIG BT_OP(BT_OGF_LE, 0x0068)
  1557. struct bt_hci_cp_le_create_big {
  1558. uint8_t big_handle;
  1559. uint8_t adv_handle;
  1560. uint8_t num_bis;
  1561. uint8_t sdu_interval[3];
  1562. uint16_t max_sdu;
  1563. uint16_t max_latency;
  1564. uint8_t rtn;
  1565. uint8_t phy;
  1566. uint8_t packing;
  1567. uint8_t framing;
  1568. uint8_t encryption;
  1569. uint8_t bcode[16];
  1570. } __packed;
  1571. #define BT_HCI_OP_LE_CREATE_BIG_TEST BT_OP(BT_OGF_LE, 0x0069)
  1572. struct bt_hci_cp_le_create_big_test {
  1573. uint8_t big_handle;
  1574. uint8_t adv_handle;
  1575. uint8_t num_bis;
  1576. uint8_t sdu_interval[3];
  1577. uint16_t iso_interval;
  1578. uint8_t nse;
  1579. uint16_t max_sdu;
  1580. uint16_t max_pdu;
  1581. uint8_t phy;
  1582. uint8_t packing;
  1583. uint8_t framing;
  1584. uint8_t bn;
  1585. uint8_t irc;
  1586. uint8_t pto;
  1587. uint8_t encryption;
  1588. uint8_t bcode[16];
  1589. } __packed;
  1590. #define BT_HCI_OP_LE_TERMINATE_BIG BT_OP(BT_OGF_LE, 0x006a)
  1591. struct bt_hci_cp_le_terminate_big {
  1592. uint8_t big_handle;
  1593. uint8_t reason;
  1594. } __packed;
  1595. #define BT_HCI_OP_LE_BIG_CREATE_SYNC BT_OP(BT_OGF_LE, 0x006b)
  1596. struct bt_hci_cp_le_big_create_sync {
  1597. uint8_t big_handle;
  1598. uint16_t sync_handle;
  1599. uint8_t encryption;
  1600. uint8_t bcode[16];
  1601. uint8_t mse;
  1602. uint16_t sync_timeout;
  1603. uint8_t num_bis;
  1604. uint8_t bis[0];
  1605. } __packed;
  1606. #define BT_HCI_OP_LE_BIG_TERMINATE_SYNC BT_OP(BT_OGF_LE, 0x006c)
  1607. struct bt_hci_cp_le_big_terminate_sync {
  1608. uint8_t big_handle;
  1609. } __packed;
  1610. struct bt_hci_rp_le_big_terminate_sync {
  1611. uint8_t status;
  1612. uint8_t big_handle;
  1613. } __packed;
  1614. #define BT_HCI_OP_LE_REQ_PEER_SC BT_OP(BT_OGF_LE, 0x006d)
  1615. struct bt_hci_cp_le_req_peer_sca {
  1616. uint16_t handle;
  1617. } __packed;
  1618. #define BT_HCI_OP_LE_SETUP_ISO_PATH BT_OP(BT_OGF_LE, 0x006e)
  1619. struct bt_hci_cp_le_setup_iso_path {
  1620. uint16_t handle;
  1621. uint8_t path_dir;
  1622. uint8_t path_id;
  1623. struct bt_hci_cp_codec_id codec_id;
  1624. uint8_t controller_delay[3];
  1625. uint8_t codec_config_len;
  1626. uint8_t codec_config[0];
  1627. } __packed;
  1628. struct bt_hci_rp_le_setup_iso_path {
  1629. uint8_t status;
  1630. uint16_t handle;
  1631. } __packed;
  1632. #define BT_HCI_OP_LE_REMOVE_ISO_PATH BT_OP(BT_OGF_LE, 0x006f)
  1633. struct bt_hci_cp_le_remove_iso_path {
  1634. uint16_t handle;
  1635. uint8_t path_dir;
  1636. } __packed;
  1637. struct bt_hci_rp_le_remove_iso_path {
  1638. uint8_t status;
  1639. uint16_t handle;
  1640. } __packed;
  1641. #define BT_HCI_OP_LE_ISO_TRANSMIT_TEST BT_OP(BT_OGF_LE, 0x0070)
  1642. struct bt_hci_cp_le_iso_transmit_test {
  1643. uint16_t handle;
  1644. uint8_t payload_type;
  1645. } __packed;
  1646. struct bt_hci_rp_le_iso_transmit_test {
  1647. uint8_t status;
  1648. uint16_t handle;
  1649. } __packed;
  1650. #define BT_HCI_OP_LE_ISO_RECEIVE_TEST BT_OP(BT_OGF_LE, 0x0071)
  1651. struct bt_hci_cp_le_iso_receive_test {
  1652. uint16_t handle;
  1653. uint8_t payload_type;
  1654. } __packed;
  1655. struct bt_hci_rp_le_iso_receive_test {
  1656. uint8_t status;
  1657. uint16_t handle;
  1658. } __packed;
  1659. #define BT_HCI_OP_LE_ISO_READ_TEST_COUNTERS BT_OP(BT_OGF_LE, 0x0072)
  1660. struct bt_hci_cp_le_read_test_counters {
  1661. uint16_t handle;
  1662. } __packed;
  1663. struct bt_hci_rp_le_read_test_counters {
  1664. uint8_t status;
  1665. uint16_t handle;
  1666. uint32_t received_cnt;
  1667. uint32_t missed_cnt;
  1668. uint32_t failed_cnt;
  1669. } __packed;
  1670. #define BT_HCI_OP_LE_ISO_TEST_END BT_OP(BT_OGF_LE, 0x0073)
  1671. struct bt_hci_cp_le_iso_test_end {
  1672. uint16_t handle;
  1673. } __packed;
  1674. struct bt_hci_rp_le_iso_test_end {
  1675. uint8_t status;
  1676. uint16_t handle;
  1677. uint32_t received_cnt;
  1678. uint32_t missed_cnt;
  1679. uint32_t failed_cnt;
  1680. } __packed;
  1681. #define BT_HCI_OP_LE_SET_HOST_FEATURE BT_OP(BT_OGF_LE, 0x0074)
  1682. struct bt_hci_cp_le_set_host_feature {
  1683. uint8_t bit_number;
  1684. uint8_t bit_value;
  1685. } __packed;
  1686. struct bt_hci_rp_le_set_host_feature {
  1687. uint8_t status;
  1688. } __packed;
  1689. #define BT_HCI_OP_LE_READ_ISO_LINK_QUALITY BT_OP(BT_OGF_LE, 0x0075)
  1690. struct bt_hci_cp_le_read_iso_link_quality {
  1691. uint16_t handle;
  1692. } __packed;
  1693. struct bt_hci_rp_le_read_iso_link_quality {
  1694. uint8_t status;
  1695. uint16_t handle;
  1696. uint32_t tx_unacked_packets;
  1697. uint32_t tx_flushed_packets;
  1698. uint32_t tx_last_subevent_packets;
  1699. uint32_t retransmitted_packets;
  1700. uint32_t crc_error_packets;
  1701. uint32_t rx_unreceived_packets;
  1702. uint32_t duplicate_packets;
  1703. } __packed;
  1704. /* Event definitions */
  1705. #define BT_HCI_EVT_UNKNOWN 0x00
  1706. #define BT_HCI_EVT_VENDOR 0xff
  1707. #define BT_HCI_EVT_INQUIRY_COMPLETE 0x01
  1708. struct bt_hci_evt_inquiry_complete {
  1709. uint8_t status;
  1710. } __packed;
  1711. #define BT_HCI_EVT_CONN_COMPLETE 0x03
  1712. struct bt_hci_evt_conn_complete {
  1713. uint8_t status;
  1714. uint16_t handle;
  1715. bt_addr_t bdaddr;
  1716. uint8_t link_type;
  1717. uint8_t encr_enabled;
  1718. } __packed;
  1719. #define BT_HCI_EVT_CONN_REQUEST 0x04
  1720. struct bt_hci_evt_conn_request {
  1721. bt_addr_t bdaddr;
  1722. uint8_t dev_class[3];
  1723. uint8_t link_type;
  1724. } __packed;
  1725. #define BT_HCI_EVT_DISCONN_COMPLETE 0x05
  1726. struct bt_hci_evt_disconn_complete {
  1727. uint8_t status;
  1728. uint16_t handle;
  1729. uint8_t reason;
  1730. } __packed;
  1731. #define BT_HCI_EVT_AUTH_COMPLETE 0x06
  1732. struct bt_hci_evt_auth_complete {
  1733. uint8_t status;
  1734. uint16_t handle;
  1735. } __packed;
  1736. #define BT_HCI_EVT_REMOTE_NAME_REQ_COMPLETE 0x07
  1737. struct bt_hci_evt_remote_name_req_complete {
  1738. uint8_t status;
  1739. bt_addr_t bdaddr;
  1740. uint8_t name[248];
  1741. } __packed;
  1742. #define BT_HCI_EVT_ENCRYPT_CHANGE 0x08
  1743. struct bt_hci_evt_encrypt_change {
  1744. uint8_t status;
  1745. uint16_t handle;
  1746. uint8_t encrypt;
  1747. } __packed;
  1748. #define BT_HCI_EVT_REMOTE_FEATURES 0x0b
  1749. struct bt_hci_evt_remote_features {
  1750. uint8_t status;
  1751. uint16_t handle;
  1752. uint8_t features[8];
  1753. } __packed;
  1754. #define BT_HCI_EVT_REMOTE_VERSION_INFO 0x0c
  1755. struct bt_hci_evt_remote_version_info {
  1756. uint8_t status;
  1757. uint16_t handle;
  1758. uint8_t version;
  1759. uint16_t manufacturer;
  1760. uint16_t subversion;
  1761. } __packed;
  1762. #define BT_HCI_EVT_CMD_COMPLETE 0x0e
  1763. struct bt_hci_evt_cmd_complete {
  1764. uint8_t ncmd;
  1765. uint16_t opcode;
  1766. } __packed;
  1767. struct bt_hci_evt_cc_status {
  1768. uint8_t status;
  1769. } __packed;
  1770. #define BT_HCI_EVT_CMD_STATUS 0x0f
  1771. struct bt_hci_evt_cmd_status {
  1772. uint8_t status;
  1773. uint8_t ncmd;
  1774. uint16_t opcode;
  1775. } __packed;
  1776. #define BT_HCI_EVT_HARDWARE_ERROR 0x10
  1777. struct bt_hci_evt_hardware_error {
  1778. uint8_t hardware_code;
  1779. } __packed;
  1780. #define BT_HCI_EVT_ROLE_CHANGE 0x12
  1781. struct bt_hci_evt_role_change {
  1782. uint8_t status;
  1783. bt_addr_t bdaddr;
  1784. uint8_t role;
  1785. } __packed;
  1786. #define BT_HCI_EVT_NUM_COMPLETED_PACKETS 0x13
  1787. struct bt_hci_evt_num_completed_packets {
  1788. uint8_t num_handles;
  1789. struct bt_hci_handle_count h[0];
  1790. } __packed;
  1791. #define BT_HCI_EVT_PIN_CODE_REQ 0x16
  1792. struct bt_hci_evt_pin_code_req {
  1793. bt_addr_t bdaddr;
  1794. } __packed;
  1795. #define BT_HCI_EVT_LINK_KEY_REQ 0x17
  1796. struct bt_hci_evt_link_key_req {
  1797. bt_addr_t bdaddr;
  1798. } __packed;
  1799. /* Link Key types */
  1800. #define BT_LK_COMBINATION 0x00
  1801. #define BT_LK_LOCAL_UNIT 0x01
  1802. #define BT_LK_REMOTE_UNIT 0x02
  1803. #define BT_LK_DEBUG_COMBINATION 0x03
  1804. #define BT_LK_UNAUTH_COMBINATION_P192 0x04
  1805. #define BT_LK_AUTH_COMBINATION_P192 0x05
  1806. #define BT_LK_CHANGED_COMBINATION 0x06
  1807. #define BT_LK_UNAUTH_COMBINATION_P256 0x07
  1808. #define BT_LK_AUTH_COMBINATION_P256 0x08
  1809. #define BT_HCI_EVT_LINK_KEY_NOTIFY 0x18
  1810. struct bt_hci_evt_link_key_notify {
  1811. bt_addr_t bdaddr;
  1812. uint8_t link_key[16];
  1813. uint8_t key_type;
  1814. } __packed;
  1815. /* Overflow link types */
  1816. #define BT_OVERFLOW_LINK_SYNCH 0x00
  1817. #define BT_OVERFLOW_LINK_ACL 0x01
  1818. #define BT_HCI_EVT_DATA_BUF_OVERFLOW 0x1a
  1819. struct bt_hci_evt_data_buf_overflow {
  1820. uint8_t link_type;
  1821. } __packed;
  1822. #define BT_HCI_EVT_INQUIRY_RESULT_WITH_RSSI 0x22
  1823. struct bt_hci_evt_inquiry_result_with_rssi {
  1824. bt_addr_t addr;
  1825. uint8_t pscan_rep_mode;
  1826. uint8_t reserved;
  1827. uint8_t cod[3];
  1828. uint16_t clock_offset;
  1829. int8_t rssi;
  1830. } __packed;
  1831. #define BT_HCI_EVT_REMOTE_EXT_FEATURES 0x23
  1832. struct bt_hci_evt_remote_ext_features {
  1833. uint8_t status;
  1834. uint16_t handle;
  1835. uint8_t page;
  1836. uint8_t max_page;
  1837. uint8_t features[8];
  1838. } __packed;
  1839. #define BT_HCI_EVT_SYNC_CONN_COMPLETE 0x2c
  1840. struct bt_hci_evt_sync_conn_complete {
  1841. uint8_t status;
  1842. uint16_t handle;
  1843. bt_addr_t bdaddr;
  1844. uint8_t link_type;
  1845. uint8_t tx_interval;
  1846. uint8_t retansmission_window;
  1847. uint16_t rx_pkt_length;
  1848. uint16_t tx_pkt_length;
  1849. uint8_t air_mode;
  1850. } __packed;
  1851. #define BT_HCI_EVT_EXTENDED_INQUIRY_RESULT 0x2f
  1852. struct bt_hci_evt_extended_inquiry_result {
  1853. uint8_t num_reports;
  1854. bt_addr_t addr;
  1855. uint8_t pscan_rep_mode;
  1856. uint8_t reserved;
  1857. uint8_t cod[3];
  1858. uint16_t clock_offset;
  1859. int8_t rssi;
  1860. uint8_t eir[240];
  1861. } __packed;
  1862. #define BT_HCI_EVT_ENCRYPT_KEY_REFRESH_COMPLETE 0x30
  1863. struct bt_hci_evt_encrypt_key_refresh_complete {
  1864. uint8_t status;
  1865. uint16_t handle;
  1866. } __packed;
  1867. #define BT_HCI_EVT_IO_CAPA_REQ 0x31
  1868. struct bt_hci_evt_io_capa_req {
  1869. bt_addr_t bdaddr;
  1870. } __packed;
  1871. #define BT_HCI_EVT_IO_CAPA_RESP 0x32
  1872. struct bt_hci_evt_io_capa_resp {
  1873. bt_addr_t bdaddr;
  1874. uint8_t capability;
  1875. uint8_t oob_data;
  1876. uint8_t authentication;
  1877. } __packed;
  1878. #define BT_HCI_EVT_USER_CONFIRM_REQ 0x33
  1879. struct bt_hci_evt_user_confirm_req {
  1880. bt_addr_t bdaddr;
  1881. uint32_t passkey;
  1882. } __packed;
  1883. #define BT_HCI_EVT_USER_PASSKEY_REQ 0x34
  1884. struct bt_hci_evt_user_passkey_req {
  1885. bt_addr_t bdaddr;
  1886. } __packed;
  1887. #define BT_HCI_EVT_SSP_COMPLETE 0x36
  1888. struct bt_hci_evt_ssp_complete {
  1889. uint8_t status;
  1890. bt_addr_t bdaddr;
  1891. } __packed;
  1892. #define BT_HCI_EVT_USER_PASSKEY_NOTIFY 0x3b
  1893. struct bt_hci_evt_user_passkey_notify {
  1894. bt_addr_t bdaddr;
  1895. uint32_t passkey;
  1896. } __packed;
  1897. #define BT_HCI_EVT_LE_META_EVENT 0x3e
  1898. struct bt_hci_evt_le_meta_event {
  1899. uint8_t subevent;
  1900. } __packed;
  1901. #define BT_HCI_EVT_AUTH_PAYLOAD_TIMEOUT_EXP 0x57
  1902. struct bt_hci_evt_auth_payload_timeout_exp {
  1903. uint16_t handle;
  1904. } __packed;
  1905. #define BT_HCI_ROLE_CENTRAL 0x00
  1906. #define BT_HCI_ROLE_PERIPHERAL 0x01
  1907. #define BT_HCI_EVT_LE_CONN_COMPLETE 0x01
  1908. struct bt_hci_evt_le_conn_complete {
  1909. uint8_t status;
  1910. uint16_t handle;
  1911. uint8_t role;
  1912. bt_addr_le_t peer_addr;
  1913. uint16_t interval;
  1914. uint16_t latency;
  1915. uint16_t supv_timeout;
  1916. uint8_t clock_accuracy;
  1917. } __packed;
  1918. #define BT_HCI_LE_RSSI_NOT_AVAILABLE 0x7F
  1919. #define BT_HCI_EVT_LE_ADVERTISING_REPORT 0x02
  1920. struct bt_hci_evt_le_advertising_info {
  1921. uint8_t evt_type;
  1922. bt_addr_le_t addr;
  1923. uint8_t length;
  1924. uint8_t data[0];
  1925. } __packed;
  1926. struct bt_hci_evt_le_advertising_report {
  1927. uint8_t num_reports;
  1928. struct bt_hci_evt_le_advertising_info adv_info[0];
  1929. } __packed;
  1930. #define BT_HCI_EVT_LE_CONN_UPDATE_COMPLETE 0x03
  1931. struct bt_hci_evt_le_conn_update_complete {
  1932. uint8_t status;
  1933. uint16_t handle;
  1934. uint16_t interval;
  1935. uint16_t latency;
  1936. uint16_t supv_timeout;
  1937. } __packed;
  1938. #define BT_HCI_EVT_LE_REMOTE_FEAT_COMPLETE 0x04
  1939. struct bt_hci_evt_le_remote_feat_complete {
  1940. uint8_t status;
  1941. uint16_t handle;
  1942. uint8_t features[8];
  1943. } __packed;
  1944. #define BT_HCI_EVT_LE_LTK_REQUEST 0x05
  1945. struct bt_hci_evt_le_ltk_request {
  1946. uint16_t handle;
  1947. uint64_t rand;
  1948. uint16_t ediv;
  1949. } __packed;
  1950. #define BT_HCI_EVT_LE_CONN_PARAM_REQ 0x06
  1951. struct bt_hci_evt_le_conn_param_req {
  1952. uint16_t handle;
  1953. uint16_t interval_min;
  1954. uint16_t interval_max;
  1955. uint16_t latency;
  1956. uint16_t timeout;
  1957. } __packed;
  1958. #define BT_HCI_EVT_LE_DATA_LEN_CHANGE 0x07
  1959. struct bt_hci_evt_le_data_len_change {
  1960. uint16_t handle;
  1961. uint16_t max_tx_octets;
  1962. uint16_t max_tx_time;
  1963. uint16_t max_rx_octets;
  1964. uint16_t max_rx_time;
  1965. } __packed;
  1966. #define BT_HCI_EVT_LE_P256_PUBLIC_KEY_COMPLETE 0x08
  1967. struct bt_hci_evt_le_p256_public_key_complete {
  1968. uint8_t status;
  1969. uint8_t key[64];
  1970. } __packed;
  1971. #define BT_HCI_EVT_LE_GENERATE_DHKEY_COMPLETE 0x09
  1972. struct bt_hci_evt_le_generate_dhkey_complete {
  1973. uint8_t status;
  1974. uint8_t dhkey[32];
  1975. } __packed;
  1976. #define BT_HCI_EVT_LE_ENH_CONN_COMPLETE 0x0a
  1977. struct bt_hci_evt_le_enh_conn_complete {
  1978. uint8_t status;
  1979. uint16_t handle;
  1980. uint8_t role;
  1981. bt_addr_le_t peer_addr;
  1982. bt_addr_t local_rpa;
  1983. bt_addr_t peer_rpa;
  1984. uint16_t interval;
  1985. uint16_t latency;
  1986. uint16_t supv_timeout;
  1987. uint8_t clock_accuracy;
  1988. } __packed;
  1989. #define BT_HCI_EVT_LE_DIRECT_ADV_REPORT 0x0b
  1990. struct bt_hci_evt_le_direct_adv_info {
  1991. uint8_t evt_type;
  1992. bt_addr_le_t addr;
  1993. bt_addr_le_t dir_addr;
  1994. int8_t rssi;
  1995. } __packed;
  1996. struct bt_hci_evt_le_direct_adv_report {
  1997. uint8_t num_reports;
  1998. struct bt_hci_evt_le_direct_adv_info direct_adv_info[0];
  1999. } __packed;
  2000. #define BT_HCI_EVT_LE_PHY_UPDATE_COMPLETE 0x0c
  2001. struct bt_hci_evt_le_phy_update_complete {
  2002. uint8_t status;
  2003. uint16_t handle;
  2004. uint8_t tx_phy;
  2005. uint8_t rx_phy;
  2006. } __packed;
  2007. #define BT_HCI_EVT_LE_EXT_ADVERTISING_REPORT 0x0d
  2008. #define BT_HCI_LE_ADV_EVT_TYPE_CONN BIT(0)
  2009. #define BT_HCI_LE_ADV_EVT_TYPE_SCAN BIT(1)
  2010. #define BT_HCI_LE_ADV_EVT_TYPE_DIRECT BIT(2)
  2011. #define BT_HCI_LE_ADV_EVT_TYPE_SCAN_RSP BIT(3)
  2012. #define BT_HCI_LE_ADV_EVT_TYPE_LEGACY BIT(4)
  2013. #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS(ev_type) (((ev_type) >> 5) & 0x03)
  2014. #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_COMPLETE 0
  2015. #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_PARTIAL 1
  2016. #define BT_HCI_LE_ADV_EVT_TYPE_DATA_STATUS_INCOMPLETE 2
  2017. struct bt_hci_evt_le_ext_advertising_info {
  2018. uint16_t evt_type;
  2019. bt_addr_le_t addr;
  2020. uint8_t prim_phy;
  2021. uint8_t sec_phy;
  2022. uint8_t sid;
  2023. int8_t tx_power;
  2024. int8_t rssi;
  2025. uint16_t interval;
  2026. bt_addr_le_t direct_addr;
  2027. uint8_t length;
  2028. uint8_t data[0];
  2029. } __packed;
  2030. struct bt_hci_evt_le_ext_advertising_report {
  2031. uint8_t num_reports;
  2032. struct bt_hci_evt_le_ext_advertising_info adv_info[0];
  2033. } __packed;
  2034. #define BT_HCI_EVT_LE_PER_ADV_SYNC_ESTABLISHED 0x0e
  2035. struct bt_hci_evt_le_per_adv_sync_established {
  2036. uint8_t status;
  2037. uint16_t handle;
  2038. uint8_t sid;
  2039. bt_addr_le_t adv_addr;
  2040. uint8_t phy;
  2041. uint16_t interval;
  2042. uint8_t clock_accuracy;
  2043. } __packed;
  2044. #define BT_HCI_EVT_LE_PER_ADVERTISING_REPORT 0x0f
  2045. struct bt_hci_evt_le_per_advertising_report {
  2046. uint16_t handle;
  2047. int8_t tx_power;
  2048. int8_t rssi;
  2049. uint8_t cte_type;
  2050. uint8_t data_status;
  2051. uint8_t length;
  2052. uint8_t data[0];
  2053. } __packed;
  2054. #define BT_HCI_EVT_LE_PER_ADV_SYNC_LOST 0x10
  2055. struct bt_hci_evt_le_per_adv_sync_lost {
  2056. uint16_t handle;
  2057. } __packed;
  2058. #define BT_HCI_EVT_LE_SCAN_TIMEOUT 0x11
  2059. #define BT_HCI_EVT_LE_ADV_SET_TERMINATED 0x12
  2060. struct bt_hci_evt_le_adv_set_terminated {
  2061. uint8_t status;
  2062. uint8_t adv_handle;
  2063. uint16_t conn_handle;
  2064. uint8_t num_completed_ext_adv_evts;
  2065. } __packed;
  2066. #define BT_HCI_EVT_LE_SCAN_REQ_RECEIVED 0x13
  2067. struct bt_hci_evt_le_scan_req_received {
  2068. uint8_t handle;
  2069. bt_addr_le_t addr;
  2070. } __packed;
  2071. #define BT_HCI_LE_CHAN_SEL_ALGO_1 0x00
  2072. #define BT_HCI_LE_CHAN_SEL_ALGO_2 0x01
  2073. #define BT_HCI_EVT_LE_CHAN_SEL_ALGO 0x14
  2074. struct bt_hci_evt_le_chan_sel_algo {
  2075. uint16_t handle;
  2076. uint8_t chan_sel_algo;
  2077. } __packed;
  2078. #define BT_HCI_LE_CTE_CRC_OK 0x0
  2079. #define BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_TIME 0x1
  2080. #define BT_HCI_LE_CTE_CRC_ERR_CTE_BASED_OTHER 0x2
  2081. #define BT_HCI_LE_CTE_INSUFFICIENT_RESOURCES 0xFF
  2082. #define B_HCI_LE_CTE_REPORT_SAMPLE_COUNT_MIN 0x9
  2083. #define B_HCI_LE_CTE_REPORT_SAMPLE_COUNT_MAX 0x52
  2084. #define BT_HCI_LE_CTE_REPORT_NO_VALID_SAMPLE 0x80
  2085. #define BT_HCI_EVT_LE_CONNECTIONLESS_IQ_REPORT 0x15
  2086. struct bt_hci_le_iq_sample {
  2087. int8_t i;
  2088. int8_t q;
  2089. };
  2090. struct bt_hci_evt_le_connectionless_iq_report {
  2091. uint16_t sync_handle;
  2092. uint8_t chan_idx;
  2093. int16_t rssi;
  2094. uint8_t rssi_ant_id;
  2095. uint8_t cte_type;
  2096. uint8_t slot_durations;
  2097. uint8_t packet_status;
  2098. uint16_t per_evt_counter;
  2099. uint8_t sample_count;
  2100. struct bt_hci_le_iq_sample sample[0];
  2101. } __packed;
  2102. #define BT_HCI_EVT_LE_CONNECTION_IQ_REPORT 0x16
  2103. struct bt_hci_evt_le_connection_iq_report {
  2104. uint16_t conn_handle;
  2105. uint8_t rx_phy;
  2106. uint8_t data_chan_idx;
  2107. int16_t rssi;
  2108. uint8_t rssi_ant_id;
  2109. uint8_t cte_type;
  2110. uint8_t slot_durations;
  2111. uint8_t packet_status;
  2112. uint16_t conn_evt_counter;
  2113. uint8_t sample_count;
  2114. struct bt_hci_le_iq_sample sample[0];
  2115. } __packed;
  2116. #define BT_HCI_EVT_LE_CTE_REQUEST_FAILED 0x17
  2117. struct bt_hci_evt_le_cte_req_failed {
  2118. uint8_t status;
  2119. uint16_t conn_handle;
  2120. } __packed;
  2121. #define BT_HCI_EVT_LE_PAST_RECEIVED 0x18
  2122. struct bt_hci_evt_le_past_received {
  2123. uint8_t status;
  2124. uint16_t conn_handle;
  2125. uint16_t service_data;
  2126. uint16_t sync_handle;
  2127. uint8_t adv_sid;
  2128. bt_addr_le_t addr;
  2129. uint8_t phy;
  2130. uint16_t interval;
  2131. uint8_t clock_accuracy;
  2132. } __packed;
  2133. #define BT_HCI_EVT_LE_CIS_ESTABLISHED 0x19
  2134. struct bt_hci_evt_le_cis_established {
  2135. uint8_t status;
  2136. uint16_t conn_handle;
  2137. uint8_t cig_sync_delay[3];
  2138. uint8_t cis_sync_delay[3];
  2139. uint8_t c_latency[3];
  2140. uint8_t p_latency[3];
  2141. uint8_t c_phy;
  2142. uint8_t p_phy;
  2143. uint8_t nse;
  2144. uint8_t c_bn;
  2145. uint8_t p_bn;
  2146. uint8_t c_ft;
  2147. uint8_t p_ft;
  2148. uint16_t c_max_pdu;
  2149. uint16_t p_max_pdu;
  2150. uint16_t interval;
  2151. } __packed;
  2152. #define BT_HCI_EVT_LE_CIS_REQ 0x1a
  2153. struct bt_hci_evt_le_cis_req {
  2154. uint16_t acl_handle;
  2155. uint16_t cis_handle;
  2156. uint8_t cig_id;
  2157. uint8_t cis_id;
  2158. } __packed;
  2159. #define BT_HCI_EVT_LE_BIG_COMPLETE 0x1b
  2160. struct bt_hci_evt_le_big_complete {
  2161. uint8_t status;
  2162. uint8_t big_handle;
  2163. uint8_t sync_delay[3];
  2164. uint8_t latency[3];
  2165. uint8_t phy;
  2166. uint8_t nse;
  2167. uint8_t bn;
  2168. uint8_t pto;
  2169. uint8_t irc;
  2170. uint16_t max_pdu;
  2171. uint16_t iso_interval;
  2172. uint8_t num_bis;
  2173. uint16_t handle[0];
  2174. } __packed;
  2175. #define BT_HCI_EVT_LE_BIG_TERMINATE 0x1c
  2176. struct bt_hci_evt_le_big_terminate {
  2177. uint8_t big_handle;
  2178. uint8_t reason;
  2179. } __packed;
  2180. #define BT_HCI_EVT_LE_BIG_SYNC_ESTABLISHED 0x1d
  2181. struct bt_hci_evt_le_big_sync_established {
  2182. uint8_t status;
  2183. uint8_t big_handle;
  2184. uint8_t latency[3];
  2185. uint8_t nse;
  2186. uint8_t bn;
  2187. uint8_t pto;
  2188. uint8_t irc;
  2189. uint16_t max_pdu;
  2190. uint16_t iso_interval;
  2191. uint8_t num_bis;
  2192. uint16_t handle[0];
  2193. } __packed;
  2194. #define BT_HCI_EVT_LE_BIG_SYNC_LOST 0x1e
  2195. struct bt_hci_evt_le_big_sync_lost {
  2196. uint8_t big_handle;
  2197. uint8_t reason;
  2198. } __packed;
  2199. #define BT_HCI_EVT_LE_REQ_PEER_SCA_COMPLETE 0x1f
  2200. struct bt_hci_evt_le_req_peer_sca_complete {
  2201. uint8_t status;
  2202. uint16_t handle;
  2203. uint8_t sca;
  2204. } __packed;
  2205. #define BT_HCI_EVT_LE_BIGINFO_ADV_REPORT 0x22
  2206. struct bt_hci_evt_le_biginfo_adv_report {
  2207. uint16_t sync_handle;
  2208. uint8_t num_bis;
  2209. uint8_t nse;
  2210. uint16_t iso_interval;
  2211. uint8_t bn;
  2212. uint8_t pto;
  2213. uint8_t irc;
  2214. uint16_t max_pdu;
  2215. uint8_t sdu_interval[3];
  2216. uint16_t max_sdu;
  2217. uint8_t phy;
  2218. uint8_t framing;
  2219. uint8_t encryption;
  2220. } __packed;
  2221. /* Event mask bits */
  2222. #define BT_EVT_BIT(n) (1ULL << (n))
  2223. #define BT_EVT_MASK_INQUIRY_COMPLETE BT_EVT_BIT(0)
  2224. #define BT_EVT_MASK_CONN_COMPLETE BT_EVT_BIT(2)
  2225. #define BT_EVT_MASK_CONN_REQUEST BT_EVT_BIT(3)
  2226. #define BT_EVT_MASK_DISCONN_COMPLETE BT_EVT_BIT(4)
  2227. #define BT_EVT_MASK_AUTH_COMPLETE BT_EVT_BIT(5)
  2228. #define BT_EVT_MASK_REMOTE_NAME_REQ_COMPLETE BT_EVT_BIT(6)
  2229. #define BT_EVT_MASK_ENCRYPT_CHANGE BT_EVT_BIT(7)
  2230. #define BT_EVT_MASK_REMOTE_FEATURES BT_EVT_BIT(10)
  2231. #define BT_EVT_MASK_REMOTE_VERSION_INFO BT_EVT_BIT(11)
  2232. #define BT_EVT_MASK_HARDWARE_ERROR BT_EVT_BIT(15)
  2233. #define BT_EVT_MASK_ROLE_CHANGE BT_EVT_BIT(17)
  2234. #define BT_EVT_MASK_PIN_CODE_REQ BT_EVT_BIT(21)
  2235. #define BT_EVT_MASK_LINK_KEY_REQ BT_EVT_BIT(22)
  2236. #define BT_EVT_MASK_LINK_KEY_NOTIFY BT_EVT_BIT(23)
  2237. #define BT_EVT_MASK_DATA_BUFFER_OVERFLOW BT_EVT_BIT(25)
  2238. #define BT_EVT_MASK_INQUIRY_RESULT_WITH_RSSI BT_EVT_BIT(33)
  2239. #define BT_EVT_MASK_REMOTE_EXT_FEATURES BT_EVT_BIT(34)
  2240. #define BT_EVT_MASK_SYNC_CONN_COMPLETE BT_EVT_BIT(43)
  2241. #define BT_EVT_MASK_EXTENDED_INQUIRY_RESULT BT_EVT_BIT(46)
  2242. #define BT_EVT_MASK_ENCRYPT_KEY_REFRESH_COMPLETE BT_EVT_BIT(47)
  2243. #define BT_EVT_MASK_IO_CAPA_REQ BT_EVT_BIT(48)
  2244. #define BT_EVT_MASK_IO_CAPA_RESP BT_EVT_BIT(49)
  2245. #define BT_EVT_MASK_USER_CONFIRM_REQ BT_EVT_BIT(50)
  2246. #define BT_EVT_MASK_USER_PASSKEY_REQ BT_EVT_BIT(51)
  2247. #define BT_EVT_MASK_SSP_COMPLETE BT_EVT_BIT(53)
  2248. #define BT_EVT_MASK_USER_PASSKEY_NOTIFY BT_EVT_BIT(58)
  2249. #define BT_EVT_MASK_LE_META_EVENT BT_EVT_BIT(61)
  2250. /* Page 2 */
  2251. #define BT_EVT_MASK_NUM_COMPLETE_DATA_BLOCKS BT_EVT_BIT(8)
  2252. #define BT_EVT_MASK_TRIGG_CLOCK_CAPTURE BT_EVT_BIT(14)
  2253. #define BT_EVT_MASK_SYNCH_TRAIN_COMPLETE BT_EVT_BIT(15)
  2254. #define BT_EVT_MASK_SYNCH_TRAIN_RX BT_EVT_BIT(16)
  2255. #define BT_EVT_MASK_CL_PER_BC_RX BT_EVT_BIT(17)
  2256. #define BT_EVT_MASK_CL_PER_BC_TIMEOUT BT_EVT_BIT(18)
  2257. #define BT_EVT_MASK_TRUNC_PAGE_COMPLETE BT_EVT_BIT(19)
  2258. #define BT_EVT_MASK_PER_PAGE_RSP_TIMEOUT BT_EVT_BIT(20)
  2259. #define BT_EVT_MASK_CL_PER_BC_CH_MAP_CHANGE BT_EVT_BIT(21)
  2260. #define BT_EVT_MASK_INQUIRY_RSP_NOT BT_EVT_BIT(22)
  2261. #define BT_EVT_MASK_AUTH_PAYLOAD_TIMEOUT_EXP BT_EVT_BIT(23)
  2262. #define BT_EVT_MASK_SAM_STATUS_CHANGE BT_EVT_BIT(24)
  2263. #define BT_EVT_MASK_LE_CONN_COMPLETE BT_EVT_BIT(0)
  2264. #define BT_EVT_MASK_LE_ADVERTISING_REPORT BT_EVT_BIT(1)
  2265. #define BT_EVT_MASK_LE_CONN_UPDATE_COMPLETE BT_EVT_BIT(2)
  2266. #define BT_EVT_MASK_LE_REMOTE_FEAT_COMPLETE BT_EVT_BIT(3)
  2267. #define BT_EVT_MASK_LE_LTK_REQUEST BT_EVT_BIT(4)
  2268. #define BT_EVT_MASK_LE_CONN_PARAM_REQ BT_EVT_BIT(5)
  2269. #define BT_EVT_MASK_LE_DATA_LEN_CHANGE BT_EVT_BIT(6)
  2270. #define BT_EVT_MASK_LE_P256_PUBLIC_KEY_COMPLETE BT_EVT_BIT(7)
  2271. #define BT_EVT_MASK_LE_GENERATE_DHKEY_COMPLETE BT_EVT_BIT(8)
  2272. #define BT_EVT_MASK_LE_ENH_CONN_COMPLETE BT_EVT_BIT(9)
  2273. #define BT_EVT_MASK_LE_DIRECT_ADV_REPORT BT_EVT_BIT(10)
  2274. #define BT_EVT_MASK_LE_PHY_UPDATE_COMPLETE BT_EVT_BIT(11)
  2275. #define BT_EVT_MASK_LE_EXT_ADVERTISING_REPORT BT_EVT_BIT(12)
  2276. #define BT_EVT_MASK_LE_PER_ADV_SYNC_ESTABLISHED BT_EVT_BIT(13)
  2277. #define BT_EVT_MASK_LE_PER_ADVERTISING_REPORT BT_EVT_BIT(14)
  2278. #define BT_EVT_MASK_LE_PER_ADV_SYNC_LOST BT_EVT_BIT(15)
  2279. #define BT_EVT_MASK_LE_SCAN_TIMEOUT BT_EVT_BIT(16)
  2280. #define BT_EVT_MASK_LE_ADV_SET_TERMINATED BT_EVT_BIT(17)
  2281. #define BT_EVT_MASK_LE_SCAN_REQ_RECEIVED BT_EVT_BIT(18)
  2282. #define BT_EVT_MASK_LE_CHAN_SEL_ALGO BT_EVT_BIT(19)
  2283. #define BT_EVT_MASK_LE_CONNECTIONLESS_IQ_REPORT BT_EVT_BIT(21)
  2284. #define BT_EVT_MASK_LE_CONNECTION_IQ_REPORT BT_EVT_BIT(22)
  2285. #define BT_EVT_MASK_LE_CTE_REQUEST_FAILED BT_EVT_BIT(23)
  2286. #define BT_EVT_MASK_LE_PAST_RECEIVED BT_EVT_BIT(23)
  2287. #define BT_EVT_MASK_LE_CIS_ESTABLISHED BT_EVT_BIT(24)
  2288. #define BT_EVT_MASK_LE_CIS_REQ BT_EVT_BIT(25)
  2289. #define BT_EVT_MASK_LE_BIG_COMPLETE BT_EVT_BIT(26)
  2290. #define BT_EVT_MASK_LE_BIG_TERMINATED BT_EVT_BIT(27)
  2291. #define BT_EVT_MASK_LE_BIG_SYNC_ESTABLISHED BT_EVT_BIT(28)
  2292. #define BT_EVT_MASK_LE_BIG_SYNC_LOST BT_EVT_BIT(29)
  2293. #define BT_EVT_MASK_LE_REQ_PEER_SCA_COMPLETE BT_EVT_BIT(30)
  2294. #define BT_EVT_MASK_LE_PATH_LOSS_THRESHOLD BT_EVT_BIT(31)
  2295. #define BT_EVT_MASK_LE_TRANSMIT_POWER_REPORTING BT_EVT_BIT(32)
  2296. #define BT_EVT_MASK_LE_BIGINFO_ADV_REPORT BT_EVT_BIT(33)
  2297. /** Allocate a HCI command buffer.
  2298. *
  2299. * This function allocates a new buffer for a HCI command. It is given
  2300. * the OpCode (encoded e.g. using the BT_OP macro) and the total length
  2301. * of the parameters. Upon successful return the buffer is ready to have
  2302. * the parameters encoded into it.
  2303. *
  2304. * @param opcode Command OpCode.
  2305. * @param param_len Length of command parameters.
  2306. *
  2307. * @return Newly allocated buffer.
  2308. */
  2309. struct net_buf *bt_hci_cmd_create(uint16_t opcode, uint8_t param_len);
  2310. /** Send a HCI command asynchronously.
  2311. *
  2312. * This function is used for sending a HCI command asynchronously. It can
  2313. * either be called for a buffer created using bt_hci_cmd_create(), or
  2314. * if the command has no parameters a NULL can be passed instead. The
  2315. * sending of the command will happen asynchronously, i.e. upon successful
  2316. * return from this function the caller only knows that it was queued
  2317. * successfully.
  2318. *
  2319. * If synchronous behavior, and retrieval of the Command Complete parameters
  2320. * is desired, the bt_hci_cmd_send_sync() API should be used instead.
  2321. *
  2322. * @param opcode Command OpCode.
  2323. * @param buf Command buffer or NULL (if no parameters).
  2324. *
  2325. * @return 0 on success or negative error value on failure.
  2326. */
  2327. int bt_hci_cmd_send(uint16_t opcode, struct net_buf *buf);
  2328. /** Send a HCI command synchronously.
  2329. *
  2330. * This function is used for sending a HCI command synchronously. It can
  2331. * either be called for a buffer created using bt_hci_cmd_create(), or
  2332. * if the command has no parameters a NULL can be passed instead.
  2333. *
  2334. * The function will block until a Command Status or a Command Complete
  2335. * event is returned. If either of these have a non-zero status the function
  2336. * will return a negative error code and the response reference will not
  2337. * be set. If the command completed successfully and a non-NULL rsp parameter
  2338. * was given, this parameter will be set to point to a buffer containing
  2339. * the response parameters.
  2340. *
  2341. * @param opcode Command OpCode.
  2342. * @param buf Command buffer or NULL (if no parameters).
  2343. * @param rsp Place to store a reference to the command response. May
  2344. * be NULL if the caller is not interested in the response
  2345. * parameters. If non-NULL is passed the caller is responsible
  2346. * for calling net_buf_unref() on the buffer when done parsing
  2347. * it.
  2348. *
  2349. * @return 0 on success or negative error value on failure.
  2350. */
  2351. int bt_hci_cmd_send_sync(uint16_t opcode, struct net_buf *buf,
  2352. struct net_buf **rsp);
  2353. /** @brief Get connection handle for a connection.
  2354. *
  2355. * @param conn Connection object.
  2356. * @param conn_handle Place to store the Connection handle.
  2357. *
  2358. * @return 0 on success or negative error value on failure.
  2359. */
  2360. int bt_hci_get_conn_handle(const struct bt_conn *conn, uint16_t *conn_handle);
  2361. /** @brief Get advertising handle for an advertising set.
  2362. *
  2363. * @param adv Advertising set.
  2364. * @param adv_handle Place to store the advertising handle.
  2365. *
  2366. * @return 0 on success or negative error value on failure.
  2367. */
  2368. int bt_hci_get_adv_handle(const struct bt_le_ext_adv *adv, uint8_t *adv_handle);
  2369. /** @typedef bt_hci_vnd_evt_cb_t
  2370. * @brief Callback type for vendor handling of HCI Vendor-Specific Events.
  2371. *
  2372. * A function of this type is registered with bt_hci_register_vnd_evt_cb()
  2373. * and will be called for any HCI Vendor-Specific Event.
  2374. *
  2375. * @param buf Buffer containing event parameters.
  2376. *
  2377. * @return true if the function handles the event or false to defer the
  2378. * handling of this event back to the stack.
  2379. */
  2380. typedef bool bt_hci_vnd_evt_cb_t(struct net_buf_simple *buf);
  2381. /** Register user callback for HCI Vendor-Specific Events
  2382. *
  2383. * @param cb Callback to be called when the stack receives a
  2384. * HCI Vendor-Specific Event.
  2385. *
  2386. * @return 0 on success or negative error value on failure.
  2387. */
  2388. int bt_hci_register_vnd_evt_cb(bt_hci_vnd_evt_cb_t cb);
  2389. #ifdef __cplusplus
  2390. }
  2391. #endif
  2392. #endif /* ZEPHYR_INCLUDE_BLUETOOTH_HCI_H_ */