tile_gap_driver.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /**
  2. * NOTICE
  3. *
  4. * Copyright 2020 Tile Inc. All Rights Reserved.
  5. * All code or other information included in the accompanying files ("Tile Source Material")
  6. * is PROPRIETARY information of Tile Inc. ("Tile") and access and use of the Tile Source Material
  7. * is subject to these terms. The Tile Source Material may only be used for demonstration purposes,
  8. * and may not be otherwise distributed or made available to others, including for commercial purposes.
  9. * Without limiting the foregoing , you understand and agree that no production use
  10. * of the Tile Source Material is allowed without a Tile ID properly obtained under a separate
  11. * agreement with Tile.
  12. * You also understand and agree that Tile may terminate the limited rights granted under these terms
  13. * at any time in its discretion.
  14. * All Tile Source Material is provided AS-IS without warranty of any kind.
  15. * Tile does not warrant that the Tile Source Material will be error-free or fit for your purposes.
  16. * Tile will not be liable for any damages resulting from your use of or inability to use
  17. * the Tile Source Material.
  18. *
  19. * Support: firmware_support@tile.com
  20. */
  21. /** @file tile_gap_driver.h
  22. ** @brief Tile GAP Driver interface. Provides TileLib Control over GAP functions, like connection,
  23. ** disconnection and connection parameters.
  24. */
  25. #ifndef TILE_GAP_DRIVER_H_
  26. #define TILE_GAP_DRIVER_H_
  27. #include <stdint.h>
  28. #define TILE_SERVICE_DATA_VERSION_0 0
  29. #define TILE_SERVICE_DATA_VERSION_2 2
  30. /**
  31. * Connection parameters.
  32. */
  33. struct tile_conn_params
  34. {
  35. uint16_t conn_interval;
  36. uint16_t slave_latency;
  37. uint16_t conn_sup_timeout;
  38. };
  39. struct tile_gap_driver
  40. {
  41. /**
  42. * Time in 10ms increments before Tile disconnects if no client has
  43. * authenticated. A value of 0 indicates that this feature is disabled.
  44. * The value may be updated at any time, but will not clear a timer which
  45. * is already running. The value is used after a connection is established.
  46. */
  47. uint16_t authentication_timer_delay;
  48. /**
  49. * Memory space for current connection parameters.
  50. */
  51. struct tile_conn_params conn_params;
  52. /**
  53. * Diagnostic info: counts the number of disconnections triggered by Auth Timer.
  54. */
  55. uint16_t* auth_disconnect_count;
  56. /**
  57. * Disconnect from the currently connected device.
  58. *
  59. * @return See @ref TILE_ERROR_CODES.
  60. */
  61. int (*gap_disconnect)(void);
  62. };
  63. /**
  64. * Register the GAP driver with Tile Library.
  65. */
  66. int tile_gap_register(struct tile_gap_driver *driver);
  67. /**
  68. * Call when a connection has been established.
  69. */
  70. int tile_gap_connected(struct tile_conn_params *conn_params);
  71. /**
  72. * Call when a connection has been terminated.
  73. */
  74. int tile_gap_disconnected(void);
  75. /**
  76. * Call when the connection parameters have been updated. This function will
  77. * update the values contained in the driver structure.
  78. */
  79. int tile_gap_params_updated(struct tile_conn_params *conn_params);
  80. /***************************************************************************************
  81. * @brief Get the advertising parameters to use from TileLib.
  82. *
  83. * @param[out] adv_interval pointer to write the Advertising Interval.
  84. * @param[out] tile_service_uuid pointer to write the Service UUID to put in the list of 16-bit UUIDs and Service Data.
  85. * @param[out] tile_service_data_length pointer to write the Service Data length.
  86. * @param[out] tile_service_data pointer to write the Service Data. The required minimum available buffer size is TILE_SERVICE_DATA_MAX_LENGTH.
  87. * @param[out] manuf pointer to indicate whether munufacturing data is available.
  88. *
  89. * @return See @ref TILE_ERROR_CODES.
  90. *
  91. ****************************************************************************************
  92. */
  93. int tile_gap_get_adv_params(uint16_t* adv_interval, uint16_t* tile_service_uuid, uint8_t* tile_service_data_length, uint8_t* tile_service_data, uint8_t* manuf);
  94. #endif