escs_defs.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /**
  2. * Copyright (c) 2016 - 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. #ifndef ESCS_DEFS_H__
  41. #define ESCS_DEFS_H__
  42. #include "es.h"
  43. /*@file Contains definitions specific to the Eddystone Configuration Service */
  44. #define ESCS_LOCK_STATE_NEW_LOCK_CODE_WRITE_LENGTH 17
  45. #define ESCS_UID_READ_LENGTH (ES_UID_LENGTH)
  46. #define ESCS_UID_WRITE_LENGTH (ES_UID_NAMESPACE_LENGTH + \
  47. ES_UID_INSTANCE_LENGTH + ES_FRAME_TYPE_LENGTH)
  48. #define ESCS_TLM_READ_LENGTH (ESCS_TLM_READ_LENGTH)
  49. #define ESCS_TLM_WRITE_LENGTH (ES_FRAME_TYPE_LENGTH)
  50. #define ESCS_EID_READ_LENGTH (14)
  51. #define ESCS_EID_WRITE_ECDH_LENGTH (34)
  52. #define ESCS_EID_WRITE_PUB_KEY_INDEX (1)
  53. #define ESCS_EID_WRITE_ENC_ID_KEY_INDEX (1)
  54. #define ESCS_EID_WRITE_IDK_LENGTH (18)
  55. #define ESCS_LOCK_STATE_READ_LENGTH (1)
  56. #define ESCS_URL_MIN_WRITE_LENGTH (4)
  57. #define ESCS_URL_WRITE_LENGTH (19)
  58. #ifdef NRF52_SERIES
  59. #define ESCS_NUM_OF_SUPPORTED_TX_POWER (9)
  60. /**@brief TX power levels, based on nRF52 specifications. */
  61. #define ESCS_SUPPORTED_TX_POWER {-40, -20, -16, -12, -8, -4, 0, 3, 4}
  62. #elif NRF51
  63. /**@brief TX power levels, based on nRF51 specifications. */
  64. #define ESCS_NUM_OF_SUPPORTED_TX_POWER (8)
  65. #define ESCS_SUPPORTED_TX_POWER {-30, -20, -16, -12, -8, -4, 0, 4}
  66. #else
  67. #error MISSING TX POWER
  68. #endif
  69. // Defined in Eddystone Specifications
  70. #define ESCS_AES_KEY_SIZE (16)
  71. #define ESCS_ECDH_KEY_SIZE (32)
  72. #define ESCS_ADV_SLOT_CHAR_LENGTH_MAX (34) // Corresponds to when the slots is configured as an EID slot
  73. // Characteristic: Broadcast Capabilities
  74. // Field: nrf_ble_escs_init_params_t.broadcast_cap.cap_bitfield
  75. #define ESCS_BROADCAST_VAR_ADV_SUPPORTED_Yes (1) // Set if the beacon supports individual per-slot adv intervals
  76. #define ESCS_BROADCAST_VAR_ADV_SUPPORTED_No (0)
  77. #define ESCS_BROADCAST_VAR_ADV_SUPPORTED_Pos (0)
  78. #define ESCS_BROADCAST_VAR_ADV_SUPPORTED_Msk (1 << ESCS_BROADCAST_VAR_ADV_SUPPORTED_Pos)
  79. #define ESCS_BROADCAST_VAR_TX_POWER_SUPPORTED_Yes (1) // Set if the beacon supports individual per-slot TX intervals
  80. #define ESCS_BROADCAST_VAR_TX_POWER_SUPPORTED_No (0)
  81. #define ESCS_BROADCAST_VAR_TX_POWER_SUPPORTED_Pos (1)
  82. #define ESCS_BROADCAST_VAR_TX_POWER_SUPPORTED_Msk (1 << ESCS_BROADCAST_VAR_TX_POWER_SUPPORTED_Pos)
  83. #define ESCS_BROADCAST_VAR_RFU_MASK (0x03) // AND Mask to guarantee that bits 0x04 to 0x80 (RFU) are cleared
  84. // Field: nrf_ble_escs_init_params_t.broadcast_cap.supp_frame_types
  85. #define ESCS_FRAME_TYPE_UID_SUPPORTED_Yes (1)
  86. #define ESCS_FRAME_TYPE_UID_SUPPORTED_No (0)
  87. #define ESCS_FRAME_TYPE_UID_SUPPORTED_Pos (0)
  88. #define ESCS_FRAME_TYPE_UID_SUPPORTED_Msk (1 << ESCS_FRAME_TYPE_UID_SUPPORTED_Pos)
  89. #define ESCS_FRAME_TYPE_URL_SUPPORTED_Yes (1)
  90. #define ESCS_FRAME_TYPE_URL_SUPPORTED_No (0)
  91. #define ESCS_FRAME_TYPE_URL_SUPPORTED_Pos (1)
  92. #define ESCS_FRAME_TYPE_URL_SUPPORTED_Msk (1 << ESCS_FRAME_TYPE_URL_SUPPORTED_Pos)
  93. #define ESCS_FRAME_TYPE_TLM_SUPPORTED_Yes (1)
  94. #define ESCS_FRAME_TYPE_TLM_SUPPORTED_No (0)
  95. #define ESCS_FRAME_TYPE_TLM_SUPPORTED_Pos (2)
  96. #define ESCS_FRAME_TYPE_TLM_SUPPORTED_Msk (1 << ESCS_FRAME_TYPE_TLM_SUPPORTED_Pos)
  97. #define ESCS_FRAME_TYPE_EID_SUPPORTED_Yes (1)
  98. #define ESCS_FRAME_TYPE_EID_SUPPORTED_No (0)
  99. #define ESCS_FRAME_TYPE_EID_SUPPORTED_Pos (3)
  100. #define ESCS_FRAME_TYPE_EID_SUPPORTED_Msk (1 << ESCS_FRAME_TYPE_EID_SUPPORTED_Pos)
  101. #define ESCS_FRAME_TYPE_RFU_MASK (0x000F) // AND Mask to guarantee that bits 0x0010 to 0x8000 (RFU) are cleared
  102. // Characteristic: Lock State: Lock State (READ)
  103. #define ESCS_LOCK_STATE_LOCKED (0x00)
  104. #define ESCS_LOCK_STATE_UNLOCKED (0x01)
  105. #define ESCS_LOCK_STATE_UNLOCKED_AUTO_RELOCK_DISABLED (0x02)
  106. // Characteristic: Lock State: Lock Byte (WRITE)
  107. #define ESCS_LOCK_BYTE_LOCK (0x00)
  108. #define ESCS_LOCK_BYTE_DISABLE_AUTO_RELOCK (0x02)
  109. // Charcteristic: Remain Connectable
  110. #define ESCS_FUNCT_REMAIN_CONNECTABLE_SUPPORTED_Yes (0x01)
  111. #define ESCS_FUNCT_REMAIN_CONNECTABLE_SUPPORTED_No (0x00)
  112. #endif // ESCS_DEFS_H__