ble_dis.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /**
  2. * Copyright (c) 2012 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. /** @file
  41. *
  42. * @defgroup ble_dis Device Information Service
  43. * @{
  44. * @ingroup ble_sdk_srv
  45. * @brief Device Information Service module.
  46. *
  47. * @details This module implements the Device Information Service.
  48. * During initialization it adds the Device Information Service to the BLE stack database.
  49. * It then encodes the supplied information, and adds the corresponding characteristics.
  50. *
  51. * @note Attention!
  52. * To maintain compliance with Nordic Semiconductor ASA Bluetooth profile
  53. * qualification listings, this section of source code must not be modified.
  54. */
  55. #ifndef BLE_DIS_H__
  56. #define BLE_DIS_H__
  57. #include <stdint.h>
  58. #include "ble_srv_common.h"
  59. #ifdef __cplusplus
  60. extern "C" {
  61. #endif
  62. /** @defgroup DIS_VENDOR_ID_SRC_VALUES Vendor ID Source values
  63. * @{
  64. */
  65. #define BLE_DIS_VENDOR_ID_SRC_BLUETOOTH_SIG 1 /**< Vendor ID assigned by Bluetooth SIG. */
  66. #define BLE_DIS_VENDOR_ID_SRC_USB_IMPL_FORUM 2 /**< Vendor ID assigned by USB Implementer's Forum. */
  67. /** @} */
  68. /**@brief System ID parameters */
  69. typedef struct
  70. {
  71. uint64_t manufacturer_id; /**< Manufacturer ID. Only 5 LSOs shall be used. */
  72. uint32_t organizationally_unique_id; /**< Organizationally unique ID. Only 3 LSOs shall be used. */
  73. } ble_dis_sys_id_t;
  74. /**@brief IEEE 11073-20601 Regulatory Certification Data List Structure */
  75. typedef struct
  76. {
  77. uint8_t * p_list; /**< Pointer the byte array containing the encoded opaque structure based on IEEE 11073-20601 specification. */
  78. uint8_t list_len; /**< Length of the byte array. */
  79. } ble_dis_reg_cert_data_list_t;
  80. /**@brief PnP ID parameters */
  81. typedef struct
  82. {
  83. uint8_t vendor_id_source; /**< Vendor ID Source. see @ref DIS_VENDOR_ID_SRC_VALUES. */
  84. uint16_t vendor_id; /**< Vendor ID. */
  85. uint16_t product_id; /**< Product ID. */
  86. uint16_t product_version; /**< Product Version. */
  87. } ble_dis_pnp_id_t;
  88. /**@brief Device Information Service init structure. This contains all possible characteristics
  89. * needed for initialization of the service.
  90. */
  91. typedef struct
  92. {
  93. ble_srv_utf8_str_t manufact_name_str; /**< Manufacturer Name String. */
  94. ble_srv_utf8_str_t model_num_str; /**< Model Number String. */
  95. ble_srv_utf8_str_t serial_num_str; /**< Serial Number String. */
  96. ble_srv_utf8_str_t hw_rev_str; /**< Hardware Revision String. */
  97. ble_srv_utf8_str_t fw_rev_str; /**< Firmware Revision String. */
  98. ble_srv_utf8_str_t sw_rev_str; /**< Software Revision String. */
  99. ble_dis_sys_id_t * p_sys_id; /**< System ID. */
  100. ble_dis_reg_cert_data_list_t * p_reg_cert_data_list; /**< IEEE 11073-20601 Regulatory Certification Data List. */
  101. ble_dis_pnp_id_t * p_pnp_id; /**< PnP ID. */
  102. security_req_t dis_char_rd_sec; /**< Security requirement for reading any DIS characteristic value. */
  103. } ble_dis_init_t;
  104. /**@brief Function for initializing the Device Information Service.
  105. *
  106. * @details This call allows the application to initialize the device information service.
  107. * It adds the DIS service and DIS characteristics to the database, using the initial
  108. * values supplied through the p_dis_init parameter. Characteristics which are not to be
  109. * added, shall be set to NULL in p_dis_init.
  110. *
  111. * @param[in] p_dis_init The structure containing the values of characteristics needed by the
  112. * service.
  113. *
  114. * @return NRF_SUCCESS on successful initialization of service.
  115. */
  116. uint32_t ble_dis_init(ble_dis_init_t const * p_dis_init);
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif // BLE_DIS_H__
  121. /** @} */