broadcaster.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. #ifndef BROADCASTER_H
  29. #define BROADCASTER_H
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #endif
  34. /*-------------------------------------------------------------------
  35. * INCLUDES
  36. */
  37. /*-------------------------------------------------------------------
  38. * CONSTANTS
  39. */
  40. /** @defgroup GAPROLE_PROFILE_PARAMETERS GAP Role Parameters
  41. * @{
  42. */
  43. #define GAPROLE_PROFILEROLE 0x300 //!< Reading this parameter will return GAP Role type. Read Only. Size is uint8.
  44. #define GAPROLE_BD_ADDR 0x301 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
  45. #define GAPROLE_ADVERT_ENABLED 0x302 //!< Enable/Disable Advertising. Read/Write. Size is uint8. Default is TRUE=Enabled.
  46. #define GAPROLE_ADVERT_OFF_TIME 0x303 //!< Advertising Off Time for Limited advertisements (in milliseconds). Read/Write. Size is uint16. Default is 30 seconds.
  47. #define GAPROLE_ADVERT_DATA 0x304 //!< Advertisement Data. Read/Write. Size is uint8[B_MAX_ADV_LEN]. Default is "02:01:01", which means that it is a Limited Discoverable Advertisement.
  48. #define GAPROLE_SCAN_RSP_DATA 0x305 //!< Scan Response Data. Read/Write. Size is uint8[B_MAX_ADV_LEN]. Defaults to all 0.
  49. #define GAPROLE_ADV_EVENT_TYPE 0x306 //!< Advertisement Type. Read/Write. Size is uint8. Default is GAP_ADTYPE_ADV_IND (defined in GAP.h).
  50. #define GAPROLE_ADV_DIRECT_TYPE 0x307 //!< Direct Advertisement Address Type. Ready/Write. Size is uint8. Default is ADDRTYPE_PUBLIC (defined in GAP.h).
  51. #define GAPROLE_ADV_DIRECT_ADDR 0x308 //!< Direct Advertisement Address. Read/Write. Size is uint8[B_ADDR_LEN]. Default is NULL.
  52. #define GAPROLE_ADV_CHANNEL_MAP 0x309 //!< Which channels to advertise on. Read/Write Size is uint8. Default is GAP_ADVCHAN_ALL (defined in GAP.h)
  53. #define GAPROLE_ADV_FILTER_POLICY 0x30A //!< Filter Policy. Ignored when directed advertising is used. Read/Write. Size is uint8. Default is GAP_FILTER_POLICY_ALL (defined in GAP.h).
  54. /** @} End GAPROLE_PROFILE_PARAMETERS */
  55. /*-------------------------------------------------------------------
  56. * TYPEDEFS
  57. */
  58. /**
  59. * GAP Broadcaster Role States.
  60. */
  61. typedef enum
  62. {
  63. GAPROLE_INIT = 0, //!< Waiting to be started
  64. GAPROLE_STARTED, //!< Started but not advertising
  65. GAPROLE_ADVERTISING, //!< Currently Advertising
  66. GAPROLE_WAITING, //!< Device is started but not advertising, is in waiting period before advertising again
  67. GAPROLE_ERROR //!< Error occurred - invalid state
  68. } gaprole_States_t;
  69. /*-------------------------------------------------------------------
  70. * MACROS
  71. */
  72. /*-------------------------------------------------------------------
  73. * Profile Callbacks
  74. */
  75. /**
  76. * Callback when the device has been started. Callback event to
  77. * the Notify of a state change.
  78. */
  79. typedef void (*gapRolesStateNotify_t)( gaprole_States_t newState );
  80. /**
  81. * Callback when the device has read an new RSSI value during a connection.
  82. */
  83. typedef void (*gapRolesRssiRead_t)( int8 newRSSI );
  84. /**
  85. * Callback structure - must be setup by the application and used when gapRoles_StartDevice() is called.
  86. */
  87. typedef struct
  88. {
  89. gapRolesStateNotify_t pfnStateChange; //!< Whenever the device changes state
  90. gapRolesRssiRead_t pfnRssiRead; //!< When a valid RSSI is read from controller
  91. } gapRolesCBs_t;
  92. /*-------------------------------------------------------------------
  93. * API FUNCTIONS
  94. */
  95. /**
  96. * @defgroup GAPROLES_BROADCASTER_API GAP Broadcaster Role API Functions
  97. *
  98. * @{
  99. */
  100. /**
  101. * @brief Set a GAP Role parameter.
  102. *
  103. * NOTE: You can call this function with a GAP Parameter ID and it will set the
  104. * GAP Parameter. GAP Parameters are defined in (gap.h). Also,
  105. * the "len" field must be set to the size of a "uint16" and the
  106. * "pValue" field must point to a "uint16".
  107. *
  108. * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
  109. * @param len - length of data to write
  110. * @param pValue - pointer to data to write. This is dependent on
  111. * the parameter ID and WILL be cast to the appropriate
  112. * data type (example: data type of uint16 will be cast to
  113. * uint16 pointer).
  114. *
  115. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  116. */
  117. extern bStatus_t GAPRole_SetParameter( uint16 param, uint8 len, void *pValue );
  118. /**
  119. * @brief Get a GAP Role parameter.
  120. *
  121. * NOTE: You can call this function with a GAP Parameter ID and it will get a
  122. * GAP Parameter. GAP Parameters are defined in (gap.h). Also, the
  123. * "pValue" field must point to a "uint16".
  124. *
  125. * @param param - Profile parameter ID: @ref GAPROLE_PROFILE_PARAMETERS
  126. * @param pValue - pointer to location to get the value. This is dependent on
  127. * the parameter ID and WILL be cast to the appropriate
  128. * data type (example: data type of uint16 will be cast to
  129. * uint16 pointer).
  130. *
  131. * @return SUCCESS or INVALIDPARAMETER (invalid paramID)
  132. */
  133. extern bStatus_t GAPRole_GetParameter( uint16 param, void *pValue );
  134. /**
  135. * @brief Does the device initialization. Only call this function once.
  136. *
  137. * @param pAppCallbacks - pointer to application callbacks.
  138. *
  139. * @return SUCCESS or bleAlreadyInRequestedMode
  140. */
  141. extern bStatus_t GAPRole_StartDevice( gapRolesCBs_t *pAppCallbacks );
  142. /**
  143. * @} End GAPROLES_BROADCASTER_API
  144. */
  145. /*-------------------------------------------------------------------
  146. * TASK FUNCTIONS - Don't call these. These are system functions.
  147. */
  148. /**
  149. * @internal
  150. *
  151. * @brief Initialization function for the GAP Role Task.
  152. * This is called during initialization and should contain
  153. * any application specific initialization (ie. hardware
  154. * initialization/setup, table initialization, power up
  155. * notificaiton ... ).
  156. *
  157. * @param the ID assigned by OSAL. This ID should be
  158. * used to send messages and set timers.
  159. *
  160. * @return void
  161. */
  162. extern void GAPRole_Init( uint8 task_id );
  163. /**
  164. * @internal
  165. *
  166. * @brief GAP Role Task event processor.
  167. * This function is called to process all events for the task.
  168. * Events include timers, messages and any other user defined
  169. * events.
  170. *
  171. * @param task_id - The OSAL assigned task ID.
  172. * @param events - events to process. This is a bit map and can
  173. * contain more than one event.
  174. *
  175. * @return events not processed
  176. */
  177. extern uint16 GAPRole_ProcessEvent( uint8 task_id, uint16 events );
  178. /*-------------------------------------------------------------------
  179. -------------------------------------------------------------------*/
  180. #ifdef __cplusplus
  181. }
  182. #endif
  183. #endif /* BROADCASTER_H */