MS_prov_api.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810
  1. /**
  2. * \file MS_prov_api.h
  3. *
  4. * \brief This file defines the Mesh Provisioning Application Interface - includes
  5. * Data Structures and Methods.
  6. */
  7. /*
  8. * Copyright (C) 2017. Mindtree Ltd.
  9. * All rights reserved.
  10. */
  11. #ifndef _H_MS_PROV_API_
  12. #define _H_MS_PROV_API_
  13. /* --------------------------------------------- Header File Inclusion */
  14. /* Bearer Layer */
  15. #include "MS_brr_api.h"
  16. /* --------------------------------------------- Global Definitions */
  17. /**
  18. * \defgroup prov_module PROVISIONING (Mesh Provisioning Layer)
  19. * \{
  20. * This section describes the interfaces & APIs offered by the EtherMind
  21. * Mesh Provisioning module to the Application and other upper
  22. * layers of the stack.
  23. */
  24. /**
  25. * \defgroup prov_defines Defines
  26. * \{
  27. * Describes defines for the module.
  28. */
  29. /**
  30. * \defgroup prov_constants Constants
  31. * \{
  32. * Describes Constants defined by the module.
  33. */
  34. /** Provisiong Roles */
  35. #define PROV_ROLE_DEVICE 0x01
  36. #define PROV_ROLE_PROVISIONER 0x02
  37. /** Provisioning Bearer Types */
  38. #define PROV_BRR_ADV 0x01
  39. #define PROV_BRR_GATT 0x02
  40. /** Provisioning PDU Types */
  41. #define PROV_PDU_TYPE_INVITE 0x00
  42. #define PROV_PDU_TYPE_CAPAB 0x01
  43. #define PROV_PDU_TYPE_START 0x02
  44. #define PROV_PDU_TYPE_PUBKEY 0x03
  45. #define PROV_PDU_TYPE_INPUT_CMPLT 0x04
  46. #define PROV_PDU_TYPE_CONF 0x05
  47. #define PROV_PDU_TYPE_RAND 0x06
  48. #define PROV_PDU_TYPE_DATA 0x07
  49. #define PROV_PDU_TYPE_COMPLETE 0x08
  50. #define PROV_PDU_TYPE_FAILED 0x09
  51. /** Provisioning algorithm values */
  52. #define PROV_ALGO_EC_FIPS_P256 0x00
  53. /** Provisioning public key values */
  54. #define PROV_PUBKEY_NO_OOB 0x00
  55. #define PROV_PUBKEY_OOB 0x01
  56. /** Provisioning authentication method values */
  57. #define PROV_AUTH_OOB_NONE 0x00
  58. #define PROV_AUTH_OOB_STATIC 0x01
  59. #define PROV_AUTH_OOB_OUTPUT 0x02
  60. #define PROV_AUTH_OOB_INPUT 0x03
  61. /** Provisioning Output OOB action values */
  62. #define PROV_OOOB_ACTION_BLINK 0x00
  63. #define PROV_OOOB_ACTION_BEEP 0x01
  64. #define PROV_OOOB_ACTION_VIBRATE 0x02
  65. #define PROV_OOOB_ACTION_NUMERIC 0x03
  66. #define PROV_OOOB_ACTION_ALPHANUMERIC 0x04
  67. /** Provisioning Input OOB action values */
  68. #define PROV_IOOB_ACTION_PUSH 0x00
  69. #define PROV_IOOB_ACTION_TWIST 0x01
  70. #define PROV_IOOB_ACTION_NUMERIC 0x02
  71. #define PROV_IOOB_ACTION_ALPHANUMERIC 0x03
  72. /** Provisioning algorithm support masks */
  73. #define PROV_MASK_ALGO_EC_FIPS_P256 (1 << 0)
  74. /** Provisioning public key supported type masks */
  75. #define PROV_MASK_PUBKEY_OOBINFO (1 << 0)
  76. /** Provisioning static oob supported type masks */
  77. #define PROV_MASK_STATIC_OOBINFO (1 << 0)
  78. /** Output OOB actions supported masks */
  79. #define PROV_MASK_OOOB_ACTION_BLINK (1 << 0)
  80. #define PROV_MASK_OOOB_ACTION_BEEP (1 << 1)
  81. #define PROV_MASK_OOOB_ACTION_VIBRATE (1 << 2)
  82. #define PROV_MASK_OOOB_ACTION_NUMERIC (1 << 3)
  83. #define PROV_MASK_OOOB_ACTION_ALPHANUMERIC (1 << 4)
  84. /** Input OOB actions supported masks */
  85. #define PROV_MASK_IOOB_ACTION_PUSH (1 << 0)
  86. #define PROV_MASK_IOOB_ACTION_TWIST (1 << 1)
  87. #define PROV_MASK_IOOB_ACTION_NUMERIC (1 << 2)
  88. #define PROV_MASK_IOOB_ACTION_ALPHANUMERIC (1 << 3)
  89. /**
  90. * \defgroup prov_control Control Constants
  91. * \{
  92. * Control constants defined by the specification.
  93. */
  94. /** Number of Fragments - Start of New Transaction */
  95. #define PROV_PCF_NUM_FRGMNTS 0x00
  96. /** Control Message */
  97. #define PROV_PCF_CTRL_MSG 0x01
  98. /** Fragment Index - Continuation of a transaction */
  99. #define PROV_PCF_CONTINU_FRGMNT 0x02
  100. /** Transport Specific Messaging (only used by PB ADV) */
  101. #define PROV_PCF_TX_SPECIFIC 0x03
  102. /** \} */
  103. /**
  104. * \defgroup prov_advtxopcodes ADV Transport Opcodes
  105. * \{
  106. * Specification defined transport Opcodes for PB-ADV bearer.
  107. */
  108. /* Link Open Request */
  109. #define PROV_PB_ADV_OPEN_REQ 0x00
  110. /* Link Open Confirm */
  111. #define PROV_PB_ADV_OPEN_CNF 0x01
  112. /* Link Close Indication */
  113. #define PROV_PB_ADV_CLOSE_IND 0x02
  114. /** \} */
  115. /**
  116. * \defgroup prov_gatttxopcodes GATT Transport Opcodes
  117. * \{
  118. * Implementation specific transport Opcodes for PB-GATT bearer.
  119. */
  120. /* Link Open Indication */
  121. #define PROV_PB_GATT_OPEN_IND 0xF1
  122. /* Link Close Indication */
  123. #define PROV_PB_GATT_CLOSE_IND 0xF0
  124. /** \} */
  125. /**
  126. * \defgroup prov_errorcode Error Codes
  127. * \{
  128. * Describes Error Codes defined by the specification.
  129. */
  130. /** Provisioning Failure Error Codes */
  131. #define PROV_ERR_PROHIBITED 0x00
  132. #define PROV_ERR_INVALID_PDU 0x01
  133. #define PROV_ERR_INVALID_FORMAT 0x02
  134. #define PROV_ERR_UNEXPECTED_PDU 0x03
  135. #define PROV_ERR_CONFIRMATION_FAILED 0x04
  136. #define PROV_ERR_OUT_OF_RESOURCES 0x05
  137. #define PROV_ERR_DECRYPTION_FAILED 0x06
  138. #define PROV_ERR_UNEXPECTED_ERROR 0x07
  139. #define PROV_ERR_CANNOT_ASSIGN_ADDRESS 0x08
  140. /** Provisioning LinkClose Error codes */
  141. #define PROV_CLOSE_REASON_SUCCESS 0x00
  142. #define PROV_CLOSE_REASON_TIMEOUT 0x01
  143. #define PROV_CLOSE_REASON_FAIL 0x02
  144. /** \} */
  145. /** Provisioning array size requirements */
  146. #define PROV_KEY_NETKEY_SIZE 16
  147. #define PROV_OOB_VALUE_SIZE 16
  148. #define PROV_URI_HASH_SIZE 4
  149. /** Provisioning OOB type masks for ADV data */
  150. #define PROV_OOB_TYPE_OTHER (1 << 0)
  151. #define PROV_OOB_TYPE_URI (1 << 1)
  152. #define PROV_OOB_TYPE_2DMRC (1 << 2)
  153. #define PROV_OOB_TYPE_BARCODE (1 << 3)
  154. #define PROV_OOB_TYPE_NFC (1 << 4)
  155. #define PROV_OOB_TYPE_NUMBER (1 << 5)
  156. #define PROV_OOB_TYPE_STRING (1 << 6)
  157. #define PROV_OOB_TYPE_ONBOX (1 << 11)
  158. #define PROV_OOB_TYPE_INSIDEBOX (1 << 12)
  159. #define PROV_OOB_TYPE_ONPIECEOFPAPER (1 << 13)
  160. #define PROV_OOB_TYPE_INSIDEMANUAL (1 << 14)
  161. #define PROV_OOB_TYPE_ONDEVICE (1 << 15)
  162. /** Invalid Provisioning Handle */
  163. #define PROV_HANDLE_INVALID 0xFF
  164. /** \} */
  165. /**
  166. * \defgroup prov_events Events
  167. * \{
  168. * This section lists the Asynchronous Events notified to Application by the
  169. * Module.
  170. */
  171. /**
  172. * This event indicates the availability of an unprovisioned device beacon,
  173. * with the following values as parameters in the
  174. * \ref PROV_UI_NOTIFY_CB callback.
  175. *
  176. * \param [in] phandle Pointer to the Provisioning context handle
  177. * \param [in] event_type \ref PROV_EVT_UNPROVISIONED_BEACON.
  178. * \param [in] event_result \ref API_SUCCESS.
  179. * \param [in] event_data Pointer to the array with the UUID of the device.
  180. * \param [in] event_datalen MS_DEVICE_UUID_SIZE
  181. *
  182. * \note This event is received by the Provisioner application. On reception of
  183. * this event, the application shall make use of the MS_prov_bind() to initiate
  184. * the provisioning procedure.
  185. *
  186. * \return \ref API_SUCCESS (always)
  187. */
  188. #define PROV_EVT_UNPROVISIONED_BEACON 0x01
  189. /**
  190. * This event indicates that the provisioning procedure capability exchange is
  191. * complete, with the following values as parameters in the
  192. * \ref PROV_UI_NOTIFY_CB callback.
  193. *
  194. * \param [in] phandle Pointer to the Provisioning context handle
  195. * \param [in] event_type \ref PROV_EVT_PROVISIONING_SETUP.
  196. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  197. * an Error Code.
  198. * \param [in] event_data When local provisioner, this contains peer device
  199. * capabilities and when local device, this contains the attention timeout
  200. * value.
  201. * \param [in] event_datalen When local provisioner, sizeof(\ref
  202. * PROV_CAPABILITIES_S) and when local device, sizeof(UINT32).
  203. *
  204. * \note When local provisioner, the appliation shall select the required
  205. * capability from the received capabilities and choose to start the procedure
  206. * by calling \ref MS_prov_start().
  207. *
  208. * \return \ref API_SUCCESS (always)
  209. */
  210. #define PROV_EVT_PROVISIONING_SETUP 0x02
  211. /**
  212. * This event indicates to the application the OOB random data that is to be
  213. * displayed on the UI via the \ref PROV_UI_NOTIFY_CB callback.
  214. *
  215. * \param [in] phandle Pointer to the Provisioning context handle
  216. * \param [in] event_type \ref PROV_EVT_OOB_DISPLAY.
  217. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  218. * an Error Code.
  219. * \param [in] event_data Pointer to OOB information as in \ref PROV_OOB_TYPE_S.
  220. * \param [in] event_datalen sizeof (\ref PROV_OOB_TYPE_S).
  221. *
  222. * \return \ref API_SUCCESS (always)
  223. */
  224. #define PROV_EVT_OOB_DISPLAY 0x03
  225. /**
  226. * This event indicates to the application requesting for OOB random data that
  227. * is to be used in the procedure via the \ref PROV_UI_NOTIFY_CB callback.
  228. *
  229. * \param [in] phandle Pointer to the Provisioning context handle
  230. * \param [in] event_type \ref PROV_EVT_OOB_ENTRY.
  231. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  232. * an Error Code.
  233. * \param [in] event_data \ref Pointer to OOB information as in \ref PROV_OOB_TYPE_S.
  234. * \param [in] event_datalen sizeof (\ref PROV_OOB_TYPE_S).
  235. *
  236. * \return \ref API_SUCCESS (always)
  237. */
  238. #define PROV_EVT_OOB_ENTRY 0x04
  239. /**
  240. * This event indicates to the application that the peer device has completed the
  241. * Input of OOB when this capability is negotiated via the
  242. * \ref PROV_UI_NOTIFY_CB callback.
  243. *
  244. * \param [in] phandle Pointer to the Provisioning context handle
  245. * \param [in] event_type \ref PROV_EVT_DEVINPUT_COMPLETE.
  246. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  247. * an Error Code.
  248. * \param [in] event_data NULL.
  249. * \param [in] event_datalen 0.
  250. *
  251. * \note This event is generated only for the provisioner application.
  252. *
  253. * \return \ref API_SUCCESS (always)
  254. */
  255. #define PROV_EVT_DEVINPUT_COMPLETE 0x05
  256. /**
  257. * This event indicates to the application requesting for Provisional data to be
  258. * sent to the peer device via the \ref PROV_UI_NOTIFY_CB callback.
  259. *
  260. * \param [in] phandle Pointer to the Provisioning context handle
  261. * \param [in] event_type \ref PROV_EVT_PROVDATA_INFO_REQ.
  262. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  263. * an Error Code.
  264. * \param [in] event_data NULL.
  265. * \param [in] event_datalen 0.
  266. *
  267. * \note This event is generated only for the provisioner application.
  268. *
  269. * \return \ref API_SUCCESS (always)
  270. */
  271. #define PROV_EVT_PROVDATA_INFO_REQ 0x06
  272. /**
  273. * This event indicates to the application the Provisional data received
  274. * from the Provisioner via the \ref PROV_UI_NOTIFY_CB callback.
  275. *
  276. * \param [in] phandle Pointer to the Provisioning context handle
  277. * \param [in] event_type \ref PROV_EVT_PROVDATA_INFO.
  278. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  279. * an Error Code.
  280. * \param [in] event_data Pointer to the provisioning data \ref PROV_DATA_S.
  281. * \param [in] event_datalen sizeof(\ref PROV_DATA_S).
  282. *
  283. * \note This event is generated only for the device application.
  284. *
  285. * \return \ref API_SUCCESS (always)
  286. */
  287. #define PROV_EVT_PROVDATA_INFO 0x07
  288. /**
  289. * This event indicates to the application that the provisioning procedure
  290. * is complete via the \ref PROV_UI_NOTIFY_CB callback.
  291. *
  292. * \param [in] phandle Pointer to the Provisioning context handle
  293. * \param [in] event_type \ref PROV_EVT_PROVISIONING_COMPLETE.
  294. * \param [in] event_result \ref API_SUCCESS on successful procedure completion, else
  295. * an Error Code.
  296. * \param [in] event_data NULL.
  297. * \param [in] event_datalen 0.
  298. *
  299. * \return \ref API_SUCCESS (always)
  300. */
  301. #define PROV_EVT_PROVISIONING_COMPLETE 0x08
  302. /** \} */
  303. /** \} */
  304. /* --------------------------------------------- Structures/Data Types */
  305. /**
  306. * \addtogroup prov_defines Defines
  307. * \{
  308. */
  309. /**
  310. * \defgroup prov_structures Structures
  311. * \{
  312. */
  313. /** Role of the device */
  314. typedef UCHAR PROV_ROLE;
  315. /** Bearer for the provisioning session */
  316. typedef UCHAR PROV_BRR;
  317. /** Handle to reference the active provisioning context */
  318. typedef UCHAR PROV_HANDLE;
  319. /** Device Information used for Provisioning */
  320. typedef struct _PROV_DEVICE_S
  321. {
  322. /**
  323. * Device UUID -
  324. * Used in unprovisioned device beacon and Provisioning Invite
  325. */
  326. UCHAR uuid[MS_DEVICE_UUID_SIZE];
  327. /** OOB Information */
  328. UINT16 oob;
  329. /** URI if any, to be given in encoded form */
  330. MS_BUFFER * uri;
  331. } PROV_DEVICE_S;
  332. /** OOB type for provisioning */
  333. typedef struct _PROV_OOB_TYPE_S
  334. {
  335. /** OOB Action information */
  336. UINT16 action;
  337. /** OOB Size information */
  338. UCHAR size;
  339. } PROV_OOB_TYPE_S;
  340. /** Device capabilities used for Provisioning */
  341. typedef struct _PROV_CAPABILITIES_S
  342. {
  343. /** Number of Elements */
  344. UCHAR num_elements;
  345. /** Supported algorithms */
  346. UINT16 supp_algorithms;
  347. /** Public key type */
  348. UCHAR supp_pubkey;
  349. /** Static OOB type */
  350. UCHAR supp_soob;
  351. /** Output OOB information */
  352. PROV_OOB_TYPE_S ooob;
  353. /** Input OOB information */
  354. PROV_OOB_TYPE_S ioob;
  355. } PROV_CAPABILITIES_S;
  356. /** Provisioning method information */
  357. typedef struct _PROV_METHOD_S
  358. {
  359. /** Algorithm selected */
  360. UCHAR algorithm;
  361. /** Public key usage */
  362. UCHAR pubkey;
  363. /** Authentication type */
  364. UCHAR auth;
  365. /** OOB type */
  366. PROV_OOB_TYPE_S oob;
  367. } PROV_METHOD_S;
  368. /** Data exchanged during Provisiong procedure */
  369. typedef struct _PROV_DATA_S
  370. {
  371. /** NetKey */
  372. UCHAR netkey[PROV_KEY_NETKEY_SIZE];
  373. /** Index of the NetKey */
  374. UINT16 keyid;
  375. /**
  376. * Flags bitmask
  377. * bit 0: Key Refresh Flag.
  378. * 0: Not-In-Phase2
  379. * 1: In-Phase2
  380. * bit 1: IV Update Flag
  381. * 0: Normal operation
  382. * 1: IV Update active
  383. *
  384. * bits 2-7: RFU
  385. */
  386. UCHAR flags;
  387. /** Current value of the IV index */
  388. UINT32 ivindex;
  389. /** Unicast address of the primary element */
  390. UINT16 uaddr;
  391. } PROV_DATA_S;
  392. /** \} */
  393. /** \} */
  394. /**
  395. * \defgroup prov_cb Application Callback
  396. * \{
  397. * This Section Describes the module Notification Callback interface offered
  398. * to the application
  399. */
  400. /**
  401. * Provisioning Application Asynchronous Notification Callback.
  402. *
  403. * Provisioning calls the registered callback to indicate events occurred to the
  404. * application.
  405. *
  406. * \param phandle Handle that identifies the provisioning context.
  407. * \param event_type Event type from any of the events in \ref prov_events.
  408. * \param event_result API_SUCCESS or any error code.
  409. * \param event_data Data associated with the event if any or NULL.
  410. * \param event_datalen Size of the event data. 0 if event data is NULL.
  411. */
  412. typedef API_RESULT (* PROV_UI_NOTIFY_CB)
  413. (
  414. PROV_HANDLE * phandle,
  415. UCHAR event_type,
  416. API_RESULT event_result,
  417. void * event_data,
  418. UINT16 event_datalen
  419. );
  420. /** \} */
  421. /* --------------------------------------------- Macros */
  422. /**
  423. * \defgroup prov_marcos Utility Macros
  424. * \{
  425. * Initialization and other Utility Macros offered by the module.
  426. */
  427. /**
  428. * \brief Setup the Device for provisioning
  429. *
  430. * \par Description This function configures the application as an Unprovisioned
  431. * device over Advertising channel bearer and sets it ready for provisioning.
  432. *
  433. * \param [in] pdev Pointer to the device strcuture \ref PROV_DEVICE_S.
  434. * \param [in] tmo The setup timeout value
  435. * \param [out] phdl The handle to the context setup on successful allocation
  436. *
  437. * \return API_SUCCESS or Error Code on failure
  438. */
  439. #define MS_prov_setup_device_pbadv(pdev, tmo, phdl) \
  440. MS_prov_setup (PROV_ROLE_DEVICE, PROV_BRR_ADV, (pdev), (tmo), (phdl))
  441. /**
  442. * \brief Setup the Provisioner for provisioning
  443. *
  444. * \par Description This function configures the application as a Provisioner
  445. * over Advertising channel bearer and sets it ready for provisioning.
  446. *
  447. * \param [in] tmo The setup timeout value
  448. * \param [out] phdl The handle to the context setup on successful allocation
  449. *
  450. * \return API_SUCCESS or Error Code on failure
  451. */
  452. #define MS_prov_setup_provisioner_pbadv(tmo, phdl) \
  453. MS_prov_setup (PROV_ROLE_PROVISIONER, PROV_BRR_ADV, NULL, (tmo), (phdl))
  454. /**
  455. * \brief Setup the device for provisioning
  456. *
  457. * \par Description This function configures the application as an Unprovisioned
  458. * device over GATT channel bearer and sets it ready for provisioning.
  459. *
  460. * \param [in] pdev Pointer to the device strcuture \ref PROV_DEVICE_S.
  461. * \param [in] tmo The setup timeout value
  462. * \param [out] phdl The handle to the context setup on successful allocation
  463. *
  464. * \return API_SUCCESS or Error Code on failure
  465. */
  466. #define MS_prov_setup_device_pbgatt(pdev, tmo, phdl) \
  467. MS_prov_setup (PROV_ROLE_DEVICE, PROV_BRR_GATT, (pdev), (tmo), (phdl))
  468. /**
  469. * \brief Setup the Provisioner for provisioning
  470. *
  471. * \par Description This function configures the application as a Provisioner
  472. * over GATT channel bearer and sets it ready for provisioning.
  473. *
  474. * \param [in] tmo The setup timeout value
  475. * \param [out] phdl The handle to the context setup on successful allocation
  476. *
  477. * \return API_SUCCESS or Error Code on failure
  478. */
  479. #define MS_prov_setup_provisioner_pbgatt(tmo, phdl) \
  480. MS_prov_setup (PROV_ROLE_PROVISIONER, PROV_BRR_GATT, NULL, (tmo), (phdl))
  481. /**
  482. * \brief Start Provisioning on the select set of device capabilities.
  483. *
  484. * \par Description This function is used by the provisioner application to start
  485. * the procedure using the selected set of capabilities of the unprovisioned
  486. * device.
  487. *
  488. * \param [in] phandle Provisioning context to be used.
  489. * \param [in] pmethod Pointer to the structure with selected method.
  490. *
  491. * \note This API will be used by the provisioner only, in response to the
  492. * \ref PROV_EVT_PROVISIONING_SETUP event
  493. *
  494. * \return API_SUCCESS or Error Code on failure
  495. */
  496. #define MS_prov_start(phandle, pmethod) \
  497. MS_prov_send_pdu ((phandle), PROV_PDU_TYPE_START, (pmethod), sizeof(PROV_METHOD_S))
  498. /**
  499. * \brief Input Authentication value from Device/Provisioner application.
  500. *
  501. * \par Description This function is used to receive the Authval from the
  502. * application and use it for the algorithm. When the application is that of a
  503. * device, it also sends the input complete message to the provisioner in the
  504. * given context.
  505. *
  506. * \param [in] phandle Provisioning context to be used.
  507. * \param [in] pauth Authentication Value (UINT32 *) or (UCHAR *)
  508. * \param [in] size Size of pauth
  509. *
  510. * \note This API will be used in response to the
  511. * \ref PROV_EVT_OOB_ENTRY event
  512. *
  513. * \return API_SUCCESS or Error Code on failure
  514. */
  515. #define MS_prov_input_authval(phandle, pauth, size) \
  516. MS_prov_send_pdu ((phandle), PROV_PDU_TYPE_INPUT_CMPLT, (pauth), (size))
  517. /**
  518. * \brief Send provisioning data to the device.
  519. *
  520. * \par Description This function is used by the provisioning application to send
  521. * the provisioning data to the device after authentication is complete.
  522. *
  523. * \param [in] phandle Provisioning context to be used.
  524. * \param [in] pdata Pointer to the Provisioning data structre as in \ref
  525. * PROV_DATA_S
  526. *
  527. * \note This API will be used by the provisioner only, in response to the
  528. * \ref PROV_EVT_PROVDATA_INFO_REQ event
  529. *
  530. * \return API_SUCCESS or Error Code on failure
  531. */
  532. #define MS_prov_data(phandle, pdata) \
  533. MS_prov_send_pdu ((phandle), PROV_PDU_TYPE_DATA, (pdata), sizeof (PROV_DATA_S))
  534. /** \} */
  535. /* --------------------------------------------- API Declarations */
  536. /**
  537. * \defgroup prvsng_api_defs API Definitions
  538. * \{
  539. * This section describes the EtherMind Mesh Provisioning Layer APIs.
  540. */
  541. #ifdef __cplusplus
  542. extern "C" {
  543. #endif
  544. /**
  545. * \brief Register provisioning capabilities and callback
  546. *
  547. * \par Description This function registers the provisioning capabilities of the
  548. * application along with the application callback to notify events during the
  549. * provisioning procedure.
  550. *
  551. * \param [in] pcapab Pointer to the provisioning capabilities structure \ref PROV_CAPABILITIES_S
  552. * \param [in] cb Application callback function pointer
  553. *
  554. * \return API_SUCCESS or Error Code on failure
  555. */
  556. API_RESULT MS_prov_register
  557. (
  558. /* IN */ PROV_CAPABILITIES_S * pcapab,
  559. /* IN */ PROV_UI_NOTIFY_CB cb
  560. );
  561. API_RESULT MS_prov_stop_interleave_timer
  562. (
  563. void
  564. );
  565. /**
  566. * \brief Setup the device for provisioning
  567. *
  568. * \par Description This function configures the device to get in a provisionable
  569. * state by specifying the role, bearer and creating a context.
  570. *
  571. * \param [in] role Provisioniong role to be setup - Device or Provisioner.
  572. * \param [in] bearer Provisioning bearer to be setup - PB-ADV or PB-GATT
  573. * \param [in] pdevice Pointer to the device strcuture \ref PROV_DEVICE_S
  574. * containing the UUID to be beaconed. This parameter is used only when the
  575. * role is PROV_ROLE_DEVICE and ignored otherwise.
  576. * \param [in] timeout The time period for which the setup shall be active.
  577. *
  578. * \return API_SUCCESS or Error Code on failure
  579. */
  580. API_RESULT MS_prov_setup
  581. (
  582. /* IN */ PROV_ROLE role,
  583. /* IN */ PROV_BRR bearer,
  584. /* IN */ PROV_DEVICE_S * pdevice,
  585. /* IN */ UINT16 gatt_timeout,
  586. /* IN */ UINT16 adv_timeout
  587. );
  588. /**
  589. * \brief Bind to the peer device for provisioning
  590. *
  591. * \par Description This function establishes a provisioning link with the peer device
  592. * and exchanges the capabilities for provisioning.
  593. *
  594. * \param [in] bearer Provisioning bearer on which to be bound - PB-ADV or PB-GATT
  595. * \param [in] pdevice Pointer to the device strcuture \ref PROV_DEVICE_S.
  596. * \param [in] attention The attention duration in seconds to be configured by the
  597. * device. This parameter is dont care if the role is PROV_ROLE_DEVICE.
  598. * \param [out] phandle The handle to the context setup on successful allocation.
  599. *
  600. * \note This API is for use by the Provisioner application only upon
  601. * reception of an Unprovisioned Device Beacon.
  602. *
  603. * \return API_SUCCESS or Error Code on failure
  604. */
  605. API_RESULT MS_prov_bind
  606. (
  607. /* IN */ PROV_BRR bearer,
  608. /* IN */ PROV_DEVICE_S * pdevice,
  609. /* IN */ UCHAR attention,
  610. /* OUT */ PROV_HANDLE * phandle
  611. );
  612. /**
  613. * \brief Send provisioning PDUs to the peer.
  614. *
  615. * \par Description This function is used by the provisioning application to send
  616. * the provisioning PDUs to the peer device during the procedure.
  617. *
  618. * \param [in] phandle Provisioning context to be used.
  619. * \param [in] pdu Following PDU types are handled -
  620. * PROV_PDU_TYPE_START
  621. * PROV_PDU_TYPE_INPUT_CMPLT
  622. * PROV_PDU_TYPE_DATA
  623. * \param [in] pdata Pointer to the data corresponding to the above PDUs
  624. * \param [in] datalen Size of the pdata
  625. *
  626. * \return API_SUCCESS or Error Code on failure
  627. */
  628. API_RESULT MS_prov_send_pdu
  629. (
  630. /* IN */ PROV_HANDLE * phandle,
  631. /* IN */ UCHAR pdu,
  632. /* IN */ void * pdata,
  633. /* IN */ UINT16 datalen
  634. );
  635. /**
  636. * \brief Set the display authval.
  637. *
  638. * \par Description This function shall be used by the provisioning application
  639. * to set the authval being displayed to the user on receiving \ref
  640. * PROV_EVT_OOB_DISPLAY event with the respective OOB Action and Size.
  641. *
  642. * \param [in] phandle Provisioning context to be used.
  643. * \param [in] pdata Pointer to the Authval (UINT32 *) or (UCHAR *)
  644. * \param [in] datalen Size of the pdata
  645. *
  646. * \return API_SUCCESS or Error Code on failure
  647. */
  648. API_RESULT MS_prov_set_authval
  649. (
  650. /* IN */ PROV_HANDLE * phandle,
  651. /* IN */ void * pdata,
  652. /* IN */ UINT16 datalen
  653. );
  654. /**
  655. * \brief Abort the provisioning procedure
  656. *
  657. * \par Description
  658. * This API can be used by the application to abort the ongoing provisioning
  659. * procedure. This routine closes the provisioning link with the reason as
  660. * specified.
  661. *
  662. * \param [in] phandle Provisioning context to be used.
  663. * \param [in] reason Reason for termination.
  664. *
  665. * \return API_SUCCESS or Error Code on failure
  666. */
  667. API_RESULT MS_prov_abort
  668. (
  669. PROV_HANDLE * phandle,
  670. UCHAR reason
  671. );
  672. /**
  673. * \brief Utility API to fetch current ECDH Public Key to be used for
  674. * Provisioning
  675. *
  676. * \par Description
  677. * This API can be used by the application to fetch the current ECDH P256
  678. * Public Key which is to be used for the Provisioning Procedure.
  679. *
  680. * \param [out] public_key to a pointer of \ref UCHAR array of length
  681. * \ref PROV_PUBKEY_SIZE
  682. *
  683. * \return API_SUCCESS or Error Code on failure
  684. */
  685. API_RESULT MS_prov_get_local_public_key
  686. (
  687. /* OUT */ UCHAR * public_key
  688. );
  689. #ifdef __cplusplus
  690. };
  691. #endif
  692. /** \} */
  693. /** \} */
  694. #endif /* _H_MS_PROV_API_ */