heartrateservice.h 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  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. /**************************************************************************************************
  29. Filename: heartrateservice.h
  30. Revised:
  31. Revision:
  32. Description: This file contains the Heart Rate service definitions and
  33. prototypes.
  34. **************************************************************************************************/
  35. #ifndef HEARTRATESERVICE_H
  36. #define HEARTRATESERVICE_H
  37. #ifdef __cplusplus
  38. extern "C"
  39. {
  40. #endif
  41. /*********************************************************************
  42. * INCLUDES
  43. */
  44. /*********************************************************************
  45. * CONSTANTS
  46. */
  47. // Heart Rate Service Parameters
  48. #define HEARTRATE_MEAS 0
  49. #define HEARTRATE_MEAS_CHAR_CFG 1
  50. #define HEARTRATE_SENS_LOC 2
  51. #define HEARTRATE_COMMAND 3
  52. // Maximum length of heart rate measurement characteristic
  53. #define HEARTRATE_MEAS_MAX (ATT_MTU_SIZE -5)
  54. // Values for flags
  55. #define HEARTRATE_FLAGS_FORMAT_UINT16 0x01
  56. #define HEARTRATE_FLAGS_CONTACT_NOT_SUP 0x00
  57. #define HEARTRATE_FLAGS_CONTACT_NOT_DET 0x04
  58. #define HEARTRATE_FLAGS_CONTACT_DET 0x06
  59. #define HEARTRATE_FLAGS_ENERGY_EXP 0x08
  60. #define HEARTRATE_FLAGS_RR 0x10
  61. // Values for sensor location
  62. #define HEARTRATE_SENS_LOC_OTHER 0x00
  63. #define HEARTRATE_SENS_LOC_CHEST 0x01
  64. #define HEARTRATE_SENS_LOC_WRIST 0x02
  65. #define HEARTRATE_SENS_LOC_FINGER 0x03
  66. #define HEARTRATE_SENS_LOC_HAND 0x04
  67. #define HEARTRATE_SENS_LOC_EARLOBE 0x05
  68. #define HEARTRATE_SENS_LOC_FOOT 0x06
  69. // Value for command characteristic
  70. #define HEARTRATE_COMMAND_ENERGY_EXP 0x01
  71. // ATT Error code
  72. // Control point value not supported
  73. #define HEARTRATE_ERR_NOT_SUP 0x80
  74. // Heart Rate Service bit fields
  75. #define HEARTRATE_SERVICE 0x00000001
  76. // Callback events
  77. #define HEARTRATE_MEAS_NOTI_ENABLED 1
  78. #define HEARTRATE_MEAS_NOTI_DISABLED 2
  79. #define HEARTRATE_COMMAND_SET 3
  80. /*********************************************************************
  81. * TYPEDEFS
  82. */
  83. // Heart Rate Service callback function
  84. typedef void (*heartRateServiceCB_t)(uint8 event);
  85. /*********************************************************************
  86. * MACROS
  87. */
  88. /*********************************************************************
  89. * Profile Callbacks
  90. */
  91. /*********************************************************************
  92. * API FUNCTIONS
  93. */
  94. /*
  95. * HeartRate_AddService- Initializes the Heart Rate service by registering
  96. * GATT attributes with the GATT server.
  97. *
  98. * @param services - services to add. This is a bit map and can
  99. * contain more than one service.
  100. */
  101. extern bStatus_t HeartRate_AddService( uint32 services );
  102. /*
  103. * HeartRate_Register - Register a callback function with the
  104. * Heart Rate Service
  105. *
  106. * @param pfnServiceCB - Callback function.
  107. */
  108. extern void HeartRate_Register( heartRateServiceCB_t pfnServiceCB );
  109. /*
  110. * HeartRate_SetParameter - Set a Heart Rate parameter.
  111. *
  112. * param - Profile parameter ID
  113. * len - length of data to right
  114. * value - pointer to data to write. This is dependent on
  115. * the parameter ID and WILL be cast to the appropriate
  116. * data type (example: data type of uint16 will be cast to
  117. * uint16 pointer).
  118. */
  119. extern bStatus_t HeartRate_SetParameter( uint8 param, uint8 len, void *value );
  120. /*
  121. * HeartRate_GetParameter - Get a Heart Rate parameter.
  122. *
  123. * param - Profile parameter ID
  124. * value - pointer to data to write. This is dependent on
  125. * the parameter ID and WILL be cast to the appropriate
  126. * data type (example: data type of uint16 will be cast to
  127. * uint16 pointer).
  128. */
  129. extern bStatus_t HeartRate_GetParameter( uint8 param, void *value );
  130. /*********************************************************************
  131. * @fn HeartRate_MeasNotify
  132. *
  133. * @brief Send a notification containing a heart rate
  134. * measurement.
  135. *
  136. * @param connHandle - connection handle
  137. * @param pNoti - pointer to notification structure
  138. *
  139. * @return Success or Failure
  140. */
  141. extern bStatus_t HeartRate_MeasNotify( uint16 connHandle, attHandleValueNoti_t *pNoti );
  142. /*********************************************************************
  143. * @fn HeartRate_HandleConnStatusCB
  144. *
  145. * @brief Heart Rate Service link status change handler function.
  146. *
  147. * @param connHandle - connection handle
  148. * @param changeType - type of change
  149. *
  150. * @return none
  151. */
  152. extern void HeartRate_HandleConnStatusCB( uint16 connHandle, uint8 changeType );
  153. /*********************************************************************
  154. *********************************************************************/
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif /* HEARTRATESERVICE_H */