observer.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 OBSERVER_H
  29. #define OBSERVER_H
  30. #ifdef __cplusplus
  31. extern "C"
  32. {
  33. #endif
  34. /*********************************************************************
  35. * INCLUDES
  36. */
  37. #include "bcomdef.h"
  38. #include "OSAL.h"
  39. #include "gap.h"
  40. /*********************************************************************
  41. * CONSTANTS
  42. */
  43. /** @defgroup GAPOBSERVERROLE_PROFILE_PARAMETERS GAP Observer Role Parameters
  44. * @{
  45. */
  46. #define GAPOBSERVERROLE_BD_ADDR 0x400 //!< Device's Address. Read Only. Size is uint8[B_ADDR_LEN]. This item is read from the controller.
  47. #define GAPOBSERVERROLE_MAX_SCAN_RES 0x401 //!< Maximum number of discover scan results to receive. Default is 0 = unlimited.
  48. /** @} End GAPOBSERVERROLE_PROFILE_PARAMETERS */
  49. /*********************************************************************
  50. * VARIABLES
  51. */
  52. /*********************************************************************
  53. * MACROS
  54. */
  55. /*********************************************************************
  56. * TYPEDEFS
  57. */
  58. /**
  59. * Observer Event Structure
  60. */
  61. typedef union
  62. {
  63. gapEventHdr_t gap; //!< GAP_MSG_EVENT and status.
  64. gapDeviceInitDoneEvent_t initDone; //!< GAP initialization done.
  65. gapDeviceInfoEvent_t deviceInfo; //!< Discovery device information event structure.
  66. gapDevDiscEvent_t discCmpl; //!< Discovery complete event structure.
  67. } gapObserverRoleEvent_t;
  68. /**
  69. * RSSI Read Callback Function
  70. */
  71. typedef void (*pfnGapObserverRoleRssiCB_t)
  72. (
  73. uint16 connHandle, //!< Connection handle.
  74. int8 rssi //!< New RSSI value.
  75. );
  76. /**
  77. * Observer Event Callback Function
  78. */
  79. typedef void (*pfnGapObserverRoleEventCB_t)
  80. (
  81. gapObserverRoleEvent_t *pEvent //!< Pointer to event structure.
  82. );
  83. /**
  84. * Observer Callback Structure
  85. */
  86. typedef struct
  87. {
  88. pfnGapObserverRoleRssiCB_t rssiCB; //!< RSSI callback.
  89. pfnGapObserverRoleEventCB_t eventCB; //!< Event callback.
  90. } gapObserverRoleCB_t;
  91. /*********************************************************************
  92. * VARIABLES
  93. */
  94. /*********************************************************************
  95. * API FUNCTIONS
  96. */
  97. /*-------------------------------------------------------------------
  98. * Observer Profile Public APIs
  99. */
  100. /**
  101. * @defgroup OBSERVER_PROFILE_API Observer Profile API Functions
  102. *
  103. * @{
  104. */
  105. /**
  106. * @brief Start the device in Observer role. This function is typically
  107. * called once during system startup.
  108. *
  109. * @param pAppCallbacks - pointer to application callbacks
  110. *
  111. * @return SUCCESS: Operation successful.<BR>
  112. * bleAlreadyInRequestedMode: Device already started.<BR>
  113. */
  114. extern bStatus_t GAPObserverRole_StartDevice( gapObserverRoleCB_t *pAppCallbacks );
  115. /**
  116. * @brief Set a parameter in the Observer Profile.
  117. *
  118. * @param param - profile parameter ID: @ref GAPOBSERVERROLE_PROFILE_PARAMETERS
  119. * @param len - length of data to write
  120. * @param pValue - pointer to data to write. This is dependent on
  121. * the parameter ID and WILL be cast to the appropriate
  122. * data type.
  123. *
  124. * @return SUCCESS: Operation successful.<BR>
  125. * INVALIDPARAMETER: Invalid parameter ID.<BR>
  126. */
  127. extern bStatus_t GAPObserverRole_SetParameter( uint16 param, uint8 len, void *pValue );
  128. /**
  129. * @brief Get a parameter in the Observer Profile.
  130. *
  131. * @param param - profile parameter ID: @ref GAPOBSERVERROLE_PROFILE_PARAMETERS
  132. * @param pValue - pointer to buffer to contain the read data
  133. *
  134. * @return SUCCESS: Operation successful.<BR>
  135. * INVALIDPARAMETER: Invalid parameter ID.<BR>
  136. */
  137. extern bStatus_t GAPObserverRole_GetParameter( uint16 param, void *pValue );
  138. /**
  139. * @brief Start a device discovery scan.
  140. *
  141. * @param mode - discovery mode: @ref GAP_DEVDISC_MODE_DEFINES
  142. * @param activeScan - TRUE to perform active scan
  143. * @param whiteList - TRUE to only scan for devices in the white list
  144. *
  145. * @return SUCCESS: Discovery scan started.<BR>
  146. * bleIncorrectMode: Invalid profile role.<BR>
  147. * bleAlreadyInRequestedMode: Not available.<BR>
  148. */
  149. extern bStatus_t GAPObserverRole_StartDiscovery( uint8 mode, uint8 activeScan, uint8 whiteList );
  150. /**
  151. * @brief Cancel a device discovery scan.
  152. *
  153. * @return SUCCESS: Cancel started.<BR>
  154. * bleInvalidTaskID: Not the task that started discovery.<BR>
  155. * bleIncorrectMode: Not in discovery mode.<BR>
  156. */
  157. extern bStatus_t GAPObserverRole_CancelDiscovery( void );
  158. /**
  159. * @}
  160. */
  161. /*-------------------------------------------------------------------
  162. * TASK API - These functions must only be called by OSAL.
  163. */
  164. /**
  165. * @internal
  166. *
  167. * @brief Observer Profile Task initialization function.
  168. *
  169. * @param taskId - Task ID.
  170. *
  171. * @return void
  172. */
  173. extern void GAPObserverRole_Init( uint8 taskId );
  174. /**
  175. * @internal
  176. *
  177. * @brief Observer Profile Task event processing function.
  178. *
  179. * @param taskId - Task ID
  180. * @param events - Events.
  181. *
  182. * @return events not processed
  183. */
  184. extern uint16 GAPObserverRole_ProcessEvent( uint8 taskId, uint16 events );
  185. /*********************************************************************
  186. *********************************************************************/
  187. #ifdef __cplusplus
  188. }
  189. #endif
  190. #endif /* OBSERVER_H */