provision.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /* SPDX-License-Identifier: LGPL-2.1-or-later */
  2. /*
  3. *
  4. * BlueZ - Bluetooth protocol stack for Linux
  5. *
  6. * Copyright (C) 2018 Intel Corporation. All rights reserved.
  7. *
  8. *
  9. */
  10. /*
  11. * size: hard define (mesh.conf - OOB_NUMBEROOB_NUMBER)
  12. * oob size - 8 if alpha or numeric
  13. * else 1 if mask is non zero
  14. * else 0
  15. */
  16. struct bt_mesh;
  17. struct mesh_prov;
  18. struct mesh_agent;
  19. /* Provisioner Agent Response Types */
  20. #define OOB_CANCEL 0x00
  21. #define OOB_PRIV_KEY 0x01
  22. #define OOB_PUB_KEY 0x02
  23. #define OOB_NUMBER 0x03
  24. #define OOB_STATIC 0x04
  25. #define OOB_NUMBER_DISPLAY 0x05
  26. /* Spec defined Provisioning message types */
  27. #define PROV_INVITE 0x00
  28. #define PROV_CAPS 0x01
  29. #define PROV_START 0x02
  30. #define PROV_PUB_KEY 0x03
  31. #define PROV_INP_CMPLT 0x04
  32. #define PROV_CONFIRM 0x05
  33. #define PROV_RANDOM 0x06
  34. #define PROV_DATA 0x07
  35. #define PROV_COMPLETE 0x08
  36. #define PROV_FAILED 0x09
  37. #define PROV_NONE 0xFF
  38. /* Spec defined Error Codes */
  39. #define PROV_ERR_SUCCESS 0x00
  40. #define PROV_ERR_INVALID_PDU 0x01
  41. #define PROV_ERR_INVALID_FORMAT 0x02
  42. #define PROV_ERR_UNEXPECTED_PDU 0x03
  43. #define PROV_ERR_CONFIRM_FAILED 0x04
  44. #define PROV_ERR_INSUF_RESOURCE 0x05
  45. #define PROV_ERR_DECRYPT_FAILED 0x06
  46. #define PROV_ERR_UNEXPECTED_ERR 0x07
  47. #define PROV_ERR_CANT_ASSIGN_ADDR 0x08
  48. /* Internally generated Error Codes */
  49. #define PROV_ERR_TIMEOUT 0xFF
  50. /* Provisioner Action values */
  51. /* IN */
  52. #define PROV_ACTION_PUSH 0x00
  53. #define PROV_ACTION_TWIST 0x01
  54. #define PROV_ACTION_IN_NUMERIC 0x02
  55. #define PROV_ACTION_IN_ALPHA 0x03
  56. /* OUT */
  57. #define PROV_ACTION_BLINK 0x00
  58. #define PROV_ACTION_BEEP 0x01
  59. #define PROV_ACTION_VIBRATE 0x02
  60. #define PROV_ACTION_OUT_NUMERIC 0x03
  61. #define PROV_ACTION_OUT_ALPHA 0x04
  62. /* OOB_Info defines from Table 3.54 of Mesh profile Specification v1.0 */
  63. #define OOB_INFO_URI_HASH 0x0002
  64. /* PB_REMOTE not supported from unprovisioned state */
  65. enum trans_type {
  66. PB_ADV = 0,
  67. PB_GATT,
  68. };
  69. #define PROV_FLAG_KR 0x01
  70. #define PROV_FLAG_IVU 0x02
  71. struct mesh_prov_node_info {
  72. uint32_t iv_index;
  73. uint16_t unicast;
  74. uint16_t net_index;
  75. uint8_t num_ele;
  76. uint8_t net_key[16];
  77. uint8_t device_key[16];
  78. uint8_t flags; /* IVU and KR bits */
  79. };
  80. typedef bool (*mesh_prov_acceptor_complete_func_t)(void *user_data,
  81. uint8_t status,
  82. struct mesh_prov_node_info *info);
  83. typedef void (*mesh_prov_initiator_start_func_t)(void *user_data, int err);
  84. typedef bool (*mesh_prov_initiator_data_req_func_t)(void *user_data,
  85. uint8_t num_elem);
  86. typedef bool (*mesh_prov_initiator_complete_func_t)(void *user_data,
  87. uint8_t status,
  88. struct mesh_prov_node_info *info);
  89. /* This starts unprovisioned device beacon */
  90. bool acceptor_start(uint8_t num_ele, uint8_t uuid[16],
  91. uint16_t algorithms, uint32_t timeout,
  92. struct mesh_agent *agent,
  93. mesh_prov_acceptor_complete_func_t complete_cb,
  94. void *caller_data);
  95. void acceptor_cancel(void *user_data);
  96. bool initiator_start(enum trans_type transport,
  97. uint8_t uuid[16],
  98. uint16_t max_ele,
  99. uint32_t timeout, /* in seconds from mesh.conf */
  100. struct mesh_agent *agent,
  101. mesh_prov_initiator_start_func_t start_cb,
  102. mesh_prov_initiator_data_req_func_t data_req_cb,
  103. mesh_prov_initiator_complete_func_t complete_cb,
  104. void *node, void *caller_data);
  105. void initiator_prov_data(uint16_t net_idx, uint16_t primary, void *caller_data);
  106. void initiator_cancel(void *caller_data);