es_adv_timing_resolver.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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 ES_ADV_TIMING_RESOLVER_H__
  41. #define ES_ADV_TIMING_RESOLVER_H__
  42. #include <stdbool.h>
  43. #include <stdint.h>
  44. #include "es_app_config.h"
  45. /**
  46. * @file
  47. * @addtogroup eddystone_adv_timing
  48. * @{
  49. */
  50. /** @brief Timing parameters for a single slot. */
  51. typedef struct
  52. {
  53. bool is_etlm; //!< Flag that specifies if the slot is an eTLM.
  54. uint8_t slot_no; /**< @brief Slot number. @details
  55. * For non-eTLM slots: The slot number of the given frame.
  56. *
  57. * For eTLM slots: The slot number of the corresponding EID frame. */
  58. uint16_t delay_ms; //!< Delay from this frame to the next.
  59. } es_adv_timing_resolver_adv_timing_t;
  60. /**@brief Results of calculating advertisement delays. */
  61. typedef struct
  62. {
  63. es_adv_timing_resolver_adv_timing_t timing_results[APP_MAX_ADV_SLOTS - APP_MAX_EID_SLOTS +
  64. (APP_MAX_EID_SLOTS * 2)]; //!< List of timing results.
  65. uint8_t len_timing_results; //!< Length of results.
  66. } es_adv_timing_resolver_result_t;
  67. /**@brief Input to the timing resolver. */
  68. typedef struct
  69. {
  70. uint16_t adv_interval; //!< Global advertisement interval.
  71. uint8_t num_slots_configured; //!< Number of configured slots.
  72. const uint8_t * p_slots_configured; //!< Pointer to the list of configured slots.
  73. uint8_t num_eid_slots_configured; //!< Number of configured EID slots.
  74. const uint8_t * p_eid_slots_configured; //!< Pointer to the list of configured EID slots.
  75. bool tlm_configured; //!< Flag that specifies if TLM slot is configured.
  76. uint8_t tlm_slot; //!< Slot number of the TLM slot (if @p tlm_configured is true).
  77. es_adv_timing_resolver_result_t * p_result; //!< Output result.
  78. } es_adv_timing_resolver_input_t;
  79. /**@brief Function for getting the input for advertisement interval calculation.
  80. *
  81. * @param[in,out] p_input Input to advertisement interval calculation (see @ref es_adv_timing_resolver_input_t).
  82. * @retval NRF_SUCCESS If the operation was successful. Otherwise, an error code is returned.
  83. */
  84. ret_code_t es_adv_timing_resolve(es_adv_timing_resolver_input_t * p_input);
  85. /**
  86. * @}
  87. */
  88. #endif // ES_ADV_TIMING_RESOLVER_H__