aboutsummaryrefslogtreecommitdiff
path: root/inc/bluetooth/profile
diff options
context:
space:
mode:
Diffstat (limited to 'inc/bluetooth/profile')
-rw-r--r--inc/bluetooth/profile/client/ams_client.h419
-rw-r--r--inc/bluetooth/profile/client/ancs_client.h300
-rw-r--r--inc/bluetooth/profile/client/bas_client.h337
-rw-r--r--inc/bluetooth/profile/client/dfu_client.h319
-rw-r--r--inc/bluetooth/profile/client/dis_client.h304
-rw-r--r--inc/bluetooth/profile/client/gaps_client.h276
-rw-r--r--inc/bluetooth/profile/client/gatts_client.h276
-rw-r--r--inc/bluetooth/profile/client/gcs_client.h626
-rw-r--r--inc/bluetooth/profile/client/hids_client.h355
-rw-r--r--inc/bluetooth/profile/client/ias_client.h284
-rw-r--r--inc/bluetooth/profile/client/ipss_client.h74
-rw-r--r--inc/bluetooth/profile/client/kns_client.h289
-rw-r--r--inc/bluetooth/profile/client/lls_client.h279
-rw-r--r--inc/bluetooth/profile/client/ota_client.h254
-rw-r--r--inc/bluetooth/profile/client/simple_ble_client.h292
-rw-r--r--inc/bluetooth/profile/client/tps_client.h273
-rw-r--r--inc/bluetooth/profile/gatt.h275
-rw-r--r--inc/bluetooth/profile/gatt_builtin_services.h276
-rw-r--r--inc/bluetooth/profile/profile_client.h611
-rw-r--r--inc/bluetooth/profile/profile_server.h452
-rw-r--r--inc/bluetooth/profile/server/atvv_service.h227
-rw-r--r--inc/bluetooth/profile/server/bas.h230
-rw-r--r--inc/bluetooth/profile/server/bas_config.h39
-rw-r--r--inc/bluetooth/profile/server/cscs.h433
-rw-r--r--inc/bluetooth/profile/server/cscs_config.h40
-rw-r--r--inc/bluetooth/profile/server/dfu_service.h117
-rw-r--r--inc/bluetooth/profile/server/dis.h228
-rw-r--r--inc/bluetooth/profile/server/dis_config.h155
-rw-r--r--inc/bluetooth/profile/server/gls.h638
-rw-r--r--inc/bluetooth/profile/server/gls_config.h102
-rw-r--r--inc/bluetooth/profile/server/hids.h283
-rw-r--r--inc/bluetooth/profile/server/hids_kb.h281
-rw-r--r--inc/bluetooth/profile/server/hids_ms.h280
-rw-r--r--inc/bluetooth/profile/server/hids_mulkb.h284
-rw-r--r--inc/bluetooth/profile/server/hids_rmc.h252
-rw-r--r--inc/bluetooth/profile/server/hrs.h296
-rw-r--r--inc/bluetooth/profile/server/hts.h349
-rw-r--r--inc/bluetooth/profile/server/ias.h102
-rw-r--r--inc/bluetooth/profile/server/ipss.h77
-rw-r--r--inc/bluetooth/profile/server/lls.h159
-rw-r--r--inc/bluetooth/profile/server/lns.h484
-rw-r--r--inc/bluetooth/profile/server/ota_service.h142
-rw-r--r--inc/bluetooth/profile/server/plxs.h401
-rw-r--r--inc/bluetooth/profile/server/plxs_config.h128
-rw-r--r--inc/bluetooth/profile/server/rcu_dfu_service.h256
-rw-r--r--inc/bluetooth/profile/server/rcu_ota_service.h153
-rw-r--r--inc/bluetooth/profile/server/rscs.h446
-rw-r--r--inc/bluetooth/profile/server/simple_ble_config.h63
-rw-r--r--inc/bluetooth/profile/server/simple_ble_service.h205
-rw-r--r--inc/bluetooth/profile/server/sps.h219
-rw-r--r--inc/bluetooth/profile/server/sps_config.h35
-rw-r--r--inc/bluetooth/profile/server/tps.h158
-rw-r--r--inc/bluetooth/profile/server/vendor_service.h80
-rw-r--r--inc/bluetooth/profile/server/voice_service.h155
-rw-r--r--inc/bluetooth/profile/server/wss.h303
55 files changed, 14371 insertions, 0 deletions
diff --git a/inc/bluetooth/profile/client/ams_client.h b/inc/bluetooth/profile/client/ams_client.h
new file mode 100644
index 0000000..dc0ef40
--- /dev/null
+++ b/inc/bluetooth/profile/client/ams_client.h
@@ -0,0 +1,419 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2018, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ams_client.h
+ * @brief
+ * @details
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+*/
+
+#ifndef _AMS_CLIENT_H_
+#define _AMS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#include <stdbool.h>
+#include <stdint.h>
+#include "profile_client.h"
+
+
+/** @defgroup AMS_CLIENT AMS Client
+* @brief AMS client
+* @{
+*/
+
+
+/** @addtogroup AMS_CLIENT_Exported_Macros AMS Client Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @brief Define links number. range: 0-4 */
+#define AMS_MAX_LINKS 4
+
+
+/** End of AMS_CLIENT_Exported_Macros
+* @}
+*/
+
+
+
+/** @defgroup AMS_CLIENT_Exported_Types AMS Client Exported Types
+ * @brief
+ * @{
+ */
+
+
+/** @brief AMS client remote command id*/
+typedef enum
+{
+ REMOTE_CMD_ID_PLAY = 0,
+ REMOTE_CMD_ID_PAUSE = 1,
+ REMOTE_CMD_ID_TOGGLE_PLAY_PAUSE = 2,
+ REMOTE_CMD_ID_NEXT_TRACK = 3,
+ REMOTE_CMD_ID_PREVIOUS_TRACK = 4,
+ REMOTE_CMD_ID_VOLUME_UP = 5,
+ REMOTE_CMD_ID_VOLUME_DOWN = 6,
+ REMOTE_CMD_ID_ADVANCE_REPEAT_MODE = 7,
+ REMOTE_CMD_ID_ADVANCE_SHUFFLE_MODE = 8,
+ REMOTE_CMD_ID_SKIP_FORWARD = 9,
+ REMOTE_CMD_ID_SKIP_BACKWARD = 10,
+ REMOTE_CMD_ID_LIKE_TRACK = 11,
+ REMOTE_CMD_ID_DISLIKE_TRACK = 12,
+ REMOTE_CMD_ID_BOOK_MARK_TRACK = 13,
+ REMOTE_CMD_ID_RESERVED = 255
+} T_AMS_REMOTE_CMD_ID;
+
+/** @brief AMS client entity id*/
+typedef enum
+{
+ ENTITY_ID_PLAYER = 0,
+ ENTITY_ID_QUEUE = 1,
+ ENTITY_ID_TRACK = 2,
+ ENTITY_ID_RESERVED = 255
+} T_AMS_ENTITY_ID;
+
+/** @brief AMS client entity player attribute id*/
+typedef enum
+{
+ PLAYER_ATTR_IDPLAYER_ATTR_ID_VOLUME_NAME = 0,
+ PLAYER_ATTR_ID_PLAYBACK_INFO = 1,
+ PLAYER_ATTR_ID_VOLUME = 2,
+ PLAYER_ATTR_ID_RESERVED = 255
+} T_AMS_ENTITY_PLAYER_ATTR_ID;
+
+/** @brief AMS client entity queue attribute id*/
+typedef enum
+{
+ QUEUE_ATTR_ID_INDEX = 0,
+ QUEUE_ATTR_ID_COUNT = 1,
+ QUEUE_ATTR_ID_SHUFFLE_MODE = 2,
+ QUEUE_ATTR_ID_REPEAT_MODE = 3,
+ QUEUE_ATTR_ID_RESERVED = 255
+} T_AMS_ENTITY_QUEUE_ATTR_ID;
+
+/** @brief AMS client entity track attribute id*/
+typedef enum
+{
+ TRACK_ATTR_ID_ARTIST = 0,
+ TRACK_ATTR_ID_ALBUM = 1,
+ TRACK_ATTR_ID_TITLE = 2,
+ TRACK_ATTR_ID_DURATION = 3,
+ TRACK_ATTR_ID_RESERVED = 255
+} T_AMS_ENTITY_TRACK_ATTR_ID;
+
+/** @brief AMS client entity attribute id*/
+typedef union
+{
+ T_AMS_ENTITY_PLAYER_ATTR_ID player_atrr_id;
+ T_AMS_ENTITY_QUEUE_ATTR_ID queue_attr_id;
+ T_AMS_ENTITY_TRACK_ATTR_ID track_attr_id;
+} T_AMS_ENTITY_ATTR_ID;
+
+/** @brief AMS client entity attribute*/
+typedef struct
+{
+ T_AMS_ENTITY_ID entity_id;
+ T_AMS_ENTITY_ATTR_ID attr_id;
+} T_AMS_ENTITY_ATTR;
+
+
+/** @brief AMS client handle type*/
+typedef enum
+{
+ AMS_HDL_SRV_START, //!< service start handle
+ AMS_HDL_SRV_END, //!< service end handle
+ AMS_HDL_REMOTE_CMD_VALUE, //!< remote command characteristic value handle
+ AMS_HDL_REMOTE_CMD_CCCD, //!< remote command characteristic CCCD handle
+ AMS_HDL_ENTITY_UPD_VALUE, //!< entity update characteristic value handle
+ AMS_HDL_ENTITY_UPD_CCCD, //!< entity update characteristic CCCD handle
+ AMS_HDL_ENTITY_ATTR_VALUE, //!< entity attribute characteristic value handle
+ AMS_HDL_CACHE_LEN, //!< handle cache length
+} T_AMS_HANDLE_TYPE;
+
+
+/** @brief AMS client discovery state*/
+typedef enum
+{
+ AMS_DISC_IDLE,
+ AMS_DISC_START,
+ AMS_DISC_DONE,
+ AMS_DISC_FAILED
+} T_AMS_DISC_STATE;
+
+/** @brief AMS client write type*/
+typedef enum
+{
+ AMS_WRITE_REMOTE_CMD_VALUE,
+ AMS_WRITE_REMOTE_CMD_NOTIFY_ENABLE,
+ AMS_WRITE_REMOTE_CMD_NOTIFY_DISABLE,
+ AMS_WRITE_ENTITY_UPD_VALUE,
+ AMS_WRITE_ENTITY_UPD_NOTIFY_ENABLE,
+ AMS_WRITE_ENTITY_UPD_NOTIFY_DISABLE,
+ AMS_WRITE_ENTITY_ATTR_VALUE
+} T_AMS_WRITE_TYPE;
+
+/** @brief AMS client write result*/
+typedef struct
+{
+ T_AMS_WRITE_TYPE type;
+ uint16_t cause;
+} T_AMS_WRITE_RESULT;
+
+/** @brief AMS client data type*/
+typedef enum
+{
+ AMS_NOTIFY_FROM_REMOTE_CMD,
+ AMS_NOTIFY_FROM_ENTITY_UPD,
+ AMS_NOTIFY_FROM_ENTITY_ATTR,
+} T_AMS_NOTIFY_DATA_TYPE;
+
+/** @brief AMS client data type*/
+typedef enum
+{
+ AMS_READ_FROM_ENTITY_UPD,
+} T_AMS_READ_DATA_TYPE;
+
+
+/** @brief AMS client notification data*/
+typedef struct
+{
+ T_AMS_READ_DATA_TYPE type;
+ uint16_t cause;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_AMS_READ_DATA;
+
+/** @brief AMS client notification data*/
+typedef struct
+{
+ T_AMS_NOTIFY_DATA_TYPE type;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_AMS_NOTIFY_DATA;
+
+
+/** @brief AMS client callback content*/
+typedef union
+{
+ T_AMS_DISC_STATE disc_state;
+ T_AMS_READ_DATA read_data;
+ T_AMS_WRITE_RESULT write_result;
+ T_AMS_NOTIFY_DATA notify_data;
+} T_AMS_CB_CONTENT;
+
+/** @brief AMS client callback type*/
+typedef enum
+{
+ AMS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state
+ AMS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request result
+ AMS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail
+ AMS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server
+ AMS_CLIENT_CB_TYPE_DISCONNECT_INFO, //!< LE link disconnect
+ AMS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage
+} T_AMS_CB_TYPE;
+
+/** @brief AMS client callback data*/
+typedef struct
+{
+ T_AMS_CB_TYPE cb_type;
+ T_AMS_CB_CONTENT cb_content;
+} T_AMS_CB_DATA;
+
+/** @defgroup AMS_CLIENT_Exported_Functions AMS Client Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add ams client.
+ *
+ * @param[in] app_cb Callbackto notify client read/write/notify/indicate events.
+ * @param[in] link_num Initialize link number
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void ams_init(uint8_t link_num)
+ {
+ ams_client = ams_add_client(ams_client_cb, link_num);
+ }
+ * \endcode
+ */
+T_CLIENT_ID ams_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+
+/**
+ * @brief Used by application, to start the discovery procedure of AMS.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT test(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = ams_start_discovery(conn_id);
+ }
+ * \endcode
+ */
+bool ams_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to set the notification flag of remote command.
+ * @param[in] conn_id connection ID.
+ * @param[in] subscribe value to enable or disable notify.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ams_subscribe_remote_cmd(uint8_t conn_id, bool subscribe);
+
+/**
+ * @brief Used by application, to set the notification flag of entity update.
+ * @param[in] conn_id connection ID.
+ * @param[in] subscribe value to enable or disable notify.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ams_subscribe_entity_upd(uint8_t conn_id, bool subscribe);
+
+/**
+ * @brief Used by application, to send remote command.
+ * @param[in] conn_id connection ID.
+ * @param[in] cmd_id Remote Command ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_amscmd(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint8_t cmd_id = p_parse_value->dw_param[1];
+ bool ret = ams_write_remote_cmd(conn_id, (T_AMS_REMOTE_CMD_ID)cmd_id);
+ }
+ * \endcode
+ */
+bool ams_write_remote_cmd(uint8_t conn_id, T_AMS_REMOTE_CMD_ID cmd_id);
+
+/**
+ * @brief Used by application, to write the Entity Update characteristic.
+ *
+ * The Entity Update characteristic is the characteristic by which an MR can inform the MS
+ * which entity/attribute pairs it is interested in, and be informed about changes on these whenever they occur.
+ * For example, the MR can be informed about the title of the currently loaded track, or the name of the active media app.
+ *
+ * @param[in] conn_id connection ID.
+ * @param[in] p_value entity/attribute pairs.
+ * @param[in] value_len value length of p_value.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_amswrite(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint8_t type = p_parse_value->dw_param[1];
+ bool ret = false;
+
+ if (type == 0)
+ {
+ uint8_t cmd[3];
+ cmd[0] = ENTITY_ID_TRACK;
+ cmd[1] = TRACK_ATTR_ID_TITLE;
+ cmd[2] = TRACK_ATTR_ID_DURATION;
+ ret = ams_write_entity_upd_cmd(conn_id, cmd, 3);
+ }
+ }
+ * \endcode
+ */
+bool ams_write_entity_upd_cmd(uint8_t conn_id, uint8_t *p_value, uint8_t value_len);
+
+/**
+ * @brief Used by application, to write the Entity Attribute characteristic.
+ *
+ * This characteristic should ideally only be used if the value of an entity/attribute pair was marked as truncated
+ * in the corresponding Entity Update notification, and the MR wants to display more of the associated value.
+ *
+ * @param[in] conn_id connection ID.
+ * @param[in] entity_attr Entity Attribute command.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_amswrite(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint8_t type = p_parse_value->dw_param[1];
+ bool ret = false;
+
+ if (type == 1)
+ {
+ T_AMS_ENTITY_ATTR entity;
+ entity.entity_id = ENTITY_ID_TRACK;
+ entity.attr_id.track_attr_id = TRACK_ATTR_ID_TITLE;
+ ret = ams_write_entity_attr(conn_id, entity);
+ }
+ }
+ * \endcode
+ */
+bool ams_write_entity_attr(uint8_t conn_id, T_AMS_ENTITY_ATTR entity_attr);
+
+/**
+ * @brief Used by application, to read the Entity Attribute characteristic.
+ *
+ * This characteristic should ideally only be used if the value of an entity/attribute pair was marked as truncated
+ * in the corresponding Entity Update notification, and the MR wants to display more of the associated value.
+ *
+ * @param[in] conn_id connection ID.
+ * @param[in] entity_attr Entity Attribute command.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_amsread(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ T_AMS_ENTITY_ATTR entity;
+ bool ret;
+ entity.entity_id = ENTITY_ID_TRACK;
+ entity.attr_id.track_attr_id = TRACK_ATTR_ID_TITLE;
+ ret = ams_read_entity_attr(conn_id, entity);
+ }
+ * \endcode
+ */
+bool ams_read_entity_attr(uint8_t conn_id, T_AMS_ENTITY_ATTR entity_attr);
+
+
+/**
+ * @brief Get the handle for gatt characteristic
+ * @param[in] conn_id Connection ID.
+ * @param[in] handle_type Pre-defined Handle Type.
+ * @retval the handle value of a GATT characteristic.
+ */
+uint16_t ams_search_handle(uint8_t conn_id, T_AMS_HANDLE_TYPE handle_type);
+
+
+/** @} End of AMS_CLIENT_Exported_Functions */
+
+/** @} End of AMS_CLIENT */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/client/ancs_client.h b/inc/bluetooth/profile/client/ancs_client.h
new file mode 100644
index 0000000..164edb9
--- /dev/null
+++ b/inc/bluetooth/profile/client/ancs_client.h
@@ -0,0 +1,300 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ancs_client.h
+ * @brief Head file for using ANCS Client.
+ * @details
+ * @author jane
+ * @date 2016-02-18
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _ANCS_CLIENT_H_
+#define _ANCS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+
+/** @defgroup ANCS_CLIENT ANCS Client
+* @brief ANCS client
+* @{
+*/
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @addtogroup ANCS_CLIENT_Exported_Macros ANCS Client Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @brief Define links number. range: 0-4 */
+#define ANCS_MAX_LINKS 4
+
+
+/** End of ANCS_CLIENT_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup ANCS_CLIENT_Exported_Types ANCS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief ANCS client handle type*/
+typedef enum
+{
+ HDL_ANCS_SRV_START, //!< start handle of ANCS
+ HDL_ANCS_SRV_END, //!< end handle of ANCS
+ HDL_ANCS_CONTROL_POINT, //!< control point characteristic value handle
+ HDL_ANCS_NOTIFICATION_SOURCE, //!< notification source characteristic value handle
+ HDL_ANCS_NOTIFICATION_SOURCE_CCCD, //!< notification source characteristic CCCD handle
+ HDL_ANCS_DATA_SOURCE, //!< data source characteristic value handle
+ HDL_ANCS_DATA_SOURCE_CCCD, //!< data source characteristic CCCD handle
+ HDL_ANCS_CACHE_LEN //!< handle cache length
+} T_ANCS_HANDLE_TYPE;
+
+/** @brief ANCS client control command id*/
+typedef enum
+{
+ CP_CMD_ID_GET_NOTIFICATION_ATTR = 0,
+ CP_CMD_ID_GET_APP_ATTR = 1,
+ CP_CMD_ID_PERFORM_NOTIFICATION_ACTION = 2,
+ CP_CMD_ID_RESERVED = 255
+} T_ANCS_CP_CMD_ID;
+
+/** @brief ANCS client discovery state*/
+typedef enum
+{
+ DISC_ANCS_IDLE,
+ DISC_ANCS_START,
+ DISC_ANCS_DONE,
+ DISC_ANCS_FAILED
+} T_ANCS_DISC_STATE;
+
+/** @brief ANCS client data type*/
+typedef enum
+{
+ ANCS_FROM_DATA_SOURCE,
+ ANCS_FROM_NOTIFICATION_SOURCE,
+} T_ANCS_DATA_TYPE;
+
+/** @brief ANCS client notification data struct*/
+typedef struct
+{
+ T_ANCS_DATA_TYPE type;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_ANCS_NOTIFY_DATA;
+
+/** @brief ANCS client write type*/
+typedef enum
+{
+ ANCS_WRITE_NOTIFICATION_SOURCE_NOTIFY_ENABLE,
+ ANCS_WRITE_NOTIFICATION_SOURCE_NOTIFY_DISABLE,
+ ANCS_WRITE_DATA_SOURCE_NOTIFY_ENABLE,
+ ANCS_WRITE_DATA_SOURCE_NOTIFY_DISABLE,
+ ANCS_WRITE_CONTROL_POINT,
+} T_ANCS_WRITE_TYPE;
+
+/** @brief ANCS client write result*/
+typedef struct
+{
+ T_ANCS_WRITE_TYPE type;
+ uint16_t cause;
+} T_ANCS_WRITE_RESULT;
+
+/** @brief ANCS client callback type*/
+typedef enum
+{
+ ANCS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ ANCS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ ANCS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ ANCS_CLIENT_CB_TYPE_DISCONNECT_INFO,
+ ANCS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_ANCS_CB_TYPE;
+
+/** @brief ANCS client callback content*/
+typedef union
+{
+ T_ANCS_DISC_STATE disc_state;
+ T_ANCS_NOTIFY_DATA notify_data;
+ T_ANCS_WRITE_RESULT write_result;
+} T_ANCS_CB_CONTENT;
+
+/** @brief ANCS client callback data*/
+typedef struct
+{
+ T_ANCS_CB_TYPE cb_type;
+ T_ANCS_CB_CONTENT cb_content;
+} T_ANCS_CB_DATA;
+/** End of ANCS_CLIENT_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup ANCS_CLIENT_Exported_Functions ANCS Client Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add ancs client.
+ *
+ * @param[in] app_cb Callbackto notify client read/write/notify/indicate events.
+ * @param[in] link_num Initialize link number
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void ancs_init(uint8_t link_num)
+ {
+ ancs_client = ancs_add_client(ancs_client_cb, link_num);
+ }
+ * \endcode
+ */
+T_CLIENT_ID ancs_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+
+/**
+ * @brief Used by application, to start the discovery procedure of ANCS.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ancs_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_ancshdl(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t hdl_cache[HDL_ANCS_CACHE_LEN];
+ bool ret = ancs_get_hdl_cache(conn_id, hdl_cache,
+ sizeof(uint16_t) * HDL_ANCS_CACHE_LEN);
+ ......
+ }
+ * \endcode
+ */
+bool ancs_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_discov_services(uint8_t conn_id, bool start)
+ {
+ ......
+ if (app_srvs_table.srv_found_flags & APP_DISCOV_ANCS_FLAG)
+ {
+ ancs_set_hdl_cache(conn_id, app_srvs_table.ancs_hdl_cache, sizeof(uint16_t) * HDL_ANCS_CACHE_LEN);
+ }
+ ......
+ }
+ * \endcode
+ */
+bool ancs_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set the notification flag of notification source.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify value to enable or disable notify.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ancs_set_notification_source_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to set the notification flag of data source.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify value to enable or disable notify.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ancs_set_data_source_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to get the notification attribute.
+ * @param[in] conn_id connection ID.
+ * @param[in] notification_uid value to enable or disable notify.
+ * @param[in] p_attribute_ids Pointer to attribute ids.
+ * @param[in] attribute_ids_len Length of attribute ids.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ancs_get_notification_attr(uint8_t conn_id, uint32_t notification_uid,
+ uint8_t *p_attribute_ids, uint8_t attribute_ids_len);
+/**
+ * @brief Used by application, to get the app attribute.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_app_identifier value to enable or disable notify.
+ * @param[in] p_attribute_ids Pointer to attribute ids.
+ * @param[in] attribute_ids_len Length of attribute ids.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ancs_get_app_attr(uint8_t conn_id, char *p_app_identifier, uint8_t *p_attribute_ids,
+ uint8_t attribute_ids_len);
+
+/**
+ * @brief Used by application, to perfome the notication action.
+ * @param[in] conn_id Connection ID.
+ * @param[in] notification_uid Notification UUID.
+ * @param[in] action_id Action id.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ancs_perform_notification_action(uint8_t conn_id, uint32_t notification_uid,
+ uint8_t action_id);
+
+/**
+ * @brief Get the handle for gatt characteristic
+ * @param[in] conn_id Connection ID.
+ * @param[in] handle_type Pre-defined Handle Type.
+ * @retval the handle value of a GATT characteristic.
+ */
+uint16_t ancs_search_handle(uint8_t conn_id, T_ANCS_HANDLE_TYPE handle_type);
+
+/** @} End of ANCS_CLIENT_Exported_Functions */
+
+/** @} End of ANCS_CLIENT */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _ANCS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/bas_client.h b/inc/bluetooth/profile/client/bas_client.h
new file mode 100644
index 0000000..1eed7d1
--- /dev/null
+++ b/inc/bluetooth/profile/client/bas_client.h
@@ -0,0 +1,337 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file bas_client.h
+ * @brief Head file for using battery service client.
+ * @details Battery service client data structs and external functions declaration.
+ * @author jane
+ * @date 2016-02-18
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _BAS_CLIENT_H_
+#define _BAS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+
+
+/** @defgroup BAS_CLIENT Battery Service Client
+ * @brief BAS client
+ * @details
+ Application shall register bas client when initialization through @ref bas_add_client function.
+
+ Application can start discovery battery service through @ref bas_start_discovery function.
+
+ Application can read battery level characteristic value through @ref bas_read_battery_level function.
+
+ Application can config and read the notification flag through @ref bas_set_notify and @ref bas_read_notify function.
+
+ Application shall handle callback function registered by bas_add_client.
+ * \code{.c}
+ T_APP_RESULT app_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ if (client_id == bas_client_id)
+ {
+ T_BAS_CLIENT_CB_DATA *p_bas_cb_data = (T_BAS_CLIENT_CB_DATA *)p_data;
+ switch (p_bas_cb_data->cb_type)
+ {
+ case BAS_CLIENT_CB_TYPE_DISC_STATE:
+ switch (p_bas_cb_data->cb_content.disc_state)
+ {
+ case DISC_BAS_DONE:
+ ......
+ }
+ }
+ * \endcode
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @addtogroup BAS_CLIENT_Exported_Macros BAS Client Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @brief Define links number. range: 0-4 */
+#define BAS_MAX_LINKS 4
+
+/** End of BAS_CLIENT_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup BAS_CLIENT__Exported_Types BAS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief BAS client handle type*/
+typedef enum
+{
+ HDL_BAS_SRV_START, //!< start handle of battery service
+ HDL_BAS_SRV_END, //!< end handle of battery service
+ HDL_BAS_BATTERY_LEVEL, //!< battery level characteristic value handle
+ HDL_BAS_BATTERY_LEVEL_CCCD, //!< battery level characteristic CCCD handle
+ HDL_BAS_CACHE_LEN //!< handle cache length
+} T_BAS_HANDLE_TYPE;
+
+/** @brief BAS client discovery state*/
+typedef enum
+{
+ DISC_BAS_IDLE,
+ DISC_BAS_START,
+ DISC_BAS_DONE,
+ DISC_BAS_FAILED
+} T_BAS_DISC_STATE;
+
+/** @brief BAS client notification data struct*/
+typedef struct
+{
+ uint8_t battery_level;
+} T_BAS_NOTIFY_DATA;
+
+/** @brief BAS client write type*/
+typedef enum
+{
+ BAS_WRITE_NOTIFY_ENABLE,
+ BAS_WRITE_NOTIFY_DISABLE,
+} T_BAS_WRITE_TYPE;
+
+/** @brief BAS client write result*/
+typedef struct
+{
+ T_BAS_WRITE_TYPE type;
+ uint16_t cause;
+} T_BAS_WRITE_RESULT;
+
+/** @brief BAS client read data */
+typedef union
+{
+ uint8_t battery_level;
+ bool notify;
+} T_BAS_READ_DATA;
+
+/** @brief BAS client read type*/
+typedef enum
+{
+ BAS_READ_NOTIFY,
+ BAS_READ_BATTERY_LEVEL,
+} T_BAS_READ_TYPE;
+
+/** @brief BAS client read result*/
+typedef struct
+{
+ T_BAS_READ_TYPE type;
+ T_BAS_READ_DATA data;
+ uint16_t cause;
+} T_BAS_READ_RESULT;
+
+/** @brief BAS client callback type*/
+typedef enum
+{
+ BAS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ BAS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ BAS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ BAS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ BAS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_BAS_CLIENT_CB_TYPE;
+
+/** @brief BAS client callback content*/
+typedef union
+{
+ T_BAS_DISC_STATE disc_state;
+ T_BAS_READ_RESULT read_result;
+ T_BAS_NOTIFY_DATA notify_data;
+ T_BAS_WRITE_RESULT write_result;
+} T_BAS_CLIENT_CB_CONTENT;
+
+/** @brief BAS client callback data*/
+typedef struct
+{
+ T_BAS_CLIENT_CB_TYPE cb_type;
+ T_BAS_CLIENT_CB_CONTENT cb_content;
+} T_BAS_CLIENT_CB_DATA;
+/** End of BAS_CLIENT_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup BAS_CLIENT_Exported_Functions BAS Client Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add bas client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ bas_client_id = bas_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID bas_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of battery service.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_basdis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = bas_start_discovery(conn_id);
+ ......
+ }
+ * \endcode
+ */
+bool bas_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to set the notification flag.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify value to enable or disable notify.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_bascccd(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool notify = p_parse_value->dw_param[1];
+ bool ret;
+ ret = bas_set_notify(conn_id, notify);
+ ......
+ }
+ * \endcode
+ */
+bool bas_set_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to read the notification flag.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_basread(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = false;
+ ret = bas_read_notify(conn_id);
+ ......
+ }
+ * \endcode
+ */
+bool bas_read_notify(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read battery level.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_basread(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = false;
+ ret = bas_read_battery_level(conn_id);
+ ......
+ }
+ * \endcode
+ */
+bool bas_read_battery_level(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_bashdl(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t hdl_cache[HDL_BAS_CACHE_LEN];
+ bool ret = bas_get_hdl_cache(conn_id, hdl_cache,
+ sizeof(uint16_t) * HDL_BAS_CACHE_LEN);
+
+ ......
+ }
+ * \endcode
+ */
+bool bas_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_discov_services(uint8_t conn_id, bool start)
+ {
+ ......
+ if (app_srvs_table.srv_found_flags & APP_DISCOV_BAS_FLAG)
+ {
+ bas_set_hdl_cache(conn_id, app_srvs_table.bas_hdl_cache, sizeof(uint16_t) * HDL_BAS_CACHE_LEN);
+ }
+ ......
+ }
+ * \endcode
+ */
+bool bas_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of BAS_CLIENT_Exported_Functions */
+
+/** @} End of BAS_CLIENT */
+
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _BAS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/dfu_client.h b/inc/bluetooth/profile/client/dfu_client.h
new file mode 100644
index 0000000..5ff1019
--- /dev/null
+++ b/inc/bluetooth/profile/client/dfu_client.h
@@ -0,0 +1,319 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file dfu_client.h
+ * @brief Head file for using dfu service Client.
+ * @details Data structs and external functions declaration.
+ * @author bill
+ * @date 2018-4-17
+ * @version v2.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _DFU_CLIENT_H_
+#define _DFU_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Add Includes here */
+#include "patch_header_check.h"
+#include "profile_client.h"
+#include "dfu_api.h"
+
+/** @defgroup DFU_Client DFU Service Client
+ * @brief DFU client
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @addtogroup DFU_Client_Exported_Macros DFU Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @brief Define links number. range: 0-4 */
+#define DFU_MAX_LINKS 4
+/** End of DFU_Client_Exported_Macros * @} */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup DFU_Client_Exported_Types DFU Client Exported Types
+ * @brief
+ * @{
+ */
+/** @brief Handle cache for intrested UUIDs */
+typedef enum
+{
+ HDL_DFU_SRV_START, // start handle of dfu service
+ HDL_DFU_SRV_END, // end handle of dfu service
+ HDL_DFU_DATA,
+ HDL_DFU_CP,
+ HDL_DFU_CP_CCCD,
+ HDL_DFU_CACHE_LEN
+} T_DFU_HANDLE_TYPE;
+
+/** @brief used to inform app the discovery procedure is done or pending */
+typedef enum
+{
+ DISC_DFU_IDLE,
+ DISC_DFU_START,
+ DISC_DFU_DONE,
+ DISC_DFU_FAIL,
+} T_DFU_DISC_STATE;
+
+/** @brief read request type, used by app to send read request */
+typedef enum
+{
+ DFU_READ_CP_CCCD
+} T_DFU_READ_TYPE;
+
+/** @brief read content, used to inform app read response data content */
+typedef union
+{
+ bool dfu_cp_cccd;
+} T_DFU_READ_DATA;
+
+/** @brief read data, used to inform app read response data */
+typedef struct
+{
+ T_DFU_READ_TYPE type;
+ T_DFU_READ_DATA data;
+ uint16_t cause;
+} T_DFU_READ_RESULT;
+
+/** @brief write request result */
+typedef enum
+{
+ DFU_WRITE_CP,
+ DFU_WRITE_CP_CCCD,
+ DFU_WRITE_DATA
+} T_DFU_WRITE_TYPE;
+
+typedef struct
+{
+ T_DFU_WRITE_TYPE type;
+ uint16_t cause;
+} T_DFU_WRITE_RESULT;
+
+/** @brief notif/ind receive type */
+typedef enum
+{
+ DFU_RECEIVE_CP_NOTIFY,
+} T_DFU_NOTIFY_INDICATE_TYPE;
+
+/** @brief notif/ind receive content */
+typedef struct
+{
+ uint16_t len;
+ uint8_t *pdata;
+} T_DFU_NOTIFY_INDICATE_VAL;
+
+/** @brief The notif/ind data received by the client from the server */
+typedef struct
+{
+ T_DFU_NOTIFY_INDICATE_TYPE type;
+ T_DFU_NOTIFY_INDICATE_VAL value;
+} T_DFU_NOTIFY_INDICATE_DATA;
+
+/** @brief Event type to inform app */
+typedef enum
+{
+ DFU_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ DFU_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ DFU_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ DFU_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ DFU_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_DFU_CLIENT_CB_TYPE;
+
+/** @brief Callback content sent to application from the client */
+typedef union
+{
+ T_DFU_DISC_STATE disc_state;
+ T_DFU_READ_RESULT read_result;
+ T_DFU_WRITE_RESULT write_result;
+ T_DFU_NOTIFY_INDICATE_DATA notif_ind_data;
+} T_DFU_CLIENT_CB_CONTENT;
+
+/** @brief Callback data sent to application from the client, include type and content */
+typedef struct
+{
+ T_DFU_CLIENT_CB_TYPE cb_type;
+ T_DFU_CLIENT_CB_CONTENT cb_content;
+} T_DFU_CLIENT_CB_DATA;
+
+
+typedef enum
+{
+ DFU_FSM_WRITE_IDLE,
+ DFU_FSM_WRITE_CCCD_ENABLE,
+ DFU_FSM_WRITE_DFU_DATA,
+ DFU_FSM_WRITE_WAIT_WRITE_RESP
+} T_DFU_CLIENT_FSM_WRITE;
+
+typedef enum
+{
+ DFU_CB_START,
+ DFU_CB_END,
+ DFU_CB_FAIL,
+ DFU_CB_MAX
+} T_DFU_CB_TYPE;
+
+typedef enum
+{
+ DFU_SUCCESS,
+ DFU_FAIL_START_DFU,
+ DFU_FAIL_BUF_CHECK,
+ DFU_FAIL_VALIDATE_FW,
+} T_DFU_FAIL_TYPE;
+
+typedef union
+{
+ T_DFU_FAIL_TYPE dfu_fail_reason;
+} T_DFU_CB_DATA;
+
+/** Dfu service data to inform application */
+typedef struct
+{
+ uint8_t conn_id;
+ T_DFU_CB_TYPE type;
+ T_DFU_CB_DATA data;
+} T_DFU_CLIENT_CB_MSG;
+
+typedef enum
+{
+ DFU_FEATURE_USER_DEFINED_DFU,
+ DFU_FEATURE_AUTO_COPY_DFU,
+
+} T_DFU_CLIENT_FEATURE_TYPE;
+
+typedef enum
+{
+ DFU_SET_FEATURE,
+ DFU_SET_MODE_VALUE,
+ DFU_SET_MAX_BUF_SIZE,
+ DFU_SET_DFU_IMG_ADDR,
+ DFU_SET_DFU_IMG_VER,
+ DFU_SET_NORMAL_OTA_FLAG,
+} T_DFU_SET_CLIENT_CTX_TYPE;
+
+typedef struct
+{
+ T_IMG_CTRL_HEADER_FORMAT dfu_ctrl_header;
+
+ T_OTA_MODE ota_mode;
+ T_DFU_CLIENT_FEATURE_TYPE dfu_feature;
+ T_DFU_CLIENT_FSM_WRITE dfu_fsm_write;
+ bool is_normal_ota;
+
+ uint16_t mtu_size;
+ uint16_t max_buffer_size;
+
+ uint32_t dfu_img_start_addr;
+ uint32_t dfu_img_version;
+ uint32_t dfu_img_total_length;
+
+ uint32_t curr_offset;
+ uint32_t target_img_version;
+
+ uint16_t dfu_buf_check_crc_val;
+ uint16_t dfu_buf_check_size;
+
+ /*ctx used when enable or disable buffer check*/
+ uint16_t dfu_pkt_num;
+ uint16_t dfu_pkt_counter;
+ uint16_t dfu_last_pkt_size;
+} T_DFU_CTX;
+
+
+typedef void (*P_FUN_DFU_CLIENT_INIT_APP_CB)(void);
+
+/** End of DFU_Client_Exported_Types * @} */
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup DFU_Client_Exported_Functions DFU Client Exported Functions
+ * @{
+ */
+bool dfu_encrypt(uint8_t image[16]);
+uint16_t dfu_client_crc_cal(uint8_t *buf, uint32_t length, uint16_t checksum16);
+
+void dfu_client_set_dfu_ctx_value(T_DFU_SET_CLIENT_CTX_TYPE type, void *p_value);
+
+/**
+ * @brief start the service discovery
+ *
+ * contains the service/characteristic/cccd declaration
+ * @param[in] conn_id: the connection id
+ * @return the operation result
+ */
+bool dfu_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to set the handles in Dfu handle cache.
+ * @param handle_type: handle types of this specific profile.
+ * @param handle_value: handle value to set.
+ * @retval true--set success.
+ * false--set failed.
+ */
+bool dfu_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool dfu_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param command: 0--disable the notification, 1--enable the notification.
+ * @retval true--send request to upper stack success.
+ * false--send request to upper stack failed.
+ */
+bool dfu_client_cp_cccd_set(uint8_t conn_id, bool command);
+
+/**
+ * @brief Used internal, to send write request to peer server's V5 Control Point Characteristic.
+ * @param ctl_pnt_ptr: pointer of control point data to write.
+ * @retval true--send request to upper stack success.
+ * false--send request to upper stack failed.
+ */
+bool dfu_client_cp_write(uint8_t conn_id, uint8_t *pdata, uint16_t length);
+
+/**
+ * @brief Used internal, to send write request to peer server's V5 Control Point Characteristic.
+ * @param ctl_pnt_ptr: pointer of control point data to write.
+ * @retval true--send request to upper stack success.
+ * false--send request to upper stack failed.
+ */
+bool dfu_client_data_write(uint8_t conn_id, uint8_t *pdata, uint16_t length);
+
+/**
+ * @brief add Dfu client to application.
+ * @param appCB: pointer of app callback function to handle specific client module data.
+ * @retval Client ID of the specific client module.
+ */
+T_CLIENT_ID dfu_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+
+/** @} End of DFU_Client_Exported_Functions */
+
+/** @} End of DFU_Client */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DFU_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/dis_client.h b/inc/bluetooth/profile/client/dis_client.h
new file mode 100644
index 0000000..8514719
--- /dev/null
+++ b/inc/bluetooth/profile/client/dis_client.h
@@ -0,0 +1,304 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file dis_client.h
+ * @brief Head file for using DIS Client.
+ * @details dis data structs and external functions declaration.
+ * @author ken
+ * @date 2017-12-05
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _DIS_CLIENT_H_
+#define _DIS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+/** @defgroup DIS_Client dis service client
+ * @brief dis service client
+ * @details
+ dis Profile is a customized BLE-based Profile. Dis ble service please refer to @ref DIS_Service .
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup DIS_Client_Exported_Macros DIS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup DIS UUIDs
+ * @brief Dis BLE Profile UUID definitions
+ * @{
+ */
+#define GATT_UUID_DEVICE_INFORMATION_SERVICE 0x180A
+
+#define GATT_UUID_CHAR_SYSTEM_ID 0x2A23
+#define GATT_UUID_CHAR_MODEL_NUMBER 0x2A24
+#define GATT_UUID_CHAR_SERIAL_NUMBER 0x2A25
+#define GATT_UUID_CHAR_FIRMWARE_REVISION 0x2A26
+#define GATT_UUID_CHAR_HARDWARE_REVISION 0x2A27
+#define GATT_UUID_CHAR_SOFTWARE_REVISION 0x2A28
+#define GATT_UUID_CHAR_MANUFACTURER_NAME 0x2A29
+#define GATT_UUID_CHAR_IEEE_CERTIF_DATA_LIST 0x2A2A
+#define GATT_UUID_CHAR_PNP_ID 0x2A50
+/** @} End of DIS_UUIDs */
+
+/** @brief Define links number. range: 0-4 */
+#define DIS_MAX_LINKS 2
+/** End of DIS_Client_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup DIS_Exported_Types DIS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief DIS client handle type*/
+typedef enum
+{
+ HDL_DIS_SRV_START, //!< start handle of lls service
+ HDL_DIS_SRV_END, //!< end handle of lls service
+ HDL_DIS_SYSTEM_ID, //!< DIS system id read characteristic value handle
+ HDL_DIS_MODEL_NUMBER, //!< DIS model number read characteristic value handle
+ HDL_DIS_SERIAL_NUMBER, //!< DIS serial number read characteristic value handle
+ HDL_DIS_FIRMWARE_REVISION, //!< DIS firmware revision read characteristic value handle
+ HDL_DIS_HARDWARE_REVISION, //!< DIS hardware revision read characteristic value handle
+ HDL_DIS_SOFTWARE_REVISION, //!< DIS software revision read characteristic value handle
+ HDL_DIS_MANUFACTURER_NAME, //!< DIS manufacturer name read characteristic value handle
+ HDL_DIS_IEEE_CERTIF_DATA_LIST,//!< DIS ieee certif data list read characteristic value handle
+ HDL_DIS_PNP_ID, //!< DIS pnp id read characteristic value handle
+ HDL_DIS_CACHE_LEN //!< handle cache length
+} T_DIS_HANDLE_TYPE;
+
+/** @brief DIS client discovery state*/
+typedef enum
+{
+ DISC_DIS_IDLE,
+ DISC_DIS_START,
+ DISC_DIS_DONE,
+ DISC_DIS_FAILED
+} T_DIS_DISC_STATE;
+
+/** @brief dis client read type*/
+typedef enum
+{
+ DIS_READ_SYSTEM_ID,
+ DIS_READ_MODEL_NUMBER,
+ DIS_READ_SERIAL_NUMBER,
+ DIS_READ_FIRMWARE_REVISION,
+ DIS_READ_HARDWARE_REVISION,
+ DIS_READ_SOFTWARE_REVISION,
+ DIS_READ_MANUFACTURER_NAME,
+ DIS_READ_IEEE_CERTIF_DATA_LIST,
+ DIS_READ_PNP_ID
+} T_DIS_READ_TYPE;
+
+/** @brief DIS client read value*/
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_DIS_READ_VALUE;
+
+/** @brief DIS client read data*/
+typedef union
+{
+ T_DIS_READ_VALUE v1_read;
+// bool v3_notify_cccd;
+// bool v4_indicate_cccd;
+} T_DIS_READ_DATA;
+
+/** @brief DIS client read result*/
+typedef struct
+{
+ T_DIS_READ_TYPE type;
+ T_DIS_READ_DATA data;
+ uint16_t cause;
+} T_DIS_READ_RESULT;
+
+
+///** @brief LLS client write type*/
+//typedef enum
+//{
+// LLS_WRITE_PARA,
+//} T_LLS_WRITE_TYPE;
+
+///** @brief LLS client write result*/
+//typedef struct
+//{
+// T_LLS_WRITE_TYPE type;
+// uint16_t cause;
+//} T_LLS_WRITE_RESULT;
+
+/** @brief LLS client notif/ind receive type*/
+//typedef enum
+//{
+// LLS_KEY_NOTIFY,
+//} T_LLS_NOTIF_IND_TYPE;
+
+///** @brief LLS client notif/ind receive data*/
+//typedef struct
+//{
+// uint16_t value_size;
+// uint8_t *p_value;
+//} T_LLS_NOTIF_IND_VALUE;
+
+/** @brief LLS client notif/ind receive content*/
+//typedef struct
+//{
+// T_LLS_NOTIF_IND_TYPE type;
+// T_LLS_NOTIF_IND_VALUE data;
+//} T_LLS_NOTIF_IND_DATA;
+
+/** @brief DIS client callback type*/
+typedef enum
+{
+ DIS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ DIS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ //LLS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ //LLS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ DIS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_DIS_CLIENT_CB_TYPE;
+
+/** @brief DIS client callback content*/
+typedef union
+{
+ T_DIS_DISC_STATE disc_state;
+ T_DIS_READ_RESULT read_result;
+ //T_DIS_WRITE_RESULT write_result;
+ //T_LLS_NOTIF_IND_DATA notif_ind_data;
+} T_DIS_CLIENT_CB_CONTENT;
+
+/** @brief DIS client callback data*/
+typedef struct
+{
+ T_DIS_CLIENT_CB_TYPE cb_type;
+ T_DIS_CLIENT_CB_CONTENT cb_content;
+} T_DIS_CLIENT_CB_DATA;
+
+/** End of DIS_Client_Exported_Types * @} */
+
+/** @defgroup DIS_Client_Exported_Functions DIS Client Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Add dis service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ dis_client_id = dis_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID dis_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of dis server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool dis_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool dis_client_read_by_handle(uint8_t conn_id, T_DIS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to read data from server by using UUIDs.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool dis_client_read_by_uuid(uint8_t conn_id, T_DIS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to write data of write Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool dis_client_write_char(uint8_t conn_id, uint16_t length, uint8_t *p_value,
+// T_GATT_WRITE_TYPE type);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify 0--disable the notification, 1--enable the notification.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool lls_client_set_v3_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to enable or disable the indication of peer server's V4 Indicate Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind 0--disable the indication, 1--enable the indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool lls_client_set_v4_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool dis_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool dis_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of DIS_Client_Exported_Functions */
+
+/** @} End of DIS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _DIS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/gaps_client.h b/inc/bluetooth/profile/client/gaps_client.h
new file mode 100644
index 0000000..b3dc3e5
--- /dev/null
+++ b/inc/bluetooth/profile/client/gaps_client.h
@@ -0,0 +1,276 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file gaps_client.h
+ * @brief Head file for using GAP service client.
+ * @details GAP service client data structs and external functions declaration.
+ * @author jane
+ * @date 2016-02-18
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _GAPS_CLIENT_H_
+#define _GAPS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+
+/** @defgroup GAPS_Client GAP Service Client
+ * @brief GAP service client
+ * @details
+ Application shall register gaps client when initialization through @ref gaps_add_client function.
+
+ Application can start discovery GAP service through @ref gaps_start_discovery function.
+
+ Application can read GAP service referenced values through @ref gaps_read function.
+ * \code{.c}
+ T_APP_RESULT app_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ if (client_id == gaps_client_id)
+ {
+ T_GAPS_CLIENT_CB_DATA *p_gaps_cb_data = (T_GAPS_CLIENT_CB_DATA *)p_data;
+ switch (p_gaps_cb_data->cb_type)
+ {
+ case GAPS_CLIENT_CB_TYPE_DISC_STATE:
+ switch (p_gaps_cb_data->cb_content.disc_state)
+ {
+ case DISC_GAPS_DONE:
+ ......
+ }
+ }
+ * \endcode
+ * @{
+ */
+
+/** @defgroup GAPS_Client_Exported_Macros GAPS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @brief Define links number. range: 0-4 */
+#define GAPS_MAX_LINKS 4
+
+/** @brief GAP service UUID */
+#define GATT_UUID_GAP 0x1800
+/** @brief Resolvable private address only characteristic UUID */
+#define GATT_UUID_CHAR_RESOLVABLE_PRIVATE_ADDRESS_ONLY 0x2AC9
+/** End of GAPS_Client_Exported_Macros * @} */
+
+
+/** @defgroup GAPS_Client_Exported_Types GAPS Client Exported Types
+ * @brief
+ * @{
+ */
+/** @brief GAPS client handle type */
+typedef enum
+{
+ HDL_GAPS_SRV_START, //!< start handle of gap service
+ HDL_GAPS_SRV_END, //!< end handle of gap service
+ HDL_GAPS_DEVICE_NAME, //!< device name value handle
+ HDL_GAPS_APPEARANCE, //!< appearance value handle
+ HDL_GAPS_CENTRAL_ADDR_RESOLUTION, //!< central address resolution value handle
+ HDL_GAPS_RESOLVABLE_PRIVATE_ADDR_ONLY,//!< resolvable private address only value handle
+ HDL_GAPS_CACHE_LEN //!< handle cache length
+} T_GAP_CLIENT_HANDLE_TYPE;
+
+
+/** @brief GAPS client discovery state */
+typedef enum
+{
+ DISC_GAPS_IDLE,
+ DISC_GAPS_START,
+ DISC_GAPS_DONE,
+ DISC_GAPS_FAILED
+} T_GAPS_DISC_STATE;
+
+
+/** @brief GAPS client read type */
+typedef enum
+{
+ GAPS_READ_DEVICE_NAME,
+ GAPS_READ_APPEARANCE,
+ GAPS_READ_CENTRAL_ADDR_RESOLUTION,
+} T_GAPS_READ_TYPE;
+
+/** @brief Device name value */
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_DEVICE_NAME;
+
+/** @brief GAPS client read content */
+typedef union
+{
+ uint16_t appearance;
+ T_DEVICE_NAME device_name;
+ uint8_t central_addr_res;
+} T_GAPS_READ_DATA;
+
+/** @brief GAPS client read data, used to inform app read response data */
+typedef struct
+{
+ T_GAPS_READ_TYPE type;
+ T_GAPS_READ_DATA data;
+ uint16_t cause;
+} T_GAPS_READ_RESULT;
+
+
+/** @brief GAPS client callback type */
+typedef enum
+{
+ GAPS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ GAPS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ GAPS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_GAPS_CLIENT_CB_TYPE;
+
+/** @brief GAPS client callback content */
+typedef union
+{
+ T_GAPS_DISC_STATE disc_state;
+ T_GAPS_READ_RESULT read_result;
+} T_GAPS_CLIENT_CB_CONTENT;
+
+
+/** @brief GAPS client callback data */
+typedef struct
+{
+ T_GAPS_CLIENT_CB_TYPE cb_type;
+ T_GAPS_CLIENT_CB_CONTENT cb_content;
+} T_GAPS_CLIENT_CB_DATA;
+
+/** End of GAPS_Client_Exported_Types * @} */
+
+/** @defgroup GPAS_Client_Exported_Functions GAPS Client Exported Functions
+ * @brief
+ * @{
+ */
+/**
+ * @brief Add gap service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ gaps_client_id = gaps_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID gaps_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of GAP service.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_gapdis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = gaps_start_discovery(conn_id);
+ ......
+ }
+ * \endcode
+ */
+bool gaps_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_gapread(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ T_GAPS_READ_TYPE read_type = (T_GAPS_READ_TYPE)p_parse_value->dw_param[1];
+ bool ret = gaps_read(conn_id, read_type);
+ ......
+ }
+ * \endcode
+ */
+bool gaps_read(uint8_t conn_id, T_GAPS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in,out] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_gaphdl(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t hdl_cache[HDL_GAPS_CACHE_LEN];
+ uint8_t hdl_idx;
+ bool ret = gaps_get_hdl_cache(conn_id, hdl_cache, sizeof(uint16_t) * HDL_GAPS_CACHE_LEN);
+ ......
+ }
+ * \endcode
+ */
+bool gaps_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_discov_services(uint8_t conn_id, bool start)
+ {
+ ......
+ if (app_srvs_table.srv_found_flags & APP_DISCOV_GAPS_FLAG)
+ {
+ gaps_set_hdl_cache(conn_id, app_srvs_table.gaps_hdl_cache, sizeof(uint16_t) * HDL_GAPS_CACHE_LEN);
+ }
+ ......
+ }
+ * \endcode
+ */
+bool gaps_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to check Resolvable Private Address Only Characteristics whether existing.
+ * @param[in] conn_id connection ID.
+ * @param[in,out] p_is_exist whether existing
+ * @retval true success.
+ * @retval false failed.
+ */
+bool gaps_check_resolvable_private_addr_only_char(uint8_t conn_id, bool *p_is_exist);
+
+/** @} End of GAPS_Client_Exported_Functions */
+
+/** @} End of GAPS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _GAPS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/gatts_client.h b/inc/bluetooth/profile/client/gatts_client.h
new file mode 100644
index 0000000..4a99573
--- /dev/null
+++ b/inc/bluetooth/profile/client/gatts_client.h
@@ -0,0 +1,276 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2019, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file gatts_client.h
+ * @brief Head file for using GATT service client.
+ * @details GATT service client data structs and external functions declaration.
+ * @author
+ * @date 2019-05-27
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _GATTS_CLIENT_H_
+#define _GATTS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+/** @defgroup GATTS_Client GATT Service Client
+ * @brief GATT service client
+ * @details
+ Application shall register gatts client when initialization through @ref gatts_add_client function.
+
+ Application can start discovery GATT service through @ref gatts_start_discovery function.
+
+ * \code{.c}
+ T_APP_RESULT app_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ if (client_id == gatts_client_id)
+ {
+ T_GATTS_CLIENT_CB_DATA *p_gatts_cb_data = (T_GATTS_CLIENT_CB_DATA *)p_data;
+ switch (p_gatts_cb_data->cb_type)
+ {
+ case GATTS_CLIENT_CB_TYPE_DISC_STATE:
+ switch (p_gatts_cb_data->cb_content.disc_state)
+ {
+ case DISC_GATTS_DONE:
+ ......
+ }
+ }
+ * \endcode
+ * @{
+ */
+
+/** @defgroup GATTS_Client_Exported_Macros GATTS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @brief Define links number. range: 0-4 */
+#define GATTS_MAX_LINKS 4
+
+/** @brief GATT service UUID */
+#define GATT_UUID_GATT 0x1801
+/** End of GATTS_Client_Exported_Macros * @} */
+
+/** @defgroup GATTS_Client_Exported_Types GATTS Client Exported Types
+ * @brief
+ * @{
+ */
+/** @brief GATTS client handle type */
+typedef enum
+{
+ HDL_GATTS_SRV_START, //!< start handle of gap service
+ HDL_GATTS_SRV_END, //!< end handle of gap service
+ HDL_GATTS_SERVICE_CHANGED, //!< service changed handle
+ HDL_GATTS_SERVICE_CHANGED_CCCD, //!< service changed CCCD handle
+ HDL_GATTS_CACHE_LEN, //!< handle cache length
+} T_GATTS_CLIENT_HANDLE_TYPE;
+
+/** @brief GATTS client discovery state */
+typedef enum
+{
+ DISC_GATTS_IDLE,
+ DISC_GATTS_START,
+ DISC_GATTS_DONE,
+ DISC_GATTS_FAILED,
+} T_GATTS_DISC_STATE;
+
+/** @brief Client Supported Features value */
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_CLIENT_SUPPORTED_FEATURES;
+
+/** @brief GATTS client read content */
+typedef union
+{
+ T_CLIENT_SUPPORTED_FEATURES client_supported_features;
+ uint8_t database_hash[GATTS_DATABASE_HASH_LEN];
+} T_GATTS_READ_DATA;
+
+/** @brief GATTS client write type*/
+typedef enum
+{
+ GATTS_WRITE_SERVICE_CHANGED_IND_ENABLE,
+ GATTS_WRITE_SERVICE_CHANGED_IND_DISABLE,
+ GATTS_WRITE_CLIENT_SUPPORTED_FEATURES,
+} T_GATTS_WRITE_TYPE;
+
+/** @brief GATTS client write result*/
+typedef struct
+{
+ T_GATTS_WRITE_TYPE type;
+ uint16_t cause;
+} T_GATTS_WRITE_RESULT;
+
+/** @brief GATTS client notif/ind receive type*/
+typedef enum
+{
+ GATTS_SERVICE_CHANGED_INDICATE,
+} T_GATTS_NOTIF_IND_TYPE;
+
+/** @brief GATTS client notif/ind receive data */
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_GATTS_NOTIF_IND_VALUE;
+
+/** @brief GATTS client notif/ind receive content*/
+typedef struct
+{
+ T_GATTS_NOTIF_IND_TYPE type;
+ T_GATTS_NOTIF_IND_VALUE data;
+} T_GATTS_NOTIF_IND_DATA;
+
+/** @brief GATTS client callback type */
+typedef enum
+{
+ GATTS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ GATTS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ GATTS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ GATTS_CLIENT_CB_TYPE_INVALID, //!< Invalid callback type, no practical usage.
+} T_GATTS_CLIENT_CB_TYPE;
+
+/** @brief GATTS client callback content */
+typedef union
+{
+ T_GATTS_DISC_STATE disc_state;
+ T_GATTS_WRITE_RESULT write_result;
+ T_GATTS_NOTIF_IND_DATA notif_ind_data;
+} T_GATTS_CLIENT_CB_CONTENT;
+
+/** @brief GATTS client callback data */
+typedef struct
+{
+ T_GATTS_CLIENT_CB_TYPE cb_type;
+ T_GATTS_CLIENT_CB_CONTENT cb_content;
+} T_GATTS_CLIENT_CB_DATA;
+
+/** End of GATTS_Client_Exported_Types * @} */
+
+/** @defgroup GATTS_Client_Exported_Functions GATTS Client Exported Functions
+ * @brief
+ * @{
+ */
+/**
+ * @brief Add gatts service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ gatts_client_id = gatts_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID gatts_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of GATT service.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_gattsdis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = gatts_start_discovery(conn_id);
+ ......
+ }
+ * \endcode
+ */
+bool gatts_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to set the indication flag of service changed characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind value to enable or disable indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_srvchgcccd(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ind = p_parse_value->dw_param[1];
+ bool ret;
+ ret = gatts_client_set_service_changed_ind(conn_id, ind);
+ ......
+ }
+ * \endcode
+ */
+bool gatts_client_set_service_changed_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in,out] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_gattshdl(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t hdl_cache[HDL_GATTS_CACHE_LEN];
+ uint8_t hdl_idx;
+ bool ret = gatts_get_hdl_cache(conn_id, hdl_cache, sizeof(uint16_t) * HDL_GATTS_CACHE_LEN);
+ ......
+ }
+ * \endcode
+ */
+bool gatts_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_discov_services(uint8_t conn_id, bool start)
+ {
+ ......
+ if (app_srvs_table.srv_found_flags & APP_DISCOV_GATTS_FLAG)
+ {
+ gatts_set_hdl_cache(conn_id, app_srvs_table.gatts_hdl_cache, sizeof(uint16_t) * HDL_GATTS_CACHE_LEN);
+ }
+ ......
+ }
+ * \endcode
+ */
+bool gatts_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of GATTS_Client_Exported_Functions */
+
+/** @} End of GATTS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _GATTS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/gcs_client.h b/inc/bluetooth/profile/client/gcs_client.h
new file mode 100644
index 0000000..08ac0df
--- /dev/null
+++ b/inc/bluetooth/profile/client/gcs_client.h
@@ -0,0 +1,626 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file gcs_client.h
+ * @brief Head file for using General Common Services client.
+ * @details General common services client data structs and external functions declaration.
+ * @author jane
+ * @date 2018-12-13
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _GCS_CLIENT_H_
+#define _GCS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+/** @defgroup GCS_Client General Common Services Client
+ * @brief GCS service client
+ * @details
+ Application shall register gcs client when initialization through @ref gcs_add_client function.
+ * \code{.c}
+ T_APP_RESULT gcs_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ APP_PRINT_INFO2("gcs_client_callback: client_id %d, conn_id %d",
+ client_id, conn_id);
+ if (client_id == gcs_client_id)
+ {
+ T_GCS_CLIENT_CB_DATA *p_gcs_cb_data = (T_GCS_CLIENT_CB_DATA *)p_data;
+ switch (p_gcs_cb_data->cb_type)
+ {
+ case GCS_CLIENT_CB_TYPE_DISC_RESULT:
+ ......
+ }
+ }
+ * \endcode
+ * @{
+ */
+
+/** @defgroup GCS_Client_Exported_Macros GCS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @brief Define maximum links number. range: 0-4 */
+#define GCS_MAX_LINKS 4
+
+/** End of GCS_Client_Exported_Macros * @} */
+
+/** @defgroup GCS_Client_Exported_Types GCS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief Discovery result type.*/
+typedef enum
+{
+ GCS_ALL_PRIMARY_SRV_DISCOV, //!<Response type for gcs_all_primary_srv_discovery
+ GCS_BY_UUID128_SRV_DISCOV, //!<Response type for gcs_by_uuid128_srv_discovery
+ GCS_BY_UUID_SRV_DISCOV, //!<Response type for gcs_by_uuid_srv_discovery
+ GCS_ALL_CHAR_DISCOV, //!<Response type for gcs_all_char_discovery
+ GCS_BY_UUID_CHAR_DISCOV, //!<Response type for gcs_by_uuid_char_discovery
+ GCS_BY_UUID128_CHAR_DISCOV, //!<Response type for gcs_by_uuid128_char_discovery
+ GCS_ALL_CHAR_DESC_DISCOV, //!<Response type for gcs_all_char_descriptor_discovery
+} T_GCS_DISCOV_TYPE;
+
+/** @brief Discovery result element.*/
+typedef union
+{
+ T_GATT_SERVICE_ELEM16 srv_uuid16_disc_data;
+ T_GATT_SERVICE_ELEM128 srv_uuid128_disc_data;
+ T_GATT_SERVICE_BY_UUID_ELEM srv_disc_data;
+ T_GATT_CHARACT_ELEM16 char_uuid16_disc_data;
+ T_GATT_CHARACT_ELEM128 char_uuid128_disc_data;
+ T_GATT_CHARACT_DESC_ELEM16 char_desc_uuid16_disc_data;
+ T_GATT_CHARACT_DESC_ELEM128 char_desc_uuid128_disc_data;
+} T_GCS_DISCOV_RESULT_DATA;
+
+/** @brief GCS discovery table element.*/
+typedef struct
+{
+ T_DISCOVERY_RESULT_TYPE result_type;
+ T_GCS_DISCOV_RESULT_DATA result_data;
+} T_GCS_DISCOV_RESULT;
+
+/** @brief GCS client discovery result */
+typedef struct
+{
+ bool is_success;
+ T_GCS_DISCOV_TYPE discov_type;
+ uint16_t result_num;
+ T_GCS_DISCOV_RESULT *p_result_table;
+} T_GCS_DISCOVERY_RESULT;
+
+/** @brief GCS client read data, used to inform app read response data */
+typedef struct
+{
+ uint16_t cause;
+ uint16_t handle;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_GCS_READ_RESULT;
+
+/** @brief GCS client write result, used to inform app write response data */
+typedef struct
+{
+ uint16_t cause;
+ uint16_t handle;
+ T_GATT_WRITE_TYPE type;
+} T_GCS_WRITE_RESULT;
+
+/** @brief GCS client notification/indication*/
+typedef struct
+{
+ bool notify;
+ uint16_t handle;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_GCS_NOTIF_IND;
+
+/** @brief GCS client callback type */
+typedef enum
+{
+ GCS_CLIENT_CB_TYPE_DISC_RESULT, //!< Discovery procedure state, done or pending.
+ GCS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ GCS_CLIENT_CB_TYPE_WRITE_RESULT,
+ GCS_CLIENT_CB_TYPE_NOTIF_IND,
+ GCS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_GCS_CLIENT_CB_TYPE;
+
+/** @brief GCS client callback content */
+typedef union
+{
+ T_GCS_DISCOVERY_RESULT discov_result;
+ T_GCS_READ_RESULT read_result;
+ T_GCS_WRITE_RESULT write_result;
+ T_GCS_NOTIF_IND notif_ind;
+} T_GCS_CLIENT_CB_CONTENT;
+
+/** @brief GCS client callback data */
+typedef struct
+{
+ T_GCS_CLIENT_CB_TYPE cb_type;
+ T_GCS_CLIENT_CB_CONTENT cb_content;
+} T_GCS_CLIENT_CB_DATA;
+
+/** End of GCS_Client_Exported_Types * @} */
+
+/** @defgroup GCS_Client_Exported_Functions GCS Client Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Send discovery all primary services request.
+ * @param[in] conn_id Connection ID
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_gsrvdis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ T_GAP_CAUSE cause = gcs_all_primary_srv_discovery(conn_id);
+
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_ALL_PRIMARY_SRV_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_all_primary_srv_discovery(uint8_t conn_id);
+
+/**
+ * @brief Send discovery services by 128 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] p_uuid128 128 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_srvuuid(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+ cause = gcs_by_uuid128_srv_discovery(conn_id, uuid128);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_BY_UUID128_SRV_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_by_uuid128_srv_discovery(uint8_t conn_id, uint8_t *p_uuid128);
+
+/**
+ * @brief Send discovery services by 16 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] uuid16 16 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_srvuuid(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+ cause = gcs_by_uuid_srv_discovery(conn_id, uuid16);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_BY_UUID_SRV_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_by_uuid_srv_discovery(uint8_t conn_id, uint16_t uuid16);
+
+/**
+ * @brief Send discovery characteristics request.
+ * @param[in] conn_id Connection ID
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_chardis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t start_handle = p_parse_value->dw_param[1];
+ uint16_t end_handle = p_parse_value->dw_param[2];
+
+ T_GAP_CAUSE cause = gcs_all_char_discovery(conn_id, start_handle, end_handle);
+
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_ALL_CHAR_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_all_char_discovery(uint8_t conn_id, uint16_t start_handle, uint16_t end_handle);
+
+/**
+ * @brief Send discovery characteristics request by caracteristic uuid.
+ * @param[in] conn_id Connection ID
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] uuid16 16bit characteristic uuid to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_charuuid(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+ T_GAP_CAUSE cause = gcs_by_uuid_char_discovery(conn_id, start_handle, end_handle,
+ uuid16);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_BY_UUID_CHAR_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_by_uuid_char_discovery(uint8_t conn_id, uint16_t start_handle,
+ uint16_t end_handle, uint16_t uuid16);
+/**
+ * @brief Send discovery characteristics request by caracteristic uuid.
+ * @param[in] conn_id Connection ID
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] p_uuid128 128bit characteristic uuid to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_charuuid(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+ T_GAP_CAUSE cause = gcs_by_uuid128_char_discovery(conn_id, start_handle,
+ end_handle,
+ uuid128);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_BY_UUID128_CHAR_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_by_uuid128_char_discovery(uint8_t conn_id, uint16_t start_handle,
+ uint16_t end_handle, uint8_t *p_uuid128);
+/**
+ * @brief Send discovery characteristics descriptor request.
+ * @param[in] conn_id Connection ID
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_charddis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t start_handle = p_parse_value->dw_param[1];
+ uint16_t end_handle = p_parse_value->dw_param[2];
+
+ T_GAP_CAUSE cause = gcs_all_char_descriptor_discovery(conn_id, start_handle,
+ end_handle);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ void gcs_handle_discovery_result(uint8_t conn_id, T_GCS_DISCOVERY_RESULT discov_result)
+ {
+ uint16_t i;
+ T_GCS_DISCOV_RESULT *p_result_table;
+ uint16_t properties;
+ switch (discov_result.discov_type)
+ {
+ case GCS_ALL_CHAR_DESC_DISCOV:
+ ......
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_all_char_descriptor_discovery(uint8_t conn_id, uint16_t start_handle,
+ uint16_t end_handle);
+/**
+ * @brief Read characteristic by handle request.
+ * @param[in] conn_id Connection ID
+ * @param[in] handle Request handle.
+ * @retval GAP_CAUSE_SUCCESS Read request success.
+ * @retval other Read request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_read(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint16_t handle = p_parse_value->dw_param[1];
+ T_GAP_CAUSE cause = GAP_CAUSE_SUCCESS;
+
+ if (p_parse_value->param_count <= 2)
+ {
+ cause = gcs_attr_read(conn_id, handle);
+ }
+
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ T_APP_RESULT gcs_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ APP_PRINT_INFO2("gcs_client_callback: client_id %d, conn_id %d",
+ client_id, conn_id);
+ if (client_id == gcs_client_id)
+ {
+ T_GCS_CLIENT_CB_DATA *p_gcs_cb_data = (T_GCS_CLIENT_CB_DATA *)p_data;
+ switch (p_gcs_cb_data->cb_type)
+ {
+ case GCS_CLIENT_CB_TYPE_READ_RESULT:
+ APP_PRINT_INFO3("READ RESULT: cause 0x%4x, handle 0x%4x, value_len %d",
+ p_gcs_cb_data->cb_content.read_result.cause,
+ p_gcs_cb_data->cb_content.read_result.handle,
+ p_gcs_cb_data->cb_content.read_result.value_size);
+ APP_PRINT_INFO1("READ VALUE: %b",
+ TRACE_BINARY(p_gcs_cb_data->cb_content.read_result.value_size,
+ p_gcs_cb_data->cb_content.read_result.p_value));
+ break;
+ ......
+ }
+ }
+ return result;
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_attr_read(uint8_t conn_id, uint16_t handle);
+
+/**
+ * @brief Read characteristic by 16 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] uuid16 Request 16 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Read request success.
+ * @retval other Read request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_readu(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+ cause = gcs_attr_read_using_uuid16(conn_id, start_handle, end_handle, uuid16);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ T_APP_RESULT gcs_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ APP_PRINT_INFO2("gcs_client_callback: client_id %d, conn_id %d",
+ client_id, conn_id);
+ if (client_id == gcs_client_id)
+ {
+ T_GCS_CLIENT_CB_DATA *p_gcs_cb_data = (T_GCS_CLIENT_CB_DATA *)p_data;
+ switch (p_gcs_cb_data->cb_type)
+ {
+ case GCS_CLIENT_CB_TYPE_READ_RESULT:
+ APP_PRINT_INFO3("READ RESULT: cause 0x%4x, handle 0x%4x, value_len %d",
+ p_gcs_cb_data->cb_content.read_result.cause,
+ p_gcs_cb_data->cb_content.read_result.handle,
+ p_gcs_cb_data->cb_content.read_result.value_size);
+ APP_PRINT_INFO1("READ VALUE: %b",
+ TRACE_BINARY(p_gcs_cb_data->cb_content.read_result.value_size,
+ p_gcs_cb_data->cb_content.read_result.p_value));
+ break;
+ ......
+ }
+ }
+ return result;
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_attr_read_using_uuid16(uint8_t conn_id, uint16_t start_handle, uint16_t end_handle,
+ uint16_t uuid16);
+/**
+ * @brief Read characteristic by 128 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] p_uuid128 Request 128 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Read request success.
+ * @retval other Read request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_readu(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+ cause = gcs_attr_read_using_uuid128(conn_id, start_handle, end_handle, uuid128);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ T_APP_RESULT gcs_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ APP_PRINT_INFO2("gcs_client_callback: client_id %d, conn_id %d",
+ client_id, conn_id);
+ if (client_id == gcs_client_id)
+ {
+ T_GCS_CLIENT_CB_DATA *p_gcs_cb_data = (T_GCS_CLIENT_CB_DATA *)p_data;
+ switch (p_gcs_cb_data->cb_type)
+ {
+ case GCS_CLIENT_CB_TYPE_READ_RESULT:
+ APP_PRINT_INFO3("READ RESULT: cause 0x%4x, handle 0x%4x, value_len %d",
+ p_gcs_cb_data->cb_content.read_result.cause,
+ p_gcs_cb_data->cb_content.read_result.handle,
+ p_gcs_cb_data->cb_content.read_result.value_size);
+ APP_PRINT_INFO1("READ VALUE: %b",
+ TRACE_BINARY(p_gcs_cb_data->cb_content.read_result.value_size,
+ p_gcs_cb_data->cb_content.read_result.p_value));
+ break;
+ ......
+ }
+ }
+ return result;
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_attr_read_using_uuid128(uint8_t conn_id, uint16_t start_handle, uint16_t end_handle,
+ uint8_t *p_uuid128);
+/**
+ * @brief Confirm from application when receive indication from server.
+ * @param[in] conn_id Connection ID indicate which link is.
+ * @retval GAP_CAUSE_SUCCESS: Success.
+ * @retval other: Failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_indconf(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ T_GAP_CAUSE ret;
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ ret = gcs_attr_ind_confirm(conn_id);
+ return (T_USER_CMD_PARSE_RESULT)ret;
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_attr_ind_confirm(uint8_t conn_id);
+
+/**
+ * @brief Write characteristic request.
+ * @param[in] conn_id Connection ID
+ * @param[in] write_type Type of write.
+ * @param[in] handle Attribute handle.
+ * @param[in] length Length of data to be written.
+ If write_type is GATT_WRITE_TYPE_REQ, range of length is from 0 to 512.
+ If write_type is GATT_WRITE_TYPE_CMD, range of length is from 0 to (mtu_size - 3).
+ uint16_t mtu_size is acquired by le_get_conn_param(GAP_PARAM_CONN_MTU_SIZE, &mtu_size, conn_id).
+ * @param[in] p_data Point to the data to be written.
+ * @retval GAP_CAUSE_SUCCESS: Write request success.
+ * @retval other: Write request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_USER_CMD_PARSE_RESULT cmd_write(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ ......
+
+ T_GAP_CAUSE ret = gcs_attr_write(conn_id, (T_GATT_WRITE_TYPE)write_type, handle,
+ length, data);
+ return (T_USER_CMD_PARSE_RESULT)ret;
+ }
+ T_APP_RESULT gcs_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ APP_PRINT_INFO2("gcs_client_callback: client_id %d, conn_id %d",
+ client_id, conn_id);
+ if (client_id == gcs_client_id)
+ {
+ T_GCS_CLIENT_CB_DATA *p_gcs_cb_data = (T_GCS_CLIENT_CB_DATA *)p_data;
+ switch (p_gcs_cb_data->cb_type)
+ {
+ case GCS_CLIENT_CB_TYPE_WRITE_RESULT:
+ APP_PRINT_INFO3("WRITE RESULT: cause 0x%4x ,handle 0x%4x, type %d",
+ p_gcs_cb_data->cb_content.write_result.cause,
+ p_gcs_cb_data->cb_content.write_result.handle,
+ p_gcs_cb_data->cb_content.write_result.type);
+ break;
+ ......
+ }
+ }
+
+ return result;
+ }
+ * \endcode
+ */
+T_GAP_CAUSE gcs_attr_write(uint8_t conn_id, T_GATT_WRITE_TYPE write_type, uint16_t handle,
+ uint16_t length, uint8_t *p_data);
+
+/**
+ * @brief Add general services client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @param[in] config the discovery table number per link.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ gcs_client_id = gcs_add_client(gcs_client_callback, APP_MAX_LINKS, APP_MAX_DISCOV_TABLE_NUM);
+ }
+ * \endcode
+ */
+T_CLIENT_ID gcs_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num,
+ uint16_t max_discov_table_size);
+
+/** @} End of GCS_Client_Exported_Functions */
+
+/** @} End of GCS_Client */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _GCS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/hids_client.h b/inc/bluetooth/profile/client/hids_client.h
new file mode 100644
index 0000000..f541cb7
--- /dev/null
+++ b/inc/bluetooth/profile/client/hids_client.h
@@ -0,0 +1,355 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids_client.h
+ * @brief Head file for using hid service client.
+ * @details HID client data structs and external functions declaration.
+ * @author jane
+ * @date 2016-02-18
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _HIDS_CLIENT_H_
+#define _HIDS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+/** @defgroup HIDS_CLIENT HID Service Client
+ * @brief HIDS client
+ * @details
+ Application shall register hid host when initialization through @ref hids_add_client function.
+
+ Application can start discovery battery service through @ref hids_start_discovery function.
+
+ Application shall handle callback function registered by hids_add_client.
+ * \code{.c}
+ T_APP_RESULT app_client_callback(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ if (client_id == hid_host_id)
+ {
+ T_HIDS_CLIENT_CB_DATA *p_hids_client_cb_data = (T_HIDS_CLIENT_CB_DATA *)p_data;
+ switch (p_hids_client_cb_data->cb_type)
+ {
+ case HIDS_CLIENT_CB_TYPE_DISC_STATE:
+ switch (p_hids_client_cb_data->cb_content.disc_state)
+ {
+ case DISC_HIDS_DONE:
+ ......
+ }
+ }
+ * \endcode
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @addtogroup HIDS_CLIENT_Exported_Macros HOGP Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @brief Define links number. range: 0-4 */
+#define HIDS_CLIENT_MAX_LINKS 4
+
+/** @brief Define report number. */
+#define HIDS_CLIENT_MAX_REPORT_NUM 10
+
+/** @brief Bit field of HIDS read flag. */
+#define HIDS_READ_HID_INFO_BIT 0x01
+#define HIDS_READ_PROTOCOL_MODE_BIT 0x02
+#define HIDS_READ_REPORT_MAP_BIT 0x04
+#define HIDS_READ_REPORT_REF_BIT 0x08
+
+/** @defgroup HID UUIDs
+ * @brief HID UUID definitions
+ * @{
+ */
+#define GATT_UUID_HID 0x1812
+#define GATT_UUID_CHAR_HID_INFO 0x2A4A
+#define GATT_UUID_CHAR_REPORT_MAP 0x2A4B
+#define GATT_UUID_CHAR_HID_CONTROL_POINT 0x2A4C
+#define GATT_UUID_CHAR_REPORT 0x2A4D
+#define GATT_UUID_CHAR_PROTOCOL_MODE 0x2A4E
+
+#define GATT_UUID_CHAR_BOOT_KB_IN_REPORT 0x2A22 // boot keyboard input report
+#define GATT_UUID_CHAR_BOOT_KB_OUT_REPORT 0x2A32 // boot keyboard output report
+#define GATT_UUID_CHAR_BOOT_MS_IN_REPORT 0x2A33 // boot mouse input report
+
+/** @} End of Hid UUIDs */
+
+/** End of HIDS_CLIENT_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HIDS_CLIENT__Exported_Types HOGP Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief HID host handle type*/
+typedef enum
+{
+ HDL_HIDS_SRV_START, //!< start handle of hid service
+ HDL_HIDS_SRV_END, //!< end handle of hid service
+ HDL_HIDS_CHAR_HID_INFO, //!< hid information characteristic value handle
+ HDL_HIDS_CHAR_REPORT_MAP, //!< report map characteristic value handle
+ HDL_HIDS_CHAR_HID_CONTROL_POINT, //!< hid control point characteristic value handle
+ HDL_HIDS_CHAR_PROTOCOL_MODE, //!< protocol mode characteristic value handle
+ HDL_HIDS_CACHE_LEN //!< handle cache length
+} T_HIDS_CLIENT_HANDLE_TYPE;
+
+/** @brief HID host discovery state*/
+typedef enum
+{
+ DISC_HIDS_IDLE,
+ DISC_HIDS_START,
+ DISC_HIDS_DONE,
+ DISC_HIDS_FAILED
+} T_HIDS_CLIENT_DISC_STATE;
+
+/** @brief HID host report type*/
+typedef enum
+{
+ HIDS_RESERVED_REPORT,
+ HIDS_INPUT_REPORT,
+ HIDS_OUTPUT_REPORT,
+ HIDS_FEATURE_REPORT,
+} T_HIDS_REPORT_TYPE;
+
+/** @brief HID host report reference data*/
+typedef struct
+{
+ uint8_t report_id;
+ T_HIDS_REPORT_TYPE report_type;
+} T_HIDS_REPORT_REF_DATA;
+
+/** @brief HID host report*/
+typedef struct
+{
+ uint16_t hdl_report_value;
+ uint16_t hdl_report_cccd;
+ uint16_t hdl_report_reference;
+ T_HIDS_REPORT_REF_DATA report_ref;
+} T_HIDS_CLIENT_REPORT;
+
+
+typedef struct
+{
+ uint8_t CountryCode;
+ uint8_t bFlags;
+ uint16_t BcdHID;
+} HID_INFO_ATTRB;
+
+/** @brief HID host read type*/
+typedef enum
+{
+ HIDS_READ_PROTOCOL_MODE,
+ HIDS_READ_REPORT_MAP,
+ HIDS_READ_HID_INFO,
+} T_HIDS_READ_TYPE;
+
+/** @brief HID host read value */
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_HIDS_READ_VALUE;
+
+#if 0
+/** @brief HID host read data */
+typedef union
+{
+ T_HIDS_READ_VALUE report_map;
+ T_HIDS_READ_VALUE report_ref;
+} T_HIDS_READ_DATA;
+#endif
+
+/** @brief HID host read result type */
+typedef enum
+{
+ HIDS_READ_RESULT_RESERVED,
+ HIDS_READ_RESULT_REPORT_MAP,
+} T_HIDS_READ_RESULT_TYPE;
+
+/** @brief HID host read result */
+typedef struct
+{
+ T_HIDS_READ_RESULT_TYPE type;
+ uint16_t cause;
+} T_HIDS_CLIENT_READ_RESULT;
+
+/** @brief HID host write type*/
+typedef enum
+{
+ HIDS_WRITE_REPORT,
+ HIDS_WRITE_ALL_REPORT_CCCD,
+ //HIDS_WRITE_PROTOCOL_MODE,//write command
+ //HIDS_WRITE_HID_CONTROL_POINT,//write command
+} T_HIDS_WRITE_TYPE;
+
+typedef struct
+{
+ uint8_t report_id;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_HIDS_WRITE_REPORT_DATA;
+
+/** @brief HID host write result*/
+typedef struct
+{
+ T_HIDS_WRITE_TYPE type;
+ uint16_t cause;
+ T_HIDS_REPORT_REF_DATA report_ref; //just used for HIDS_WRITE_REPORT
+} T_HIDS_CLIENT_WRITE_RESULT;
+
+/** @brief HID host notification receive type*/
+typedef enum
+{
+ HIDS_REPORT_NOTIFY,
+} T_HIDS_NOTIF_TYPE;
+
+/** @brief HID host notification receive data*/
+typedef struct
+{
+ uint8_t report_id;
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_HIDS_NOTIF_VALUE;
+
+/** @brief HID host notification receive content*/
+typedef struct
+{
+ T_HIDS_NOTIF_TYPE type;
+ T_HIDS_NOTIF_VALUE data;
+} T_HIDS_CLIENT_NOTIF_DATA;
+
+/** @brief HOGP client callback type*/
+typedef enum
+{
+ HIDS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ HIDS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ HIDS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ HIDS_CLIENT_CB_TYPE_NOTIF_RESULT, //!< Notification or indication data received from server.
+ HIDS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_HIDS_CLIENT_CB_TYPE;
+
+/** @brief HOGP client callback content*/
+typedef union
+{
+ T_HIDS_CLIENT_DISC_STATE disc_state;
+ T_HIDS_CLIENT_READ_RESULT read_result;
+ T_HIDS_CLIENT_NOTIF_DATA notify_data;
+ T_HIDS_CLIENT_WRITE_RESULT write_result;
+} T_HIDS_CLIENT_CB_CONTENT;
+
+/** @brief HOGP client callback data*/
+typedef struct
+{
+ T_HIDS_CLIENT_CB_TYPE cb_type;
+ T_HIDS_CLIENT_CB_CONTENT cb_content;
+} T_HIDS_CLIENT_CB_DATA;
+
+/** @brief HID Host storage information block definition. */
+typedef struct
+{
+ uint8_t read_flags;
+ uint8_t protocol_mode;
+ uint8_t report_num;
+ HID_INFO_ATTRB hids_info;
+ uint16_t hdl_cache[HDL_HIDS_CACHE_LEN];
+ T_HIDS_CLIENT_REPORT report[HIDS_CLIENT_MAX_REPORT_NUM];
+} T_HIDS_CLIENT_STORAGE_INFO;
+/** End of HIDS_CLIENT_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HIDS_CLIENT_Exported_Functions HOGP Client Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add hid host to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ hids_client_client_id = hids_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID hids_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of battery service.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_hidhostdis(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ bool ret = hids_start_discovery(conn_id);
+ ......
+ }
+ * \endcode
+ */
+bool hids_start_discovery(uint8_t conn_id);
+
+bool hids_write_report(uint8_t conn_id, uint8_t report_id, T_HIDS_REPORT_TYPE report_type,
+ uint16_t length, uint8_t *p_value, T_GATT_WRITE_TYPE type);
+
+bool hids_enable_all_cccd(uint8_t conn_id);
+
+bool hids_read_saved_data(uint8_t conn_id, T_HIDS_READ_TYPE read_type, T_HIDS_READ_VALUE *p_value);
+
+bool hids_get_hdl_cache(uint8_t conn_id, T_HIDS_CLIENT_STORAGE_INFO *p_storage_info);
+
+bool hids_set_hdl_cache(uint8_t conn_id, T_HIDS_CLIENT_STORAGE_INFO *p_storage_info);
+
+bool hids_read_report_map(uint8_t conn_id);
+
+bool hids_set_report_map(uint8_t conn_id, uint16_t value_size, uint8_t *p_value);
+
+void hids_print_infos(uint8_t conn_id);
+
+/** @} End of HIDS_CLEINT_Exported_Functions */
+
+/** @} End of HIDS_CLEINT */
+
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _HIDS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/ias_client.h b/inc/bluetooth/profile/client/ias_client.h
new file mode 100644
index 0000000..16a7266
--- /dev/null
+++ b/inc/bluetooth/profile/client/ias_client.h
@@ -0,0 +1,284 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ias_client.h
+ * @brief Head file for using Ias BLE Client.
+ * @details Ias data structs and external functions declaration.
+ * @author ken
+ * @date 2017-12-04
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _IAS_CLIENT_H_
+#define _IAS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+/** @defgroup IAS_Client Ias service client
+ * @brief ias service client
+ * @details
+ Ias Profile is a customized BLE-based Profile. Ias ble service please refer to @ref IAS_Service .
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup IAS_Client_Exported_Macros IAS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup IAS UUIDs
+ * @brief Ias BLE Profile UUID definitions
+ * @{
+ */
+
+#define GATT_UUID_IMMEDIATE_ALERT_SERVICE 0x1802
+#define GATT_UUID_CHAR_ALERT_LEVEL 0x2A06
+
+/** @} End of SIMP_UUIDs */
+
+/** @brief Define links number. range: 0-4 */
+#define IAS_MAX_LINKS 2
+/** End of IAS_Client_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup IAS_Client_Exported_Types IAS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief IAS client handle type*/
+typedef enum
+{
+ HDL_IAS_SRV_START, //!< start handle of simple ble service
+ HDL_IAS_SRV_END, //!< end handle of simple ble service
+ HDL_IAS_WRITE, //!< V2 write characteristic value handle
+ HDL_IAS_CACHE_LEN //!< handle cache length
+} T_IAS_HANDLE_TYPE;
+
+/** @brief IAS client discovery state*/
+typedef enum
+{
+ DISC_IAS_IDLE,
+ DISC_IAS_START,
+ DISC_IAS_DONE,
+ DISC_IAS_FAILED
+} T_IAS_DISC_STATE;
+
+///** @brief ias client read type*/
+//typedef enum
+//{
+// IAS_READ_V1_READ,
+// IAS_READ_V3_NOTIFY_CCCD,
+// IAS_READ_V4_INDICATE_CCCD,
+//} T_IAS_READ_TYPE;
+
+///** @brief IAS client read value*/
+//typedef struct
+//{
+// uint16_t value_size;
+// uint8_t *p_value;
+//} T_IAS_READ_VALUE;
+
+///** @brief IAS client read data*/
+//typedef union
+//{
+// T_IAS_READ_VALUE v1_read;
+// bool v3_notify_cccd;
+// bool v4_indicate_cccd;
+//} T_IAS_READ_DATA;
+
+///** @brief IAS client read result*/
+//typedef struct
+//{
+// T_IAS_READ_TYPE type;
+// T_IAS_READ_DATA data;
+// uint16_t cause;
+//} T_IAS_READ_RESULT;
+
+
+/** @brief IAS client write type*/
+typedef enum
+{
+ IAS_WRITE_ALERT,
+} T_IAS_WRITE_TYPE;
+
+/** @brief IAS client write result*/
+typedef struct
+{
+ T_IAS_WRITE_TYPE type;
+ uint16_t cause;
+} T_IAS_WRITE_RESULT;
+
+///** @brief IAS client notif/ind receive type*/
+//typedef enum
+//{
+// IAS_V3_NOTIFY,
+// IAS_V4_INDICATE,
+//} T_IAS_NOTIF_IND_TYPE;
+
+///** @brief IAS client notif/ind receive data*/
+//typedef struct
+//{
+// uint16_t value_size;
+// uint8_t *p_value;
+//} T_IAS_NOTIF_IND_VALUE;
+
+///** @brief IAS client notif/ind receive content*/
+//typedef struct
+//{
+// T_IAS_NOTIF_IND_TYPE type;
+// T_IAS_NOTIF_IND_VALUE data;
+//} T_IAS_NOTIF_IND_DATA;
+
+/** @brief IAS client callback type*/
+typedef enum
+{
+ IAS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ //IAS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ IAS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ // IAS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ IAS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_IAS_CLIENT_CB_TYPE;
+
+/** @brief IAS client callback content*/
+typedef union
+{
+ T_IAS_DISC_STATE disc_state;
+ //T_IAS_READ_RESULT read_result;
+ T_IAS_WRITE_RESULT write_result;
+ //T_IAS_NOTIF_IND_DATA notif_ind_data;
+} T_IAS_CLIENT_CB_CONTENT;
+
+/** @brief IAS client callback data*/
+typedef struct
+{
+ T_IAS_CLIENT_CB_TYPE cb_type;
+ T_IAS_CLIENT_CB_CONTENT cb_content;
+} T_IAS_CLIENT_CB_DATA;
+
+/** End of IAS_Client_Exported_Types * @} */
+
+/** @defgroup IAS_Client_Exported_Functions IAS Client Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Add ias service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ ias_client_id = ias_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID ias_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of ias server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ias_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool ias_client_read_by_handle(uint8_t conn_id, T_IAS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to read data from server by using UUIDs.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool ias_client_read_by_uuid(uint8_t conn_id, T_IAS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to write data of Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ias_client_write_char(uint8_t conn_id, uint16_t length, uint8_t *p_value,
+ T_GATT_WRITE_TYPE type);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify 0--disable the notification, 1--enable the notification.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool simp_ble_client_set_v3_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to enable or disable the indication of peer server's V4 Indicate Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind 0--disable the indication, 1--enable the indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool simp_ble_client_set_v4_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool ias_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool ias_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of IAS_Client_Exported_Functions */
+
+/** @} End of IAS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _IAS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/ipss_client.h b/inc/bluetooth/profile/client/ipss_client.h
new file mode 100644
index 0000000..3aa5348
--- /dev/null
+++ b/inc/bluetooth/profile/client/ipss_client.h
@@ -0,0 +1,74 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ipss_client.c
+ * @brief Source file for client of internet protocol support service.
+ * @details Global data and function implement.
+ * @author Jeff_Zheng
+ * @date 2017-12-05
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+
+#ifndef _IPSS_CLIENT_H_
+#define _IPSS_CLIENT_H_
+
+#include <stdint.h>
+#include <stdbool.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup IPSS_CLIENT Internet Protocol Support Service Client
+ * @brief Internet Protocol Support Service Client
+ * @details
+
+ IPSS client is used to discover Internet Protocol Support Service, this file could be used if application need to find IPSS.
+
+ Application shall register IPSS client when initialization through @ref ipss_add_client function.
+
+ Application can start discovery IPSS service through @ref ipss_find_srv_dcl function.
+
+ * @{
+ */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup IPSS_CLIENT_Exported_Functions Internet Protocol Support Service Client Exported Functions
+ * @brief
+ * @{
+ */
+
+
+/**
+ * @brief add IPS service client.
+ *
+ * @param[in] p_func pointer of app callback function called by client.
+ * @return client id.
+ */
+uint8_t ipss_add_client(void *p_func);
+
+/**
+ * @brief discover IPS service by service uuid .
+ *
+ * @param[in] conn_id connection id.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ */
+bool ipss_find_srv_dcl(uint8_t conn_id);
+
+/** @} End of IPSS_CLIENT_Exported_Functions */
+
+/** @} End of IPSS_CLIENT */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/inc/bluetooth/profile/client/kns_client.h b/inc/bluetooth/profile/client/kns_client.h
new file mode 100644
index 0000000..1aae42c
--- /dev/null
+++ b/inc/bluetooth/profile/client/kns_client.h
@@ -0,0 +1,289 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file kns_client.h
+ * @brief Head file for using KNS Client.
+ * @details kns data structs and external functions declaration.
+ * @author ken
+ * @date 2017-12-04
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _KNS_CLIENT_H_
+#define _KNS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+/** @defgroup KNS_Client Kns service client
+ * @brief kns service client
+ * @details
+ kns Profile is a customized BLE-based Profile. Kns ble service please refer to @ref KNS_Service .
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup KNS_Client_Exported_Macros KNS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup KNS UUIDs
+ * @brief Kns BLE Profile UUID definitions
+ * @{
+ */
+//#define GATT_UUID_EXS 0xFFD0
+//#define GATT_UUID_CHAR_PARAM 0xFFD1
+//#define GATT_UUID_CHAR_KEY 0xFFD2
+extern uint8_t GATT_UUID128_KNS_SERVICE[16];
+#define GATT_UUID128_KNS 0xA6, 0xF6, 0xF6, 0x07, 0x4D, 0xC4, 0x9D, 0x98, 0x6D, 0x45, 0x29, 0xBB, 0xD0, 0xFF, 0x00, 0x00,
+#define GATT_UUID128_CHAR_PARAM 0xA6, 0xF6, 0xF6, 0x07, 0x4D, 0xC4, 0x9D, 0x98, 0x6D, 0x45, 0x29, 0xBB, 0xD1, 0xFF, 0x00, 0x00,
+#define GATT_UUID128_CHAR_KEY 0xA6, 0xF6, 0xF6, 0x07, 0x4D, 0xC4, 0x9D, 0x98, 0x6D, 0x45, 0x29, 0xBB, 0xD2, 0xFF, 0x00, 0x00,
+
+/** @} End of KNS_UUIDs */
+
+/** @brief Define links number. range: 0-4 */
+#define KNS_MAX_LINKS 2
+/** End of KNS_Client_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup KNS_Exported_Types KNS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief KNS client handle type*/
+typedef enum
+{
+ HDL_KNS_SRV_START, //!< start handle of kns service
+ HDL_KNS_SRV_END, //!< end handle of kns service
+ HDL_KNS_PARA, //!< KNS parameter read/write characteristic value handle
+ HDL_KNS_NOTIFY_KEY, //!< key notify characteristic value handle
+ HDL_KNS_NOTIFY_KEY_CCCD, //!< key notify characteristic CCCD handle
+ HDL_KNS_CACHE_LEN //!< handle cache length
+} T_KNS_HANDLE_TYPE;
+
+/** @brief KNS client discovery state*/
+typedef enum
+{
+ DISC_KNS_IDLE,
+ DISC_KNS_START,
+ DISC_KNS_DONE,
+ DISC_KNS_FAILED
+} T_KNS_DISC_STATE;
+
+/** @brief kns client read type*/
+typedef enum
+{
+ KNS_READ_PARAM,
+ KNS_READ_KEY_NOTIFY_CCCD,
+} T_KNS_READ_TYPE;
+
+/** @brief KNS client read value*/
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_KNS_READ_VALUE;
+
+/** @brief KNS client read data*/
+typedef union
+{
+ T_KNS_READ_VALUE v1_read;
+ bool v3_notify_cccd;
+ bool v4_indicate_cccd;
+} T_KNS_READ_DATA;
+
+/** @brief KNS client read result*/
+typedef struct
+{
+ T_KNS_READ_TYPE type;
+ T_KNS_READ_DATA data;
+ uint16_t cause;
+} T_KNS_READ_RESULT;
+
+
+/** @brief KNS client write type*/
+typedef enum
+{
+ KNS_WRITE_PARAM,
+ KNS_WRITE_KEY_NOTIFY_CCCD,
+} T_KNS_WRITE_TYPE;
+
+/** @brief KNS client write result*/
+typedef struct
+{
+ T_KNS_WRITE_TYPE type;
+ uint16_t cause;
+} T_KNS_WRITE_RESULT;
+
+/** @brief KNS client notif/ind receive type*/
+typedef enum
+{
+ KNS_KEY_NOTIFY,
+} T_KNS_NOTIF_IND_TYPE;
+
+/** @brief KNS client notif/ind receive data*/
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_KNS_NOTIF_IND_VALUE;
+
+/** @brief KNS client notif/ind receive content*/
+typedef struct
+{
+ T_KNS_NOTIF_IND_TYPE type;
+ T_KNS_NOTIF_IND_VALUE data;
+} T_KNS_NOTIF_IND_DATA;
+
+/** @brief KNS client callback type*/
+typedef enum
+{
+ KNS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ KNS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ KNS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ KNS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ KNS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_KNS_CLIENT_CB_TYPE;
+
+/** @brief KNS client callback content*/
+typedef union
+{
+ T_KNS_DISC_STATE disc_state;
+ T_KNS_READ_RESULT read_result;
+ T_KNS_WRITE_RESULT write_result;
+ T_KNS_NOTIF_IND_DATA notif_ind_data;
+} T_KNS_CLIENT_CB_CONTENT;
+
+/** @brief KNS client callback data*/
+typedef struct
+{
+ T_KNS_CLIENT_CB_TYPE cb_type;
+ T_KNS_CLIENT_CB_CONTENT cb_content;
+} T_KNS_CLIENT_CB_DATA;
+
+/** End of KNS_Client_Exported_Types * @} */
+
+/** @defgroup KNS_Client_Exported_Functions KNS Client Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Add kns service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ kns_client_id = kns_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID kns_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of ias server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool kns_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool kns_client_read_by_handle(uint8_t conn_id, T_KNS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to read data from server by using UUIDs.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool kns_client_read_by_uuid(uint8_t conn_id, T_KNS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to write data of V2 write Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool kns_client_write_v2_char(uint8_t conn_id, uint16_t length, uint8_t *p_value,
+ T_GATT_WRITE_TYPE type);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify 0--disable the notification, 1--enable the notification.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool kns_client_set_v3_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to enable or disable the indication of peer server's V4 Indicate Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind 0--disable the indication, 1--enable the indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool kns_client_set_v4_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool kns_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool kns_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of KNS_Client_Exported_Functions */
+
+/** @} End of KNS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _KNS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/lls_client.h b/inc/bluetooth/profile/client/lls_client.h
new file mode 100644
index 0000000..2602706
--- /dev/null
+++ b/inc/bluetooth/profile/client/lls_client.h
@@ -0,0 +1,279 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file lls_client.h
+ * @brief Head file for using LLS Client.
+ * @details lls data structs and external functions declaration.
+ * @author ken
+ * @date 2017-12-05
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _LLS_CLIENT_H_
+#define _LLS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+/** @defgroup LLS_Client lls service client
+ * @brief lls service client
+ * @details
+ lls Profile is a customized BLE-based Profile. Lls ble service please refer to @ref LLS_Service .
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup LLS_Client_Exported_Macros LLS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup LLS UUIDs
+ * @brief Lls BLE Profile UUID definitions
+ * @{
+ */
+#define GATT_UUID_LINK_LOSS_SERVICE 0x1803
+#define GATT_UUID_CHAR_ALERT_LEVEL 0x2A06
+/** @} End of LLS_UUIDs */
+
+/** @brief Define links number. range: 0-4 */
+#define LLS_MAX_LINKS 2
+/** End of LLS_Client_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup LLS_Exported_Types LLS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief LLS client handle type*/
+typedef enum
+{
+ HDL_LLS_SRV_START, //!< start handle of lls service
+ HDL_LLS_SRV_END, //!< end handle of lls service
+ HDL_LLS_PARA, //!< LLS parameter read/write characteristic value handle
+ HDL_LLS_CACHE_LEN //!< handle cache length
+} T_LLS_HANDLE_TYPE;
+
+/** @brief LLS client discovery state*/
+typedef enum
+{
+ DISC_LLS_IDLE,
+ DISC_LLS_START,
+ DISC_LLS_DONE,
+ DISC_LLS_FAILED
+} T_LLS_DISC_STATE;
+
+/** @brief lls client read type*/
+typedef enum
+{
+ LLS_READ_PARA,
+} T_LLS_READ_TYPE;
+
+/** @brief LLS client read value*/
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_LLS_READ_VALUE;
+
+/** @brief LLS client read data*/
+typedef union
+{
+ T_LLS_READ_VALUE v1_read;
+// bool v3_notify_cccd;
+// bool v4_indicate_cccd;
+} T_LLS_READ_DATA;
+
+/** @brief LLS client read result*/
+typedef struct
+{
+ T_LLS_READ_TYPE type;
+ T_LLS_READ_DATA data;
+ uint16_t cause;
+} T_LLS_READ_RESULT;
+
+
+/** @brief LLS client write type*/
+typedef enum
+{
+ LLS_WRITE_PARA,
+} T_LLS_WRITE_TYPE;
+
+/** @brief LLS client write result*/
+typedef struct
+{
+ T_LLS_WRITE_TYPE type;
+ uint16_t cause;
+} T_LLS_WRITE_RESULT;
+
+/** @brief LLS client notif/ind receive type*/
+//typedef enum
+//{
+// LLS_KEY_NOTIFY,
+//} T_LLS_NOTIF_IND_TYPE;
+
+///** @brief LLS client notif/ind receive data*/
+//typedef struct
+//{
+// uint16_t value_size;
+// uint8_t *p_value;
+//} T_LLS_NOTIF_IND_VALUE;
+
+/** @brief LLS client notif/ind receive content*/
+//typedef struct
+//{
+// T_LLS_NOTIF_IND_TYPE type;
+// T_LLS_NOTIF_IND_VALUE data;
+//} T_LLS_NOTIF_IND_DATA;
+
+/** @brief LLS client callback type*/
+typedef enum
+{
+ LLS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ LLS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ LLS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ //LLS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ LLS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_LLS_CLIENT_CB_TYPE;
+
+/** @brief LLS client callback content*/
+typedef union
+{
+ T_LLS_DISC_STATE disc_state;
+ T_LLS_READ_RESULT read_result;
+ T_LLS_WRITE_RESULT write_result;
+ //T_LLS_NOTIF_IND_DATA notif_ind_data;
+} T_LLS_CLIENT_CB_CONTENT;
+
+/** @brief LLS client callback data*/
+typedef struct
+{
+ T_LLS_CLIENT_CB_TYPE cb_type;
+ T_LLS_CLIENT_CB_CONTENT cb_content;
+} T_LLS_CLIENT_CB_DATA;
+
+/** End of LLS_Client_Exported_Types * @} */
+
+/** @defgroup LLS_Client_Exported_Functions LLS Client Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Add lls service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ lls_client_id = lls_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID lls_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of lls server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool lls_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool lls_client_read_by_handle(uint8_t conn_id, T_LLS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to read data from server by using UUIDs.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool lls_client_read_by_uuid(uint8_t conn_id, T_LLS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to write data of write Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool lls_client_write_char(uint8_t conn_id, uint16_t length, uint8_t *p_value,
+ T_GATT_WRITE_TYPE type);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify 0--disable the notification, 1--enable the notification.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool lls_client_set_v3_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to enable or disable the indication of peer server's V4 Indicate Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind 0--disable the indication, 1--enable the indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool lls_client_set_v4_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool lls_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool lls_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of LLS_Client_Exported_Functions */
+
+/** @} End of LLS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _LLS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/ota_client.h b/inc/bluetooth/profile/client/ota_client.h
new file mode 100644
index 0000000..7875887
--- /dev/null
+++ b/inc/bluetooth/profile/client/ota_client.h
@@ -0,0 +1,254 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ota_client.h
+ * @brief Head file for using ota service Client.
+ * @details Data structs and external functions declaration.
+ * @author
+ * @date
+ * @version
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _OTA_CLIENT_H_
+#define _OTA_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* Add Includes here */
+#include "profile_client.h"
+#include "dfu_api.h"
+
+/** @defgroup OTA_Client OTA Service Client
+ * @{
+ */
+
+/*============================================================================*
+* Macros
+*============================================================================*/
+/** @addtogroup OTA_Client_Exported_Macros OTA Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup OTA UUIDs
+ * @brief ota BLE Profile UUID definitions
+ * @{
+ */
+#define GATT_UUID_OTA_SERVICE 0x12, 0xA2, 0x4D, 0x2E, 0xFE, 0x14, 0x48, 0x8e, 0x93, 0xD2, 0x17, 0x3C, 0xFF, 0xD0, 0x00, 0x00
+
+#define GATT_UUID_OTA_PROFILE
+
+#define GATT_UUID_CHAR_OTA 0xFFD1 //1, write
+#define GATT_UUID_CHAR_MAC 0xFFD2 //2
+#define GATT_UUID_CHAR_PATCH 0xFFD3 //3
+#define GATT_UUID_CHAR_APP_VERSION 0xFFD4 //4
+#define GATT_UUID_CHAR_PATCH_EXTENSION 0xFFD5 //5
+#define GATT_UUID_CHAR_TEST_MODE 0xFFD8 //6, write
+
+#define GATT_UUID_CHAR_DEVICE_INFO 0xFFF1 //7
+#define GATT_UUID_CHAR_IMAGE_COUNT_TO_UPDATE 0xFFF2 //8, write
+#define GATT_UUID_CHAR_IMAGE_VERSION 0xFFE0
+/** @} End of OTA_UUIDs */
+
+
+#define OTA_WRITE_OTA_CMD_CHAR_VAL 0x01
+#define OTA_WRITE_TEST_MODE_CHAR_VAL 0x02
+#define OTA_WRITE_OTA_IMG_COUNTER_CHAR_VAL 0x03
+
+
+/** @brief Define links number. range: 0-4 */
+#define OTA_MAX_LINKS 4
+/** End of OTA_Client_Exported_Macros * @} */
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup OTA_Client_Exported_Types OTA Client Exported Types
+ * @brief
+ * @{
+ */
+/** @brief OTA client device info*/
+typedef struct _T_OTA_DEVICE_INFO
+{
+ uint8_t ictype;
+ uint8_t ota_version;
+ uint8_t secure_version;
+ T_OTA_MODE ota_mode;
+
+ uint16_t max_buffer_size;
+ uint16_t rsvd;
+
+ uint32_t img_indicator;
+} T_OTA_DEVICE_INFO, *P_OTA_DEVICE_INFO;
+
+/** @brief OTA client handle type*/
+typedef enum
+{
+ HDL_OTA_SRV_START, //!< start handle of battery service
+ HDL_OTA_SRV_END, //!< end handle of battery service
+ HDL_OTA_CMD, //!< OTA CMD characteristic value handle
+ HDL_OTA_DEVICE_MAC,
+ HDL_OTA_PATCH_VER,
+ HDL_OTA_APP_VER,
+ HDL_OTA_PATCH_EXT_VER,
+ HDL_OTA_TEST_MODE, //!< OTA test mode characteristic handle
+ HDL_OTA_DEVICE_INFO,
+ HDL_OTA_IMG_COUNTER, //!<OTA IMAGE COUNT TO UPDATE characteristic handle
+ HDL_OTA_IMG_VER,
+ HDL_OTA_CACHE_LEN //!< handle cache length
+} T_OTA_HANDLE_TYPE;
+
+/** @brief OTA client discovery state*/
+typedef enum
+{
+ DISC_OTA_IDLE,
+ DISC_OTA_START,
+ DISC_OTA_DONE,
+ DISC_OTA_FAILED
+} T_OTA_DISC_STATE;
+
+/** @brief OTA client read type*/
+typedef enum
+{
+ OTA_READ_DEVICE_MAC,
+ OTA_READ_PATCH_VER,
+ OTA_READ_APP_VER,
+ OTA_READ_PATCH_EXT_VER,
+ OTA_READ_DEVICE_INFO,
+ OTA_READ_IMG_VER
+} T_OTA_READ_TYPE;
+
+/** @brief OTA client read data */
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_OTA_READ_DATA;
+
+/** @brief OTA client read result*/
+typedef struct
+{
+ T_OTA_READ_TYPE type;
+ T_OTA_READ_DATA data;
+ uint16_t cause;
+} T_OTA_READ_RESULT;
+
+/** @brief OTA client write type*/
+typedef enum
+{
+ OTA_WRITE_CMD,
+ OTA_WRITE_TEST_MODE,
+ OTA_WRITE_IMG_COUNTER
+} T_OTA_WRITE_TYPE;
+
+/** @brief OTA client write result*/
+typedef struct
+{
+ T_OTA_WRITE_TYPE type;
+ uint16_t cause;
+} T_OTA_WRITE_RESULT;
+
+/** @brief OTA client callback type*/
+typedef enum
+{
+ OTA_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ OTA_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ OTA_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ OTA_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_OTA_CLIENT_CB_TYPE;
+
+/** @brief OTA client callback content*/
+typedef union
+{
+ T_OTA_DISC_STATE disc_state;
+ T_OTA_READ_RESULT read_result;
+ T_OTA_WRITE_RESULT write_result;
+} T_OTA_CLIENT_CB_CONTENT;
+
+/** @brief OTA client callback data*/
+typedef struct
+{
+ T_OTA_CLIENT_CB_TYPE cb_type;
+ T_OTA_CLIENT_CB_CONTENT cb_content;
+} T_OTA_CLIENT_CB_DATA;
+/** End of OTA_Client_Exported_Types * @} */
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup OTA_Client_Exported_Functions OTA Client Exported Functions
+ * @{
+ */
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ota_client_read_by_handle(uint8_t conn_id, T_OTA_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool ota_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool ota_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to write ota cmd write Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ota_client_write_char(uint8_t conn_id, T_OTA_WRITE_TYPE write_type);
+
+/**
+ * @brief ota client connect target device.
+ * @param p_le_scan_info: filtered scan info
+ */
+void ota_client_connect_device(T_LE_SCAN_INFO *p_le_scan_info);
+/**
+ * @brief Used by application, to start the discovery procedure of OTA server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool ota_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief add OTA client to application.
+ * @param appCB: pointer of app callback function to handle specific client module data.
+ * @retval Client ID of the specific client module.
+ */
+T_CLIENT_ID ota_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+/** @} End of OTA_Client_Exported_Functions */
+
+/** @} End of OTA_Client */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _OTA_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/simple_ble_client.h b/inc/bluetooth/profile/client/simple_ble_client.h
new file mode 100644
index 0000000..b5271e4
--- /dev/null
+++ b/inc/bluetooth/profile/client/simple_ble_client.h
@@ -0,0 +1,292 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file simple_ble_client.h
+ * @brief Head file for using Simple BLE Client.
+ * @details Simple BLE data structs and external functions declaration.
+ * @author jane
+ * @date 2016-02-18
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _SIMPLE_BLE_CLIENT_H_
+#define _SIMPLE_BLE_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+/** @defgroup SIMP_Client Simple BLE Service Client
+ * @brief Simple BLE service client
+ * @details
+ Simple BLE Profile is a customized BLE-based Profile. Simple ble service please refer to @ref SIMP_Service .
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup SIMP_Client_Exported_Macros SIMP Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup SIMP_UUIDs SIMP UUIDs
+ * @brief Simple BLE Profile UUID definitions
+ * @{
+ */
+#define GATT_UUID_SIMPLE_PROFILE 0xA00A
+#define GATT_UUID_CHAR_SIMPLE_V1_READ 0xB001
+#define GATT_UUID_CHAR_SIMPLE_V2_WRITE 0xB002
+#define GATT_UUID_CHAR_SIMPLE_V3_NOTIFY 0xB003
+#define GATT_UUID_CHAR_SIMPLE_V4_INDICATE 0xB004
+/** @} End of SIMP_UUIDs */
+
+/** @brief Define links number. range: 0-4 */
+#define SIMP_MAX_LINKS 4
+/** End of SIMP_Client_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup SIMP_Client_Exported_Types SIMP Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief SIMP client handle type*/
+typedef enum
+{
+ HDL_SIMBLE_SRV_START, //!< start handle of simple ble service
+ HDL_SIMBLE_SRV_END, //!< end handle of simple ble service
+ HDL_SIMBLE_V1_READ, //!< V1 read characteristic value handle
+ HDL_SIMBLE_V2_WRITE, //!< V2 write characteristic value handle
+ HDL_SIMBLE_V3_NOTIFY, //!< V3 notify characteristic value handle
+ HDL_SIMBLE_V3_NOTIFY_CCCD, //!< V3 notify characteristic CCCD handle
+ HDL_SIMBLE_V4_INDICATE, //!< V4 indicate characteristic value handle
+ HDL_SIMBLE_V4_INDICATE_CCCD, //!< V4 indicate characteristic CCCD handle
+ HDL_SIMBLE_CACHE_LEN //!< handle cache length
+} T_SIMP_HANDLE_TYPE;
+
+/** @brief SIMP client discovery state*/
+typedef enum
+{
+ DISC_SIMP_IDLE,
+ DISC_SIMP_START,
+ DISC_SIMP_DONE,
+ DISC_SIMP_FAILED
+} T_SIMP_DISC_STATE;
+
+/** @brief SIMP client read type*/
+typedef enum
+{
+ SIMP_READ_V1_READ,
+ SIMP_READ_V3_NOTIFY_CCCD,
+ SIMP_READ_V4_INDICATE_CCCD,
+} T_SIMP_READ_TYPE;
+
+/** @brief SIMP client read value*/
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_SIMP_READ_VALUE;
+
+/** @brief SIMP client read data*/
+typedef union
+{
+ T_SIMP_READ_VALUE v1_read;
+ bool v3_notify_cccd;
+ bool v4_indicate_cccd;
+} T_SIMP_READ_DATA;
+
+/** @brief SIMP client read result*/
+typedef struct
+{
+ T_SIMP_READ_TYPE type;
+ T_SIMP_READ_DATA data;
+ uint16_t cause;
+} T_SIMP_READ_RESULT;
+
+
+/** @brief SIMP client write type*/
+typedef enum
+{
+ SIMP_WRITE_V2_WRITE,
+ SIMP_WRITE_V3_NOTIFY_CCCD,
+ SIMP_WRITE_V4_INDICATE_CCCD,
+} T_SIMP_WRITE_TYPE;
+
+/** @brief SIMP client write result*/
+typedef struct
+{
+ T_SIMP_WRITE_TYPE type;
+ uint16_t cause;
+} T_SIMP_WRITE_RESULT;
+
+/** @brief SIMP client notif/ind receive type*/
+typedef enum
+{
+ SIMP_V3_NOTIFY,
+ SIMP_V4_INDICATE,
+} T_SIMP_NOTIF_IND_TYPE;
+
+/** @brief SIMP client notif/ind receive data*/
+typedef struct
+{
+ uint16_t value_size;
+ uint8_t *p_value;
+} T_SIMP_NOTIF_IND_VALUE;
+
+/** @brief SIMP client notif/ind receive content*/
+typedef struct
+{
+ T_SIMP_NOTIF_IND_TYPE type;
+ T_SIMP_NOTIF_IND_VALUE data;
+} T_SIMP_NOTIF_IND_DATA;
+
+/** @brief SIMP client callback type*/
+typedef enum
+{
+ SIMP_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ SIMP_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ SIMP_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ SIMP_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ SIMP_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_SIMP_CLIENT_CB_TYPE;
+
+/** @brief SIMP client callback content*/
+typedef union
+{
+ T_SIMP_DISC_STATE disc_state;
+ T_SIMP_READ_RESULT read_result;
+ T_SIMP_WRITE_RESULT write_result;
+ T_SIMP_NOTIF_IND_DATA notif_ind_data;
+} T_SIMP_CLIENT_CB_CONTENT;
+
+/** @brief SIMP client callback data*/
+typedef struct
+{
+ T_SIMP_CLIENT_CB_TYPE cb_type;
+ T_SIMP_CLIENT_CB_CONTENT cb_content;
+} T_SIMP_CLIENT_CB_DATA;
+
+/** End of SIMP_Client_Exported_Types * @} */
+
+/** @defgroup SIMP_Client_Exported_Functions SIMP Client Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Add simple ble service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ simple_ble_client_id = simp_ble_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID simp_ble_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of Simple BLE server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool simp_ble_client_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read data from server by using handles.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool simp_ble_client_read_by_handle(uint8_t conn_id, T_SIMP_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to read data from server by using UUIDs.
+ * @param[in] conn_id connection ID.
+ * @param[in] read_type one of characteristic that has the readable property.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool simp_ble_client_read_by_uuid(uint8_t conn_id, T_SIMP_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to write data of V2 write Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool simp_ble_client_write_v2_char(uint8_t conn_id, uint16_t length, uint8_t *p_value,
+ T_GATT_WRITE_TYPE type);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify 0--disable the notification, 1--enable the notification.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool simp_ble_client_set_v3_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to enable or disable the indication of peer server's V4 Indicate Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind 0--disable the indication, 1--enable the indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool simp_ble_client_set_v4_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool simp_ble_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool simp_ble_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of SIMP_Client_Exported_Functions */
+
+/** @} End of SIMP_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _SIMPLE_BLE_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/client/tps_client.h b/inc/bluetooth/profile/client/tps_client.h
new file mode 100644
index 0000000..68ec51a
--- /dev/null
+++ b/inc/bluetooth/profile/client/tps_client.h
@@ -0,0 +1,273 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file tps_client.h
+ * @brief Head file for using TPS Client.
+ * @details tps data structs and external functions declaration.
+ * @author ken
+ * @date 2017-12-05
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _TPS_CLIENT_H_
+#define _TPS_CLIENT_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_client.h>
+
+
+/** @defgroup TPS_Client tps service client
+ * @brief tps service client
+ * @details
+ tps Profile is a customized BLE-based Profile. Tps ble service please refer to @ref TPS_Service .
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup TPS_Client_Exported_Macros TPS Client Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup TPS UUIDs
+ * @brief Tps BLE Profile UUID definitions
+ * @{
+ */
+#define GATT_UUID_TX_POWER_SERVICE 0x1804
+#define GATT_UUID_CHAR_TX_LEVEL 0x2A07
+/** @} End of TPS_UUIDs */
+
+/** @brief Define links number. range: 0-4 */
+#define TPS_MAX_LINKS 2
+/** End of TPS_Client_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup TPS_Exported_Types TPS Client Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief TPS client handle type*/
+typedef enum
+{
+ HDL_TPS_SRV_START, //!< start handle of tps service
+ HDL_TPS_SRV_END, //!< end handle of tps service
+ HDL_TPS_PARA, //!< TPS parameter read/write characteristic value handle
+ HDL_TPS_CACHE_LEN //!< handle cache length
+} T_TPS_HANDLE_TYPE;
+
+/** @brief TPS client discovery state*/
+typedef enum
+{
+ DISC_TPS_IDLE,
+ DISC_TPS_START,
+ DISC_TPS_DONE,
+ DISC_TPS_FAILED
+} T_TPS_DISC_STATE;
+
+/** @brief tps client read type*/
+typedef enum
+{
+ TPS_READ_PARA,
+} T_TPS_READ_TYPE;
+
+
+/** @brief TPS client read data */
+typedef union
+{
+ uint8_t txpower_level;
+} T_TPS_READ_DATA;
+
+
+/** @brief TPS client read result*/
+typedef struct
+{
+ T_TPS_READ_TYPE type;
+ T_TPS_READ_DATA data;
+ uint16_t cause;
+} T_TPS_READ_RESULT;
+
+/** @brief LLS client write type*/
+//typedef enum
+//{
+// LLS_WRITE_PARA,
+//} T_LLS_WRITE_TYPE;
+
+///** @brief LLS client write result*/
+//typedef struct
+//{
+// T_LLS_WRITE_TYPE type;
+// uint16_t cause;
+//} T_LLS_WRITE_RESULT;
+
+/** @brief LLS client notif/ind receive type*/
+//typedef enum
+//{
+// LLS_KEY_NOTIFY,
+//} T_LLS_NOTIF_IND_TYPE;
+
+///** @brief LLS client notif/ind receive data*/
+//typedef struct
+//{
+// uint16_t value_size;
+// uint8_t *p_value;
+//} T_LLS_NOTIF_IND_VALUE;
+
+/** @brief LLS client notif/ind receive content*/
+//typedef struct
+//{
+// T_LLS_NOTIF_IND_TYPE type;
+// T_LLS_NOTIF_IND_VALUE data;
+//} T_LLS_NOTIF_IND_DATA;
+
+/** @brief TPS client callback type*/
+typedef enum
+{
+ TPS_CLIENT_CB_TYPE_DISC_STATE, //!< Discovery procedure state, done or pending.
+ TPS_CLIENT_CB_TYPE_READ_RESULT, //!< Read request's result data, responsed from server.
+ //LLS_CLIENT_CB_TYPE_WRITE_RESULT, //!< Write request result, success or fail.
+ //LLS_CLIENT_CB_TYPE_NOTIF_IND_RESULT, //!< Notification or indication data received from server.
+ TPS_CLIENT_CB_TYPE_INVALID //!< Invalid callback type, no practical usage.
+} T_TPS_CLIENT_CB_TYPE;
+
+/** @brief TPS client callback content*/
+typedef union
+{
+ T_TPS_DISC_STATE disc_state;
+ T_TPS_READ_RESULT read_result;
+ //T_TPS_WRITE_RESULT write_result;
+ //T_LLS_NOTIF_IND_DATA notif_ind_data;
+} T_TPS_CLIENT_CB_CONTENT;
+
+/** @brief TPS client callback data*/
+typedef struct
+{
+ T_TPS_CLIENT_CB_TYPE cb_type;
+ T_TPS_CLIENT_CB_CONTENT cb_content;
+} T_TPS_CLIENT_CB_DATA;
+
+/** End of TPS_Client_Exported_Types * @} */
+
+/** @defgroup TPS_Client_Exported_Functions TPS Client Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Add tps service client to application.
+ * @param[in] app_cb pointer of app callback function to handle specific client module data.
+ * @param[in] link_num initialize link num.
+ * @return Client ID of the specific client module.
+ * @retval 0xff failed.
+ * @retval other success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ tps_client_id = tps_add_client(app_client_callback, APP_MAX_LINKS);
+ }
+ * \endcode
+ */
+T_CLIENT_ID tps_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num);
+
+/**
+ * @brief Used by application, to start the discovery procedure of ias server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool tps_start_discovery(uint8_t conn_id);
+
+/**
+ * @brief Used by application, to read power level from server.
+ * @param[in] conn_id connection ID.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+bool tps_read_power_level(uint8_t conn_id);
+
+
+//bool tps_client_read_by_handle(uint8_t conn_id, T_TPS_READ_TYPE read_type);
+
+///**
+// * @brief Used by application, to read data from server by using UUIDs.
+// * @param[in] conn_id connection ID.
+// * @param[in] read_type one of characteristic that has the readable property.
+// * @retval true send request to upper stack success.
+// * @retval false send request to upper stack failed.
+// */
+//bool tps_client_read_by_uuid(uint8_t conn_id, T_TPS_READ_TYPE read_type);
+
+/**
+ * @brief Used by application, to write data of write Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] length write data length
+ * @param[in] p_value point the value to write
+ * @param[in] type write type.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool tps_client_write_char(uint8_t conn_id, uint16_t length, uint8_t *p_value,
+// T_GATT_WRITE_TYPE type);
+
+/**
+ * @brief Used by application, to enable or disable the notification of peer server's V3 Notify Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] notify 0--disable the notification, 1--enable the notification.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool lls_client_set_v3_notify(uint8_t conn_id, bool notify);
+
+/**
+ * @brief Used by application, to enable or disable the indication of peer server's V4 Indicate Characteristic.
+ * @param[in] conn_id connection ID.
+ * @param[in] ind 0--disable the indication, 1--enable the indication.
+ * @retval true send request to upper stack success.
+ * @retval false send request to upper stack failed.
+ */
+//bool lls_client_set_v4_ind(uint8_t conn_id, bool ind);
+
+/**
+ * @brief Used by application, to get handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool tps_client_get_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/**
+ * @brief Used by application, to set handle cache.
+ * @param[in] conn_id connection ID.
+ * @param[in] p_hdl_cache pointer of the handle cache table
+ * @param[in] len the length of handle cache table
+ * @retval true success.
+ * @retval false failed.
+ */
+bool tps_client_set_hdl_cache(uint8_t conn_id, uint16_t *p_hdl_cache, uint8_t len);
+
+/** @} End of LLS_Client_Exported_Functions */
+
+/** @} End of LLS_Client */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _KNS_CLIENT_H_ */
diff --git a/inc/bluetooth/profile/gatt.h b/inc/bluetooth/profile/gatt.h
new file mode 100644
index 0000000..d250150
--- /dev/null
+++ b/inc/bluetooth/profile/gatt.h
@@ -0,0 +1,275 @@
+#ifndef _GATT_H_
+#define _GATT_H_
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/*============================================================================*
+* Macros
+*============================================================================*/
+
+/**
+
+ * \addtogroup GATT_SERVER_API GATT Server API
+ *
+ * \defgroup GATT_ATTRIBUTE GATT Attribute
+ *
+ * \brief GATT Attribute Definitions
+ *
+ * \ingroup GATT_SERVER_API
+ */
+
+/**
+ * gatt.h
+ *
+ * \name GATT_DECLARATIONS_UUID
+ * \brief GATT declarations uuid.
+ * \anchor GATT_DECLARATIONS_UUID
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define GATT_UUID_PRIMARY_SERVICE 0x2800 /**< GATT Primary Service Declaration. */
+#define GATT_UUID_SECONDARY_SERVICE 0x2801 /**< GATT Secondary Service Declaration. */
+#define GATT_UUID_INCLUDE 0x2802 /**< GATT Include Declaration. */
+#define GATT_UUID_CHARACTERISTIC 0x2803 /**< GATT Characteristic Declaration. */
+
+/**
+ * gatt.h
+ *
+ * \name GATT_DESCRIPTORS_UUID
+ * \brief GATT descriptors uuid.
+ * \anchor GATT_DESCRIPTORS_UUID
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define GATT_UUID_CHAR_EXTENDED_PROP 0x2900 /**< Characteristic Extended Properties. */
+#define GATT_UUID_CHAR_USER_DESCR 0x2901 /**< Characteristic User Description. */
+#define GATT_UUID_CHAR_CLIENT_CONFIG 0x2902 /**< Client Characteristic Configuration. */
+#define GATT_UUID_CHAR_SERVER_CONFIG 0x2903 /**< Server Characteristic Configuration. */
+#define GATT_UUID_CHAR_FORMAT 0x2904 /**< Characteristic Presentation Format. */
+#define GATT_UUID_CHAR_AGGR_FORMAT 0x2905 /**< Characteristic Aggregate Format. */
+#define GATT_UUID_CHAR_VALID_RANGE 0x2906 /**< Valid Range. */
+#define GATT_UUID_CHAR_EXTERNAL_REPORT_REFERENCE 0x2907 /**< External Report Reference. */
+#define GATT_UUID_CHAR_REPORT_REFERENCE 0x2908 /**< Report Reference. */
+#define GATT_UUID_CHAR_DESCRIPTOR_NUM_OF_DIGITALS 0x2909 /**< Number of Digitals. */
+#define GATT_UUID_CHAR_DESCRIPTOR_VALUE_TRIGGER_SETTING 0x290A /**< Value Trigger Setting. */
+#define GATT_UUID_CHAR_SENSING_CONFIGURATION 0x290B /**< Environmental Sensing Configuration. */
+#define GATT_UUID_CHAR_SENSING_MEASUREMENT 0x290C /**< Environmental Sensing Measurement. */
+#define GATT_UUID_CHAR_SENSING_TRIGGER_SETTING 0x290D /**< Environmental Sensing Trigger Setting. */
+#define GATT_UUID_CHAR_DESCRIPTOR_TIME_TRIGGER_SETTING 0x290E /**< Time Trigger Setting. */
+
+/**
+ * gatt.h
+ *
+ * \name GATT_CHARACTERISTICS_UUID
+ * \brief GATT characteristics uuid.
+ * \anchor GATT_CHARACTERISTICS_UUID
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define GATT_UUID_CHAR_DEVICE_NAME 0x2A00 /**< Device Name. */
+#define GATT_UUID_CHAR_APPEARANCE 0x2A01 /**< Appearance. */
+#define GATT_UUID_CHAR_PER_PRIV_FLAG 0x2A02 /**< Peripheral Privacy Flag. */
+#define GATT_UUID_CHAR_RECONN_ADDRESS 0x2A03 /**< Reconnection Address. */
+#define GATT_UUID_CHAR_PER_PREF_CONN_PARAM 0x2A04 /**< Peripheral Preferred Connection Parameters. */
+#define GATT_UUID_CHAR_SERVICE_CHANGED 0x2A05 /**< Service Changed. */
+#define GATT_UUID_CHAR_CENTRAL_ADDRESS_RESOLUTION 0x2AA6 /**< Central Address Resolution. */
+#define GATT_UUID_CHAR_RESOLVABLE_PRIVATE_ADDRESS_ONLY 0x2AC9 /**< Resolvable Private Address Only. */
+#define GATT_UUID_CHAR_CLIENT_SUPPORTED_FEATURES 0x2B29 /**< Client Supported Features. */
+#define GATT_UUID_CHAR_DATABASE_HASH 0x2B2A /**< Database Hash. */
+
+/** @brief GATT Service Client Supported Features length. variable length, 1 is used in Core Spec v5.2. */
+#define GATTS_CLIENT_SUPPORTED_FEATURES_LEN 1
+
+/** @brief GATT Service Database Hash length. */
+#define GATTS_DATABASE_HASH_LEN 16
+
+/**
+ * gatt.h
+ *
+ * \name GATT_SERVICE_UUID
+ * \brief GATT services uuid.
+ * \anchor GATT_SERVICE_UUID
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define GATT_UUID_GAP 0x1800 /**< Generic Access. */
+#define GATT_UUID_GATT 0x1801 /**< Generic Attribute. */
+
+/**
+ * gatt.h
+ *
+ * \name GATT_ATTRIBUTE_PERMISSIONS
+ * \brief Attribute read/write permissions, encryption key size.
+ * \anchor GATT_ATTRIBUTE_PERMISSIONS
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define GATT_PERM_NONE 0x00
+#define GATT_PERM_ALL 0x01 /**< bits 0..1 (rd), 4..5 (wr), 8..9 (notif/ind) */
+#define GATT_PERM_AUTHEN_REQ 0x02
+#define GATT_PERM_AUTHEN_MITM_REQ 0x03
+#define GATT_PERM_AUTHOR_REQ 0x04 /**< bits 2 (rd), 6 (wr), 10 (notif/ind) */
+#define GATT_PERM_ENCRYPTED_REQ 0x08 /**< bits 3 (rd), 7 (wr), 11 (notif/ind) */
+#define GATT_PERM_AUTHEN_SC_REQ 0x00010000
+
+/** @brief read (bits 0..3) */
+#define GATT_PERM_READ GATT_PERM_ALL
+#define GATT_PERM_READ_AUTHEN_REQ GATT_PERM_AUTHEN_REQ
+#define GATT_PERM_READ_AUTHEN_MITM_REQ GATT_PERM_AUTHEN_MITM_REQ
+#define GATT_PERM_READ_AUTHOR_REQ GATT_PERM_AUTHOR_REQ
+#define GATT_PERM_READ_ENCRYPTED_REQ GATT_PERM_ENCRYPTED_REQ
+#define GATT_PERM_READ_AUTHEN_SC_REQ GATT_PERM_AUTHEN_SC_REQ
+
+#define GATT_PERM_READ_AUTHEN_GET(x) (x & 0x03)
+#define GATT_PERM_READ_AUTHOR_GET(x) (x & 0x04)
+#define GATT_PERM_READ_ENCRYPT_GET(x) (x & 0x08)
+#define GATT_PERM_READ_AUTHEN_SC_GET(x) (x & 0x00010000)
+
+/** @brief write (bits 4..7) */
+#define GATT_PERM_WRITE (GATT_PERM_ALL << 4)
+#define GATT_PERM_WRITE_AUTHEN_REQ (GATT_PERM_AUTHEN_REQ << 4)
+#define GATT_PERM_WRITE_AUTHEN_MITM_REQ (GATT_PERM_AUTHEN_MITM_REQ << 4)
+#define GATT_PERM_WRITE_AUTHOR_REQ (GATT_PERM_AUTHOR_REQ << 4)
+#define GATT_PERM_WRITE_ENCRYPTED_REQ (GATT_PERM_ENCRYPTED_REQ << 4)
+#define GATT_PERM_WRITE_AUTHEN_SC_REQ (GATT_PERM_AUTHEN_SC_REQ<<4)
+
+#define GATT_PERM_WRITE_AUTHEN_GET(x) ((x >> 4) & 0x03)
+#define GATT_PERM_WRITE_AUTHOR_GET(x) ((x >> 4) & 0x04)
+#define GATT_PERM_WRITE_ENCRYPT_GET(x) ((x >> 4) & 0x08)
+#define GATT_PERM_WRITE_AUTHEN_SC_GET(x) ((x>>4) & 0x00010000)
+
+/** @brief notification/indication (bits 8..11) */
+#define GATT_PERM_NOTIF_IND (GATT_PERM_ALL << 8)
+#define GATT_PERM_NOTIF_IND_AUTHEN_REQ (GATT_PERM_AUTHEN_REQ << 8)
+#define GATT_PERM_NOTIF_IND_AUTHEN_MITM_REQ (GATT_PERM_AUTHEN_MITM_REQ << 8)
+#define GATT_PERM_NOTIF_IND_AUTHOR_REQ (GATT_PERM_AUTHOR_REQ << 8)
+#define GATT_PERM_NOTIF_IND_ENCRYPTED_REQ (GATT_PERM_ENCRYPTED_REQ << 8)
+#define GATT_PERM_NOTIF_IND_AUTHEN_SC_REQ (GATT_PERM_AUTHEN_SC_REQ<<8)
+
+#define GATT_PERM_NOTIF_IND_AUTHEN_GET(x) ((x >> 8) & 0x03)
+#define GATT_PERM_NOTIF_IND_AUTHOR_GET(x) ((x >> 8) & 0x04)
+#define GATT_PERM_NOTIF_IND_ENCRYPT_GET(x) ((x >> 8) & 0x08)
+#define GATT_PERM_NOTIF_IND_AUTHEN_SC_GET(x) ((x>>8) & 0x00010000)
+
+/** @brief key size - 1 (bits 12..15) */
+#define GATT_PERM_KEYSIZE(size) ((size-1) << 12)
+#define GATT_PERM_KEYSIZE_GET(x, size) { \
+ size = ((x >> 12) & 0x0F); \
+ if ( size > 0 ) \
+ size++; \
+ }
+
+/**
+ * gatt.h
+ *
+ * \name GATT_CHARACTERISTIC_PROPERTIES
+ * \brief GATT characteristic properties.
+ * \anchor GATT_CHARACTERISTIC_PROPERTIES
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define GATT_CHAR_PROP_BROADCAST 0x01 /**< If set, permits broadcasts of the Characteristic Value using
+Server Characteristic Configuration Descriptor. */
+#define GATT_CHAR_PROP_READ 0x02 /**< If set, permits reads of the Characteristic Value */
+#define GATT_CHAR_PROP_WRITE_NO_RSP 0x04 /**< If set, permit writes of the Characteristic Value without response */
+#define GATT_CHAR_PROP_WRITE 0x08 /**< If set, permits writes of the Characteristic Value with response */
+#define GATT_CHAR_PROP_NOTIFY 0x10 /**< If set, permits notifications of a Characteristic Value without acknowledgment */
+#define GATT_CHAR_PROP_INDICATE 0x20 /**< If set, permits indications of a Characteristic Value with acknowledgment */
+#define GATT_CHAR_PROP_WRITE_AUTHEN_SIGNED 0x40 /**< If set, permits signed writes to the Characteristic Value */
+#define GATT_CHAR_PROP_EXT_PROP 0x80 /**< If set, additional characteristic properties are defined in the Characteristic
+Extended Properties Descriptor */
+
+/** @brief GATT client characteristic configuration bit field */
+#define GATT_CLIENT_CHAR_CONFIG_DEFAULT 0x0000 /**< The Characteristic Value shall be neither indicated nor notified. */
+#define GATT_CLIENT_CHAR_CONFIG_NOTIFY 0x0001 /**< The Characteristic Value shall be notified. */
+#define GATT_CLIENT_CHAR_CONFIG_INDICATE 0x0002 /**< The Characteristic Value shall be indicated. */
+#define GATT_CLIENT_CHAR_CONFIG_NOTIFY_INDICATE 0x0003 /**< The Characteristic Value shall be both indicated and notified. */
+
+#define GATT_CLIENT_CHAR_NOTIF_IND_DATA_PENGDING 0x8000
+
+/** @brief GATT server characteristic configuration bit field */
+#define GATT_SERVER_CHAR_CONFIG_BROADCAST 0x0001 /**< The Characteristic Value shall be broadcast. */
+
+
+/**
+ * gatt.h
+ *
+ * \name GATT_UUID_SIZE
+ * \brief GATT uuid size.
+ * \anchor GATT_UUID_SIZE
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define UUID_16BIT_SIZE 2 /**< 16 bits UUID size. */
+#define UUID_128BIT_SIZE 16 /**< 128 bits UUID size. */
+
+#define ATT_ATTRIBUTE_MAX_LENGTH 512 /**< Attribute Max length. */
+
+#define HI_WORD(x) ((uint8_t)((x & 0xFF00) >> 8))
+#define LO_WORD(x) ((uint8_t)(x))
+
+
+/*---------------------------------------------------------------------------
+ * GATT server attribute descriptor
+ *--------------------------------------------------------------------------*/
+
+/**
+ * gatt.h
+ *
+ * \name GATT_ATTRIBUTE_FLAG
+ * \brief GATT attribute flag.
+ * \anchor GATT_ATTRIBUTE_FLAG
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+#define ATTRIB_FLAG_VOID 0x0000 /**< Attribute value neither supplied by application
+nor included following 16bit UUID. Attribute value is pointed by p_value_context
+and value_len shall be set to the length of attribute value. */
+#define ATTRIB_FLAG_UUID_128BIT 0x0001 /**< Attribute uses 128 bit UUID */
+#define ATTRIB_FLAG_VALUE_INCL 0x0002 /**< Attribute value is included following 16 bit UUID */
+#define ATTRIB_FLAG_VALUE_APPL 0x0004 /**< Application has to supply write value */
+#define ATTRIB_FLAG_ASCII_Z 0x0008 /**< Attribute value is ASCII_Z string */
+#define ATTRIB_FLAG_CCCD_APPL 0x0010 /**< Application will be informed about CCCD value is changed */
+#define ATTRIB_FLAG_CCCD_NO_FILTER 0x0020 /**< Application will be informed about CCCD value
+when CCCD is write by client, no matter it is changed or not */
+#define ATTRIB_FLAG_INCLUDE_MULTI 0x0040
+#define ATTRIB_FLAG_LE 0x0800 /**< Used only for primary service declaration attributes if GATT over BLE is supported */
+
+/**
+ * gatt.h
+ *
+ * \name GATT_ATTRIBUTE_APPL
+ * \brief GATT attribute definition.
+ * \anchor GATT_ATTRIBUTE_APPL
+ */
+/**
+ * \ingroup GATT_ATTRIBUTE
+ */
+typedef struct
+{
+ uint16_t flags; /**< Attribute flags @ref GATT_ATTRIBUTE_FLAG */
+ uint8_t type_value[2 + 14]; /**< 16 bit UUID + included value or 128 bit UUID */
+ uint16_t value_len; /**< Length of value */
+ void *p_value_context; /**< Pointer to value if @ref ATTRIB_FLAG_VALUE_INCL
+ and @ref ATTRIB_FLAG_VALUE_APPL not set */
+ uint32_t permissions; /**< Attribute permission @ref GATT_ATTRIBUTE_PERMISSIONS */
+} T_ATTRIB_APPL;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _GATT_H_ */
diff --git a/inc/bluetooth/profile/gatt_builtin_services.h b/inc/bluetooth/profile/gatt_builtin_services.h
new file mode 100644
index 0000000..28130e3
--- /dev/null
+++ b/inc/bluetooth/profile/gatt_builtin_services.h
@@ -0,0 +1,276 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file gatt_builtin_services.h
+ * @brief Head file for using builtin services, including GAP service and GATT service.
+ * @details GAPS data structs and external functions declaration.
+ * @author jane
+ * @date 2015-5-12
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _BUILTIN_SERVICES_H_
+#define _BUILTIN_SERVICES_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "upperstack_config.h"
+#include "profile_server.h"
+
+/** @defgroup GAP_GATT_SERVICE GAP and GATT Inbox Services
+ * @brief GAP and GATT inbox services
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup GAP_GATT_SERVICE_Exported_Macros GAP and GATT Service Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup GAPS_Write_PROPERTY GAP Service Write Property
+ * @brief GAP service write property.
+ * @{
+ */
+#define GAPS_PROPERTY_WRITE_DISABLE 0
+#define GAPS_PROPERTY_WRITE_ENABLE 1
+/** @} */
+
+
+/** @defgroup GAPS_WRITE_TYPE GAP and GATT Service Write Type
+ * @brief GAP and GATT Service Write Type.
+ * @{
+ */
+#define GAPS_WRITE_DEVICE_NAME 1
+#define GAPS_WRITE_APPEARANCE 2
+#define GATT_SERVICE_CHANGE_CCCD_ENABLE 3
+#define GATT_SERVICE_CHANGE_CCCD_DISABLE 4
+#define GATT_SERVICE_WRITE_CLIENT_SUPPORTED_FEATURES 5
+/** @} */
+
+/** @brief GATT Service Client Supported Features bit field. */
+#define GATTS_CLIENT_SUPPORTED_FEAUTRES_DEFAULT_VALUE 0x00 /**< Server shall not use any of the features associated with that bit when communicating with this client. */
+#define GATTS_CLIENT_SUPPORTED_FEAUTRES_ROBUST_CACHING_BIT 0x01 /**< The client supports robust caching. */
+#define GATTS_CLIENT_SUPPORTED_FEAUTRES_EATT_BEARER_BIT 0x02 /**< The client supports Enhanced ATT bearer. */
+#define GATTS_CLIENT_SUPPORTED_FEAUTRES_MULTI_NOTIF_BIT 0x04 /**< The client supports receiving ATT_MULTIPLE_HANDLE_VALUE_NTF PDUs. */
+
+/** End of GAP_GATT_SERVICE_Exported_Macros
+* @}
+*/
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup GAP_GATT_SERVICE_Exported_Types GAP and GATT Service Exported Types
+ * @brief
+ * @{
+ */
+
+/** @brief GAPS parameter type */
+typedef enum
+{
+ GAPS_PARAM_DEVICE_NAME = 0x00,
+ GAPS_PARAM_APPEARANCE = 0x01,
+#if F_BT_LE_PRIVACY_SUPPORT
+ GAPS_PARAM_CENTRAL_ADDRESS_RESOLUTION = 0x02,
+#endif
+ GAPS_PARAM_DEVICE_NAME_PROPERTY = 0x03,
+ GAPS_PARAM_APPEARANCE_PROPERTY = 0x04,
+} T_GAPS_PARAM_TYPE;
+
+/** @brief Builtin services data struct for notification data to application. */
+typedef struct
+{
+ uint8_t opcode; //!< ref: @ref GAPS_WRITE_TYPE
+ uint16_t len;
+ uint8_t *p_value;
+} T_GAPS_UPSTREAM_MSG_DATA;
+
+/** @brief Builtin services callback data to inform application */
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ uint8_t conn_id;
+ T_GAPS_UPSTREAM_MSG_DATA msg_data;
+} T_GAPS_CALLBACK_DATA;
+
+/** End of GAP_GATT_SERVICE_Exported_Types
+* @}
+*/
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup GAP_GATT_SERVICE_Exported_Functions GAP and GATT Service Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Register callback to builtin services.
+ *
+ * @param[in] p_func Callback to notify app.
+ * @return none.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t appearance_prop = GAPS_PROPERTY_WRITE_ENABLE;
+ uint8_t device_name_prop = GAPS_PROPERTY_WRITE_ENABLE;
+ gaps_set_parameter(GAPS_PARAM_APPEARANCE_PROPERTY, sizeof(appearance_prop), &appearance_prop);
+ gaps_set_parameter(GAPS_PARAM_DEVICE_NAME_PROPERTY, sizeof(device_name_prop), &device_name_prop);
+ gatt_register_callback(gap_service_callback);
+ }
+ T_APP_RESULT gap_service_callback(T_SERVER_ID service_id, void *p_para)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ T_GAPS_CALLBACK_DATA *p_gap_data = (T_GAPS_CALLBACK_DATA *)p_para;
+ APP_PRINT_INFO2("gap_service_callback conn_id = %d msg_type = %d\n", p_gap_data->conn_id,
+ p_gap_data->msg_type);
+ if (p_gap_data->msg_type == SERVICE_CALLBACK_TYPE_WRITE_CHAR_VALUE)
+ {
+ switch (p_gap_data->msg_data.opcode)
+ {
+ case GAPS_WRITE_DEVICE_NAME:
+ {
+ T_LOCAL_NAME device_name;
+ memcpy(device_name.local_name, p_gap_data->msg_data.p_value, p_gap_data->msg_data.len);
+ device_name.local_name[p_gap_data->msg_data.len] = 0;
+ flash_save_local_name(&device_name);
+ }
+ break;
+
+ case GAPS_WRITE_APPEARANCE:
+ {
+ uint16_t appearance_val;
+ T_LOCAL_APPEARANCE appearance;
+
+ LE_ARRAY_TO_UINT16(appearance_val, p_gap_data->msg_data.p_value);
+ appearance.local_appearance = appearance_val;
+ flash_save_local_appearance(&appearance);
+ }
+ break;
+
+ default:
+ break;
+ }
+ }
+ else if (p_gap_data->msg_type == SERVICE_CALLBACK_TYPE_INDIFICATION_NOTIFICATION)
+ {
+ if (p_gap_data->msg_data.opcode == GATT_SERVICE_CHANGE_CCCD_ENABLE)
+ {
+ APP_PRINT_INFO0("GATT_SERVICE_CHANGE_CCCD_ENABLE");
+ }
+ }
+ return result;
+ }
+ * \endcode
+ */
+void gatt_register_callback(void *p_func);
+
+/**
+ * @brief Set GAP service parameter.
+ *
+ * @param[in] param_type parameter type to set: @ref T_GAPS_PARAM_TYPE
+ * @param[in] length value length to be set.
+ * @param[in] p_value value to set.
+ * @return parameter set result.
+ * @retval 0 false
+ * @retval 1 true
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t appearance_prop = GAPS_PROPERTY_WRITE_ENABLE;
+ uint8_t device_name_prop = GAPS_PROPERTY_WRITE_ENABLE;
+ gaps_set_parameter(GAPS_PARAM_APPEARANCE_PROPERTY, sizeof(appearance_prop), &appearance_prop);
+ gaps_set_parameter(GAPS_PARAM_DEVICE_NAME_PROPERTY, sizeof(device_name_prop), &device_name_prop);
+ gatt_register_callback(gap_service_callback);
+ }
+ * \endcode
+ */
+bool gaps_set_parameter(T_GAPS_PARAM_TYPE param_type, uint8_t length, void *p_value);
+
+
+/**
+ * @brief Set the preferred connection parameter.
+ *
+ * @param[in] conn_interval_min Defines minimum value for the connection interval in the
+ following manner:
+ connIntervalmin = Conn_Interval_Min * 1.25 ms
+ Conn_Interval_Min range: 0x0006 to 0x0C80
+ Value of 0xFFFF indicates no specific minimum.
+ Values outside the range (except 0xFFFF) are reserved for
+ future use.
+ * @param[in] conn_interval_max Defines maximum value for the connection interval in the
+ following manner:
+ connIntervalmax = Conn_Interval_Max * 1.25 ms
+ Conn_Interval_Max range: 0x0006 to 0x0C80
+ Shall be equal to or greater than the Conn_Interval_Min.
+ Value of 0xFFFF indicates no specific maximum.
+ Values outside the range (except 0xFFFF) are reserved for
+ future use.
+ * @param[in] slave_latency Defines the slave latency for the connection in number of
+ connection events.
+ Slave latency range: 0x0000 to 0x01F3
+ Values outside the range are reserved for future use.
+ * @param[in] supervision_timeout Defines the connection supervisor timeout multiplier as amultiple of 10ms.
+ Range: 0xFFFF indicates no specific value requested.
+ Range: 0x000A to 0x0C80
+ Time = N * 10 ms
+ Time Range: 100 ms to 32 seconds
+ Values outside the range (except 0xFFFF) are reserved for
+ future use.
+ * @return none
+ */
+void gaps_set_peripheral_preferred_conn_param(uint16_t conn_interval_min,
+ uint16_t conn_interval_max,
+ uint16_t slave_latency,
+ uint16_t supervision_timeout);
+
+/**
+ * @brief Send service changed indication.
+ *
+ * @param[in] conn_id Connection id
+ * @param[in] start_handle Start of Affected Attribute Handle Range
+ * @param[in] end_handle End of Affected Attribute Handle Range
+ * @return parameter set result.
+ * @retval 0 false
+ * @retval 1 true
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t conn_id = 0;
+ uint16_t start_handle = 0x05;
+ uint16_t end_handle = 0xFF;
+ gatts_service_changed_indicate(conn_id, start_handle, end_handle);
+ }
+ * \endcode
+ */
+bool gatts_service_changed_indicate(uint8_t conn_id, uint16_t start_handle, uint16_t end_handle);
+
+/** End of GAP_GATT_SERVICE_Exported_Functions
+* @}
+*/
+
+/** End of GAP_GATT_SERVICE
+* @}
+*/
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _BUILTIN_SERVICES_H_ */
diff --git a/inc/bluetooth/profile/profile_client.h b/inc/bluetooth/profile/profile_client.h
new file mode 100644
index 0000000..ce0ab96
--- /dev/null
+++ b/inc/bluetooth/profile/profile_client.h
@@ -0,0 +1,611 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file profile_client.h
+ * @brief Head file for profile client structure.
+ * @details Common data struct definition.
+ * @author ethan_su
+ * @date 2016-02-18
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef PROFILE_CLIENT_H
+#define PROFILE_CLIENT_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*============================================================================*
+ * Header Files
+ *============================================================================*/
+#include "upperstack_config.h"
+#if F_BT_LE_GATT_CLIENT_SUPPORT
+#include "gatt.h"
+#include <bt_types.h>
+#include "gap_le.h"
+
+
+/** @defgroup GATT_CLIENT_API GATT Client API
+ * @brief GATT client API
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup GATT_Client_Exported_Macros GATT Client Exported Macros
+ * @{
+ */
+#define CLIENT_PROFILE_GENERAL_ID 0xff //!< General Client ID used by application, when directly calls the APIs of profile client layer. Distinguish with other specific client module.
+
+/** End of GATT_Client_Exported_Macros
+* @}
+*/
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup GATT_Client_Exported_Types GATT Client Exported Types
+ * @{
+ */
+
+typedef uint8_t T_CLIENT_ID; //!< Client ID
+
+/* callback related data to inform application. */
+
+
+/** @brief Discovery state during discovery procedure.*/
+typedef enum
+{
+ DISC_STATE_IDLE,
+ DISC_STATE_SRV,
+ DISC_STATE_SRV_DONE,
+ DISC_STATE_RELATION,
+ DISC_STATE_RELATION_DONE,
+ DISC_STATE_CHAR,
+ DISC_STATE_CHAR_DONE,
+ DISC_STATE_CHAR_UUID16_DONE,
+ DISC_STATE_CHAR_UUID128_DONE,
+ DISC_STATE_CHAR_DESCRIPTOR,
+ DISC_STATE_CHAR_DESCRIPTOR_DONE,
+ DISC_STATE_FAILED
+} T_DISCOVERY_STATE;
+
+/** @brief Discovery result type*/
+typedef enum
+{
+ DISC_RESULT_ALL_SRV_UUID16,
+ DISC_RESULT_ALL_SRV_UUID128,
+ DISC_RESULT_SRV_DATA,
+ DISC_RESULT_CHAR_UUID16,
+ DISC_RESULT_CHAR_UUID128,
+ DISC_RESULT_CHAR_DESC_UUID16,
+ DISC_RESULT_CHAR_DESC_UUID128,
+ DISC_RESULT_RELATION_UUID16,
+ DISC_RESULT_RELATION_UUID128,
+ DISC_RESULT_BY_UUID16_CHAR,
+ DISC_RESULT_BY_UUID128_CHAR,
+} T_DISCOVERY_RESULT_TYPE;
+
+/** @brief GATT write type*/
+typedef enum
+{
+ GATT_WRITE_TYPE_REQ = 0x01, /**< ATT "Write Request" */
+ GATT_WRITE_TYPE_CMD = 0x02, /**< ATT "Write Command" */
+ GATT_WRITE_TYPE_SIGNED_CMD = 0x04 /**< ATT "Signed Write Command" */
+} T_GATT_WRITE_TYPE;
+
+typedef struct
+{
+ uint16_t att_handle; /**< The handle for the service declaration */
+ uint16_t end_group_handle; /**< The handle of the last attribute
+ within the service definition */
+ uint16_t uuid16; /**< 16 bit UUID */
+} T_GATT_SERVICE_ELEM16;
+
+typedef struct
+{
+ uint16_t att_handle; /**< The handle for the service declaration */
+ uint16_t end_group_handle;
+ /**< The handle of the last attribute within the service definition */
+ uint8_t uuid128[16]; /**< 128 bit UUID */
+} T_GATT_SERVICE_ELEM128;
+
+
+typedef struct
+{
+ uint16_t att_handle; /**< The handle for the service declaration */
+ uint16_t end_group_handle;
+ /**< The handle of the last attribute within the service definition */
+} T_GATT_SERVICE_BY_UUID_ELEM;
+
+/** @brief Characteristic declaration for 16 bit UUID.*/
+typedef struct
+{
+ uint16_t decl_handle; /**< Attribute handle */
+ uint16_t properties; /**< Characteristic Properties, high nibble is reserved */
+ uint16_t value_handle; /**< Characteristic Value Handle */
+ uint16_t uuid16; /**< 16-bit Bluetooth UUID for Characteristic Value */
+} T_GATT_CHARACT_ELEM16;
+
+/** @brief Characteristic declaration for 128 bit UUID.*/
+typedef struct
+{
+ uint16_t decl_handle; /**< Attribute handle */
+ uint16_t properties; /**< Characteristic Properties, high nibble is reserved */
+ uint16_t value_handle; /**< Characteristic Value Handle */
+ uint8_t uuid128[16]; /**< 128-bit UUID for Characteristic Value */
+} T_GATT_CHARACT_ELEM128;
+
+/** @brief Characteristic descriptor for 16 bit UUID.*/
+typedef struct
+{
+ uint16_t handle; /**< Attribute handle */
+ uint16_t uuid16; /**< 16 bit UUID */
+} T_GATT_CHARACT_DESC_ELEM16;
+
+/** @brief Characteristic descriptor for 128 bit UUID.*/
+typedef struct
+{
+ uint16_t handle; /**< Attribute handle */
+ uint8_t uuid128[16]; /**< 128 bit UUID */
+} T_GATT_CHARACT_DESC_ELEM128;
+
+/** @brief Relationship discovery for 16 bit UUID.*/
+typedef struct
+{
+ uint16_t decl_handle;
+ uint16_t att_handle;
+ uint16_t end_group_handle;
+ uint16_t uuid16;
+} T_GATT_RELATION_ELEM16;
+
+/** @brief Relationship discovery for 128 bit UUID.*/
+typedef struct
+{
+ uint16_t decl_handle;
+ uint16_t att_handle;
+ uint16_t end_group_handle;
+ uint8_t uuid128[16];
+} T_GATT_RELATION_ELEM128;
+
+/** @brief Discovery result data*/
+typedef union
+{
+ T_GATT_SERVICE_ELEM16 *p_srv_uuid16_disc_data;
+ T_GATT_SERVICE_ELEM128 *p_srv_uuid128_disc_data;
+ T_GATT_SERVICE_BY_UUID_ELEM *p_srv_disc_data;
+ T_GATT_CHARACT_ELEM16 *p_char_uuid16_disc_data;
+ T_GATT_CHARACT_ELEM128 *p_char_uuid128_disc_data;
+ T_GATT_CHARACT_DESC_ELEM16 *p_char_desc_uuid16_disc_data;
+ T_GATT_CHARACT_DESC_ELEM128 *p_char_desc_uuid128_disc_data;
+ T_GATT_RELATION_ELEM16 *p_relation_uuid16_disc_data;
+ T_GATT_RELATION_ELEM128 *p_relation_uuid128_disc_data;
+} T_DISCOVERY_RESULT_DATA;
+
+/** @defgroup General_cb_data General Client Callback Data
+ * @{
+ */
+/** @brief The callback data of CLIENT_APP_CB_TYPE_DISC_STATE.
+ *
+ * Discovery procedure related data to inform application
+ */
+typedef struct
+{
+ T_DISCOVERY_STATE disc_state;
+} T_DISC_STATE_CB_DATA;
+
+/** @brief The callback data of CLIENT_APP_CB_TYPE_DISC_RESULT.
+ *
+ * Discovery result data will be sent to upper through the callback
+ */
+typedef struct
+{
+ T_DISCOVERY_RESULT_TYPE result_type;
+ T_DISCOVERY_RESULT_DATA result_data;
+} T_DISC_RESULT_CB_DATA;
+
+
+/** @brief The callback type of T_CLIENT_APP_CB_DATA.
+ *
+ * Message data type, when data sent to app directly
+ */
+typedef enum
+{
+ CLIENT_APP_CB_TYPE_DISC_STATE,
+ CLIENT_APP_CB_TYPE_DISC_RESULT
+} T_CLIENT_CB_TYPE;
+
+/** @brief The callback data of T_CLIENT_APP_CB_DATA.
+ *
+ * Client received data from server, when no specific client registered, will be sent to app directly
+ */
+typedef union
+{
+ T_DISC_STATE_CB_DATA disc_state_data;
+ T_DISC_RESULT_CB_DATA disc_result_data;
+} T_CLIENT_CB_DATA;
+
+/** @brief The General Client Callback Data Struct.
+ *
+ * Callback data sent to application directly from client, include type and content
+ */
+typedef struct
+{
+ T_CLIENT_CB_TYPE cb_type;
+ T_CLIENT_CB_DATA cb_content;
+} T_CLIENT_APP_CB_DATA;
+/** End of General_cb_data
+ * @}
+ */
+
+
+/** @defgroup pfnSpecificClientAppCB_t1 General Client Callback Function Point Definition
+ * @{ function ponter used in each specific profile, to send events to application
+ */
+typedef T_APP_RESULT(*P_FUN_GENERAL_APP_CB)(T_CLIENT_ID client_id, uint8_t conn_id, void *p_data);
+/** End of pfnSpecificClientAppCB_t1
+ * @}
+ */
+
+
+/** @defgroup Specific_cb Specific Client Callback Function Point Definition
+ * @{ Function ponter used in each specific client module, to send events to specific client module.
+ */
+typedef void (*P_FUN_DISCOVER_STATE_CB)(uint8_t conn_id, T_DISCOVERY_STATE discovery_state);
+typedef void (*P_FUN_DISCOVER_RESULT_CB)(uint8_t conn_id, T_DISCOVERY_RESULT_TYPE result_type,
+ T_DISCOVERY_RESULT_DATA result_data);
+typedef void (*P_FUN_READ_RESULT_CB)(uint8_t conn_id, uint16_t cause, uint16_t handle,
+ uint16_t value_size, uint8_t *p_value);
+typedef void (*P_FUN_WRITE_RESULT_CB)(uint8_t conn_id, T_GATT_WRITE_TYPE type, uint16_t handle,
+ uint16_t cause, uint8_t credits);
+typedef T_APP_RESULT(*P_FUN_NOTIFY_IND_RESULT_CB)(uint8_t conn_id, bool notify, uint16_t handle,
+ uint16_t value_size, uint8_t *p_value);
+typedef void (*P_FUN_DISCONNECT_CB)(uint8_t conn_id);
+/** End of Specific_cb
+ * @}
+ */
+
+/** @defgroup T_FUN_CLIENT_CBS Specific Client Callback Functions Struct
+ * @{
+ */
+typedef struct
+{
+ P_FUN_DISCOVER_STATE_CB discover_state_cb; //!< Discovery state callback function pointer
+ P_FUN_DISCOVER_RESULT_CB discover_result_cb; //!< Discovery reault callback function pointer
+ P_FUN_READ_RESULT_CB read_result_cb; //!< Read response callback function pointer
+ P_FUN_WRITE_RESULT_CB write_result_cb; //!< Write result callback function pointer
+ P_FUN_NOTIFY_IND_RESULT_CB notify_ind_result_cb;//!< Notify Indication callback function pointer
+ P_FUN_DISCONNECT_CB disconnect_cb; //!< Disconnection callback function pointer
+} T_FUN_CLIENT_CBS;
+/** End of T_FUN_CLIENT_CBS * @} */
+
+/** End of GATT_Client_Exported_Types
+* @}
+*/
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup GATT_Client_Exported_Functions GATT Client Exported Functions
+ * @{
+ */
+/**
+ * @brief Initialize parameters of GATT client.
+ *
+ * @param[in] client_num Set the number of clients that needs to register.
+ * @retval None
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ simple_ble_client_id = simp_ble_add_client(app_client_callback);
+ client_register_general_client_cb(app_client_callback);
+ }
+ * \endcode
+ */
+void client_init(uint8_t client_num);
+
+/**
+ * @brief Used by application, register general client callback.
+ * @param[in] p_fun_cb Function offered by application.
+ * @retval None
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ client_init(1);
+ simple_ble_client_id = simp_ble_add_client(app_client_callback);
+ client_register_general_client_cb(app_client_callback);
+ }
+ * \endcode
+ */
+void client_register_general_client_cb(P_FUN_GENERAL_APP_CB p_fun_cb);
+
+/**
+ * @brief Used by specific client, register callback.
+ * @param[in,out] p_out_client_id Client ID generated for registered specific client module.
+ * @param[in] client_cbs Callback functions implemented in specific client module.
+ * @retval true Register successful.
+ * @retval false Register failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+
+ T_CLIENT_ID simp_ble_add_client(P_FUN_GENERAL_APP_CB app_cb, uint8_t link_num)
+ {
+ uint16_t size;
+ if (link_num > SIMP_MAX_LINKS)
+ {
+ APP_PRINT_ERROR1("simp_ble_add_client: invalid link_num %d", link_num);
+ return 0xff;
+ }
+ if (false == client_register_spec_client_cb(&simp_client, &simp_ble_client_cbs))
+ {
+ simp_client = CLIENT_PROFILE_GENERAL_ID;
+ APP_PRINT_ERROR0("simp_ble_add_client failed");
+ return simp_client;
+ }
+ APP_PRINT_INFO1("simp_ble_add_client: simp_client %d", simp_client);
+
+ simp_client_cb = app_cb;
+ simp_link_num = link_num;
+ size = simp_link_num * sizeof(T_SIMP_LINK);
+ simp_table = os_mem_zalloc(RAM_TYPE_DATA_ON, size);
+
+ return simp_client;
+ }
+ * \endcode
+ */
+bool client_register_spec_client_cb(T_CLIENT_ID *p_out_client_id,
+ const T_FUN_CLIENT_CBS *client_cbs);
+
+/**
+ * @brief Send discovery all primary services request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_all_primary_srv_discovery(uint8_t conn_id, T_CLIENT_ID client_id);
+
+/**
+ * @brief Send discovery services by 16 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] uuid16 16 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_by_uuid_srv_discovery(uint8_t conn_id, T_CLIENT_ID client_id, uint16_t uuid16);
+
+/**
+ * @brief Send discovery services by 128 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] p_uuid128 128 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_by_uuid128_srv_discovery(uint8_t conn_id, T_CLIENT_ID client_id,
+ uint8_t *p_uuid128);
+
+/**
+ * @brief Send discovery relationship services request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_relationship_discovery(uint8_t conn_id, T_CLIENT_ID client_id,
+ uint16_t start_handle, uint16_t end_handle);
+
+/**
+ * @brief Send discovery characteristics request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_all_char_discovery(uint8_t conn_id, T_CLIENT_ID client_id, uint16_t start_handle,
+ uint16_t end_handle);
+
+/**
+ * @brief Send discovery characteristics request by caracteristic uuid.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] uuid16 16bit characteristic uuid to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_by_uuid_char_discovery(uint8_t conn_id, T_CLIENT_ID client_id,
+ uint16_t start_handle,
+ uint16_t end_handle, uint16_t uuid16);
+/**
+ * @brief Send discovery characteristics request by caracteristic uuid.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] p_uuid128 128bit characteristic uuid to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_by_uuid128_char_discovery(uint8_t conn_id, T_CLIENT_ID client_id,
+ uint16_t start_handle,
+ uint16_t end_handle, uint8_t *p_uuid128);
+/**
+ * @brief Send discovery characteristics descriptor request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @retval GAP_CAUSE_SUCCESS Discovery request success.
+ * @retval other Discovery request failed.
+ */
+T_GAP_CAUSE client_all_char_descriptor_discovery(uint8_t conn_id, T_CLIENT_ID client_id,
+ uint16_t start_handle, uint16_t end_handle);
+
+/**
+ * @brief Read characteristic by handle request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] handle Request handle.
+ * @retval GAP_CAUSE_SUCCESS Read request success.
+ * @retval other Read request failed.
+ */
+T_GAP_CAUSE client_attr_read(uint8_t conn_id, T_CLIENT_ID client_id, uint16_t handle);
+
+/**
+ * @brief Read characteristic by 16 bit UUID request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] start_handle Start handle of range to be searched.
+ * @param[in] end_handle End handle of range to be searched.
+ * @param[in] uuid16 Request 16 bit UUID.
+ * @param[in] p_uuid128 Request 128 bit UUID.
+ * @retval GAP_CAUSE_SUCCESS Read request success.
+ * @retval other Read request failed.
+ */
+T_GAP_CAUSE client_attr_read_using_uuid(uint8_t conn_id, T_CLIENT_ID client_id,
+ uint16_t start_handle,
+ uint16_t end_handle, uint16_t uuid16, uint8_t *p_uuid128);
+/**
+ * @brief Write characteristic request.
+ * @param[in] conn_id Connection ID
+ * @param[in] client_id Client ID of specific client module.
+ * @param[in] write_type Type of write.
+ * @param[in] handle Attribute handle.
+ * @param[in] length Length of data to be written.
+ If write_type is GATT_WRITE_TYPE_REQ, range of length is from 0 to 512.
+ If write_type is GATT_WRITE_TYPE_CMD, range of length is from 0 to (mtu_size - 3).
+ If write_type is GATT_WRITE_TYPE_SIGNED_CMD, range of length is from 0 to (mtu_size - 15).
+ uint16_t mtu_size is acquired by le_get_conn_param(GAP_PARAM_CONN_MTU_SIZE, &mtu_size, conn_id).
+ * @param[in] p_data Point to the data to be written.
+ * @retval GAP_CAUSE_SUCCESS: Write request success.
+ * @retval other: Write request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ //if write_type is GATT_WRITE_TYPE_SIGNED_CMD, GAP_MSG_LE_GATT_SIGNED_STATUS_INFO will be notified to app
+ T_APP_RESULT app_gap_callback(uint8_t cb_type, void *p_cb_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ T_LE_CB_DATA cb_data;
+ memcpy(&cb_data, p_cb_data, sizeof(T_LE_CB_DATA));
+ APP_PRINT_TRACE1("app_gap_callback: cb_type = %d", cb_type);
+ switch (cb_type)
+ {
+ ...
+ case GAP_MSG_LE_GATT_SIGNED_STATUS_INFO:
+ APP_PRINT_INFO5("GAP_MSG_LE_GATT_SIGNED_STATUS_INFO:conn_id %d, cause 0x%x, update_local %d, local_sign_count %d,remote_sign_count %d",
+ cb_data.p_le_gatt_signed_status_info->conn_id,
+ cb_data.p_le_gatt_signed_status_info->cause,
+ cb_data.p_le_gatt_signed_status_info->update_local,
+ cb_data.p_le_gatt_signed_status_info->local_sign_count,
+ cb_data.p_le_gatt_signed_status_info->remote_sign_count);
+ break;
+ ...
+ }
+ }
+ * \endcode
+ */
+T_GAP_CAUSE client_attr_write(uint8_t conn_id, T_CLIENT_ID client_id,
+ T_GATT_WRITE_TYPE write_type,
+ uint16_t handle, uint16_t length, uint8_t *p_data);
+
+/**
+ * @brief Confirm from application when receive indication from server.
+ * @param[in] conn_id Connection ID indicate which link is.
+ * @retval true: Confirm OK.
+ * @retval false: Confirm failed.
+ */
+T_GAP_CAUSE client_attr_ind_confirm(uint8_t conn_id);
+
+/**
+ * @brief Get the header point of the notification data buffer.
+ * This function is used to get the header buffer point of the notification command data.
+ * This function only can be called in notify_ind_result_cb.
+ *
+ * @param[in] conn_id Connection id indicate which link is.
+ * @param[in,out] pp_buffer Pointer to the address of the buffer.
+ * @param[in,out] p_offset Pointer to the offset of the data.
+ * @return Buffer get result
+ * @retval true Success.
+ * @retval false Failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ uint8_t *p_data_buf;
+ uint16_t data_offset;
+ static T_APP_RESULT simp_ble_client_notif_ind_result_cb(uint8_t conn_id, bool notify,
+ uint16_t handle,
+ uint16_t value_size, uint8_t *p_value)
+ {
+ ......
+ client_get_notify_data_buffer(conn_id, &p_data_buf, &data_offset);
+ return APP_RESULT_NOT_RELEASE;
+ }
+ void release(void)
+ {
+ if(p_data_buf != NULL)
+ {
+ gap_buffer_free(p_data_buf);
+ p_data_buf = NULL;
+ }
+ }
+ * \endcode
+ */
+bool client_get_notify_data_buffer(uint8_t conn_id, uint8_t **pp_buffer, uint16_t *p_offset);
+
+/**
+ * @brief Send the exchange MTU request.
+ * This function is used to send the exchange MTU request.
+ *
+ * @param[in] conn_id Connection id indicate which link is.
+ * @retval GAP_CAUSE_SUCCESS: Write request success.
+ * @retval other: Write request failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ uint8_t *p_data_buf;
+ uint16_t data_offset;
+ static T_USER_CMD_PARSE_RESULT cmd_send_mtu_req(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ T_GAP_CAUSE cause;
+ uint8_t conn_id = p_parse_value->dw_param[0];
+
+ cause = client_send_exchange_mtu_req(conn_id);
+ return (T_USER_CMD_PARSE_RESULT)cause;
+ }
+ * \endcode
+ */
+T_GAP_CAUSE client_send_exchange_mtu_req(uint8_t conn_id);
+
+/** End of GATT_Client_Exported_Functions
+* @}
+*/
+
+/** End of GATT_CLIENT_API
+* @}
+*/
+#endif
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PROFILE_CLIENT_H */
+
diff --git a/inc/bluetooth/profile/profile_server.h b/inc/bluetooth/profile/profile_server.h
new file mode 100644
index 0000000..f6b380a
--- /dev/null
+++ b/inc/bluetooth/profile/profile_server.h
@@ -0,0 +1,452 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file profile_server.h
+ * @brief Head file for server structure.
+ * @details Common data struct definition.
+ * @author
+ * @date 2017-02-18
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef PROFILE_SERVER_H
+#define PROFILE_SERVER_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/*============================================================================*
+ * Header Files
+ *============================================================================*/
+#include "upperstack_config.h"
+#if F_BT_LE_GATT_SERVER_SUPPORT
+#include <bt_types.h>
+#include "gatt.h"
+#include "gap_le.h"
+
+
+/** @defgroup GATT_SERVER_API GATT Server API
+ * @brief GATT Server API
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup GATT_SERVER_Exported_Macros GATT Server Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup General_Service_ID General Service ID
+ * @brief Service ID for general profile events.
+ * @{
+ */
+#define SERVICE_PROFILE_GENERAL_ID 0xff
+/** @} */
+
+/** End of GATT_SERVER_Exported_Macros
+ * @}
+ */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup GATT_SERVER_Exported_Types GATT Server Exported Types
+ * @brief
+ * @{
+ */
+
+typedef uint8_t T_SERVER_ID; //!< Service ID
+
+/** @brief GATT write data type*/
+typedef enum
+{
+ WRITE_REQUEST, /**< Write request. */
+ WRITE_WITHOUT_RESPONSE, /**< Write without response. */
+ WRITE_SIGNED_WITHOUT_RESPONSE, /**< Signed write without response. */
+ WRITE_LONG, /**< Write long request. */
+} T_WRITE_TYPE;
+
+/** @brief GATT PDU type*/
+typedef enum
+{
+ GATT_PDU_TYPE_ANY = 0x00, /**< Any PDU type. */
+ GATT_PDU_TYPE_NOTIFICATION = 0x01, /**< Notification PDU type. */
+ GATT_PDU_TYPE_INDICATION = 0x02 /**< Indication PDU type. */
+} T_GATT_PDU_TYPE;
+
+/** @brief Event type to inform app*/
+typedef enum
+{
+ SERVICE_CALLBACK_TYPE_INDIFICATION_NOTIFICATION = 1, /**< CCCD update event */
+ SERVICE_CALLBACK_TYPE_READ_CHAR_VALUE = 2, /**< client read event */
+ SERVICE_CALLBACK_TYPE_WRITE_CHAR_VALUE = 3, /**< client write event */
+} T_SERVICE_CALLBACK_TYPE;
+
+/** @defgroup GATT_SERVER_CB_DATA App Callback data
+ * @brief data for profile to inform application.
+ * @{
+ */
+/** @brief Event ID */
+typedef enum
+{
+ PROFILE_EVT_SRV_REG_COMPLETE, /**< Services register complete event
+ when application calls server_add_service before calling gap_start_bt_stack. */
+ PROFILE_EVT_SEND_DATA_COMPLETE, /**< Notification or indication data send complete event. */
+ PROFILE_EVT_SRV_REG_AFTER_INIT_COMPLETE, /**< Services register complete event
+ when application calls server_add_service after receiving @ref GAP_INIT_STATE_STACK_READY. */
+} T_SERVER_CB_TYPE;
+
+/** @brief The callback data of PROFILE_EVT_SRV_REG_COMPLETE */
+typedef enum
+{
+ GATT_SERVER_SUCCESS,
+ GATT_SERVER_FAIL
+} T_SERVER_RESULT;
+
+/** @brief The callback data of PROFILE_EVT_SRV_REG_AFTER_INIT_COMPLETE */
+typedef struct
+{
+ T_SERVER_RESULT result;
+ T_SERVER_ID service_id;
+ uint16_t cause;
+} T_SERVER_REG_AFTER_INIT_RESULT;
+
+/** @brief The callback data of PROFILE_EVT_SEND_DATA_COMPLETE */
+typedef struct
+{
+ uint16_t credits;
+ uint8_t conn_id;
+ T_SERVER_ID service_id;
+ uint16_t attrib_idx;
+ uint16_t cause;
+} T_SEND_DATA_RESULT;
+
+/** @brief Service callback data */
+typedef union
+{
+ T_SERVER_RESULT service_reg_result;
+ T_SEND_DATA_RESULT send_data_result;
+ T_SERVER_REG_AFTER_INIT_RESULT server_reg_after_init_result;
+} T_SERVER_CB_DATA;
+
+typedef struct
+{
+ T_SERVER_CB_TYPE eventId; /**< @brief EventId defined upper */
+ T_SERVER_CB_DATA event_data; /**< @brief Event data */
+} T_SERVER_APP_CB_DATA;
+/** @} End of GATT_SERVER_CB_DATA */
+
+
+
+/** @defgroup P_FUN_WRITE_IND_POST_PROC TGATTDWriteIndPostProc
+ * @brief Call back function to execute some post procedure after handle write request from client.
+ * @{
+ */
+typedef void (* P_FUN_WRITE_IND_POST_PROC)(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attrib_index, uint16_t length,
+ uint8_t *p_value);
+/** @} End of P_FUN_WRITE_IND_POST_PROC */
+
+/** @defgroup Specific_srv_cb Specific Service Callback Function Point Definition
+ * @{ Function ponter used in each specific service module, to send events to specific service module.
+ */
+typedef T_APP_RESULT(*P_FUN_GATT_READ_ATTR_CB)(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attrib_index,
+ uint16_t offset, uint16_t *p_length, uint8_t **pp_value);
+typedef T_APP_RESULT(*P_FUN_GATT_WRITE_ATTR_CB)(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attrib_index, T_WRITE_TYPE write_type,
+ uint16_t length, uint8_t *p_value, P_FUN_WRITE_IND_POST_PROC *p_write_post_proc);
+typedef void (*P_FUN_GATT_CCCD_UPDATE_CB)(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attrib_index, uint16_t ccc_bits);
+/** End of Specific_srv_cb
+ * @}
+ */
+
+/** @defgroup P_FUN_SERVER_GENERAL_CB General Server Callback Function Point Definition
+ * @brief function ponter Type used to generate Call back, to send events to application.
+ * @{
+ */
+typedef T_APP_RESULT(*P_FUN_SERVER_GENERAL_CB)(T_SERVER_ID service_id, void *p_para);
+/** @} End of pfnAPPHandleInfoCB_t1 */
+
+
+/** @brief GATT service callbacks */
+typedef struct
+{
+ P_FUN_GATT_READ_ATTR_CB read_attr_cb; /**< Read callback function pointer.
+ Return value: @ref T_APP_RESULT. */
+ P_FUN_GATT_WRITE_ATTR_CB write_attr_cb; /**< Write callback function pointer.
+ Return value: @ref T_APP_RESULT. */
+ P_FUN_GATT_CCCD_UPDATE_CB cccd_update_cb; /**< Update cccd callback function pointer. */
+} T_FUN_GATT_SERVICE_CBS;
+
+/** End of GATT_SERVER_Exported_Types
+ * @}
+ */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup GATT_SERVER_Exported_Functions GATT Server Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Initialize parameters of GATT Server.
+ *
+ * @param[in] service_num Set the number of services that needs to register.
+ * @retval None
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ server_init(1);
+ simp_srv_id = simp_ble_service_add_service(app_profile_callback);
+ server_register_app_cb(app_profile_callback);
+ }
+ * \endcode
+ */
+void server_init(uint8_t service_num);
+
+/**
+ * @brief Register builtin services including GAP and GATT service.
+ *
+ * If application does not need to register GAP and GATT service.
+ * Application shall call server_builtin_service_reg(false) before server_init().
+ *
+ * @param[in] reg Whether to register builtin services. Default value is true.
+ * @retval None
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ server_builtin_service_reg(false);
+ server_init(1);
+ simp_srv_id = simp_ble_service_add_service(app_profile_callback);
+ server_register_app_cb(app_profile_callback);
+ }
+ * \endcode
+ */
+void server_builtin_service_reg(bool reg);
+
+/**
+ * @brief Register specific service without start handle
+ *
+ * Add specific service information to gatt_svc_table struct, will be registered to GATT later.
+ *
+ * @param[in,out] p_out_service_id Service ID of specific service.
+ * @param[in] p_database Database pointer of specific service.
+ * @param[in] length Length of Database of specific service.
+ * @param[in] srv_cbs Service callback functions of specific service.
+ * @retval true Add service success
+ * @retval false Add service failed
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_SERVER_ID bas_add_service(void *p_func)
+ {
+ T_SERVER_ID service_id;
+ if (false == server_add_service(&service_id,
+ (uint8_t *)bas_attr_tbl,
+ bas_attr_tbl_size,
+ bas_cbs))
+ {
+ APP_PRINT_ERROR1("bas_add_service: service_id %d", service_id);
+ service_id = 0xff;
+ }
+ pfn_bas_cb = (P_FUN_SERVER_GENERAL_CB)p_func;
+ return service_id;
+ }
+ * \endcode
+ */
+bool server_add_service(T_SERVER_ID *p_out_service_id, uint8_t *p_database, uint16_t length,
+ const T_FUN_GATT_SERVICE_CBS srv_cbs);
+
+/**
+ * @brief Register specific service with start handle
+ *
+ * Add specific service information to gatt_svc_table struct, will be registered to GATT later.
+ *
+ * @param[in,out] p_out_service_id Service ID of specific service.
+ * @param[in] p_database Database pointer of specific service.
+ * @param[in] length Length of Database of specific service.
+ * @param[in] srv_cbs Service callback functions of specific service.
+ * @param[in] start_handle Start handle of this service.
+ * @retval true Add service success
+ * @retval false Add service failed
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_SERVER_ID bas_add_service(void *p_func)
+ {
+ T_SERVER_ID service_id;
+ if (false == server_add_service_by_start_handle(&service_id,
+ (uint8_t *)bas_attr_tbl,
+ bas_attr_tbl_size,
+ bas_cbs, 0x00f0))
+ {
+ APP_PRINT_ERROR1("bas_add_service: service_id %d", service_id);
+ service_id = 0xff;
+ }
+ pfn_bas_cb = (P_FUN_SERVER_GENERAL_CB)p_func;
+ return service_id;
+ }
+ * \endcode
+ */
+bool server_add_service_by_start_handle(uint8_t *p_out_service_id, uint8_t *p_database,
+ uint16_t length,
+ const T_FUN_GATT_SERVICE_CBS srv_cbs, uint16_t start_handle);
+/**
+ * @brief Register callback function to send events to application.
+ *
+ * @param[in] p_fun_cb Callback function.
+ * @retval None
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ server_init(1);
+ simp_srv_id = simp_ble_service_add_service(app_profile_callback);
+ server_register_app_cb(app_profile_callback);
+ }
+ * \endcode
+ */
+void server_register_app_cb(P_FUN_SERVER_GENERAL_CB p_fun_cb);
+
+/**
+ * @brief Confirm from application when receive read Request from client.
+ * @param[in] conn_id Connection id indicate which link is.
+ * @param[in] service_id Service ID.
+ * @param[in] attrib_index Attribute index of attribute to read confirm from application.
+ * @param[in] p_data Point to the readed value.
+ * @param[in] length The length of the data.
+ * @param[in] cause Cause for read confirm. @ref T_APP_RESULT
+ * @retval true: confirm from app OK.
+ * @retval false: confirm from app failed.
+ */
+bool server_attr_read_confirm(uint8_t conn_id, T_SERVER_ID service_id, uint16_t attrib_index,
+ uint8_t *p_data, uint16_t length, T_APP_RESULT cause);
+/**
+ * @brief Confirm from application when receive Execute Write Request from client.
+ * @param[in] conn_id Connection id indicate which link is.
+ * @param[in] cause Cause for execute write confirm. @ref T_APP_RESULT
+ * @param[in] handle Gatt attribute handle.
+ * @retval true: confirm from app OK.
+ * @retval false: confirm from app failed.
+ */
+bool server_exec_write_confirm(uint8_t conn_id, uint16_t cause, uint16_t handle);
+
+/**
+ * @brief Confirm from application when receive Write Request from client.
+ * @param[in] conn_id Connection id indicate which link is.
+ * @param[in] service_id Service ID.
+ * @param[in] attrib_index Attribute index of attribute to write confirm from application.
+ * @param[in] cause Write request app handle result, APP_RESULT_SUCCESS or other. @ref T_APP_RESULT
+ * @retval true: confirm from app OK.
+ * @retval false: confirm from app failed.
+ */
+bool server_attr_write_confirm(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attrib_index, T_APP_RESULT cause);
+
+/**
+ * @brief Send characteristic value to peer device.
+ *
+ * @param[in] conn_id Connection id indicate which link is.
+ * @param[in] service_id Service ID.
+ * @param[in] attrib_index Attribute index of characteristic.
+ * @param[in] p_data Point to data to be sent.
+ * @param[in] data_len Length of value to be sent, range: 0~(mtu_size - 3).
+ uint16_t mtu_size is acquired by le_get_conn_param(GAP_PARAM_CONN_MTU_SIZE, &mtu_size, conn_id).
+ * @param[in] type GATT pdu type.
+ * @return Data sent result
+ * @retval true Success.
+ * @retval false Failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ bool bas_battery_level_value_notify(uint8_t conn_id, uint8_t service_id, uint8_t battery_level)
+ {
+ return server_send_data(conn_id, service_id, GATT_SVC_BAS_BATTERY_LEVEL_INDEX, &battery_level,
+ sizeof(battery_level), GATT_PDU_TYPE_ANY);
+ }
+ * \endcode
+ */
+bool server_send_data(uint8_t conn_id, T_SERVER_ID service_id, uint16_t attrib_index,
+ uint8_t *p_data, uint16_t data_len, T_GATT_PDU_TYPE type);
+
+uint16_t server_get_start_handle(T_SERVER_ID service_id);
+/**
+ * @brief Get the header point of the write command data buffer.
+ * This function is used to get the buffer point of the write command data.
+ * This function only can be called in write_attr_cb.
+ *
+ * @param[in] conn_id Connection id indicate which link is.
+ * @param[in,out] pp_buffer Pointer to the address of the buffer.
+ * @param[in,out] p_offset Pointer to the offset of the data.
+ * @return Buffer get result
+ * @retval true Success.
+ * @retval false Failed.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ uint8_t *p_data_buf;
+ uint16_t data_offset;
+ T_APP_RESULT simp_ble_service_attr_write_cb(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attrib_index, T_WRITE_TYPE write_type, uint16_t length, uint8_t *p_value,
+ P_FUN_WRITE_IND_POST_PROC *p_write_ind_post_proc)
+ {
+ ......
+ server_get_write_cmd_data_buffer(conn_id, &p_data_buf, &data_offset);
+ return APP_RESULT_NOT_RELEASE;
+ }
+ void release(void)
+ {
+ if(p_data_buf != NULL)
+ {
+ gap_buffer_free(p_data_buf);
+ p_data_buf = NULL;
+ }
+ }
+ * \endcode
+ */
+bool server_get_write_cmd_data_buffer(uint8_t conn_id, uint8_t **pp_buffer, uint16_t *p_offset);
+
+/**
+ * @brief Get the start handle of the service
+ *
+ * @param[in] service_id Service ID.
+ * @return Start handle
+ * @retval 0 Failed.
+ * @retval other Success.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint16_t start_handle;
+ start_handle = server_get_start_handle(simp_srv_id);
+ }
+ * \endcode
+ */
+uint16_t server_get_start_handle(T_SERVER_ID service_id);
+
+/** @} End of GATT_SERVER_Exported_Functions */
+
+/** @} End of GATT_SERVER_API */
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* PROFILE_SERVER_H */
diff --git a/inc/bluetooth/profile/server/atvv_service.h b/inc/bluetooth/profile/server/atvv_service.h
new file mode 100644
index 0000000..8ce2552
--- /dev/null
+++ b/inc/bluetooth/profile/server/atvv_service.h
@@ -0,0 +1,227 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file atvv_service.h
+ * @brief Head file for using ATV voice service.
+ * @details ATVV data structs and external functions declaration.
+ * @author Chenjie Jin
+ * @date 2017-12-8
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _ATVV_H_
+#define _ATVV_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+/** @defgroup ATVV ATV Voice Service
+ * @brief ATV voice service
+ * @{
+ */
+
+/** @defgroup ATVV_Exported_Constants ATVV Exported Constants
+ * @brief macros that other .c files may use all defined here
+ * @{
+ */
+
+///@cond
+#define ATVV_VERSION_1_0 0x0100
+#define ATVV_VERSION_0_4 0x0004
+
+#define ATTV_CODEC_MASK_8K_ADPCM 0x0001
+#define ATTV_CODEC_MASK_16K_ADPCM 0x0002
+#define ATTV_CODEC_MASK_OPUS 0x0004
+
+#define ATVV_CHAR_RX_DATA_LEN 20
+#define ATVV_CHAR_CTL_DATA_LEN 20
+#define ATVV_CHAR_WRITE_DATA_LEN 20
+
+/** @brief ATVV related services UUIDs */
+#define GATT_UUID_ATV_CHAR_TX 0x64, 0xB6, 0x17, 0xF6, 0x01, 0xAF, 0x7D, 0xBC, 0x05, 0x4F, 0x21, 0x5A, 0x02, 0x00, 0x5E, 0xAB
+#define GATT_UUID_ATV_CHAR_RX 0x64, 0xB6, 0x17, 0xF6, 0x01, 0xAF, 0x7D, 0xBC, 0x05, 0x4F, 0x21, 0x5A, 0x03, 0x00, 0x5E, 0xAB
+#define GATT_UUID_ATV_CHAR_CTL 0x64, 0xB6, 0x17, 0xF6, 0x01, 0xAF, 0x7D, 0xBC, 0x05, 0x4F, 0x21, 0x5A, 0x04, 0x00, 0x5E, 0xAB
+
+/** @brief Index defines for Characteristic's value */
+#define GATT_SVC_ATVV_CHAR_TX_VALUE_INDEX 2
+#define GATT_SVC_ATVV_CHAR_RX_VALUE_INDEX 4
+#define GATT_SVC_ATVV_CHAR_RX_CCCD_INDEX 5
+#define GATT_SVC_ATVV_CHAR_CTL_VALUE_INDEX 7
+#define GATT_SVC_ATVV_CHAR_CTL_CCCD_INDEX 8
+///@endcond
+
+/** @} End of ATVV_Exported_Constants */
+
+/** @defgroup ATVV_Exported_Types IAS Exported Types
+ * @brief types that other .c files may use all defined here
+ * @{
+ */
+/* Add all public types here */
+/** @defgroup ATVV_Callback_Data ATTB Callback Data
+ * @brief ATVV data struct for notification data to application.
+ * @{
+ */
+
+/** @defgroup ATVV_Read_Info ATVV Read Info
+ * @brief Parameter for read characteristic value.
+ * @{
+ */
+#define ATVV_READ_CHAR_RX_INDEX 1
+#define ATVV_READ_CHAR_CTL_INDEX 2
+/** @} */
+
+/** @defgroup ATVV_Write_Info ATVV Write Info
+ * @brief Parameter for write characteristic value.
+ * @{
+ */
+#define ATVV_WRITE_CHAR_TX_INDEX 1
+/** @} */
+
+/** @defgroup ATVV_Notify_Indicate_Info ATVV Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define ATVV_CHAR_RX_NOTIFY_ENABLE 1
+#define ATVV_CHAR_RX_NOTIFY_DISABLE 2
+#define ATVV_CHAR_CTL_NOTIFY_ENABLE 3
+#define ATVV_CHAR_CTL_NOTIFY_DISABLE 4
+
+/** @defgroup ATT MTU zie and Date length extantion
+ * @brief GATT client negotiate ATT MTU and send DLE
+ * @{
+ */
+#define ATVV_DLE_AND_MTU_UPDATE_DISABLE 0
+#define ATVV_DLE_ENABLE_MTU_SIZE_UPDATE 1
+
+/** Message content */
+typedef union
+{
+ struct
+ {
+ uint8_t len;
+ uint8_t *report;
+ } report_data;
+} T_ATVV_WRITE_PARAMETER;
+
+/** @struct _TATVV_WRITE_MSG
+ * @brief write message
+ */
+typedef struct
+{
+ uint8_t write_type; /**< ref: @ref ATVV_RmC_Write_Info */
+ T_ATVV_WRITE_PARAMETER write_parameter;
+} T_ATVV_WRITE_MSG;
+
+typedef union _TATVV_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index; /**< ref: @ref ATVV_RmC_Notify_Indicate_Info */
+ uint8_t read_value_index; /**< ref: @ref ATVV_RmC_Read_Info */
+ T_ATVV_WRITE_MSG write;
+} T_ATVV_UPSTREAM_MSG_DATA;
+
+/** ATVV service data to inform application */
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_ATVV_UPSTREAM_MSG_DATA msg_data;
+} T_ATVV_CALLBACK_DATA;
+/** @} */
+
+typedef enum
+{
+ ATV_TX_OPCODE_GET_CAPS = 0x0A,
+ ATV_TX_OPCODE_MIC_OPEN = 0x0C,
+ ATV_TX_OPCODE_MIC_CLOSE = 0x0D,
+ ATV_TX_OPCODE_EXTEND = 0x0E,
+} ATV_CHAR_TX_OPCODE;
+
+#define ATV_TX_OPCODE_GET_CAPS_LEN 5
+#define ATV_TX_OPCODE_MIC_OPEN_LEN 5
+
+typedef enum
+{
+ ATV_CTL_OPCODE_AUDIO_STOP = 0x00,
+ ATV_CTL_OPCODE_AUDIO_START = 0x04,
+ ATV_CTL_OPCODE_DPAD_SELECT = 0x07,
+ ATV_CTL_OPCODE_START_SEARCH = 0x08,
+ ATV_CTL_OPCODE_AUDIO_SYNC = 0x0A,
+ ATV_CTL_OPCODE_GET_CAPS_RESP = 0x0B,
+ ATV_CTL_OPCODE_MIC_OPEN_ERROR = 0x0C,
+} ATV_CHAR_CTL_CMD_OPCODE;
+
+typedef enum
+{
+ ATV_START_REASON_MIC_OPEN_REQUEST = 0x00,
+ ATV_START_REASON_PTT = 0x01,
+ ATV_START_REASON_HTT = 0x03,
+ ATV_START_REASON_INVALID = 0xFF
+} ATV_AUDIO_START_REASON;
+
+typedef enum
+{
+ ATV_STOP_REASON_MIC_CLOSE_MESSAGE = 0x00,
+ ATV_STOP_REASON_HTT = 0x02,
+ ATV_STOP_REASON_AUDIO_START_COMMAND = 0x04,
+ ATV_STOP_REASON_AUDIO_TRANSFER_TIMEOUT = 0x08,
+ ATV_STOP_REASON_ATVV_CHAR_AUDIO_DISABLE = 0x10,
+ ATV_STOP_REASON_OTHERS = 0x80,
+} ATV_AUDIO_STOP_REASON;
+
+typedef enum
+{
+ ATV_MIC_OPEN_ERROR_RESERVED = 0x0f01,
+ ATV_MIC_OPEN_ERROR_REMOTE_IS_NOT_ACTIVE = 0x0f02,
+ ATV_MIC_OPEN_ERROR_ATVV_CHAR_AUDIO_IS_DISABLE = 0x0f03,
+ ATV_MIC_OPEN_ERROR_PTT_HTT_IS_IN_PROGRESS = 0x0f80,
+ ATV_MIC_OPEN_ERROR_INTERNAL_ERROR = 0x0fff,
+} ATV_MIC_OPEN_ERROR;
+
+typedef enum
+{
+ ATV_ASSISTANT_INTERACTION_MODEL_ON_REQUEST = 0x00,
+ ATV_ASSISTANT_INTERACTION_MODEL_PRESS_TO_TALK = 0x01,
+ ATV_ASSISTANT_INTERACTION_MODEL_HOLD_TO_TALK = 0x03,
+} ATV_ASSISTANT_INTERACTION_MODEL;
+
+/** @} End of IAS_Exported_Types */
+
+typedef struct
+{
+ uint16_t app_support_version;
+ uint16_t codec_support;
+ uint16_t codec_used;
+ uint8_t atv_start_reason;
+ uint8_t assistant_interaction_model;
+ uint8_t audio_consumption_mode;
+ uint8_t stream_id;
+ uint8_t char_rx_data_buff[ATVV_CHAR_RX_DATA_LEN];
+ uint8_t char_ctl_data_buff[ATVV_CHAR_RX_DATA_LEN];
+ uint8_t char_write_dat_buff[ATVV_CHAR_WRITE_DATA_LEN];
+} T_ATVV_GLOBAL_DATA;
+
+extern T_ATVV_GLOBAL_DATA atvv_global_data;
+
+/** @defgroup ATVV_Exported_Functions IAS Exported Functions
+ * @brief functions that other .c files may use all defined here.
+ * @{
+ */
+uint8_t atvv_add_service(void *p_func);
+/** @} End of ATVV_Exported_Functions */
+
+/** @} End of ATVV */
+
+#endif /* (VOICE_FLOW_SEL == ATV_GOOGLE_VOICE_FLOW) */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
diff --git a/inc/bluetooth/profile/server/bas.h b/inc/bluetooth/profile/server/bas.h
new file mode 100644
index 0000000..7eee3d4
--- /dev/null
+++ b/inc/bluetooth/profile/server/bas.h
@@ -0,0 +1,230 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file bas.h
+ * @brief Head file for using battery service.
+ * @details BAS data structs and external functions declaration.
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _BAS_H_
+#define _BAS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+
+/** @defgroup BAS Battery Service
+ * @brief Battery service
+ * @details
+
+ The Battery Service exposes the state of a battery within a device.
+
+ Battery Service generally makes up a profile with some other services, and it can provide the state of a battery within a device.
+
+ The default supported feature provided by BAS is the notify property of battery level characteristic,
+ and the application developers can modify the feature supported by BAS according to their own requirements.
+ The specific configuration process can be achieved by modifying file @ref bas_config.h.
+
+ * <b>Example usage</b>
+ * \code{.c}
+
+ #define BAS_BATTERY_LEVEL_NOTIFY_SUPPORT 1
+
+ * \endcode
+
+ Application shall register battery service when initialization through @ref bas_add_service function.
+
+ Application can set the battery level of BAS through @ref bas_set_parameter function.
+
+ Application can send the battery level value of BAS to the client with a notification through @ref bas_battery_level_value_notify function.
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup BAS_Exported_Macros BAS Exported Macros
+ * @brief
+ * @{
+ */
+
+#define BAS_READ_BATTERY_LEVEL 1
+#define BAS_NOTIFY_BATTERY_LEVEL_ENABLE 1
+#define BAS_NOTIFY_BATTERY_LEVEL_DISABLE 2
+
+/** End of BAS_Exported_Macros
+* @}
+*/
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup BAS_Exported_Types BAS Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Battery service parameter type
+*/
+typedef enum
+{
+ BAS_PARAM_BATTERY_LEVEL = 0x01,
+} T_BAS_PARAM_TYPE;
+
+/**
+* @brief set battery service parameter upstream message data
+*/
+typedef union
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+} T_BAS_UPSTREAM_MSG_DATA;
+
+/**
+* @brief set battery service parameter upstream callback data
+*/
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_BAS_UPSTREAM_MSG_DATA msg_data;
+} T_BAS_CALLBACK_DATA;
+
+/** End of BAS_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup BAS_Exported_Functions BAS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add battery service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ bas_id = bas_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID bas_add_service(void *p_func);
+
+/**
+ * @brief Set a battery service parameter.
+ *
+ * NOTE: You can call this function with a battery service parameter type and it will set the
+ * battery service parameter. Battery service parameters are defined in @ref T_BAS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Battery service parameter type: @ref T_BAS_PARAM_TYPE
+ * @param[in] length Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ the parameter type and will be cast to the appropriate data type.
+ If param_type is set to @ref BAS_PARAM_BATTERY_LEVEL, p_value pointer to the current
+ charge level of a battery. Unit is org.bluetooth.unit.percentage. Minimum value is 0,
+ and maximum value is 100. 100% represents fully charged while 0% represents fully discharged.
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t battery_level = 80;
+ bas_set_parameter(BAS_PARAM_BATTERY_LEVEL, 1, &battery_level);
+ }
+ * \endcode
+ */
+bool bas_set_parameter(T_BAS_PARAM_TYPE param_type, uint8_t length, uint8_t *p_value);
+
+
+/**
+ * @brief Send notify battery level notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] battery_level The current charge level of a battery.
+ Unit is org.bluetooth.unit.percentage. Minimum value is 0, and maximum value is 100.
+ 100% represents fully charged while 0% represents fully discharged.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t battery_level = 90;
+ bas_battery_level_value_notify(conn_id, bas_id, battery_level);
+ }
+ * \endcode
+ */
+bool bas_battery_level_value_notify(uint8_t conn_id, T_SERVER_ID service_id, uint8_t battery_level);
+
+
+/**
+ * @brief Confirm for read battery level value request.
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] battery_level The current charge level of a battery.
+ Unit is org.bluetooth.unit.percentage. Minimum value is 0, and maximum value is 100.
+ 100% represents fully charged while 0% represents fully discharged.
+
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t battery_level = 90;
+ bas_battery_level_value_read_confirm(conn_id, bas_id, battery_level);
+ }
+ * \endcode
+ */
+bool bas_battery_level_value_read_confirm(uint8_t conn_id, T_SERVER_ID service_id,
+ uint8_t battery_level);
+
+/** @} End of BAS_Exported_Functions */
+
+/** @} End of BAS */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _BAS_H_ */
diff --git a/inc/bluetooth/profile/server/bas_config.h b/inc/bluetooth/profile/server/bas_config.h
new file mode 100644
index 0000000..6be3546
--- /dev/null
+++ b/inc/bluetooth/profile/server/bas_config.h
@@ -0,0 +1,39 @@
+#ifndef _BAS_CONFIG_H_
+#define _BAS_CONFIG_H_
+
+
+/** @defgroup BAS Battery Service
+ * @brief Battery service
+ * @{
+ */
+
+
+/** @defgroup BAS_CONFIG Battery Service Config
+ * @brief Battery service configuration file
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup BAS_Common_Exported_Macros BAS Common Exported Macros
+ * @{
+ */
+
+/** @details
+ Set BAS_BATTERY_LEVEL_NOTIFY_SUPPORT to 1 to support Battery level notification feature,
+ otherwise set it to 0.
+*/
+#define BAS_BATTERY_LEVEL_NOTIFY_SUPPORT 1
+
+
+/** @} End of BAS_Common_Exported_Macros */
+
+/** @} End of BAS_CONFIG */
+
+/** @} End of BAS */
+
+
+
+#endif
diff --git a/inc/bluetooth/profile/server/cscs.h b/inc/bluetooth/profile/server/cscs.h
new file mode 100644
index 0000000..7af191a
--- /dev/null
+++ b/inc/bluetooth/profile/server/cscs.h
@@ -0,0 +1,433 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file csc_service.h
+ * @brief Variables and interfaces for Cycling Speed and Cadence Service.
+ * @details CSC service data structs and functions.
+ * @author ethan_su
+ * @date 2017-10-13
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _CSCS_SERVICE_DEF_H
+#define _CSCS_SERVICE_DEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+#include "cscs_config.h"
+
+
+/** @defgroup CSCS Cycling Speed and Cadence Service
+ * @brief Cycling Speed and Cadence Service
+ * @details
+
+ The Cycling Speed and Cadence (CSC) Service exposes speed-related data and/or
+ cadence-related data while using the Cycling Speed and Cadence sensor (Server).
+ CSC Measurement, CSC Measurement Client Characteristic Configuration descriptor and CSC Feature characteristic are mandatory
+ exposed in the Cycling Speed and Cadence Service.
+ if the Multiple Sensor Locations feature is supported, CSC Feature will be mandatory, otherwise optional.
+ if at least one SC Control Point procedure is supported, SC Control Point and SC Control Point Client
+ Characteristic Configuration Descriptor will be mandatory, otherwise excluded.
+
+ The CSC Measurement characteristic is used to send speed-related data and/or cadence-related data.
+ The CSC Feature characteristic shall be used to describe the supported features of the Server.
+ The Sensor Location characteristic of the device may be used to describe the physical location of the Server when correctly fitted.
+
+ If the SC Control Point is supported, profiles utilizing this service are required to ensure that the Client configures the
+ SC Control Point characteristic for indications (i.e. via the Client Characteristic Configuration descriptor) at the first connection.
+
+ Application shall register Cycling Speed and Cadence service when initialization through @ref cscs_add_service function.
+
+ Application can set the Cycling Speed and Cadence parameters through @ref cscs_set_parameter function.
+
+ Application can send the measurement value through @ref cscs_meas_value_notify function.
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup CSCS_Exported_Constants CSC Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup CSCS_Optional_Features CSC Optional Features
+ * @brief CSC Service optional features bit mask
+ * @{
+ */
+
+/** @defgroup CSCS_Measurement_Flags CSC Measurement Flags
+ * @brief CSC measurement 'Flags' present bit mask
+ * @{
+ */
+#define CSCS_INC_WHEEL_REVOL_MASK (1)
+#define CSCS_INC_CRANK_REVOL_MASK (1<<1)
+#define CSCS_INC_ALL_PRESENTS (0x03)
+/** @} */
+
+/** @defgroup CSCS_Features CSC Features
+ * @brief CSC features bit mask
+ * @{
+ */
+#define CSCS_SUPPORT_WHEEL_REVOL_MASK (1)
+#define CSCS_SUPPORT_CRANK_REVOL_MASK (1<<1)
+#define CSCS_SUPPORT_MULTI_SENSOR_MASK (1<<2)
+#define CSCS_ALL_FEATURE_SUPPORTED (0x07)
+/** @} */
+
+/** @defgroup CSCS_Sensor_Location CSC Sensor Location
+ * @brief CSC supported sensor location bit mask
+ * @{
+ */
+#define CSCS_SENS_LOC_OTHER_MASK (1)
+#define CSCS_SENS_LOC_TOP_OF_SHOE_MASK (1<<1)
+#define CSCS_SENS_LOC_IN_SHOE_MASK (1<<2)
+#define CSCS_SENS_LOC_HIP_MASK (1<<3)
+#define CSCS_SENS_LOC_FRONT_WHEEL_MASK (1<<4)
+#define CSCS_SENS_LOC_LEFT_CRANK_MASK (1<<5)
+#define CSCS_SENS_LOC_RIGHT_CRANK_MASK (1<<6)
+#define CSCS_SENS_LOC_LEFT_PEDAL_MASK (1<<7)
+#define CSCS_SENS_LOC_RIGHT_PEDAL_MASK (1<<8)
+#define CSCS_SENS_LOC_FRONT_HUB_MASK (1<<9)
+#define CSCS_SENS_LOC_REAR_DROPOUT_MASK (1<<10)
+#define CSCS_SENS_LOC_CHAINSTAY_MASK (1<<11)
+#define CSCS_SENS_LOC_REAR_WHEEL_MASK (1<<12)
+#define CSCS_SENS_LOC_REAR_HUB_MASK (1<<13)
+#define CSCS_SENS_LOC_CHEST_MASK (1<<14)
+#define CSCS_ALL_SENS_LOC_SUPPORTED (0x7FFF)
+/** @} */
+
+/** @} End of CSCS_Optional_Features */
+
+/**
+* @brief CSC service parameter type
+*/
+typedef enum
+{
+ CSCS_PARAM_CSCS_FEATURE = 0x01,
+ CSCS_PARAM_INC_FLAG = 0x11,
+ CSCS_PARAM_WHEEL_REVOL,
+ CSCS_PARAM_WHEEL_EVT_TIME,
+ CSCS_PARAM_CRANK_REVOL,
+ CSCS_PARAM_CRANK_EVT_TIME,
+ CSCS_PARAM_CTL_PNT_PROG_CLR = 0x17,
+ CSCS_PARAM_SENSOR_LOC = 0x21,
+} T_CSCS_PARAM_TYPE;
+
+
+/** @defgroup CSCS_Upstream_Message CSC Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+
+/** @defgroup CSCS_Read_Info CSC Read Info
+ * @brief Parameter for reading characteristic value.
+ * @{
+ */
+#define CSCS_READ_CSCS_FEATURE 1
+#define CSCS_READ_SENSOR_LOCATION 2
+/** @} */
+
+/** @defgroup CSCS_Notify_Indicate_Info CSC Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define CSCS_NOTIFY_INDICATE_MEASUREMENT_ENABLE 1
+#define CSCS_NOTIFY_INDICATE_MEASUREMENT_DISABLE 2
+#define CSCS_NOTIFY_INDICATE_SC_CP_ENABLE 3
+#define CSCS_NOTIFY_INDICATE_SC_CP_DISABLE 4
+/** @} */
+
+/** @} End of CSCS_Upstream_Message */
+
+/** @defgroup CSCS_Control_Point CSC Control Point
+ * @brief Control Point
+ * @{
+ */
+
+/** @defgroup CSCS_Control_Point_OpCodes CSC Control Point OpCodes
+ * @brief Control Point OpCodes
+ * @{
+ */
+#define CSCS_CP_OPCODE_RESERVED 0x00
+#define CSCS_CP_OPCODE_SET_CUMULATIVE 0x01
+#define CSCS_CP_OPCODE_UPDATE_SENS_LOC 0x03
+#define CSCS_CP_OPCODE_REQ_SENS_LOC_LIST 0x04
+#define CSCS_CP_OPCODE_RSP_CODE 0x10
+/** @} */
+
+/** @defgroup CSCS_Control_Point_Response_Codes CSC Control Point Response Codes
+ * @brief Control Point Response Codes
+ * @{
+ */
+#define CSCS_CP_RSPCODE_RESERVED 0x00
+#define CSCS_CP_RSPCODE_SUCCESS 0x01
+#define CSCS_CP_RSPCODE_OPCODE_UNSUPPORT 0x02
+#define CSCS_CP_RSPCODE_INVALID_PARAMETER 0x03
+#define CSCS_CP_RSPCODE_OPERATION_FAILED 0x04
+/** @} */
+
+///@cond
+/** @brief Judge CSC Control Point operation is available or not. */
+#define CSCS_CTL_PNT_OPERATE_ACTIVE(x) \
+ ( (x == CSCS_CP_OPCODE_SET_CUMULATIVE) || \
+ (x == CSCS_CP_OPCODE_UPDATE_SENS_LOC) || \
+ (x == CSCS_CP_OPCODE_REQ_SENS_LOC_LIST) || \
+ (x == CSCS_CP_OPCODE_RSP_CODE) )
+///@endcond
+
+/** @} End of CSCS_Control_Point */
+
+/**
+ * @brief CSC sensor locations.
+ *
+ * All CSC sensor locations defined in spec.
+*/
+typedef enum
+{
+ CSCS_SENSOR_LOC_OTHER = 0,
+ CSCS_SENSOR_LOC_TOP_OF_SHOE = 1,
+ CSCS_SENSOR_LOC_IN_SHOE = 2,
+ CSCS_SENSOR_LOC_HIP = 3,
+ CSCS_SENSOR_LOC_FRONT_WHEEL = 4,
+ CSCS_SENSOR_LOC_LEFT_CRANK = 5,
+ CSCS_SENSOR_LOC_RIGHT_CRANK = 6,
+ CSCS_SENSOR_LOC_LEFT_PEDAL = 7,
+ CSCS_SENSOR_LOC_RIGHT_PEDAL = 8,
+ CSCS_SENSOR_LOC_FRONT_HUB = 9,
+ CSCS_SENSOR_LOC_REAR_DROPOUT = 10,
+ CSCS_SENSOR_LOC_CHAINSTAY = 11,
+ CSCS_SENSOR_LOC_REAL_WHEEL = 12,
+ CSCS_SENSOR_LOC_REAL_HUB = 13,
+ CSCS_SENSOR_LOC_CHEST = 14,
+ CSCS_SENSOR_LOC_MAX
+} T_CSCS_SENSOR_LOCATION;
+
+///@cond
+/** @brief Error codes defined in CSC service. */
+#define CSCS_ERR_PROC_ALREADY_IN_PROG 0x80
+#define CSCS_ERR_CCCD_IMPROPERLY_CFG 0x81
+
+/** @brief Max bytes of CSC Measurement data. */
+#define CSCS_MAX_MEASUREMENT_VALUE 11
+/** @brief Max bytes of CSC Control Point data. */
+#define CSCS_MAX_CTL_PNT_VALUE 18
+///@endcond
+
+/** @} End of CSCS_Exported_Constants */
+
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup CSCS_Exported_Types CSC Exported Types
+ * @brief
+ * @{
+ */
+
+/* Add all public types here */
+/** @defgroup CSCS_Callback_Data CSC Callback Data
+ * @brief CSC data struct for notification data to application.
+ * @{
+ */
+typedef union
+{
+ uint8_t sensor_location_value;
+ uint32_t cumulative_value;
+
+} T_CSCS_CP_PARAMETER;
+
+typedef struct
+{
+ uint8_t opcode; //!< ref: @ref CSCS_Control_Point_OpCodes
+ T_CSCS_CP_PARAMETER cp_parameter;
+} T_CSCS_WRITE_MSG;
+
+typedef union
+{
+ uint8_t notification_indification_index; //!< ref: @ref CSCS_Notify_Indicate_Info
+ uint8_t read_value_index; //!< ref: @ref CSCS_Read_Info
+ T_CSCS_WRITE_MSG write;
+} T_CSCS_UPSTREAM_MSG_DATA;
+
+/** CSC service data to inform application */
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_CSCS_UPSTREAM_MSG_DATA msg_data;
+} T_CSCS_CALLBACK_DATA;
+/** @} */
+
+/** @brief CSC measurement data, variable length during connection, max can reach 11 bytes */
+typedef struct
+{
+ uint8_t cur_length; /**< length of current CSC measurement data. */
+ uint8_t value[CSCS_MAX_MEASUREMENT_VALUE];/**< value of current CSC measurement data. */
+} T_CSCS_MEASUREMENT;
+
+/**
+ * @brief CSC Control Point data, variable length during connection, max can reach 17 bytes.
+ *
+ * CSC Control Point data used to store the Control Point Command received from the client.
+*/
+typedef struct
+{
+ uint8_t cur_length; /**< length of current CSC Control Point data, . */
+ uint8_t
+ value[CSCS_MAX_CTL_PNT_VALUE]; /**< value of current CSC Control Point data, . */
+} T_CSCS_CONTROL_POINT;
+/** @} End of CSCS_Exported_Types */
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+
+/** @defgroup CSCS_Exported_Functions CSC Exported Functions
+ * @brief
+ * @{
+ */
+
+
+/**
+ * @brief Add cycling speed and cadence service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ cscs_id = cscs_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID cscs_add_service(void *p_func);
+
+/**
+ * @brief Set a cycling speed and cadence service parameter.
+ *
+ * NOTE: You can call this function with a cycling speed and cadence service parameter type and it will set the
+ * cycling speed and cadence service parameter. Cycling speed and cadence service parameters are defined in @ref T_CSCS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Cycling speed and cadence service parameter type: @ref T_CSCS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and will be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ cscs_set_parameter(CSCS_PARAM_CTL_PNT_PROG_CLR, 0, NULL);
+ }
+ * \endcode
+ */
+bool cscs_set_parameter(T_CSCS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Get a cycling speed and cadence parameter.
+ *
+ * NOTE: You can call this function with a cycling speed and cadence parameter type and it will get a
+ * gulcose parameter. Cycling speed and cadence service parameters are defined in @ref T_CSCS_PARAM_TYPE.
+ *
+ * @param[in] param_type Cycling speed and cadence parameter type: @ref T_CSCS_PARAM_TYPE
+ * @param[in,out] p_value Pointer to the location to get the parameter value. This is dependent on
+ * the parameter type and will be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval GAP_CAUSE_SUCCESS Operation success.
+ * @retval GAP_CAUSE_INVALID_PARAM Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ int record_num;
+ gls_get_parameter(GLS_PARAM_RECORD_NUM, &len, &record_num);
+ }
+ * \endcode
+ */
+bool cscs_get_parameter(T_CSCS_PARAM_TYPE param_type, void *p_value);
+
+
+/**
+ * @brief Send measurement value notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ bool op_result;
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ cscs_set_parameter(CSCS_PARAM_WHEEL_REVOL, sizeof(cscs_cul_value), &cscs_cul_value);
+ op_result = cscs_meas_value_notify(conn_id, cscs_id);
+ }
+ * \endcode
+ */
+bool cscs_meas_value_notify(uint8_t conn_id, T_SERVER_ID service_id);
+
+
+
+/**
+ * @brief Send control point indication.
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] op_code Op code.
+ * @param[in] rsp_code Response code.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ */
+bool cscs_ctl_pnt_indicate(uint8_t conn_id, T_SERVER_ID service_id, uint8_t op_code,
+ uint8_t rsp_code);
+
+
+
+
+/** @} End of CSCS_Exported_Functions */
+
+/** @} End of CSC */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _CSCS_DEF_H */
+
diff --git a/inc/bluetooth/profile/server/cscs_config.h b/inc/bluetooth/profile/server/cscs_config.h
new file mode 100644
index 0000000..7b0d3d6
--- /dev/null
+++ b/inc/bluetooth/profile/server/cscs_config.h
@@ -0,0 +1,40 @@
+#ifndef _CSCS_CONFIG_H_
+#define _CSCS_CONFIG_H_
+
+
+
+/** @defgroup CSCS Cycling Speed and Cadence Service
+ * @brief Cycling Speed and Cadence Service
+ * @{
+ */
+
+/** @defgroup CSCS_CONFIG Cycling Speed and Cadence Service Config
+ * @brief Cycling Speed and Cadence service configuration file
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup CSCS_Common_Exported_Macros CSCS Common Exported Macros
+ * @{
+ */
+
+#define CSCS_MULTIPLE_SENSOR_LOCATIONS_SUPPORT
+#define CSCS_SC_CONTROL_POINT_SUPPORT
+
+/** @brief Index of each characteristic in CSC service database. */
+#define GATT_SVC_CSCS_MEASUREMENT_INDEX 2
+#define GATT_SVC_CSCS_FEATURE_INDEX 5
+#define GATT_SVC_CSCS_SENS_LOC_INDEX 7
+#define GATT_SVC_CSCS_CTL_PNT_INDEX 9
+#define GATT_SVC_CSCS_MEAS_CCCD_INDEX (GATT_SVC_CSCS_MEASUREMENT_INDEX + 1)
+#define GATT_SVC_CSCS_CTL_PNT_CCCD_INDEX (GATT_SVC_CSCS_CTL_PNT_INDEX + 1)
+
+/** @} End of CSCS_Common_Exported_Macros */
+
+/** @} End of CSCS_CONFIG */
+
+/** @} End of CSCS */
+
+#endif
diff --git a/inc/bluetooth/profile/server/dfu_service.h b/inc/bluetooth/profile/server/dfu_service.h
new file mode 100644
index 0000000..a5af29f
--- /dev/null
+++ b/inc/bluetooth/profile/server/dfu_service.h
@@ -0,0 +1,117 @@
+/**
+*********************************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+**********************************************************************************************************
+* @file dfu_service.h
+* @brief
+* @details
+* @author ken_mei
+* @date 02-09-2016
+* @version v1.0.0
+******************************************************************************
+* @attention
+* <h2><center>&copy; COPYRIGHT 2015 Realtek Semiconductor Corporation</center></h2>
+******************************************************************************
+*/
+
+#ifndef _DFU_SERVICE_H_
+#define _DFU_SERVICE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+#include "patch_header_check.h"
+#include "dfu_api.h"
+
+#define DFU_NOTIFY_ENABLE 1
+#define DFU_NOTIFY_DISABLE 2
+
+/*attribut index*/
+#define INDEX_DFU_PACKET_VALUE 0x02
+#define INDEX_DFU_CONTROL_POINT_CHAR_VALUE 0x04
+#define INDEX_DFU_CHAR_CCCD_INDEX 0x05
+
+
+
+typedef struct _T_DFU_CTRL_POINT
+{
+ uint8_t opcode;
+ T_IMG_CTRL_HEADER_FORMAT start_dfu; /* start dfu trans first 12 bytes ctrl header*/
+} T_DFU_CTRL_POINT, * P_DFU_CTRL_POINT;
+
+typedef struct
+{
+ T_IMG_CTRL_HEADER_FORMAT ctrl_header;
+ uint32_t image_total_length;
+ uint32_t origin_image_version;
+ uint32_t cur_offset;
+ uint8_t mtu_size;
+ bool dfu_conn_para_update_in_progress;
+ uint16_t dfu_conn_interval;
+ uint16_t dfu_conn_lantency;
+} T_DFU_PARA;
+
+typedef struct
+{
+ T_IMG_ID image_id;
+ uint32_t image_size;
+ uint32_t image_offset;
+} T_TEMP_IMAGE_INFO;
+
+typedef enum
+{
+ DFU_FAIL_UPDATE_FLASH,
+ DFU_FAIL_SYSTEM_RESET_CMD,
+ DFU_FAIL_EXCEED_MAX_BUFFER_SIZE,
+ DFU_FAIL_EXCEED_IMG_TOTAL_LEN,
+
+} T_DFU_FAIL_REASON;
+
+typedef enum
+{
+ DFU_WRITE_ATTR_ENTER,
+ DFU_WRITE_ATTR_EXIT,
+ DFU_WRITE_START,
+ DFU_WRITE_DOING,
+ DFU_WRITE_END,
+ DFU_WRITE_FAIL,
+} T_DFU_WRITE_OPCODE;
+
+
+typedef struct
+{
+ uint8_t opcode;
+ uint8_t write_attrib_index;
+ uint16_t length;
+ uint8_t *p_value;
+} T_DFU_WRITE_MSG;
+
+typedef union _TDFU_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index;
+ T_DFU_WRITE_MSG write;
+} T_DFU_UPSTREAM_MSG_DATA;
+
+/** Dfu service data to inform application */
+typedef struct _TDFU_CALLBACK_DATA
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_DFU_UPSTREAM_MSG_DATA msg_data;
+} T_DFU_CALLBACK_DATA;
+
+extern uint8_t *p_ota_temp_buffer_head;
+extern uint16_t g_ota_tmp_buf_used_size;
+extern T_DFU_PARA g_dfu_para;
+
+extern void dfu_notify_conn_para_update_req(uint8_t conn_id, T_DFU_ARV_ERROR_CODE error_code);
+extern void dfu_service_handle_valid_fw(uint8_t conn_id);
+extern uint8_t dfu_add_service(void *pFunc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/server/dis.h b/inc/bluetooth/profile/server/dis.h
new file mode 100644
index 0000000..a56df39
--- /dev/null
+++ b/inc/bluetooth/profile/server/dis.h
@@ -0,0 +1,228 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file dis.h
+ * @brief Head file for using device information service.
+ * @details DIS data structs and external functions declaration.
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _DEVICE_INFO_SERVICE_H_
+#define _DEVICE_INFO_SERVICE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+
+/**
+ * @defgroup DIS Device Information Service
+ * @brief Device information service
+ * @details
+ The Device Information Service exposes manufacturer and/or vendor information about a device.
+ This module implements the Device Information Service.
+ The Device Information Service may expose one or more of the characteristics. It can be
+ configured in file @ref dis_config.h.
+
+ Application shall register device information service when initialization.
+
+ * Sample code:
+ * \code{.c}
+ void app_le_profile_init(void)
+ {
+ dis_service_id = dis_add_service(app_profile_callback);
+ }
+ * \endcode
+
+ When characteristic value was read, write or cccd updated by remote device, @ref app_profile_callback will be
+ called.
+ Application shall set dis parameter value by call @ref dis_set_parameter.
+
+ * Sample code:
+ * \code{.c}
+ T_APP_RESULT app_profile_callback(T_SERVER_ID service_id, void *p_data)
+ {
+ ...
+ if (dis_service_id == service_id)
+ {
+ T_DIS_CALLBACK_DATA *p_dis_cb_data = (T_DIS_CALLBACK_DATA *)p_data;
+ switch (p_dis_cb_data->msg_type)
+ {
+ case SERVICE_CALLBACK_TYPE_READ_CHAR_VALUE:
+ {
+ if (p_dis_cb_data->msg_data.read_value_index == DIS_READ_MANU_NAME_INDEX)
+ {
+ const uint8_t dis_manufacture_name[] = "Realtek BT";
+ dis_set_parameter(DIS_PARAM_MANUFACTURER_NAME,
+ sizeof(dis_manufacture_name),
+ (void *)dis_manufacture_name);
+ }
+ else if (p_dis_cb_data->msg_data.read_value_index == DIS_READ_MODEL_NUM_INDEX)
+ {
+ const uint8_t dis_model_number[] = "Model Num 1.0";
+ dis_set_parameter(DIS_PARAM_MODEL_NUMBER,
+ sizeof(dis_model_number),
+ (void *)dis_model_number);
+ }
+ ...
+ ...
+
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ }
+ * \endcode
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup DIS_Exported_Macros DIS Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup DIS_READ_INFO_INDEX DIS Read Informatio Index
+ * @brief Read characteristic value index.
+ * @{
+ */
+#define DIS_READ_MANU_NAME_INDEX 1
+#define DIS_READ_MODEL_NUM_INDEX 2
+#define DIS_READ_SERIAL_NUM_INDEX 3
+#define DIS_READ_HARDWARE_REV_INDEX 4
+#define DIS_READ_FIRMWARE_REV_INDEX 5
+#define DIS_READ_SOFTWARE_REV_INDEX 6
+#define DIS_READ_SYSTEM_ID_INDEX 7
+#define DIS_READ_IEEE_CERT_STR_INDEX 8
+#define DIS_READ_PNP_ID_INDEX 9
+/** @} */
+
+#define DIS_SYSTEM_ID_LENGTH 8
+#define DIS_PNP_ID_LENGTH 7
+
+/** @} End of DIS_Exported_Macros */
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup DIS_Exported_Types DIS Exported Types
+ * @brief
+ * @{
+ */
+/** @defgroup DIS_PARAM_TYPE DIS parameter type
+* @brief Type of parameters set/got from application.
+* @{
+*/
+typedef enum
+{
+ DIS_PARAM_MANUFACTURER_NAME,
+ DIS_PARAM_MODEL_NUMBER,
+ DIS_PARAM_SERIAL_NUMBER,
+ DIS_PARAM_HARDWARE_REVISION,
+ DIS_PARAM_FIRMWARE_REVISION,
+ DIS_PARAM_SOFTWARE_REVISION,
+ DIS_PARAM_SYSTEM_ID,
+ DIS_PARAM_IEEE_DATA_LIST,
+ DIS_PARAM_PNP_ID
+} T_DIS_PARAM_TYPE;
+/** @} */
+
+/** DIS upstream message data*/
+typedef union
+{
+ uint8_t read_value_index;
+} T_DIS_UPSTREAM_MSG_DATA;
+
+/** DIS callback data*/
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ uint8_t conn_id;
+ T_DIS_UPSTREAM_MSG_DATA msg_data;
+} T_DIS_CALLBACK_DATA;
+
+/** @} End of DIS_Exported_Types */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup DIS_Exported_Functions DIS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Set a device information service parameter.
+ *
+ * NOTE: You can call this function with a device information service parameter type and it will set the
+ * device information service parameter. Device information service parameters are defined in @ref T_DIS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Device information service parameter type: @ref T_DIS_PARAM_TYPE
+ * @param[in] length Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ const uint8_t dis_manufacture_name[] = "Realtek BT";
+ dis_set_parameter(DIS_PARAM_MANUFACTURER_NAME,
+ sizeof(dis_manufacture_name),
+ (void *)dis_manufacture_name);
+ }
+ * \endcode
+ */
+bool dis_set_parameter(T_DIS_PARAM_TYPE param_type, uint8_t length, void *p_value);
+
+/**
+ * @brief Add device information service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ dis_id = dis_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+
+T_SERVER_ID dis_add_service(void *p_func);
+
+/** @} End of DIS_Exported_Functions */
+
+/** @} End of DIS */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _DEVICE_INFO_SERVICE_H_ */
diff --git a/inc/bluetooth/profile/server/dis_config.h b/inc/bluetooth/profile/server/dis_config.h
new file mode 100644
index 0000000..3c36523
--- /dev/null
+++ b/inc/bluetooth/profile/server/dis_config.h
@@ -0,0 +1,155 @@
+#ifndef _DIS_CONFIG_H_
+#define _DIS_CONFIG_H_
+
+
+
+/** @defgroup DIS Device Information Service
+ * @brief Device information service
+ * @{
+ */
+
+
+/** @defgroup DIS_CONFIG Device Information Service Config
+ * @brief Device information service config
+ * @{
+ */
+
+/** @defgroup DIS_Common_Exported_Macros Device Information Service Config Common Exported Macros
+ * @{
+ */
+
+
+/** @defgroup DIS_Config_Supported_Features Device Information Service Config Supported Features
+ * @brief
+ The Device Information Service may expose one or more of the characteristics, user can
+ config DIS_CHAR_XXX_SUPPORT to 1 to support it, otherwise set it to 0.
+ * @{
+ */
+
+/** @details
+ Set DIS_CHAR_MANUFACTURER_NAME_SUPPORT to 1 to support Manufacturer Name String characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_MANUFACTURER_NAME_SUPPORT 1
+
+/** @details
+ Set DIS_CHAR_MODEL_NUMBER_SUPPORT to 1 to support Model Number String characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_MODEL_NUMBER_SUPPORT 1
+
+/** @details
+ Set DIS_CHAR_SERIAL_NUMBER_SUPPORT to 1 to support Serial Number String characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_SERIAL_NUMBER_SUPPORT 1
+
+/** @details
+ Set DIS_CHAR_FIRMWARE_REVISION_SUPPORT to 1 to support Firmware Revision String characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_FIRMWARE_REVISION_SUPPORT 1
+
+/** @details
+ Set DIS_CHAR_HARDWARE_REVISION_SUPPORT to 1 to support Hardware Revision String characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_HARDWARE_REVISION_SUPPORT 1
+
+/** @details
+ Set DIS_CHAR_SOFTWARE_REVISION_SUPPORT to 1 to support Software Revision String characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_SOFTWARE_REVISION_SUPPORT 1
+
+
+/** @details
+ Set DIS_CHAR_SYSTEM_ID_SUPPORT to 1 to support System ID characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_SYSTEM_ID_SUPPORT 1
+
+
+/** @details
+ Set DIS_CHAR_IEEE_CERTIF_DATA_LIST_SUPPORT to 1 to support IEEE 11073-20601 Regulatory Certification Data List characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_IEEE_CERTIF_DATA_LIST_SUPPORT 1
+
+/** @details
+ Set DIS_CHAR_PNP_ID_SUPPORT to 1 to support PnP ID characteristic,
+ otherwise set it to 0.
+*/
+#define DIS_CHAR_PNP_ID_SUPPORT 1
+/**
+ * @}
+ */
+
+
+
+/** @defgroup DIS_Config_Max_Char_Value_Length Device Information Service Config Supported Value Length
+ * @brief
+ The max length of characteristic value can be configured here.
+ * @{
+ */
+#ifdef DIS_CHAR_MANUFACTURER_NAME_SUPPORT
+#define DIS_CHAR_MANUFACTURER_NAME_STR_MAX_LENGTH 20 /**< Max length of Manufacturer Name String characteristic value*/
+#endif
+
+#ifdef DIS_CHAR_MODEL_NUMBER_SUPPORT
+#define DIS_CHAR_MODEL_NUMBER_STR_MAX_LENGTH 20 /**< Max length of Model Number String characteristic value*/
+#endif
+
+#ifdef DIS_CHAR_SERIAL_NUMBER_SUPPORT
+#define DIS_CHAR_SERIAL_NUMBER_STR_MAX_LENGTH 20 /**< Max length of Serial Number String characteristic value*/
+#endif
+
+#ifdef DIS_CHAR_FIRMWARE_REVISION_SUPPORT
+#define DIS_CHAR_FIRMWARE_REVISION_STR_MAX_LENGTH 20 /**< Max length of Firmware Revision String characteristic value*/
+#endif
+
+#ifdef DIS_CHAR_HARDWARE_REVISION_SUPPORT
+#define DIS_CHAR_HARDWARE_REVISION_STR_MAX_LENGTH 20 /**< Max length of Hardware Revision String scharacteristic value*/
+#endif
+
+#ifdef DIS_CHAR_SOFTWARE_REVISION_SUPPORT
+#define DIS_CHAR_SOFTWARE_REVISION_STR_MAX_LENGTH 20 /**< Max length of Software Revision String characteristic value*/
+#endif
+
+
+#ifdef DIS_CHAR_IEEE_CERTIF_DATA_LIST_SUPPORT
+#define DIS_CHAR_IEEE_CERTIF_DATA_LIST_MAX_LENGTH 30 /**< Max length of IEEE 11073-20601 Regulatory Certification Data List characteristic value*/
+#endif
+/**
+ * @}
+ */
+
+
+
+/** @defgroup DIS_Config_Char_Value_Index Device Information Service Config Characteristic Value Index
+ * @brief
+ Attribute index value of each characteristic shall be configured by characteristic supported. If some
+ * @{
+ */
+#define GATT_SVC_DIS_MANU_NAME_INDEX 2 /**< Attribute index of Manufacturer Name String characteristic */
+#define GATT_SVC_DIS_MODEL_NUM_INDEX 4 /**< Attribute index of Model Number String characteristic */
+#define GATT_SVC_DIS_SERIAL_NUM_INDEX 6 /**< Attribute index of Serial Number String characteristic */
+#define GATT_SVC_DIS_HARDWARE_REV_INDEX 8 /**< Attribute index of Hardware Revision String characteristic */
+#define GATT_SVC_DIS_FIRMWARE_REV_INDEX 10 /**< Attribute index of Firmware Revision String characteristic */
+#define GATT_SVC_DIS_SOFTWARE_REV_INDEX 12 /**< Attribute index of Software Revision String characteristic */
+#define GATT_SVC_DIS_SYSTEM_ID_INDEX 14 /**< Attribute index of System ID characteristic */
+#define GATT_SVC_DIS_IEEE_CERT_STR_INDEX 16 /**< Attribute index of IEEE 11073-20601 Regulatory Certification Data List characteristic */
+#define GATT_SVC_DIS_PNP_ID_INDEX 18 /**< Attribute index of Pnp ID characteristic */
+/**
+ * @}
+ */
+
+
+/** @} End of DIS_Common_Exported_Macros */
+
+/** @} End of DIS_CONFIG */
+
+/** @} End of DIS */
+
+
+#endif
diff --git a/inc/bluetooth/profile/server/gls.h b/inc/bluetooth/profile/server/gls.h
new file mode 100644
index 0000000..363598c
--- /dev/null
+++ b/inc/bluetooth/profile/server/gls.h
@@ -0,0 +1,638 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file gls.h
+ * @brief Head file for using glucose service.
+ * @details Glusose data types and external functions declaration.
+ * @author bill
+ * @date 2017-6-8
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _GLS_H
+#define _GLS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+#include "gls_config.h"
+
+
+/** @defgroup GLS Glucose Service
+ * @brief Glucose service
+ * @details
+
+ The Glucose Service exposes glucose and other data related to a personal glucose sensor for
+ consumer healthcare applications and is not designed for clinical use.
+ Glucose Measurement, Glucose Measurement - Client Characteristic Configuration descriptor,
+ Glucose Feature, Record Access Control Point, Record Access Control Point - Client Characteristic Configuration descriptor
+ are mandatory exposed in the Glucose Service.
+ Glucose Measurement Context is optional, and if the Glucose Measurement Context characteristic is supported,
+ Glucose Measurement Context - Client Characteristic Configuration descriptor shall be mandatory.
+
+ The Glucose Measurement characteristic shall be used to send glucose measurements.
+ The Glucose Measurement Context characteristic may be used to send additional contextual information relative to
+ a Glucose Measurement characteristic.
+ The Glucose Feature characteristic shall be used to describe the supported features of the Server.
+ For this service to operate, profiles or other applications utilizing this service will need to ensure that
+ the Client configures the Record Access Control Point (RACP) characteristic for indications.
+ The Client must perform a write to the Record Access Control Point to execute a desired procedure at the Server.
+
+ Application shall register glucose service when initialization through @ref gls_add_service function.
+
+ Application can set the glucose service parameters through @ref gls_set_parameter function.
+
+ Application can send the glucose measurements through @ref gls_glc_measurement_notify function.
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+
+/** @defgroup GLS_Exported_Macros GLS Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup GLS_Feature GLS Feature
+ * @brief glucose feature bits.
+ * @{
+ */
+#define GLC_FEATURES_LOW_BATTERY 0x0001
+#define GLC_FEATURES_SENSOR_MALFUNCTION 0x0002
+#define GLC_FEATURES_SENSOR_SAMPLE_SIZE 0x0004
+#define GLC_FEATURES_SENSOR_STRIP_INS_ERROR 0x0008
+#define GLC_FEATURES_SENSOR_STRIP_TYPE_ERROR 0x0010
+#define GLC_FEATURES_SENSOR_RESULT_HIGH_LOW 0x0020
+#define GLC_FEATURES_SENSOR_TEMP_HIGH_LOW 0x0040
+#define GLC_FEATURES_SENSOR_READ_INTERRUPT 0x0080
+#define GLC_FEATURES_GENERAL_DEVICE_FAULT 0x0100
+#define GLC_FEATURES_TIME_FAULT 0x0200
+#define GLC_FEATURES_MULTIPLE_BOND 0x0400
+
+/** GLC features supported: */
+#define GLC_FEATURES (GLC_FEATURES_LOW_BATTERY | \
+ GLC_FEATURES_SENSOR_STRIP_INS_ERROR)
+/** @} */
+
+/**
+* @brief Gulcose service parameter type
+*/
+typedef enum
+{
+ /** glucose measurement parameters */
+ GLS_PARAM_GLC_MS_FLAG = 0x01,
+ GLS_PARAM_GLC_MS_BASE_TIME,
+ GLS_PARAM_GLC_MS_TIME_OFFSET,
+ GLS_PARAM_GLC_MS_CONCENTRATION,
+ GLS_PARAM_GLC_MS_CONCENTRATION_UNITS,
+ GLS_PARAM_GLC_MS_TYPE_SAMPLE_LOCATION,
+ GLS_PARAM_GLC_MS_SENSOR_STATUS_ANNUNCIATION,
+
+ /** glucose measurement context parameters */
+ GLS_PARAM_GLC_MS_CT_FLAG,
+ GLS_PARAM_GLC_MS_CT_CARBOHYDRATE_ID,
+ GLS_PARAM_GLC_MS_CT_CARBOHYDRATE,
+ GLS_PARAM_GLC_MS_CT_MEAL,
+ GLS_PARAM_GLC_MS_CT_TESTER_HEALTH,
+ GLS_PARAM_GLC_MS_CT_EXERCISE_DURATION,
+ GLS_PARAM_GLC_MS_CT_EXERCISE_INTENSITY,
+ GLS_PARAM_GLC_MS_CT_MEDICATION_ID,
+ GLS_PARAM_GLC_MS_CT_MEDICATION,
+ GLS_PARAM_GLC_MS_CT_MEDICATION_UNITS,
+ GLS_PARAM_GLC_MS_CT_HbA1c,
+
+ /** Parameters that can be get by application */
+ GLS_PARAM_GLC_FEATURES,
+ GLS_PARAM_CTL_PNT_PROG_CLR,
+ GLS_PARAM_RECORD_NUM,
+ GLS_PARAM_RECORD_SEQ_NUM
+} T_GLS_PARAM_TYPE;
+
+
+/** @defgroup GLS_Upstream_Message GLS Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+
+/** @defgroup GLS_Read_Info GLS Read Info
+ * @brief Parameter for read characteristic value.
+ * @{
+ */
+#define GLS_EVT_READ_FEATURE 0x01
+/** @} */
+
+/** @defgroup GLS_Notify_Indicate_Info GLS Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define GLS_EVT_GLC_MEASUREMENT_NOTIFY_ENABLE 0x01
+#define GLS_EVT_GLC_MEASUREMENT_NOTIFY_DISABLE 0x02
+#define GLS_EVT_GLC_MEASUREMENT_CONTEXT_NOTIFY_ENABLE 0x03
+#define GLS_EVT_GLC_MEASUREMENT_CONTEXT_NOTIFY_DISABLE 0x04
+#define GLS_EVT_GLC_RACP_INDICATE_ENABLE 0x05
+#define GLS_EVT_GLC_RACP_INDICATE_DISABLE 0x06
+/** @} */
+
+/** @} End of GLS_Upstream_Message */
+
+/** @defgroup GLS_Control_Point GLS Control Point
+ * @brief glucose record access control point
+ * @{
+ */
+
+/** @brief Glucose Record Access Control Point OpCodes. */
+typedef enum
+{
+ GLC_RACP_OPCODE_RESERVED = 0x00,
+ GLC_RACP_OPCODE_REPORT_RECS = 0x01,
+ GLC_RACP_OPCODE_DELETE_RECS = 0x02,
+ GLC_RACP_OPCODE_ABORT_OPERATION = 0x03,
+ GLC_RACP_OPCODE_REPORT_NBR_OF_RECS = 0x04,
+ GLC_RACP_OPCODE_NBR_OF_RECS_RESP = 0x05,
+ GLC_RACP_OPCODE_RESP_CODE = 0x06
+} T_GLC_CTRL_POINT_OPCODE;
+
+/** @brief Check glucose Record Access Control Point operation is available or not. */
+#define GLC_RACP_OPERATION_ACTIVE(x) \
+ ((x >= GLC_RACP_OPCODE_REPORT_RECS) && \
+ (x <= GLC_RACP_OPCODE_RESP_CODE))
+
+/** @brief Glucose Record Access Control Point Operator. */
+typedef enum
+{
+ GLC_RACP_OPERATOR_NULL = 0x00,
+ GLC_RACP_OPERATOR_ALL_RECS = 0x01,
+ GLC_RACP_OPERATOR_LT_EQ = 0x02,
+ GLC_RACP_OPERATOR_GT_EQ = 0x03,
+ GLC_RACP_OPERATOR_RANGE = 0x04,
+ GLC_RACP_OPERATOR_FIRST = 0x05,
+ GLC_RACP_OPERATOR_LAST = 0x06
+} T_GLC_CTRL_POINT_OPERATOR;
+
+/** @brief Filter Type values. */
+typedef enum
+{
+ GLC_RACP_FILTER_TYPE_RESERVED = 0x00,
+ GLC_RACP_FILTER_TYPE_SEQ_NBR = 0x01,
+ GLC_RACP_FILTER_TYPE_TIME = 0x02
+} T_GLC_CTRL_POINT_FILTER_TYPE;
+
+/** @brief Glucose Record Access Control Point Response Codes. */
+typedef enum
+{
+ GLC_RACP_RESP_RESERVED = 0x00,
+ GLC_RACP_RESP_SUCCESS = 0x01,
+ GLC_RACP_RESP_OPCODE_NOT_SUPPORTED = 0x02,
+ GLC_RACP_RESP_INVALID_OPERATOR = 0x03,
+ GLC_RACP_RESP_OPERATOR_NOT_SUPPORTED = 0x04,
+ GLC_RACP_RESP_INVALID_OPERAND = 0x05,
+ GLC_RACP_RESP_NO_RECS_FOUND = 0x06,
+ GLC_RACP_RESP_ABORT_UNSUCCESSFUL = 0x07,
+ GLC_RACP_RESP_PROC_NOT_COMPLETED = 0x08,
+ GLC_RACP_RESP_OPERAND_NOT_SUPPORTED = 0x09
+} T_GLC_CTRL_POINT_RESP_CODES;
+
+/** @brief profile specific attribute protocol application error codes */
+#define GLC_ERR_PROC_ALREADY_IN_PROGRESS 0x80
+#define GLC_ERR_CCCD_IMPROPERLY_CONFIGURED 0x81
+/** @} */
+
+/** @brief concentration unit */
+#define GLC_FLAGS_UNITS_MOL_L_ON 1
+#define GLC_FLAGS_UNITS_KG_L_ON 0
+
+/** @brief medication unit */
+#define GLC_FLAGS_MEDICATION_UNITS_LITERS_ON 1
+#define GLC_FLAGS_MEDICATION_UNITS_KG_ON 0
+
+/** GLC sensor status annunciation bits */
+#define GLC_SS_ANNUNC_LOW_BATTERY 0x0001
+
+/** special short float values */
+#define SFLOAT_VALUE_NaN 0x07ff /**< not a number */
+#define SFLOAT_VALUE_NRes 0x0800 /**< not at this resolution */
+#define SFLOAT_VALUE_PlusINFINITY 0x07fe /**< + INFINITY */
+#define SFLOAT_VALUE_MinusINFINITY 0x0802 /**< - INFINITY */
+#define SFLOAT_VALUE_RFU 0x0801 /**< reserved for future use */
+
+/** @brief RACP database parameters */
+#define GLC_RACP_DATABASE_SIZE (GLC_RACP_MAX_NBR_OF_STORED_RECS + 1)
+#define GLC_RACP_INIT_SEQ_NBR_DEFAULT 0
+
+/** @} End of GLS_Exported_Macros */
+
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+
+/** @defgroup GLS_Exported_Types GLS Exported Types
+ * @brief
+ * @{
+ */
+
+/* Add all public types here */
+
+/** GLC measurement flag bits */
+typedef struct
+{
+ uint8_t time_offset: 1; /**< time offset */
+ uint8_t con_ts_loc: 1; /**< concentration, time/sample location */
+ uint8_t con_units: 1; /**< 0: kg/L, 1: mol/L */
+ uint8_t ss_annuciation: 1; /**< sensor status annunciation */
+ uint8_t ctxt_info_follows: 1; /**< context information */
+ uint8_t rfu: 3;
+} T_GLC_MEASUREMENT_FLAG;
+
+/** GLC measurement context flag bits */
+typedef struct
+{
+ uint8_t carbohydrate: 1; /**< Carbohydrates ID and field */
+ uint8_t meal: 1; /**< Meal ID and field */
+ uint8_t tester_health: 1; /**< Tester-Health field */
+ uint8_t exercise: 1; /**< Exercise Duration and Intensity field */
+ uint8_t medication: 1; /**< Medication ID and field */
+ uint8_t medication_units: 1; /**< Medication units 0:kg, 1:liter */
+ uint8_t hb_a1c: 1; /**< hb_a1c field */
+ uint8_t ext_flags: 1; /**< extended flag */
+} T_GLC_MSR_CTXT_FLAG;
+
+typedef uint8_t TIMESTAMP[7];
+typedef uint8_t SFLOAT[2]; /* 4 bit (MSB) exponent, 12 bit mantissa */
+
+typedef struct
+{
+ T_GLC_MEASUREMENT_FLAG flags;
+ uint16_t seq_num;
+ TIMESTAMP base_time;
+#if (GLC_INCLUDE_TIME_OFFSET)
+ int16_t time_offset; //minutes
+#endif
+#if (GLC_INCLUDE_CONC_TS_LOC)
+ SFLOAT concentration;
+ uint8_t type_sample_location;
+#endif
+#if (GLC_INCLUDE_SS_ANNUNC)
+ uint16_t ss_annunciation;
+#endif
+} T_GLC_MEASUREMENT_VALUE;
+
+typedef struct
+{
+ T_GLC_MSR_CTXT_FLAG flags;
+ uint16_t seq_num;
+#if (GLC_INCLUDE_EXT_FLAGS)
+ uint8_t ext_flags;
+#endif
+#if (GLC_INCLUDE_CARBOHYDRATE)
+ uint8_t carbohydrate_ID;
+ SFLOAT carbohydrate;
+#endif
+#if (GLC_INCLUDE_MEAL)
+ uint8_t meal;
+#endif
+#if (GLC_INCLUDE_TESTER_HEALTH)
+ uint8_t tester_health;
+#endif
+#if (GLC_INCLUDE_EXERCISE)
+ uint16_t exercise_duration;
+ uint8_t exercise_intensity;
+#endif
+#if (GLC_INCLUDE_MEDICATION)
+ uint8_t medication_ID;
+ SFLOAT medication;
+#endif
+#if (GLC_INCLUDE_HbA1c)
+ SFLOAT hb_a1c;
+#endif
+} T_GLC_MEASUREMENT_CONTEXT;
+
+typedef struct
+{
+ T_GLC_CTRL_POINT_OPCODE op_code;
+ T_GLC_CTRL_POINT_OPERATOR op; /**< operator */
+ uint8_t operand[18];
+} T_GLC_CONTROL_POINT;
+
+typedef struct
+{
+ T_GLC_MEASUREMENT_VALUE glc_measurement_value;
+#if GLC_MEASUREMENT_CONTEXT_SUPPORT
+ T_GLC_MEASUREMENT_CONTEXT glc_measurement_context;
+#endif
+} T_PATIENT_RECORD;
+
+typedef struct
+{
+ T_PATIENT_RECORD records[GLC_RACP_DATABASE_SIZE];
+ uint8_t record_num;
+ /**
+ The tail points to an empty record who plays a role as a guard.
+ 1. empty tail == head
+ 2. one (tail - head + GLC_RACP_DATABASE_SIZE) % GLC_RACP_DATABASE_SIZE == 1
+ 3. full (head - tail + GLC_RACP_DATABASE_SIZE) % GLC_RACP_DATABASE_SIZE == 1
+ */
+ uint8_t head;
+ uint8_t tail;
+ uint16_t seq_num; /**< sequence number of latest record */
+} T_RECORD_DATA_BASE;
+
+typedef struct
+{
+ T_GLC_CONTROL_POINT ctrl_point;
+ uint8_t cp_length; /**< length of current operand of control point */
+ T_RECORD_DATA_BASE record_db;
+} T_GLC_RACP;
+
+/** Flags indicate CCCD */
+typedef struct
+{
+ uint8_t GLC_measurement_notify_enable: 1;
+ uint8_t GLC_measurement_context_notify_enable: 1;
+ uint8_t GLC_RACP_indicate_enable: 1;
+ uint8_t rfu: 5;
+} T_GLC_NOTIFY_INDICATE_FLAG;
+
+/** @defgroup GLS_Callback_Data GLS Callback Data
+ * @brief GLS data struct for notification data to application.
+ * @{
+ */
+typedef union
+{
+ uint8_t notify_indicate_index;
+ uint8_t read_value_index;
+ T_GLC_CONTROL_POINT write;
+} T_GLS_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_GLS_UPSTREAM_MSG_DATA msg_data;
+} T_GLS_CALLBACK_DATA;
+/** @} */
+
+/** @} End of GLS_Exported_Types */
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+
+/** @defgroup GLS_Exported_Functions GLS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add gulcose service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ gls_id = gls_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID gls_add_service(void *p_func);
+
+
+/**
+ * @brief Set a GLS parameter.
+ *
+ * NOTE: You can call this function with a gulcose service parameter type and it will set the
+ * gulcose service parameter. Gulcose service parameters are defined in @ref T_GLS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Gulcose service parameter type: @ref T_GLS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ T_GLC_MEASUREMENT_FLAG ms_flag =
+ {
+ 1, //time_offset
+ 1, //con_ts_loc
+ GLC_FLAGS_UNITS_MOL_L_ON, //con_units
+ 1, //ss_annuciation
+ 0, //ctxt_info_follows
+ 0 //rfu
+ };
+ gls_set_parameter(GLS_PARAM_GLC_MS_FLAG, 1, &ms_flag);
+ }
+ * \endcode
+ */
+bool gls_set_parameter(T_GLS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+
+/**
+ * @brief Get a GLS parameter.
+ *
+ * NOTE: You can call this function with a gulcose parameter type and it will get a
+ * gulcose parameter. Gulcose parameters are defined in @ref T_GLS_PARAM_TYPE.
+ *
+ * @param[in] param_type Gulcose parameter type: @ref T_GLS_PARAM_TYPE
+ * @param[in,out] len Pointer to the location to get the length of data.
+ * @param[in,out] p_value Pointer to the location to get the parameter value. This is dependent on
+ * the parameter type and will be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval GAP_CAUSE_SUCCESS Operation success.
+ * @retval GAP_CAUSE_INVALID_PARAM Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ int record_num;
+ gls_get_parameter(GLS_PARAM_RECORD_NUM, &len, &record_num);
+ }
+ * \endcode
+ */
+bool gls_get_parameter(T_GLS_PARAM_TYPE param_type, uint8_t *len, void *p_value);
+
+
+/**
+ * @brief Send measurement notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] index Index.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t battery_level = 90;
+ bas_battery_level_value_notify(conn_id, bas_id, battery_level);
+ }
+ * \endcode
+ */
+bool gls_glc_measurement_notify(uint8_t conn_id, T_SERVER_ID service_id, uint8_t index);
+
+#if GLC_MEASUREMENT_CONTEXT_SUPPORT
+
+/**
+ * @brief Send measurement context notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] index Index.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t battery_level = 90;
+ bas_battery_level_value_notify(conn_id, bas_id, battery_level);
+ }
+ * \endcode
+ */
+bool gls_glc_measurement_context_notify(uint8_t conn_id, T_SERVER_ID service_id, uint8_t index);
+#endif
+
+
+/**
+ * @brief Indicate control point data response to client from application
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] rsp_code Response code.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ */
+bool gls_racp_response(uint8_t conn_id, T_SERVER_ID service_id, uint8_t rsp_code);
+
+/**
+ * @brief Indicate control point data number response to client from application
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] num Number of glucose records.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ */
+bool gls_racp_num_response(uint8_t conn_id, T_SERVER_ID service_i, uint16_t num);
+
+/**
+ * @brief Prepare a new record in database.
+ * @return void.
+ *
+ */
+void gls_prepare_new_record(void);
+
+
+/**
+ * @brief Push a new record into database.
+ * @return void.
+ *
+ */
+void gls_push_new_record(void);
+
+/**
+ * @brief Report records sub procedure.
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t battery_level = 90;
+ bas_battery_level_value_notify(conn_id, bas_id, battery_level);
+ }
+ * \endcode
+ */
+bool gls_report_records_task(uint8_t conn_id, T_SERVER_ID service_id);
+
+/**
+ * @brief Calculate user facing time by adding basetime and timeoffset.
+ *
+ *
+ * @param[in] time_in Connection id.
+ * @param[in] time_offset Service id.
+ * @param[in] time_out Battery level value.
+ * @return void.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ user_face_time(time, 30, time);
+ }
+ * \endcode
+ */
+
+void user_face_time(TIMESTAMP time_in, int16_t time_offset, TIMESTAMP time_out);
+
+/**
+ * @brief Abort RACP procedure by app.
+ *
+ * @return void.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ gls_abort_racp_procedure();
+ }
+ * \endcode
+ */
+void gls_abort_racp_procedure(void);
+
+/** @} End of GLS_Exported_Functions */
+
+/** @} End of GLS */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GLUCOSE_SERVICE_H */
diff --git a/inc/bluetooth/profile/server/gls_config.h b/inc/bluetooth/profile/server/gls_config.h
new file mode 100644
index 0000000..d16b3d0
--- /dev/null
+++ b/inc/bluetooth/profile/server/gls_config.h
@@ -0,0 +1,102 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file gls_config.h
+ * @brief glucose service configuration file.
+ * @details Configure the optional characteristic and fields in the glucose service.
+ * @author bill
+ * @date 2017-6-8
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _GLS_CONFIG_H_
+#define _GLS_CONFIG_H_
+
+/** @defgroup GLS Glucose Service
+ * @brief Glucose service
+ * @{
+ */
+
+
+/** @defgroup GLS_CONFIG Glusose Service Config
+ * @brief Glusose service configuration file
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup GLS_Common_Exported_Macros GLS Common Exported Macros
+ * @{
+ */
+
+/** @brief glucose maximum number of records in database */
+#define GLC_RACP_MAX_NBR_OF_STORED_RECS 10
+
+/** @defgroup GLS_Optional_Characteristic GLS Optional Characteristic
+ * @brief glucose optional characteristic configuration
+ * @{
+ */
+#define GLC_MEASUREMENT_CONTEXT_SUPPORT 1
+/** @} */
+
+/** @defgroup GLS_Optional_Field GLS Optional Field
+ * @brief glucose optional field.
+ * @{
+ */
+/** glucose measurement optional fields configuration */
+#define GLC_INCLUDE_TIME_OFFSET 1
+#define GLC_INCLUDE_CONC_TS_LOC 1
+#define GLC_INCLUDE_SS_ANNUNC 1
+
+/** glucose measurement context optional fields configuration */
+#if (GLC_MEASUREMENT_CONTEXT_SUPPORT)
+#define GLC_INCLUDE_CARBOHYDRATE 1
+#define GLC_INCLUDE_MEAL 1
+#define GLC_INCLUDE_TESTER_HEALTH 1
+#define GLC_INCLUDE_EXERCISE 1
+#define GLC_INCLUDE_MEDICATION 1
+#define GLC_INCLUDE_HbA1c 1
+#define GLC_INCLUDE_EXT_FLAGS 0
+
+#define GLC_MS_CTXT_INCLUDE_XXX (GLC_INCLUDE_CARBOHYDRATE + \
+ GLC_INCLUDE_MEAL + \
+ GLC_INCLUDE_TESTER_HEALTH + \
+ GLC_INCLUDE_EXERCISE + \
+ GLC_INCLUDE_MEDICATION + \
+ GLC_INCLUDE_HbA1c)
+#if (GLC_MS_CTXT_INCLUDE_XXX == 0)
+#error "Glucose measurement context characteristic value shall include at least one field, in addition to the Flags field and Sequence Number field!"
+#endif
+#endif
+/** @} */
+
+/** @defgroup GLS_Attribute_Index GLS Attribute Index
+ * @brief Index of each characteristic in service database
+ * @{
+ */
+#define INDEX_OFFSET0 (0)
+#define GLS_CHAR_GLC_MEASUREMENT_INDEX (INDEX_OFFSET0+0x02)
+#define GLS_CHAR_GLC_MEASUREMENT_CCCD_INDEX (GLS_CHAR_GLC_MEASUREMENT_INDEX + 1)
+
+#if (GLC_MEASUREMENT_CONTEXT_SUPPORT)
+#define GLS_CHAR_GLC_MEASUREMENT_CONTEXT_INDEX (INDEX_OFFSET0+0x05)
+#define GLS_CHAR_GLC_MEASUREMENT_CONTEXT_CCCD_INDEX (GLS_CHAR_GLC_MEASUREMENT_CONTEXT_INDEX + 1)
+#endif
+
+#define INDEX_OFFSET1 (INDEX_OFFSET0+GLC_MEASUREMENT_CONTEXT_SUPPORT*3)
+#define GLS_CHAR_GLC_FEATURE_INDEX (INDEX_OFFSET1+0x05)
+#define GLS_CHAR_GLC_RACP_INDEX (INDEX_OFFSET1+0x07)
+#define GLS_CHAR_GLC_RACP_CCCD_INDEX (GLS_CHAR_GLC_RACP_INDEX + 1)
+/** @} */
+
+
+/** @} End of GLS_Common_Exported_Macros */
+
+/** @} End of GLS_CONFIG */
+
+/** @} End of GLS */
+#endif
diff --git a/inc/bluetooth/profile/server/hids.h b/inc/bluetooth/profile/server/hids.h
new file mode 100644
index 0000000..80843d3
--- /dev/null
+++ b/inc/bluetooth/profile/server/hids.h
@@ -0,0 +1,283 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids.h
+ * @brief Head file for using Human Interface Device Service.
+ * @details HIDS data structs and external functions declaration.
+ * @author Jeff_Zheng
+ * @date 2017-12-01
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _HIDS_H_
+#define _HIDS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+
+/** @defgroup HIDS Human Interface Device Service
+ * @brief Human Interface Device Service
+ * @details
+
+ The HID Service exposes data and associated formatting for HID Devices and HID Hosts.
+
+ Application shall register HID service when initialization through @ref hids_add_service function.
+
+ Application can set the HID service through @ref hids_set_parameter function.
+
+ Application can send report data of HID service to the client with a notification through @ref hids_send_report function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup HIDS_Exported_Macros HIDS Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup HIDS_Index HIDS Attribute Index
+ * @brief Index defines for Characteristic's value in HID Device
+ * @{
+ */
+#define GATT_SVC_HID_PROTOCOL_MODE_INDEX (2)
+#define GATT_SVC_HID_REPORT_INPUT_INDEX (4)
+#define GATT_SVC_HID_REPORT_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORT_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_OUTPUT_INDEX (8)
+#define GATT_SVC_HID_REPORT_FEATURE_INDEX (11)
+#define GATT_SVC_HID_REPORT_MAP_INDEX (14)
+#define GATT_SVC_HID_EXTERNAL_REPORT_REFER_INDEX (GATT_SVC_HID_REPORT_MAP_INDEX+1)
+#define GATT_SVC_HID_BOOT_KB_IN_REPORT_INDEX (17)
+#define GATT_SVC_HID_BOOT_KB_IN_REPORT_CCCD_INDEX (GATT_SVC_HID_BOOT_KB_IN_REPORT_INDEX+1)
+#define GATT_SVC_HID_BOOT_KB_OUT_REPORT_INDEX (20)
+#define GATT_SVC_HID_BOOT_MS_IN_REPORT_INDEX (22)
+#define GATT_SVC_HID_BOOT_MS_IN_REPORT_CCCD_INDEX (GATT_SVC_HID_BOOT_MS_IN_REPORT_INDEX+1)
+#define GATT_SVC_HID_INFO_INDEX (25)
+#define GATT_SVC_HID_CONTROL_POINT_INDEX (27)
+/** @} */
+
+/** End of HIDS_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HIDS_Exported_Types HIDS Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Human Interface Device Service parameter type
+*/
+typedef enum
+{
+ HID_PROTOCOL_MODE = 0x01,
+ HID_REPORT_INPUT,
+ HID_REPORT_OUTPUT,
+ HID_REPORT_FEATURE,
+ HID_REPORT_MAP,
+ HID_EXTERNAL_REPORT_REFER,
+ HID_BOOT_KB_IN_REPORT,
+ HID_BOOT_KB_OUT_REPORT,
+ HID_BOOT_MS_IN_REPORT,
+ HID_INFO,
+ HID_CONTROL_POINT,
+} T_HIDS_PARAM_TYPE;
+
+/**
+* @brief Human Interface Device Service information
+*/
+typedef struct
+{
+ uint8_t b_country_code;
+ uint8_t flags;
+ uint16_t bcd_hid;
+} T_HID_INFO;
+
+/**
+* @brief Human Interface Device Service report type
+*/
+typedef enum
+{
+ HID_INPUT_TYPE = 1,
+ HID_OUTPUT_TYPE = 2,
+ HID_FEATURE_TYPE = 3
+} T_PROFILE_HID_REPORT_TYPE;
+
+/**
+* @brief Human Interface Device Service control point
+*/
+typedef enum
+{
+ HID_SUSPEND = 0,
+ HID_EXIT_SUSPEND = 1,
+} T_HID_CTL_POINT;
+
+/**
+* @brief Human Interface Device Service protocol mode
+*/
+typedef enum
+{
+ BOOT_PROTOCOL_MODE = 0,
+ REPORT_PROCOCOL_MODE = 1
+} T_HID_PROTOCOL_MODE;
+
+/** @defgroup HIDS_Upstream_Message HIDS Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+typedef enum
+{
+ NOTIFY_ENABLE,
+ NOTIFY_DISABLE
+} T_HID_NOTIFY;
+
+typedef union
+{
+ uint8_t voice_enable;
+ uint8_t protocol_mode;
+ uint8_t suspend_mode;
+ struct
+ {
+ uint8_t reportLen;
+ uint8_t *report;
+ } report_data;
+} T_HID_WRITE_PARAMETER;
+
+typedef struct
+{
+ uint8_t write_type;
+ T_HID_WRITE_PARAMETER write_parameter;
+} T_HID_WRITE_MSG;
+
+typedef struct
+{
+ uint8_t index;
+ T_HID_NOTIFY value;
+} T_HID_NOT_IND_DATA;
+
+typedef union
+{
+ uint8_t read_value_index;
+ T_HID_WRITE_MSG write_msg;
+ T_HID_NOT_IND_DATA not_ind_data;
+} T_HID_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_HID_UPSTREAM_MSG_DATA msg_data;
+} T_HID_CALLBACK_DATA;
+
+/** @} End of HIDS_Upstream_Message */
+
+
+/** End of HIDS_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HIDS_Exported_Functions HIDS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add HID service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ hids_id = hids_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID hids_add_service(void *p_func);
+
+/**
+ * @brief Set a HID service parameter.
+ *
+ * NOTE: You can call this function with a HID service parameter type and it will set the
+ * HID service parameter. HID service parameters are defined in @ref T_HIDS_PARAM_TYPE.
+ *
+ * @param[in] param_type HID service parameter type: @ref T_HIDS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t mode = 1;
+ hids_set_parameter(HID_PROTOCOL_MODE, 1, &mode);
+ }
+ * \endcode
+ */
+bool hids_set_parameter(T_HIDS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send HIDS notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] index hids characteristic index.
+ * @param[in] p_data report value pointer.
+ * @param[in] data_len length of report data.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t conn_id = 0;
+ T_SERVER_ID service_id = hids_id;
+ uint8_t hid_report_input[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
+ hids_send_report(conn_id, service_id, GATT_SVC_HID_REPORT_INPUT_INDEX, hid_report_input, sizeof(hid_report_input));
+ }
+ * \endcode
+ */
+bool hids_send_report(uint8_t conn_id, T_SERVER_ID service_id, uint16_t index, uint8_t *p_data,
+ uint16_t data_len);
+
+
+/** @} End of HIDS_Exported_Functions */
+
+/** @} End of HIDS */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/inc/bluetooth/profile/server/hids_kb.h b/inc/bluetooth/profile/server/hids_kb.h
new file mode 100644
index 0000000..6f55e23
--- /dev/null
+++ b/inc/bluetooth/profile/server/hids_kb.h
@@ -0,0 +1,281 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids_kb.h
+ * @brief Head file for using Human Interface Device Service.
+ * @details HIDS data structs and external functions declaration.
+ * @author Jeff_Zheng
+ * @date 2017-12-01
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _HIDS_KB_H_
+#define _HIDS_KB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+
+/** @defgroup HIDS_KB Human Interface Device Service of Keyboard
+ * @brief Human Interface Device Service
+ * @details
+
+ The HID Service exposes data and associated formatting for HID Devices and HID Hosts.
+
+ Application shall register HID service when initialization through @ref hids_add_service function.
+
+ Application can set the HID service through @ref hids_set_parameter function.
+
+ Application can send report data of HID service to the client with a notification through @ref hids_send_report function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup HIDS_KB_Exported_Macros HIDS Keyboard Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup HIDS_KB_Index HIDS Keyboard Attribute Index
+ * @brief Index defines for Characteristic's value in HID Device
+ * @{
+ */
+#define GATT_SVC_HID_PROTOCOL_MODE_INDEX (2)
+#define GATT_SVC_HID_REPORT_INPUT_INDEX (4)
+#define GATT_SVC_HID_REPORT_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORT_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_OUTPUT_INDEX (8)
+#define GATT_SVC_HID_REPORT_FEATURE_INDEX (11)
+#define GATT_SVC_HID_REPORT_MAP_INDEX (14)
+#define GATT_SVC_HID_EXTERNAL_REPORT_REFER_INDEX (GATT_SVC_HID_REPORT_MAP_INDEX+1)
+#define GATT_SVC_HID_BOOT_KB_IN_REPORT_INDEX (17)
+#define GATT_SVC_HID_BOOT_KB_IN_REPORT_CCCD_INDEX (GATT_SVC_HID_BOOT_KB_IN_REPORT_INDEX+1)
+#define GATT_SVC_HID_BOOT_KB_OUT_REPORT_INDEX (20)
+#define GATT_SVC_HID_INFO_INDEX (22)
+#define GATT_SVC_HID_CONTROL_POINT_INDEX (24)
+/** @} */
+
+/** End of HIDS_KB_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HIDS_KB_Exported_Types HIDS Keyboard Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Human Interface Device Service parameter type
+*/
+typedef enum
+{
+ HID_PROTOCOL_MODE = 0x01,
+ HID_REPORT_INPUT,
+ HID_REPORT_OUTPUT,
+ HID_REPORT_FEATURE,
+ HID_REPORT_MAP,
+ HID_EXTERNAL_REPORT_REFER,
+ HID_BOOT_KB_IN_REPORT,
+ HID_BOOT_KB_OUT_REPORT,
+ HID_INFO,
+ HID_CONTROL_POINT,
+} T_HIDS_PARAM_TYPE;
+
+/**
+* @brief Human Interface Device Service information
+*/
+typedef struct
+{
+ uint8_t b_country_code;
+ uint8_t flags;
+ uint16_t bcd_hid;
+} T_HID_INFO;
+
+/**
+* @brief Human Interface Device Service report type
+*/
+typedef enum
+{
+ HID_INPUT_TYPE = 1,
+ HID_OUTPUT_TYPE = 2,
+ HID_FEATURE_TYPE = 3
+} T_PROFILE_HID_REPORT_TYPE;
+
+/**
+* @brief Human Interface Device Service control point
+*/
+typedef enum
+{
+ HID_SUSPEND = 0,
+ HID_EXIT_SUSPEND = 1,
+} T_HID_CTL_POINT;
+
+/**
+* @brief Human Interface Device Service protocol mode
+*/
+typedef enum
+{
+ BOOT_PROTOCOL_MODE = 0,
+ REPORT_PROCOCOL_MODE = 1
+} T_HID_PROTOCOL_MODE;
+
+/** @defgroup HIDS_KB_Upstream_Message HIDS Keyboard Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+typedef enum
+{
+ NOTIFY_ENABLE,
+ NOTIFY_DISABLE
+} T_HID_NOTIFY;
+
+typedef union
+{
+ uint8_t voice_enable;
+ uint8_t protocol_mode;
+ uint8_t suspend_mode;
+ uint8_t output;
+ struct
+ {
+ uint8_t reportLen;
+ uint8_t *report;
+ } report_data;
+} T_HID_WRITE_PARAMETER;
+
+typedef struct
+{
+ uint8_t write_type;
+ T_HID_WRITE_PARAMETER write_parameter;
+} T_HID_WRITE_MSG;
+
+typedef struct
+{
+ uint8_t index;
+ T_HID_NOTIFY value;
+} T_HID_NOT_IND_DATA;
+
+typedef struct
+{
+ uint8_t read_value_index;
+ T_HID_WRITE_MSG write_msg;
+ T_HID_NOT_IND_DATA not_ind_data;
+} T_HID_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_HID_UPSTREAM_MSG_DATA msg_data;
+} T_HID_CALLBACK_DATA;
+
+/** @} End of HIDS_KB_Upstream_Message */
+
+
+/** End of HIDS_KB_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HIDS_KB_Exported_Functions HIDS Keyboard Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add HID service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ hids_id = hids_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID hids_add_service(void *p_func);
+
+/**
+ * @brief Set a HID service parameter.
+ *
+ * NOTE: You can call this function with a HID service parameter type and it will set the
+ * HID service parameter. HID service parameters are defined in @ref T_HIDS_PARAM_TYPE.
+ *
+ * @param[in] param_type HID service parameter type: @ref T_HIDS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t mode = 1;
+ hids_set_parameter(HID_PROTOCOL_MODE, 1, &mode);
+ }
+ * \endcode
+ */
+bool hids_set_parameter(T_HIDS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send HIDS notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] index hids characteristic index.
+ * @param[in] p_data report value pointer.
+ * @param[in] data_len length of report data.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t conn_id = 0;
+ T_SERVER_ID service_id = hids_id;
+ uint8_t hid_report_input[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
+ hids_send_report(conn_id, service_id, GATT_SVC_HID_REPORT_INPUT_INDEX, hid_report_input, sizeof(hid_report_input));
+ }
+ * \endcode
+ */
+bool hids_send_report(uint8_t conn_id, T_SERVER_ID service_id, uint16_t index, uint8_t *p_data,
+ uint16_t data_len);
+
+
+/** @} End of HIDS_KB_Exported_Functions */
+
+/** @} End of HIDS_KB */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/inc/bluetooth/profile/server/hids_ms.h b/inc/bluetooth/profile/server/hids_ms.h
new file mode 100644
index 0000000..de69532
--- /dev/null
+++ b/inc/bluetooth/profile/server/hids_ms.h
@@ -0,0 +1,280 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids_ms.h
+ * @brief Head file for using Human Interface Device Service.
+ * @details HIDS data structs and external functions declaration.
+ * @author Jeff_Zheng
+ * @date 2017-12-01
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _HIDS_MS_H_
+#define _HIDS_MS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+
+/** @defgroup HIDS_MS Human Interface Device Service of Mouse
+ * @brief Human Interface Device Service
+ * @details
+
+ The HID Service exposes data and associated formatting for HID Devices and HID Hosts.
+
+ Application shall register HID service when initialization through @ref hids_add_service function.
+
+ Application can set the HID service through @ref hids_set_parameter function.
+
+ Application can send report data of HID service to the client with a notification through @ref hids_send_report function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup HIDS_MS_Exported_Macros HIDS Mouse Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup HIDS_MS_Index HIDS Mouse Attribute Index
+ * @brief Index defines for Characteristic's value in HID Device
+ * @{
+ */
+#define GATT_SVC_HID_PROTOCOL_MODE_INDEX (2)
+#define GATT_SVC_HID_REPORT_MOUSE_INPUT_INDEX (4)
+#define GATT_SVC_HID_REPORT_MOUSE_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORT_MOUSE_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_VENDOR_INPUT_INDEX (8)
+#define GATT_SVC_HID_REPORT_VNEDOR_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORT_VENDOR_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_OUTPUT_INDEX (12)
+#define GATT_SVC_HID_REPORT_FEATURE_INDEX (15)
+#define GATT_SVC_HID_REPORT_MAP_INDEX (18)
+#define GATT_SVC_HID_EXTERNAL_REPORT_REFER_INDEX (GATT_SVC_HID_REPORT_MAP_INDEX+1)
+#define GATT_SVC_HID_BOOT_MS_IN_REPORT_INDEX (21)
+#define GATT_SVC_HID_BOOT_MS_IN_REPORT_CCCD_INDEX (GATT_SVC_HID_BOOT_MS_IN_REPORT_INDEX+1)
+#define GATT_SVC_HID_INFO_INDEX (24)
+#define GATT_SVC_HID_CONTROL_POINT_INDEX (26)
+/** @} */
+
+/** End of HIDS_MS_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HIDS_MS_Exported_Types HIDS Mouse Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Human Interface Device Service parameter type
+*/
+typedef enum
+{
+ HID_PROTOCOL_MODE = 0x01,
+ HID_REPORT_INPUT,
+ HID_REPORT_OUTPUT,
+ HID_REPORT_FEATURE,
+ HID_REPORT_MAP,
+ HID_EXTERNAL_REPORT_REFER,
+ HID_BOOT_MS_IN_REPORT,
+ HID_INFO,
+ HID_CONTROL_POINT,
+} T_HIDS_PARAM_TYPE;
+
+/**
+* @brief Human Interface Device Service information
+*/
+typedef struct
+{
+ uint8_t b_country_code;
+ uint8_t flags;
+ uint16_t bcd_hid;
+} T_HID_INFO;
+
+/**
+* @brief Human Interface Device Service report type
+*/
+typedef enum
+{
+ HID_INPUT_TYPE = 1,
+ HID_OUTPUT_TYPE = 2,
+ HID_FEATURE_TYPE = 3
+} T_PROFILE_HID_REPORT_TYPE;
+
+/**
+* @brief Human Interface Device Service control point
+*/
+typedef enum
+{
+ HID_SUSPEND = 0,
+ HID_EXIT_SUSPEND = 1,
+} T_HID_CTL_POINT;
+
+/**
+* @brief Human Interface Device Service protocol mode
+*/
+typedef enum
+{
+ BOOT_PROTOCOL_MODE = 0,
+ REPORT_PROCOCOL_MODE = 1
+} T_HID_PROTOCOL_MODE;
+
+/** @defgroup HIDS_MS_Upstream_Message HIDS Mouse Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+typedef enum
+{
+ NOTIFY_ENABLE,
+ NOTIFY_DISABLE
+} T_HID_NOTIFY;
+
+typedef union
+{
+ uint8_t voice_enable;
+ uint8_t protocol_mode;
+ uint8_t suspend_mode;
+ struct
+ {
+ uint8_t reportLen;
+ uint8_t *report;
+ } report_data;
+} T_HID_WRITE_PARAMETER;
+
+typedef struct
+{
+ uint8_t write_type;
+ T_HID_WRITE_PARAMETER write_parameter;
+} T_HID_WRITE_MSG;
+
+typedef struct
+{
+ uint8_t index;
+ T_HID_NOTIFY value;
+} T_HID_NOT_IND_DATA;
+
+typedef union
+{
+ uint8_t read_value_index;
+ T_HID_WRITE_MSG write_msg;
+ T_HID_NOT_IND_DATA not_ind_data;
+} T_HID_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_HID_UPSTREAM_MSG_DATA msg_data;
+} T_HID_CALLBACK_DATA;
+
+/** @} End of HIDS_MS_Upstream_Message */
+
+
+/** End of HIDS_MS_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HIDS_MS_Exported_Functions HIDS Mouse Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add HID service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ hids_id = hids_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID hids_add_service(void *p_func);
+
+/**
+ * @brief Set a HID service parameter.
+ *
+ * NOTE: You can call this function with a HID service parameter type and it will set the
+ * HID service parameter. HID service parameters are defined in @ref T_HIDS_PARAM_TYPE.
+ *
+ * @param[in] param_type HID service parameter type: @ref T_HIDS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t mode = 1;
+ hids_set_parameter(HID_PROTOCOL_MODE, 1, &mode);
+ }
+ * \endcode
+ */
+bool hids_set_parameter(T_HIDS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send HIDS notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] index hids characteristic index.
+ * @param[in] p_data report value pointer.
+ * @param[in] data_len length of report data.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t conn_id = 0;
+ T_SERVER_ID service_id = hids_id;
+ uint8_t hid_report_input[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
+ hids_send_report(conn_id, service_id, GATT_SVC_HID_REPORT_MOUSE_INPUT_INDEX, hid_report_input, sizeof(hid_report_input));
+ }
+ * \endcode
+ */
+bool hids_send_report(uint8_t conn_id, T_SERVER_ID service_id, uint16_t index, uint8_t *p_data,
+ uint16_t data_len);
+
+
+/** @} End of HIDS_MS_Exported_Functions */
+
+/** @} End of HIDS_MS */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/inc/bluetooth/profile/server/hids_mulkb.h b/inc/bluetooth/profile/server/hids_mulkb.h
new file mode 100644
index 0000000..6cab7b6
--- /dev/null
+++ b/inc/bluetooth/profile/server/hids_mulkb.h
@@ -0,0 +1,284 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids_kb.h
+ * @brief Head file for using Human Interface Device Service.
+ * @details HIDS data structs and external functions declaration.
+ * @author Jeff_Zheng
+ * @date 2017-12-01
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _HIDS_KB_H_
+#define _HIDS_KB_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+
+/** @defgroup HIDS_KB Human Interface Device Service of Keyboard
+ * @brief Human Interface Device Service
+ * @details
+
+ The HID Service exposes data and associated formatting for HID Devices and HID Hosts.
+
+ Application shall register HID service when initialization through @ref hids_add_service function.
+
+ Application can set the HID service through @ref hids_set_parameter function.
+
+ Application can send report data of HID service to the client with a notification through @ref hids_send_report function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup HIDS_KB_Exported_Macros HIDS Keyboard Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup HIDS_KB_Index HIDS Keyboard Attribute Index
+ * @brief Index defines for Characteristic's value in HID Device
+ * @{
+ */
+#define GATT_SVC_HID_PROTOCOL_MODE_INDEX (2)
+#define GATT_SVC_HID_REPORTID1_INPUT_INDEX (4)
+#define GATT_SVC_HID_REPORTID1_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORTID1_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_OUTPUT_INDEX (8)
+#define GATT_SVC_HID_REPORTID3_INPUT_INDEX (11)
+#define GATT_SVC_HID_REPORTID3_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORTID3_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_VENDOR_INPUT_INDEX (15)
+#define GATT_SVC_HID_REPORT_VNEDOR_INPUT_CCCD_INDEX (GATT_SVC_HID_REPORT_VENDOR_INPUT_INDEX+1)
+#define GATT_SVC_HID_REPORT_MAP_INDEX (19)
+#define GATT_SVC_HID_EXTERNAL_REPORT_REFER_INDEX (GATT_SVC_HID_REPORT_MAP_INDEX+1)
+//#define GATT_SVC_HID_BOOT_KB_IN_REPORT_INDEX (17)
+//#define GATT_SVC_HID_BOOT_KB_IN_REPORT_CCCD_INDEX (GATT_SVC_HID_BOOT_KB_IN_REPORT_INDEX+1)
+//#define GATT_SVC_HID_BOOT_KB_OUT_REPORT_INDEX (20)
+#define GATT_SVC_HID_INFO_INDEX (21)
+#define GATT_SVC_HID_CONTROL_POINT_INDEX (23)
+/** @} */
+
+/** End of HIDS_KB_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HIDS_KB_Exported_Types HIDS Keyboard Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Human Interface Device Service parameter type
+*/
+typedef enum
+{
+ HID_PROTOCOL_MODE = 0x01,
+ HID_REPORT_INPUT,
+ HID_REPORT_OUTPUT,
+ HID_REPORT_FEATURE,
+ HID_REPORT_MAP,
+ HID_EXTERNAL_REPORT_REFER,
+ HID_BOOT_KB_IN_REPORT,
+ HID_BOOT_KB_OUT_REPORT,
+ HID_INFO,
+ HID_CONTROL_POINT,
+} T_HIDS_PARAM_TYPE;
+
+/**
+* @brief Human Interface Device Service information
+*/
+typedef struct
+{
+ uint8_t b_country_code;
+ uint8_t flags;
+ uint16_t bcd_hid;
+} T_HID_INFO;
+
+/**
+* @brief Human Interface Device Service report type
+*/
+typedef enum
+{
+ HID_INPUT_TYPE = 1,
+ HID_OUTPUT_TYPE = 2,
+ HID_FEATURE_TYPE = 3
+} T_PROFILE_HID_REPORT_TYPE;
+
+/**
+* @brief Human Interface Device Service control point
+*/
+typedef enum
+{
+ HID_SUSPEND = 0,
+ HID_EXIT_SUSPEND = 1,
+} T_HID_CTL_POINT;
+
+/**
+* @brief Human Interface Device Service protocol mode
+*/
+typedef enum
+{
+ BOOT_PROTOCOL_MODE = 0,
+ REPORT_PROCOCOL_MODE = 1
+} T_HID_PROTOCOL_MODE;
+
+/** @defgroup HIDS_KB_Upstream_Message HIDS Keyboard Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+typedef enum
+{
+ NOTIFY_ENABLE,
+ NOTIFY_DISABLE
+} T_HID_NOTIFY;
+
+typedef union
+{
+ uint8_t voice_enable;
+ uint8_t protocol_mode;
+ uint8_t suspend_mode;
+ uint8_t output;
+ struct
+ {
+ uint8_t reportLen;
+ uint8_t *report;
+ } report_data;
+} T_HID_WRITE_PARAMETER;
+
+typedef struct
+{
+ uint8_t write_type;
+ T_HID_WRITE_PARAMETER write_parameter;
+} T_HID_WRITE_MSG;
+
+typedef struct
+{
+ uint8_t index;
+ T_HID_NOTIFY value;
+} T_HID_NOT_IND_DATA;
+
+typedef struct
+{
+ uint8_t read_value_index;
+ T_HID_WRITE_MSG write_msg;
+ T_HID_NOT_IND_DATA not_ind_data;
+} T_HID_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_HID_UPSTREAM_MSG_DATA msg_data;
+} T_HID_CALLBACK_DATA;
+
+/** @} End of HIDS_KB_Upstream_Message */
+
+
+/** End of HIDS_KB_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HIDS_KB_Exported_Functions HIDS Keyboard Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add HID service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ hids_id = hids_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID hids_add_service(void *p_func);
+
+/**
+ * @brief Set a HID service parameter.
+ *
+ * NOTE: You can call this function with a HID service parameter type and it will set the
+ * HID service parameter. HID service parameters are defined in @ref T_HIDS_PARAM_TYPE.
+ *
+ * @param[in] param_type HID service parameter type: @ref T_HIDS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t mode = 1;
+ hids_set_parameter(HID_PROTOCOL_MODE, 1, &mode);
+ }
+ * \endcode
+ */
+bool hids_set_parameter(T_HIDS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send HIDS notification data .
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] index hids characteristic index.
+ * @param[in] p_data report value pointer.
+ * @param[in] data_len length of report data.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t conn_id = 0;
+ T_SERVER_ID service_id = hids_id;
+ uint8_t hid_report_input[] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
+ hids_send_report(conn_id, service_id, GATT_SVC_HID_REPORT_INPUT_INDEX, hid_report_input, sizeof(hid_report_input));
+ }
+ * \endcode
+ */
+bool hids_send_report(uint8_t conn_id, T_SERVER_ID service_id, uint16_t index, uint8_t *p_data,
+ uint16_t data_len);
+
+
+/** @} End of HIDS_KB_Exported_Functions */
+
+/** @} End of HIDS_KB */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
diff --git a/inc/bluetooth/profile/server/hids_rmc.h b/inc/bluetooth/profile/server/hids_rmc.h
new file mode 100644
index 0000000..ccd3986
--- /dev/null
+++ b/inc/bluetooth/profile/server/hids_rmc.h
@@ -0,0 +1,252 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids_rmc.h
+ * @brief Head file for using Human Interface Device Service Remote Controller.
+ * @details HIDS RMC data structs and external functions declaration.
+ * @author Chenjie Jin
+ * @date 2018-5-7
+ * @version v1.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _HIDS_RMC_H
+#define _HIDS_RMC_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+#include "board.h"
+
+/** @defgroup HIDS_RmC HIDS Human Interface Device Service of Remote Controller
+ * @brief Human Interface Device Service Remote Controller
+ * @{
+ */
+
+/** @defgroup HIDS_RmC_Exported_Constants HIDS RmC Exported Constants
+ * @brief macros that other .c files may use all defined here
+ * @{
+ */
+
+/** @brief HIDS Report Id Definition. */
+#define HIDS_KB_REPORT_ID 1
+#if FEATURE_SUPPORT_MULTIMEDIA_KEYBOARD
+#define HIDS_MM_KB_REPORT_ID 2
+#endif
+#if (VOICE_ENC_TYPE == SW_MSBC_ENC)
+#define HIDS_VOICE_REPORT_ID 0x5A // input and output
+#elif (VOICE_ENC_TYPE == SW_SBC_ENC)
+#define HIDS_VOICE_REPORT_ID 0x5B // input and output
+#else
+#define HIDS_VOICE_REPORT_ID 0x5A // input and output
+#endif
+
+
+/** @defgroup HIDS_RmC_Application_Parameters HIDS RmC Application Parameters
+ * @brief Type of parameters set/got from application.
+ * @{
+ */
+#define HIDS_PARAM_PROTOCOL_MODE 1
+#define HIDS_PARAM_SUSPEND_MODE 2
+#define HIDS_PARAM_HID_INFO 3
+#define HIDS_PARAM_REPORT 4
+/** @} */
+
+///@cond
+/** @brief HIDS_RmC related UUIDs. */
+#define GATT_UUID_HID 0x1812
+#define GATT_UUID_CHAR_HID_CONTROL_POINT 0x2A4C
+#define GATT_UUID_CHAR_HID_INFO 0x2A4A
+#define GATT_UUID_CHAR_REPORT 0x2A4D
+#define GATT_UUID_CHAR_REPORT_MAP 0x2A4B
+#define GATT_UUID_CHAR_RECORD_ACCESS_POINT 0x2A52
+#define GATT_UUID_CHAR_PROTOCOL_MODE 0x2A4E
+#define GATT_UUID_CHAR_BOOT_KB_IN_REPORT 0x2A22
+#define GATT_UUID_CHAR_BOOT_KB_OUT_REPORT 0x2A32
+#define GATT_UUID_CHAR_BOOT_MOUSE_IN_REPORT 0x2A33
+#define GATT_UUID_CHAR_REPORT_REFERENCE 0x2908
+#define GATT_UUID_CHAR_EXTERNAL_REPORT_REFERENCE 0x2907
+
+///@endcond
+
+/** @defgroup HIDS_RmC_Attribute_Index HIDS RmC Attribute Index
+ * @brief Index defines for Characteristic's value in HID Device
+ * @{
+ */
+#define GATT_SRV_HID_INDEX_MAX 23
+#define GATT_SVC_HID_INFO_INDEX (2) /**< @brief Index for HID Information chars's value */
+#define GATT_SVC_HID_CONTROL_POINT_INDEX (4) /**< @brief Index for HID Control Point chars's value */
+#define GATT_SVC_HID_PROTOCOL_MODE_INDEX (6) /**< @brief Index for HID Protocol Mode chars's value */
+#define GATT_SVC_HID_REPORT_MAP_INDEX (8) /**< @brief Index for HID Report Map chars's value */
+
+#define GATT_SRV_HID_KB_INPUT_INDEX (10)
+#define GATT_SRV_HID_KB_CCCD_INDEX (GATT_SRV_HID_KB_INPUT_INDEX + 1)
+
+#if SUPPORT_VOICE_FEATURE
+#define GATT_SRV_HID_VOICE_INPUT_INDEX (14)
+#define GATT_SRV_HID_VOICE_INPUT_CCCD_INDEX (GATT_SRV_HID_VOICE_INPUT_INDEX + 1)
+#define GATT_SRV_HID_VOICE_OUTPUT_INDEX (18)
+#endif
+
+#if FEATURE_SUPPORT_MULTIMEDIA_KEYBOARD
+#if SUPPORT_VOICE_FEATURE
+#define GATT_SRV_HID_MM_KB_INPUT_INDEX (21)
+#define GATT_SRV_HID_MM_KB_INPUT_CCCD_INDEX (GATT_SRV_HID_MM_KB_INPUT_INDEX + 1)
+#else
+#define GATT_SRV_HID_MM_KB_INPUT_INDEX (14)
+#define GATT_SRV_HID_MM_KB_INPUT_CCCD_INDEX (GATT_SRV_HID_MM_KB_INPUT_INDEX + 1)
+#endif
+#endif
+/** @} */
+
+/** @defgroup HIDS_RmC_Upstream_Message HIDS RmC Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+
+/** @defgroup HIDS_RmC_Read_Info HIDS RmC Read Info
+ * @brief Parameter for read characteristic value.
+ * @{
+ */
+#define HIDS_READ_PARAM_PROTOCOL_MODE 1
+#define HIDS_READ_PARAM_SUSPEND_MODE 2
+#define HIDS_READ_PARAM_HID_INFO 3
+#define HIDS_READ_PARAM_REPORT 4
+/** @} */
+
+/** @defgroup HIDS_RmC_Write_Info HIDS RmC Write Info
+ * @brief Parameter for write characteristic value.
+ * @{
+ */
+#define HID_WRITE_VIOCE_CMD 1
+#define HID_WRITE_PROTOCOL_MODE 2
+#define HID_WRITE_SUSPEND_MODE 3
+#define HID_WRITE_OUTPUT 4
+#define HID_WRITE_INPUT_REPORT 5
+/** @} */
+
+/** @defgroup HIDS_RmC_Notify_Indicate_Info HIDS RmC Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define HID_NOTIFY_INDICATE_KB_ENABLE 1
+#define HID_NOTIFY_INDICATE_KB_DISABLE 2
+#define HID_NOTIFY_INDICATE_VOICE_ENABLE 3
+#define HID_NOTIFY_INDICATE_VOICE_DISABLE 4
+#define HID_NOTIFY_INDICATE_MM_KB_ENABLE 5
+#define HID_NOTIFY_INDICATE_MM_KB_DISABLE 6
+
+/** @} */
+
+/** @} End of HIDS_RmC_Upstream_Message */
+
+/** @} End of HIDS_RmC_Exported_Constants */
+
+/** @defgroup HIDS_RmC_Exported_Types HIDS RmC Exported Types
+ * @brief types that other.c files may use all defined here
+ * @{
+ */
+
+/* Add all public types here */
+
+/** @struct _HID_INFO_ATTRB hids_rmc.h "hids_rmc.h"
+ * @brief type define for value of HID information
+ */
+typedef struct _HID_INFO_ATTRB
+{
+ uint8_t CountryCode;
+ uint8_t bFlags;
+ uint16_t BcdHID;
+} HID_INFO_ATTRB;
+
+/** @brief enum for TProfile_HIDReportType*/
+typedef enum
+{
+ HID_INPUT_TYPE = 1, /**< @enum Input report */
+ HID_OUTPUT_TYPE = 2, /**< @enum Output report */
+ HID_FEATURE_TYPE = 3 /**< @enum Feature report */
+} TProfile_HIDReportType;
+
+/** @struct _TProfile_REPORT_REFE_TABLE hids_rmc.h "hids_rmc.h"
+ * @brief type define for info reference to report data
+ */
+typedef struct _TProfile_REPORT_REFE_TABLE
+{
+ uint8_t report_size; /**< @brief report size according to value of Report Map value, byte */
+ uint8_t report_id; /**< @brief report ID defined in value of Report Map Char, byte */
+ uint8_t report_type; /**< @brief report Type(Input,Output,Feature), ref: @ref TProfile_HIDReportType */
+} TProfile_REPORT_REFE_TABLE;
+
+/** @defgroup HIDS_RmC_Callback_Data HIDS RmC Callback Data
+ * @brief HIDS RmC data struct for notification data to application.
+ * @{
+ */
+
+/** @brief value for HID protocol mode characteristic */
+enum TProfile_HID_PROTOCOL_MODE
+{
+ BOOT_PROTOCOL_MODE = 0, /**< @enum boot protocol mode */
+ REPORT_PROCOCOL_MODE = 1 /**< @enum report protocol mode */
+};
+
+typedef union _THID_WRITE_PARAMETER
+{
+ uint8_t voice_enable;
+ uint8_t protocol_mode; /**< ref: @ref TProfile_HID_PROTOCOL_MODE */
+ uint8_t suspend_mode;
+ struct
+ {
+ uint8_t reportLen;
+ uint8_t *report;
+ } report_data;
+} THID_WRITE_PARAMETER;
+
+/** @struct _THID_WRITE_MSG hids_rmc.h "hids_rmc.h"
+ * @brief write message
+ */
+typedef struct _THID_WRITE_MSG
+{
+ uint8_t write_type; /**< ref: @ref HIDS_RmC_Write_Info */
+ THID_WRITE_PARAMETER write_parameter;
+} THID_WRITE_MSG;
+
+typedef union _THID_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index; /**< ref: @ref HIDS_RmC_Notify_Indicate_Info */
+ uint8_t read_value_index; /**< ref: @ref HIDS_RmC_Read_Info */
+ THID_WRITE_MSG write;
+} THID_UPSTREAM_MSG_DATA;
+
+/** @struct _T_HID_CALLBACK_DATA hids_rmc.h "hids_rmc.h"
+ * @brief callback data
+ */
+typedef struct _T_HID_CALLBACK_DATA
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ THID_UPSTREAM_MSG_DATA msg_data;
+} T_HID_CALLBACK_DATA;
+/** @} End of HIDS_RmC_Callback_Data */
+
+/** @} End of HIDS_RmC_Exported_Types */
+
+/** @defgroup HIDS_RmC_Exported_Functions HIDS RmC Exported Functions
+ * @brief functions that other .c files may use all defined here
+ * @{
+ */
+bool hids_set_parameter(uint8_t param_type, uint8_t length, void *value_ptr);
+uint8_t hids_add_service(void *p_func);
+/** @} End of HIDS_RmC_Exported_Functions */
+
+/** @} End of HIDS_RmC */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _HIDS_RMC_H */
diff --git a/inc/bluetooth/profile/server/hrs.h b/inc/bluetooth/profile/server/hrs.h
new file mode 100644
index 0000000..9825b1b
--- /dev/null
+++ b/inc/bluetooth/profile/server/hrs.h
@@ -0,0 +1,296 @@
+/*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hrs.h
+ * @brief Variables and interfaces for using Heart Rate Service.
+ * @details Heart Rate Service data structs and functions.
+ * @author
+ * @date 2017-09-21
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _HRS_SERVICE_DEF_H
+#define _HRS_SERVICE_DEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+
+/** @defgroup HRS Heart Rate Service
+ * @brief Heart Rate Service
+ * @details
+
+ The Heart Rate Service exposes heart rate and other data related to a heart rate sensor intended for fitness applications.
+
+ Application shall register heart rate service when initialization through @ref hrs_add_service function.
+
+ The Heart Rate Measurement characteristic is used to send a heart rate measurement. Included in the characteristic are a Flags field (for showing the presence of optional fields and features
+ supported), a heart rate measurement value field and, depending upon the contents of the Flags field, an Energy Expended field and an RR-Interval field. The RR-Interval represents the time between
+ two consecutive R waves in an Electrocardiogram (ECG) waveform.
+ Application can send heart rate measurement value through @ref hrs_heart_rate_measurement_value_notify function.
+
+ The Body Sensor Location characteristic of the device is used to describe the intended location of the heart rate measurement for the device.
+ The value of the Body Sensor Location characteristic is static while in a connection.
+
+ The Heart Rate Control Point characteristic is used to enable a Client to write control points to a Server to control behavior.
+ Support for this characteristic is mandatory if the Server supports the Energy Expended feature.
+
+ Application can set heart rate measurement parameter and location of the heart rate measurement for the device through @ref hrs_set_parameter function.
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup HRS_Exported_Macros HRS Exported Macros
+ * @brief
+ * @{
+ */
+
+
+/** @defgroup HRS_Read_Info HRS Read Info
+ * @brief Parameter for reading characteristic value.
+ * @{
+ */
+#define HRS_READ_BODY_SENSOR_LOCATION_VALUE 1
+/** @} */
+
+/** @defgroup HRS_Notify_Indicate_Info HRS Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define HRS_NOTIFY_INDICATE_MEASUREMENT_VALUE_ENABLE 1
+#define HRS_NOTIFY_INDICATE_MEASUREMENT_VALUE_DISABLE 2
+/** @} */
+
+
+
+/** @defgroup HRS_Sensor_Location HRS Sensor Location
+ * @brief Body Sensor Location Value
+ * @{
+ */
+#define BODY_SENSOR_LOCATION_VALUE_OTHER 0
+#define BODY_SENSOR_LOCATION_VALUE_CHEST 1
+#define BODY_SENSOR_LOCATION_VALUE_WRIST 2
+#define BODY_SENSOR_LOCATION_VALUE_FINGER 3
+#define BODY_SENSOR_LOCATION_VALUE_HAND 4
+#define BODY_SENSOR_LOCATION_VALUE_EAR_LOBE 5
+#define BODY_SENSOR_LOCATION_VALUE_FOOT 6
+/** @} */
+
+#define HRS_MAX_CTL_PNT_VALUE 1
+
+/** End of HRS_Exported_Macros
+* @}
+*/
+
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HRS_Exported_Types HRS Exported Types
+ * @brief
+ * @{
+ */
+
+typedef enum
+{
+ HRS_HEART_RATE_MEASUREMENT_PARAM_FLAG = 0x01,
+ HRS_HEART_RATE_MEASUREMENT_PARAM_MEASUREMENT_VALUE,
+ HRS_HEART_RATE_MEASUREMENT_PARAM_ENERGY_EXPENDED,
+ HRS_HEART_RATE_MEASUREMENT_PARAM_RR_INTERVAL,
+ HRS_BODY_SENSOR_LOCATION_PARAM_VALUE = 0x10,
+} T_HRS_PARAM_TYPE;
+
+typedef enum
+{
+ HRS_HEART_RATE_CP_OPCODE_RESERVED = 0,
+ HRS_HEART_RATE_CP_OPCODE_RESET_ENERGY_EXPENDED = 1
+} T_HRS_HEART_RATE_CP_OPCODE;
+
+
+/** notification indification flag */
+typedef struct
+{
+ uint8_t heart_rate_measurement_notify_enable: 1;
+ uint8_t rfu: 7;
+} HRS_NOTIFY_INDICATE_FLAG;
+
+/** Heart Rate Measurement Value Flag */
+typedef struct
+{
+ uint8_t heart_rate_value_format_bit: 1;
+ uint8_t sensor_contact_status_bits: 2;
+ uint8_t energy_expended_status_bit: 1;
+ uint8_t rr_interval_bit: 1;
+ uint8_t rfu: 3;
+} T_HEART_RATE_MEASUREMENT_VALUE_FLAG;
+
+/** Heart Rate Measurement Value */
+typedef struct
+{
+ T_HEART_RATE_MEASUREMENT_VALUE_FLAG flag;
+ uint16_t heart_rate_measurement_value;
+ uint16_t energy_expended;
+ uint16_t rr_interval;
+} T_HEART_RATE_MEASUREMENT_VALUE;
+
+/**
+ * @brief HRS Control Point data, variable length during connection, max can reach 17 bytes.
+ *
+ * HRS Control Point data used to store the Control Point Command received from the client.
+*/
+typedef struct
+{
+ uint8_t cur_length; /**< length of current CSC Control Point data . */
+ uint8_t value[HRS_MAX_CTL_PNT_VALUE]; /**< value of current CSC Control Point data . */
+} T_HRS_CONTROL_POINT;
+
+typedef struct
+{
+ T_HRS_HEART_RATE_CP_OPCODE opcode;
+} T_HRS_WRITE_MSG;
+
+typedef union
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+ T_HRS_WRITE_MSG write;
+} T_HRS_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_HRS_UPSTREAM_MSG_DATA msg_data;
+} T_HRS_CALLBACK_DATA;
+/** End of HRS_Exported_Types
+* @}
+*/
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HRS_Exported_Functions HRS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add heart rate service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ hrs_id = hrs_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+uint8_t hrs_add_service(void *p_func);
+
+
+/**
+ * @brief Set a heart rate service parameter.
+ *
+ * NOTE: You can call this function with a heart rate service parameter type and it will set the
+ * heart rate service parameter. Heart rate service parameters are defined
+ * in @ref T_HTS_TEMPERATURE_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Health thermometer service parameter type: @ref T_HRS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ T_HEART_RATE_MEASUREMENT_VALUE_FLAG flag;
+ flag.heart_rate_value_format_bit = 1;
+ flag.sensor_contact_status_bits = 3;
+ if (p_parse_value->param_count >= 1)
+ {
+ flag.sensor_contact_status_bits = p_parse_value->dw_param[1];
+ }
+
+ flag.energy_expended_status_bit = 1;
+ flag.rr_interval_bit = 1;
+ flag.rfu = 0;
+
+ hrs_set_parameter(HRS_HEART_RATE_MEASUREMENT_PARAM_FLAG, 1, &flag);
+ }
+ * \endcode
+ */
+
+bool hrs_set_parameter(T_HRS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send heart rate measurement value notification data.
+ * Application shall call @ref hrs_set_parameter to set heart rate measurement value first,
+ * and the call this api to send the notication value.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ bool op_result;
+
+ T_HEART_RATE_MEASUREMENT_VALUE_FLAG flag;
+ flag.heart_rate_value_format_bit = 1;
+ flag.sensor_contact_status_bits = 3;
+ if (p_parse_value->param_count >= 1)
+ {
+ flag.sensor_contact_status_bits = p_parse_value->dw_param[1];
+ }
+
+ flag.energy_expended_status_bit = 1;
+ flag.rr_interval_bit = 1;
+ flag.rfu = 0;
+
+ hrs_set_parameter(HRS_HEART_RATE_MEASUREMENT_PARAM_FLAG, 1, &flag);
+
+ op_result = hrs_heart_rate_measurement_value_notify(p_parse_value->dw_param[0], hrs_id);
+ }
+ * \endcode
+ */
+bool hrs_heart_rate_measurement_value_notify(uint8_t conn_id, T_SERVER_ID service_id);
+
+/** @} End of HRS_Exported_Functions */
+
+/** @} End of HRS */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _HRS_SERVICE_DEF_H */
+
diff --git a/inc/bluetooth/profile/server/hts.h b/inc/bluetooth/profile/server/hts.h
new file mode 100644
index 0000000..179642d
--- /dev/null
+++ b/inc/bluetooth/profile/server/hts.h
@@ -0,0 +1,349 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hts.h
+ * @brief Variables and interfaces for using Health Thermometer Service.
+ * @details Health Thermometer Service data structs and functions.
+ * @author
+ * @date 2017-09-20
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _HTS_SERVICE_DEF_H
+#define _HTS_SERVICE_DEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "stdint.h"
+#include "profile_server.h"
+#include "rtl876x.h"
+
+
+/** @defgroup HTS Health Thermometer Service
+ * @brief Health Thermometer Service
+ * @details
+
+ The Health Thermometer Service exposes temperature and other data related to a thermometer used for healthcare applications.
+ Application shall register Health Thermometer Service when initialization through @ref hts_add_service function.
+
+ The Temperature Measurement characteristic is used to send a temperature measurement.
+ Application can send a temperature measurement through @ref hts_measurement_value_indicate function.
+
+ The Intermediate Temperature characteristic is used to send intermediate temperature values to a device
+ for display purposes while the measurement is in progress.
+ Application can send intermediate temperature values through @ref hts_intermediate_temperature_value_notify function.
+
+ The Measurement Interval characteristic is used to enable and control the interval
+ between consecutive temperature measurements.
+ Application can send interval through @ref hts_measurement_interval_notify function.
+
+
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup HTS_Exported_Macros HTS Exported Macros
+ * @brief
+ * @{
+ */
+
+#define HTS_READ_TEMPERATURE_TYPE_VALUE 1
+#define HTS_READ_MEASUREMENT_INTERVAL_VALUE 2
+#define HTS_READ_VALID_RANGE_VALUE 3
+
+
+#define HTS_WRITE_MEASUREMENT_INTERVAL_VALUE 1
+
+/** @defgroup HTS_Notify_Indicate_Info HTS Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define HTS_NOTIFY_INDICATE_TEMPERATURE_MEASUREMENT_VALUE_ENABLE 1
+#define HTS_NOTIFY_INDICATE_TEMPERATURE_MEASUREMENT_VALUE_DISABLE 2
+#define HTS_NOTIFY_INDICATE_INTERMEDIATE_TEMPERATURE_VALUE_ENABLE 3
+#define HTS_NOTIFY_INDICATE_INTERMEDIATE_TEMPERATURE_VALUE_DISABLE 4
+#define HTS_NOTIFY_INDICATE_MEASUREMENT_INTERVAL_VALUE_ENABLE 5
+#define HTS_NOTIFY_INDICATE_MEASUREMENT_INTERVAL_VALUE_DISABLE 6
+/** @} */
+
+/** @defgroup HTS_Measurement_Flag HTS Measurement Flag
+ * @{
+ */
+#define HTS_FLAG_MEASUREMENT_UINT_BIT BIT0
+#define HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT BIT1
+#define HTS_FLAG_MEASUREMENT_TYPE_PRESENT_BIT BIT2
+/** @} */
+
+/** End of HTS_Exported_Macros
+* @}
+*/
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup HTS_Exported_Types HTS Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Health Thermometer parameter type
+*/
+typedef enum
+{
+ HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG = 1,
+ HTS_PARAM_MEASUREMENT_TEMPERATUER_VALUE,
+ HTS_PARAM_MEASUREMENT_TIME_STAMP,
+ HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE,
+ HTS_PARAM_MEASUREMENT_INTERVAL,
+ HTS_PARAM_VALID_RANGE
+} T_HTS_PARAM_TYPE;
+
+/**
+* @brief Health Thermometer temperature type
+*/
+typedef enum
+{
+ HTS_TEMPERATURE_TYPE_ARMPIT = 1,
+ HTS_TEMPERATURE_TYPE_BODY,
+ HTS_TEMPERATURE_TYPE_EAR,
+ HTS_TEMPERATURE_TYPE_FINGER,
+ HTS_TEMPERATURE_TYPE_GASTRO_INTESTINAL_TRACT,
+ HTS_TEMPERATURE_TYPE_MOUTH,
+ HTS_TEMPERATURE_TYPE_RECTUM,
+ HTS_TEMPERATURE_TYPE_TOE,
+ HTS_TEMPERATURE_TYPE_TYMPANUM,
+ HTS_TEMPERATURE_TYPE_RESERVED,
+} T_HTS_TEMPERATURE_TYPE;
+
+/**
+* @brief Health Thermometer Measurement Value Flag
+*/
+typedef struct
+{
+ uint8_t temp_value_units_bit: 1;
+ uint8_t temp_time_stamp_present_bit: 1;
+ uint8_t temp_type_present_bit: 1;
+ uint8_t rfu: 5;
+} T_HEALTH_THERMOMETER_MEASUREMENT_VALUE_FLAG;
+
+typedef struct
+{
+ uint16_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hours;
+ uint8_t minutes;
+ uint8_t seconds;
+} T_TIME_STAMP;
+
+typedef struct
+{
+ uint16_t lower_value;
+ uint16_t upper_value;
+} T_HTS_MEASUREMENT_INTERVAL_VALID_RANGE;
+
+typedef struct
+{
+ uint8_t write_index;
+ uint16_t measurement_interval;
+} T_HTS_WRITE_MSG;
+
+/**
+* @brief Health Thermometer Service upper stream message data
+*/
+typedef union
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+ T_HTS_WRITE_MSG write;
+} T_HTS_UPSTREAM_MSG_DATA;
+
+/**
+* @brief Health Thermometer Service callback data
+*/
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_HTS_UPSTREAM_MSG_DATA msg_data;
+} T_HTS_CALLBACK_DATA;
+
+/** End of HTS_Exported_Types
+* @}
+*/
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup HTS_Exported_Functions HTS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add health thermometer service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ hts_id = hts_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+uint8_t hts_add_service(void *p_func);
+
+
+/**
+ * @brief Set a health thermometer service parameter.
+ *
+ * NOTE: You can call this function with a health thermometer service parameter type and it will set the
+ * health thermometer service parameter. Health thermometer service parameters are defined
+ * in @ref T_HTS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Health thermometer service parameter type: @ref T_HTS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t hts_flag = HTS_FLAG_MEASUREMENT_UINT_BIT | HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT |
+ HTS_FLAG_MEASUREMENT_TYPE_PRESENT_BIT;
+ T_HTS_TEMPERATURE_TYPE temperature_type = HTS_TEMPERATURE_TYPE_ARMPIT;
+
+ hts_measure_time_stamp.seconds += hts_measurement_interval;
+
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG, sizeof(hts_flag), &hts_flag);
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(hts_measure_time_stamp),
+ &hts_measure_time_stamp);
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE, 1, &temperature_type);
+ }
+ * \endcode
+ */
+
+bool hts_set_parameter(T_HTS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send measurement value indication data .
+ * Application shall call @ref hts_set_parameter to set intermediate temperature value first,
+ * and the call this api to send the notication value.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t hts_flag = HTS_FLAG_MEASUREMENT_UINT_BIT | HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT |
+ HTS_FLAG_MEASUREMENT_TYPE_PRESENT_BIT;
+ T_HTS_TEMPERATURE_TYPE temperature_type = HTS_TEMPERATURE_TYPE_ARMPIT;
+
+ hts_measure_time_stamp.seconds += hts_measurement_interval;
+
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG, sizeof(hts_flag), &hts_flag);
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(hts_measure_time_stamp),
+ &hts_measure_time_stamp);
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE, 1, &temperature_type);
+
+ hts_measurement_value_indicate(p_parse_value->dw_param[0], hts_id);
+ }
+ * \endcode
+ */
+bool hts_measurement_value_indicate(uint8_t conn_id, uint8_t service_id);
+
+/**
+ * @brief Send intermediate temperature notification data.
+ * Application shall call @ref hts_set_parameter to set intermediate temperature value first,
+ * and the call this api to send the notication value.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t hts_flag = HTS_FLAG_MEASUREMENT_UINT_BIT
+ | HTS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT
+ | HTS_FLAG_MEASUREMENT_TYPE_PRESENT_BIT;
+ T_HTS_TEMPERATURE_TYPE temperature_type = HTS_TEMPERATURE_TYPE_ARMPIT;
+
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPPARAM_FLAG, sizeof(hts_flag), &hts_flag);
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(hts_measure_time_stamp),
+ &hts_measure_time_stamp);
+ hts_set_parameter(HTS_PARAM_MEASUREMENT_TEMPERATURE_TYPE, 1, &temperature_type);
+
+ hts_intermediate_temperature_value_notify(p_parse_value->dw_param[0], hts_id);
+
+ return RESULT_SUCCESS;
+
+ }
+ * \endcode
+ */
+bool hts_intermediate_temperature_value_notify(uint8_t conn_id, uint8_t service_id);
+
+
+/**
+ * @brief Send measurement interval notification data.
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] seconds Measurement interval.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint16_t interval = 90;
+ hts_measurement_interval_notify(p_parse_value->dw_param[0], hts_id, interval);
+ }
+ * \endcode
+ */
+bool hts_measurement_interval_notify(uint8_t conn_id, uint8_t service_id, uint16_t seconds);
+
+/** @} End of HTS_Exported_Functions */
+
+/** @} End of HTS */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _HTS_SERVICE_DEF_H
+
diff --git a/inc/bluetooth/profile/server/ias.h b/inc/bluetooth/profile/server/ias.h
new file mode 100644
index 0000000..3e30cf3
--- /dev/null
+++ b/inc/bluetooth/profile/server/ias.h
@@ -0,0 +1,102 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ias.h
+ * @brief Head file for using immediate alert service.
+ * @details IAS data structs and external functions declaration.
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _IAS_H_
+#define _IAS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+
+/** @defgroup IAS Immediate Alert Service
+ * @brief Immediate alert service
+ * @details
+
+ The Immediate Alert Service (IAS) exposes a control point to allow a peer device to cause the device to immediately alert.
+
+ Immediate Alert Service contains an Alert Level characteristic, to which any value other than "No Alert" being written will trigger alarm in the device.
+
+ Immediate Alert Service generally constitutes a profile collectively with other Services, such as Proximity or Find Me etc., which enables immediate alert in device.
+
+ Application shall register Immediate Alert Service when initialization through @ref ias_add_service function.
+
+ * @{
+ */
+/*============================================================================*
+ * Types
+ *============================================================================*/
+
+/** @defgroup IAS_Exported_Types IAS Exported Types
+ * @brief
+ * @{
+ */
+/** Message content */
+typedef union
+{
+ uint8_t write_alert_level;
+} T_IAS_UPSTREAM_MSG_DATA;
+
+/** IAS service data to inform application */
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_IAS_UPSTREAM_MSG_DATA msg_data;
+} T_IAS_CALLBACK_DATA;
+
+/** @} End of IAS_Exported_Types */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+
+/** @defgroup IAS_Exported_Functions IAS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add immediate alert service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ ias_id = ias_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID ias_add_service(void *p_func);
+
+/** @} End of IAS_Exported_Functions */
+
+/** @} End of IAS */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif //_IAS_H
+
diff --git a/inc/bluetooth/profile/server/ipss.h b/inc/bluetooth/profile/server/ipss.h
new file mode 100644
index 0000000..3589c3d
--- /dev/null
+++ b/inc/bluetooth/profile/server/ipss.h
@@ -0,0 +1,77 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file ipss.h
+ * @brief Head file for using internet protocol support service.
+ * @details HIDS data structs and external functions declaration.
+ * @author Jeff_Zheng
+ * @date 2017-12-01
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _IPSS_H_
+#define _IPSS_H_
+
+#include <stdint.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup IPSS Internet Protocol Support Service
+ * @brief Internet Protocol Support Service
+ * @details
+
+ The Internet Protocol Support Profile (IPSP) allows devices to discover and communicate to
+ other devices that support IPSP. The communication between the devices that support IPSP
+ is done using IPv6 packets over the Bluetooth Low Energy transport.
+
+ Application shall register IPS service when initialization through @ref ipss_add_service function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup IPSS_Exported_Macros IPSS Exported Macros
+ * @brief
+ * @{
+ */
+#define GATT_UUID_IPSS 0x1820
+
+/** End of IPSS_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup IPSS_Exported_Functions IPSS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief add ipss service to application.
+ *
+ * @param[in] p_func pointer of app callback function called by profile.
+ * @return service id auto generated by profile layer.
+ * @retval service id
+ */
+uint8_t ipss_add_service(void *p_func);
+
+/** @} End of IPSS_Exported_Functions */
+
+/** @} End of IPSS */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
diff --git a/inc/bluetooth/profile/server/lls.h b/inc/bluetooth/profile/server/lls.h
new file mode 100644
index 0000000..4036bbb
--- /dev/null
+++ b/inc/bluetooth/profile/server/lls.h
@@ -0,0 +1,159 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file lls.h
+ * @brief Head file for using link loss service.
+ * @details LLS data structs and external functions declaration.
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _LLS_H_
+#define _LLS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+/** @defgroup LLS Link Loss Service
+ * @brief Link loss service
+ * @details
+
+ The Link Loss Service (LLS) defines behavior when a link is lost between two devices.
+
+ The Link Loss Service uses the Alert Level characteristic to cause an alert in the device
+ when the link is lost.
+
+ Link Loss Service generally constitutes a profile collectively with other Services, such
+ as Proximity or Find Me etc., which enables device to cause an alert when the link is lost.
+
+ Application shall register link loss service when initialization through @ref lls_add_service function.
+
+ Application can set LLS alert level value through @ref lls_set_parameter function.
+
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup LLS_Exported_Macros LLS Service Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup LLS_Read_Info LLS Read Info
+ * @brief Read characteristic value.
+ * @{
+ */
+#define LLS_READ_ALERT_LEVEL 1
+/** @} */
+
+/** @} End of LLS_Exported_Macros */
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+
+/** @defgroup LLS_Exported_Types LLS Exported Types
+ * @brief
+ * @{
+ */
+
+/** @defgroup LLS_PARAM_TYPE LLS Parameter Type
+* @brief Type of parameters set from application.
+* @{
+*/
+typedef enum
+{
+ LLS_PARAM_LINK_LOSS_ALERT_LEVEL
+} T_LLS_PARAM_TYPE;
+/** @} */
+
+/** @defgroup LLS_Callback_Data LLS Callback Data
+ * @brief LLS data struct for notification data to application.
+ * @{
+ */
+/** Message content: @ref T_LLS_CALLBACK_DATA */
+typedef union
+{
+ uint8_t read_value_index;
+ uint8_t write_alert_level;
+} T_LLS_UPSTREAM_MSG_DATA;
+
+/** LLSdata service data to inform application */
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_LLS_UPSTREAM_MSG_DATA msg_data;
+} T_LLS_CALLBACK_DATA;
+/** @} */
+
+/** @} End of LLS_Exported_Types */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+
+/** @defgroup LLS_Exported_Functions LLS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Set a link loss service parameter.
+ *
+ * NOTE: You can call this function with a link loss service parameter type and it will set the
+ * link loss service parameter. Link loss service parameters are defined in @ref T_LLS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Link loss service parameter type: @ref T_LLS_PARAM_TYPE
+ * @param[in] length Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ */
+bool lls_set_parameter(T_LLS_PARAM_TYPE param_type, uint8_t length, void *p_value);
+
+/**
+ * @brief Add link loss service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ lls_id = lls_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID lls_add_service(void *p_func);
+/** @} End of LLS_Exported_Functions */
+
+/** @} End of LLS*/
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/inc/bluetooth/profile/server/lns.h b/inc/bluetooth/profile/server/lns.h
new file mode 100644
index 0000000..d4cf795
--- /dev/null
+++ b/inc/bluetooth/profile/server/lns.h
@@ -0,0 +1,484 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file lns.h
+ * @brief Variables and interfaces for using Location And Navigation Service.
+ * @details Location And Navigation Service data structs and functions.
+ * @author ranhui
+ * @date 2017-09-20
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _LNS_SERVICE_DEF_H
+#define _LNS_SERVICE_DEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+/** @defgroup LNS Location And Navigation Service
+ * @brief Location And Navigation service
+ * @details
+
+ The Location and Navigation Service (LN Service) exposes location and navigation-related data from a
+ Location and Navigation sensor (Server) intended for outdoor activity applications.
+
+ Application shall register LN Service when initialization through @ref lns_add_service function.
+
+ The LN Feature characteristic shall be used to describe the supported features of the Server.
+ Reserved for Future Use (RFU) bits in the LN Feature characteristic value shall be set to 0.
+
+ The Location and Speed characteristic is used to send location and speed related data.
+
+ Application can send location and speed related data through @ref lns_location_and_speed_value_notify function.
+
+ The Position Quality characteristic is used to send position quality-related data.
+
+ If the LN Control Point is supported, profiles utilizing this service are required to ensure that the Client configures the LN Control Point characteristic for indications (i.e., via the Client
+ Characteristic Configuration descriptor) at the first connection.
+ Support for this characteristic is mandatory if the Server supports any of the features requiring control point procedures.
+
+ The Navigation characteristic is used to send navigation-related data.
+ Application can send navigation-related data through @ref lns_navigation_value_notify function.
+
+ Application can set the parameters of LNS through @ref lns_set_parameter function.
+
+
+ * @{
+ */
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup LNS_Exported_Macros LNS Exported Macros
+ * @brief
+ * @{
+ */
+
+
+/** @defgroup LNS_LN_Feature LNS LN Feature
+ * @{
+ */
+#define LN_FEATURE_INSTANTANEOUS_SPEED_SUPPORTED BIT0
+#define LN_FEATURE_TOTAL_DISTANCE_SUPPORTED BIT1
+#define LN_FEATURE_LOCATION_SUPPORTED BIT2
+#define LN_FEATURE_ELEVATION_SUPPORTED BIT3
+#define LN_FEATURE_HEADING_SUPPORTED BIT4
+#define LN_FEATURE_ROLLING_TIME_SUPPORTED BIT5
+#define LN_FEATURE_UTC_TIME_SUPPORTED BIT6
+#define LN_FEATURE_REMAINING_DISTANCE_SUPPORTED BIT7
+#define LN_FEATURE_REMAINING_VERTICAL_DISTANCE_SUPPORTED BIT8
+#define LN_FEATURE_ESTIMATED_TIME_OF_ARRIVAL_SUPPORTED BIT9
+#define LN_FEATURE_NUMBER_OF_BEACONS_IN_SOLUTION_SUPPORTED BIT10
+#define LN_FEATURE_NUMBER_OF_BEACONS_IN_VIEW_SUPPORTED BIT11
+#define LN_FEATURE_TIME_TO_FIRST_FIX_SUPPORTED BIT12
+#define LN_FEATURE_ESTIMATED_HORIZONTAL_POSITION_ERROR_SUPPORTED BIT13
+#define LN_FEATURE_ESTIMATED_VERTICAL_POSITION_ERROR_SUPPORTED BIT14
+#define LN_FEATURE_HORIZONTAL_DILUTION_OF_PRECISION_SUPPORTED BIT15
+#define LN_FEATURE_VERTICAL_DILUTION_OF_PRECISION_SUPPORTED BIT16
+#define LN_FEATURE_LOCATION_AND_SPEED_CHARACTERISTIC_CONTENT_MASKING_SUPPORTED BIT17
+#define LN_FEATURE_FIX_RATE_SETTING_SUPPORTED BIT18
+#define LN_FEATURE_ELEVATION_SETTING_SUPPORTED BIT19
+#define LN_FEATURE_POSITION_STATUS_SUPPORTED BIT20
+#define LN_FEATURE_RFU BIT21
+/** @} */
+
+#define LNS_READ_POSITION_QUALITY_VALUE 1
+
+#define LNS_NOTIFY_INDICATE_LOCATION_AND_SPEED_ENABLE 1
+#define LNS_NOTIFY_INDICATE_LOCATION_AND_SPEED_DISABLE 2
+#define LNS_NOTIFY_INDICATE_CP_ENABLE 3
+#define LNS_NOTIFY_INDICATE_CP_DISABLE 4
+#define LNS_NOTIFY_INDICATE_NAVIGATION_ENABLE 5
+#define LNS_NOTIFY_INDICATE_NAVIGATION_DISABLE 6
+
+#define LNS_MAX_CTL_PNT_VALUE 17
+
+/** End of LNS_Exported_Macros
+* @}
+*/
+
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup LNS_Exported_Types LNS Exported Types
+ * @brief
+ * @{
+ */
+
+typedef enum
+{
+ LNS_LAS_PARAM_INC_FLAG = 0x01,
+ LNS_LAS_PARAM_INSTANTANEOUS_SPEED,
+ LNS_LAS_PARAM_TOTAL_DISTANCE,
+ LNS_LAS_PARAM_LOCATION_LATITUDE,
+ LNS_LAS_PARAM_LOCATION_LONGITUDE,
+ LNS_LAS_PARAM_ELEVATION,
+ LNS_LAS_PARAM_HEADING,
+ LNS_LAS_PARAM_ROLLING_TIME,
+ LNS_LAS_PARAM_UTC_TIME,
+ LNS_LAS_PARAM_POSITION_STATUS,
+ LNS_LAS_PARAM_SPEED_AND_DISTANCE_FORMAT,
+ LNS_LAS_PARAM_ELEVATION_SOURCE,
+ LNS_LAS_PARAM_HEADING_SOURCE,
+
+ LNS_NAVIGATION_PARAM_INC_FLAG = 0x11,
+ LNS_NAVIGATION_PARAM_BEARING,
+ LNS_NAVIGATION_PARAM_HEADING,
+ LNS_NAVIGATION_PARAM_REMAINING_DISTANCE,
+ LNS_NAVIGATION_PARAM_REMAINING_VERTICAL_DISTANCE,
+ LNS_NAVIGATION_PARAM_ESTIMATED_TIME_OF_ARRIVAL,
+ LNS_NAVIGATION_PARAM_POSITION_STATUS,
+ LNS_NAVIGATION_PARAM_HEADING_SOURCE,
+ LNS_NAVIGATION_PARAM_NAVIGATION_INDICATOR_TYPE,
+ LNS_NAVIGATION_PARAM_WAYPOINT_REACHED,
+ LNS_NAVIGATION_PARAM_DESTINATION_REACHED,
+
+ LNS_PQ_PARAM_INC_FLAG = 0x20,
+ LNS_PQ_PARAM_NUMBER_OF_BEACONS_IN_SOLUTION,
+ LNS_PQ_PARAM_NUMBER_OF_BEACONS_IN_VIEW,
+ LNS_PQ_PARAM_TIME_TO_FIRST_FIX,
+ LNS_PQ_PARAM_EHPE,
+ LNS_PQ_PARAM_EVPE,
+ LNS_PQ_PARAM_HDOP,
+ LNS_PQ_PARAM_VDOP,
+
+ LNS_PARAM_LN_FEATURE_SUPPORT = 0x30,
+
+ LNS_CP_PARA_NUMBER_OF_ROUTE = 0x41,
+ LNS_CP_PARA_NAME_OF_ROUTE,
+
+ LNS_PARAM_CTL_PNT_PROG_CLR = 0x51,
+} T_LNS_PARAM_TYPE;
+
+/* Add all public types here */
+typedef struct
+{
+ uint16_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hours;
+ uint8_t minutes;
+ uint8_t seconds;
+} T_DATE_TIME;
+
+/** Position Quality Value Flag */
+typedef struct
+{
+ uint16_t number_of_beacons_in_solution_present: 1;
+ uint16_t number_of_beacons_in_view_present: 1;
+ uint16_t time_to_first_fix_present: 1;
+ uint16_t ehpe_present: 1;
+ uint16_t evpe_present: 1;
+ uint16_t hdop_present: 1;
+ uint16_t vdop_present: 1;
+ uint16_t position_status: 2;
+ uint16_t rfu: 7;
+} T_POSITION_QUALITY_VALUE_FLAG;
+
+/** Position Quality Value */
+typedef struct
+{
+ T_POSITION_QUALITY_VALUE_FLAG flag;
+ uint8_t number_of_beacons_in_solution;
+ uint8_t number_of_beacons_in_view;
+ uint16_t time_to_first_fix;
+ uint32_t ehpe;
+ uint32_t evpe;
+ uint8_t hdop;
+ uint8_t vdop;
+} T_POSITION_QUALITY_VALUE;
+
+typedef struct
+{
+ uint8_t location_and_speed_notify_enable: 1;
+ uint8_t ln_cp_indicate_enable: 1;
+ uint8_t navigation_enable: 1;
+ uint8_t rfu: 5;
+} T_LNS_NOTIFY_INDICATE_FLAG;
+
+typedef struct
+{
+ uint16_t instantaneous_speed_present: 1;
+ uint16_t total_distance_present: 1;
+ uint16_t location_present: 1;
+ uint16_t elevation_present: 1;
+ uint16_t heading_present: 1;
+ uint16_t rolling_time_present: 1;
+ uint16_t utc_time_present: 1;
+ uint16_t position_status: 2;
+ uint16_t speed_and_distance_format: 1;
+ uint16_t elevation_source: 2;
+ uint16_t heading_source: 1;
+ uint16_t rfu: 3;
+} T_LOCATION_AND_SPEED_VALUE_FLAG;
+
+/** Location and Speed Value */
+typedef struct
+{
+ T_LOCATION_AND_SPEED_VALUE_FLAG flag;
+ uint16_t instantaneous_speed;
+ uint32_t total_distance; //uint24
+ int32_t location_latitude; //sint32
+ int32_t location_longitude;
+ int32_t elevation;//sint24
+ uint16_t heading;
+ uint8_t rolling_time;
+ T_DATE_TIME utc_time;
+} LOCATION_AND_SPEED_VALUE;
+
+/** Navigation Value */
+typedef struct
+{
+ uint16_t remaining_distance_present: 1;
+ uint16_t remaining_vertical_distance_present: 1;
+ uint16_t estimated_time_of_arrival_present: 1;
+ uint16_t position_status: 2;
+ uint16_t heading_source: 1;
+ uint16_t navigation_indicator_type: 1;
+ uint16_t waypoint_reached: 1;
+ uint16_t destination_reached: 1;
+ uint16_t rfus: 7;
+} T_NAVIGATION_VALUE_FLAG;
+
+typedef struct
+{
+ T_NAVIGATION_VALUE_FLAG flag;
+ uint16_t bearing;
+ uint16_t heading;
+ uint32_t reamining_distance;
+ int32_t reamining_vertical_distance;
+ T_DATE_TIME estimated_time_of_arrival;
+} T_NAVIGATION_VALUE;
+
+typedef enum
+{
+ LN_CP_OPCODE_RESERVED = 0,
+ LN_CP_OPCODE_SET_CUMULATIVE_VALUE = 1,
+ LN_CP_OPCODE_MASK_LOCATION_AND_SPEED_CHAR_CONTENT = 2,
+ LN_CP_OPCODE_NAVIGATION_CONTROL = 3,
+ LN_CP_OPCODE_REQUEST_NUMBER_OF_ROUTES = 4,
+ LN_CP_OPCODE_REQUEST_NAME_OF_ROUTE = 5,
+ LN_CP_OPCODE_SELECT_ROUTE = 6,
+ LN_CP_OPCODE_SET_FIX_RATE = 7,
+ LN_CP_OPCODE_SET_ELEVATION = 8,
+ LN_CP_OPCODE_RESPONSE_CODE = 32
+} T_LN_CP_OPCODE;
+
+
+/**
+ * @brief CSC Control Point data, variable length during connection, max can reach 17 bytes.
+ *
+ * CSC Control Point data used to store the Control Point Command received from the client.
+*/
+typedef struct
+{
+ uint8_t cur_length; /**< length of current LNS Control Point data, . */
+ uint8_t
+ value[LNS_MAX_CTL_PNT_VALUE]; /**< value of current LNS Control Point data, . */
+} T_LNS_CONTROL_POINT;
+
+/** @defgroup LNS_Callback_Data LNS Callback Data
+ * @brief LNS data struct for notification data to application.
+ * @{
+ */
+typedef union
+{
+ uint32_t cumulative_total_distance; //uint24
+ uint16_t mask_location_and_speed;
+ uint8_t navigation_control;
+ uint16_t number_of_desired_route; //request_name_of_route
+ uint16_t select_route_desired_route_number;
+ uint8_t set_fix_rate;
+ int32_t set_elevation; //sint24
+} T_LNS_CP_PARAMETER;
+
+typedef struct
+{
+ T_LN_CP_OPCODE opcode;
+ T_LNS_CP_PARAMETER cp_parameter;
+} T_LNS_WRITE_MSG;
+
+typedef union
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+ T_LNS_WRITE_MSG write;
+} T_LNS_UPSTREAM_MSG_DATA;
+
+/** LNS service data to inform application */
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_LNS_UPSTREAM_MSG_DATA msg_data;
+} T_LNS_CALLBACK_DATA;
+/** @} */
+
+/** End of LNS_Exported_Types
+* @}
+*/
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup LNS_Exported_Functions LNS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add location and navigation service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ lns_id = lns_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+uint8_t lns_add_service(void *p_func);
+
+/**
+ * @brief Set a Location And Navigation service parameter.
+ *
+ * NOTE: You can call this function with a Location And Navigation service parameter type and it will set the
+ * Location And Navigation service parameter. Location And Navigation service parameters are defined
+ * in @ref T_LNS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Location And Navigation service parameter type: @ref T_LNS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ T_LOCATION_AND_SPEED_VALUE_FLAG flag;
+ flag.instantaneous_speed_present = 1;
+ flag.total_distance_present = 1;
+ flag.location_present = 1;
+ flag.elevation_present = 1;
+ flag.heading_present = 1;
+ flag.rolling_time_present = 1;
+ flag.utc_time_present = 1;
+ flag.position_status = 1;
+ flag.speed_and_distance_format = 1;
+ flag.elevation_source = 1;
+ flag.heading_source = 1;
+ flag.rfu = 0;
+
+ lns_set_parameter(LNS_LAS_PARAM_INC_FLAG, 2, &flag);
+ }
+ * \endcode
+ */
+bool lns_set_parameter(T_LNS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Send location and speed value notification data.
+ * Application shall call @ref lns_set_parameter to set location and speed value first,
+ * and the call this api to send the notication value.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ bool op_result;
+ T_LOCATION_AND_SPEED_VALUE_FLAG flag;
+ flag.instantaneous_speed_present = 1;
+ flag.total_distance_present = 1;
+ flag.location_present = 1;
+ flag.elevation_present = 1;
+ flag.heading_present = 1;
+ flag.rolling_time_present = 1;
+ flag.utc_time_present = 1;
+ flag.position_status = 1;
+ flag.speed_and_distance_format = 1;
+ flag.elevation_source = 1;
+ flag.heading_source = 1;
+ flag.rfu = 0;
+
+ lns_set_parameter(LNS_LAS_PARAM_INC_FLAG, 2, &flag);
+
+ op_result = lns_location_and_speed_value_notify(p_parse_value->dw_param[0], lns_id);
+ }
+ * \endcode
+ */
+bool lns_location_and_speed_value_notify(uint8_t conn_id, T_SERVER_ID service_id);
+
+/**
+ * @brief Send navigation value notification data.
+ * Application shall call @ref lns_set_parameter to set navigation value first,
+ * and the call this api to send the notication value.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ bool op_result;
+
+ T_NAVIGATION_VALUE_FLAG flag;
+ flag.remaining_distance_present = 1;
+ flag.remaining_vertical_distance_present = 1;
+ flag.estimated_time_of_arrival_present = 1;
+ flag.position_status = 1;
+ flag.heading_source = 1;
+ flag.navigation_indicator_type = 1;
+ flag.waypoint_reached = 1;
+ flag.destination_reached = 1;
+ flag.rfus = 0;
+
+ lns_set_parameter(LNS_NAVIGATION_PARAM_INC_FLAG, 2, &flag);
+
+ op_result = lns_navigation_value_notify(p_parse_value->dw_param[0], lns_id);
+
+ }
+ * \endcode
+ */
+bool lns_navigation_value_notify(uint8_t conn_id, T_SERVER_ID service_id);
+
+/** @} End of LNS_Exported_Functions */
+
+/** @} End of LNS */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // _LNS_SERVICE_DEF_H
+
diff --git a/inc/bluetooth/profile/server/ota_service.h b/inc/bluetooth/profile/server/ota_service.h
new file mode 100644
index 0000000..9f4e0dc
--- /dev/null
+++ b/inc/bluetooth/profile/server/ota_service.h
@@ -0,0 +1,142 @@
+/**
+*********************************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+**********************************************************************************************************
+* @file ota_service.h
+* @brief
+* @details
+* @author hunter_shuai
+* @date 14-July-2015
+* @version v1.0.0
+******************************************************************************
+* @attention
+* <h2><center>&copy; COPYRIGHT 2015 Realtek Semiconductor Corporation</center></h2>
+******************************************************************************
+*/
+
+#ifndef _OTA_SERVICE_H_
+#define _OTA_SERVICE_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+#include "dfu_api.h"
+/** @brief Demo Profile service related UUIDs. */
+
+#define GATT_UUID_CHAR_OTA 0xFFD1 //1
+#define GATT_UUID_CHAR_MAC 0xFFD2 //2
+#define GATT_UUID_CHAR_PATCH 0xFFD3 //3
+#define GATT_UUID_CHAR_APP_VERSION 0xFFD4 //4
+#define GATT_UUID_CHAR_PATCH_EXTENSION 0xFFD5 //5
+#define GATT_UUID_CHAR_TEST_MODE 0xFFD8 //6
+
+#define GATT_UUID_CHAR_DEVICE_INFO 0xFFF1 //7
+#define GATT_UUID_CHAR_IMAGE_COUNT_TO_UPDATE 0xFFF2 //8
+#define GATT_UUID_CHAR_IMAGE_VERSION0 0xFFE0 //mandatory when OTA version >= 1
+#define GATT_UUID_CHAR_IMAGE_VERSION1 0xFFE1
+#define GATT_UUID_CHAR_IMAGE_VERSION2 0xFFE2
+#define GATT_UUID_CHAR_PROTOCOL_TYPE 0xFFF3
+
+/** @brief Index of each characteristic in Demo Profile service database. */
+#define BLE_SERVICE_CHAR_OTA_INDEX 0x02 /**< attr write */
+#define BLE_SERVICE_CHAR_MAC_ADDRESS_INDEX 0x04 /**< attr read */
+#define BLE_SERVICE_CHAR_PATCH_INDEX 0x06 /**< attr read */
+#define BLE_SERVICE_CHAR_APP_VERSION_INDEX 0x08 /**< attr read */
+#define BLE_SERVICE_CHAR_PATCH_EXTENSION_INDEX 0x0a /**< attr read */
+#define BLE_SERVICE_CHAR_TEST_MODE_INDEX 0x0c /**< attr write */
+#define BLE_SERVICE_CHAR_DEVICE_INFO_INDEX 0x0e /**< attr read */
+#define BLE_SERVICE_CHAR_IMAGE_COUNT_INDEX 0x10 /**< attr write */
+#define BLE_SERVICE_CHAR_IMAGE_VERSION0_INDEX 0x12 /**< attr read */
+#define BLE_SERVICE_CHAR_IMAGE_VERSION1_INDEX 0x14 /**< attr read */
+#define BLE_SERVICE_CHAR_IMAGE_VERSION2_INDEX 0x16 /**< attr read */
+#define BLE_SERVICE_CHAR_PROTOCOL_TYPE_INDEX 0x18 /**< attr read */
+
+/** @brief OTA Read callback data type definition.*/
+#define OTA_READ_CHAR_MAC_ADDRESS_INDEX 0x01
+#define OTA_READ_CHAR_PATCH_INDEX 0x02
+#define OTA_READ_CHAR_APP_VERSION_INDEX 0x03
+#define OTA_READ_CHAR_PATCH_EXTENSION_INDEX 0x04
+#define OTA_READ_CHAR_DEVICE_INFO_INDEX 0x05
+#define OTA_READ_CHAR_IMAGE_VERSION_INDEX 0x06
+#define OTA_READ_CHAR_PROTOCOL_TYPE_INDEX 0x07
+
+
+/** @brief OTA Write callback data type definition.*/
+#define OTA_WRITE_CHAR_VAL 0x01 /**< switch ota mode write opcode */
+#define OTA_VALUE_ENTER 0x01 /**< switch ota mode write value */
+
+/** @brief OTA Write callback data type definition.*/
+#define OTA_WRITE_TEST_MODE_CHAR_VAL 0x02 /**< test mode write opcode */
+
+/** @brief OTA Write callback data type definition.*/
+#define OTA_WRITE_IMAGE_COUNT_VAL 0x02 /**< image count write opcode */
+#define OTA_VALUE_IMAGE_COUNT_APP_ONLY 0x01
+#define OTA_VALUE_IMAGE_COUNT_PATCH_ONLY 0x02
+#define OTA_VALUE_IMAGE_COUNT_APP_AND_PATCH 0x03
+
+#define OTA_CHAR_IMAGE_COUNT_LEN 5
+
+#define CHAR2SHORT(p) (((*(p)) & 0xff) + ((*((p)+1)) << 8))
+
+typedef struct _T_DFU_DEVICE_INFO
+{
+ uint8_t ic_type;
+ uint8_t ota_version;
+ uint8_t secure_version;
+ T_OTA_MODE ota_mode;
+
+ uint16_t max_buffer_size;
+ uint8_t temp_bank_size; //Unit:4K, 0x00:No Limitation of OTA Temp Buffer Size,Only available when Updating Multi Image at a time is supported.
+ uint8_t rsvd;
+ uint32_t img_indicator;
+
+} T_DFU_DEVICE_INFO, * P_DFU_DEVICE_INFO;
+
+typedef struct _T_OTA_UPDATE_IMAGE_INFO
+{
+ uint8_t image_count;
+ uint16_t update_patch_version;
+ uint16_t update_app_version;
+} T_OTA_UPDATE_IMAGE_INFO;
+
+typedef struct _T_OTA_WRITE_MSG
+{
+ uint8_t opcode;
+ union
+ {
+ uint8_t value;
+ T_OTA_UPDATE_IMAGE_INFO update_image_info;
+ } u;
+} T_OTA_WRITE_MSG;
+
+typedef union _T_OTA_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+ T_OTA_WRITE_MSG write;
+} T_OTA_UPSTREAM_MSG_DATA;
+
+/**
+ * @brief OTA servic data struct for notification data to application.
+ *
+ * OTA service data to inform application.
+*/
+typedef struct _T_OTA_CALLBACK_DATA
+{
+ T_SERVICE_CALLBACK_TYPE msg_type; /**< @brief EventId defined upper */
+ T_OTA_UPSTREAM_MSG_DATA msg_data;
+} T_OTA_CALLBACK_DATA;
+
+
+extern uint8_t ota_add_service(void *pFunc);
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/server/plxs.h b/inc/bluetooth/profile/server/plxs.h
new file mode 100644
index 0000000..85a40ce
--- /dev/null
+++ b/inc/bluetooth/profile/server/plxs.h
@@ -0,0 +1,401 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2018, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file plxs.h
+ * @brief Head file for using Pulse Oximeter Service .
+ * @details Pulse Oximeter Service data types and external functions declaration.
+ * @author danni
+ * @date 2018-12-27
+ * @version v1.0
+ * *************************************************************************************
+ */
+/* Define to prevent recursive inclusion */
+#ifndef _PLXS_H
+#define _PLXS_H
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+#include "plxs_config.h"
+
+/** @defgroup PLXS Pulse Oximeter Service
+ * @brief Pulse Oximeter Service
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup PLXS_Exported_Macros PLXS Exported Macros
+ * @brief
+ * @{
+ */
+#define PLXS_SPOT_CHECK_MEASUREMENT_INDICATION_ENABLE 1 /**< spot check measurement indication cccd enable */
+#define PLXS_SPOT_CHECK_MEASUREMENT_INDICATION_DISABLE 2 /**< spot check measurement indication cccd disable */
+#define PLXS_CONTINUOUS_MEASUREMENT_NOTIFY_ENABLE 3 /**< continuous measurement notify cccd enable */
+#define PLXS_CONTINUOUS_MEASUREMENT_NOTIFY_DISABLE 4 /**< continuous measurement notify cccd disable */
+#define PLXS_RACP_INDICATION_ENABLE 5 /**< racp indication cccd enable*/
+#define PLXS_RACP_INDICATION_DISABLE 6 /**< racp indication cccd disable*/
+
+#define PLXS_SFLOAT_VALUE_NaN 0x07ff /**< not a number */
+#define PLXS_SFLOAT_VALUE_NRes 0x0800 /**< not at this resolution */
+#define PLXS_SFLOAT_VALUE_PlusINFINITY 0x07fe /**< + INFINITY */
+#define PLXS_SFLOAT_VALUE_MinusINFINITY 0x0802 /**< - INFINITY */
+#define PLXS_SFLOAT_VALUE_RFU 0x0801 /**< reserved for future use */
+/** @} End of PLXS_Exported_Macros */
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup PLXS_Exported_Types PLXS Exported Types
+ * @brief
+ * @{
+ */
+/** @brief define PLXS_TIMESTAMP type to store date time data,PLXS_TIMESTAMP[0] = LSO,PLXS_TIMESTAMP[6]=MSO*/
+typedef uint8_t PLXS_TIMESTAMP[7];
+
+/** @brief define PLXS_SFLOAT type to store spo2,pr,Pulse Amplitude Index value,PLXS_SFLOAT[0] = LSO,PLXS_SFLOAT[1] = MSO*/
+typedef uint8_t PLXS_SFLOAT[2];
+
+/** @brief plxs service parameter type*/
+typedef enum
+{
+ PLXS_PARAM_SPOT_CHECK_MEASUREMENT_FLAGS = 0x01,
+ PLXS_PARAM_CONTINUOUS_MEASUREMENT_FLAGS,
+ PLXS_PARAM_FEATURE_FLAGS
+} T_PLXS_PARAM_TYPE;
+
+/** @brief spot check measurement vaule indicate, continuous measurement vaule notify or racp procedure status */
+typedef enum
+{
+ PLXS_STATUS_SPOT_CHECK_MEASUREMENT_INDICATION_IDLE = 0x00,/**< function plxs_spot_check_measurement_value_indicate() never be called and in initialization state*/
+ PLXS_STATUS_SPOT_CHECK_MEASUREMENT_INDICATION_DOING,/**< function plxs_spot_check_measurement_value_indicate() be called success, but PROFILE_EVT_SEND_DATA_COMPLETE was not received*/
+ PLXS_STATUS_SPOT_CHECK_MEASUREMENT_INDICATION_DONE,/**< function plxs_spot_check_measurement_value_indicate() be called success, and PROFILE_EVT_SEND_DATA_COMPLETE was received*/
+ PLXS_STATUS_CONTINUOUS_MEASUREMENT_NOTIFY_IDLE,/**< function plxs_continuous_measurement_value_notify() never be called and in initialization state*/
+ PLXS_STATUS_CONTINUOUS_MEASUREMENT_NOTIFY_DOING,/**< function plxs_continuous_measurement_value_notify() be called success, but PROFILE_EVT_SEND_DATA_COMPLETE was not received*/
+ PLXS_STATUS_CONTINUOUS_MEASUREMENT_NOTIFY_DONE,/**< function plxs_continuous_measurement_value_notify() be called success, and PROFILE_EVT_SEND_DATA_COMPLETE was received*/
+ PLXS_STATUS_REPORT_RECORDS_INDICATION_IDLE,/**< function plxs_spot_check_measurement_value_store_indicate() never be called and in initialization state*/
+ PLXS_STATUS_REPORT_RECORDS_INDICATION_DOING,/**< function plxs_spot_check_measurement_value_store_indicate() be called success, but PROFILE_EVT_SEND_DATA_COMPLETE was not received*/
+ PLXS_STATUS_REPORT_RECORDS_INDICATION_DONE,/**< function plxs_spot_check_measurement_value_store_indicate() be called success and PROFILE_EVT_SEND_DATA_COMPLETE was received*/
+ PLXS_STATUS_NOT_SUPPORT,/**< status not supported*/
+} T_PLXS_DATA_SEND_STATUS;
+
+/** @brief APP Return Result List */
+typedef enum
+{
+ PLXS_APP_RESULT_SUCCESS = 0x00,/**< plx service return result success*/
+ PLXS_APP_RESULT_PENDING,/**< if plx service return pending, means that report stored records procedure is in progress,please send data later*/
+ PLXS_APP_RESULT_QUEUE_NULL,/**< plx service return result empty*/
+ PLXS_APP_RESULT_NOT_SUPPORT,/**< plx service return result procedure not support*/
+ PLXS_APP_RESULT_INVALID_VALUE_SIZE,/**< plx service return result invalid value size*/
+ PLXS_APP_RESULT_INVALID_TYPE,/**< plx service return result invalid type*/
+ PLXS_APP_RESULT_INVALID_OFFSET,/**< plx service return result invalid offset*/
+ PLXS_APP_RESULT_POINTER_NULL,/**< plx service return result pointer is null*/
+ PLXS_APP_RESULT_FAIL,/**< plx service return result fail for other reasons*/
+ PLXS_APP_RESULT_CCCD_NOT_ENABLED/**< plx service return result cccd not enable*/
+} T_PLXS_APP_RESULT;
+
+/** @brief measurement status bits*/
+typedef struct
+{
+ uint16_t rfu: 5;
+ uint16_t measurement_ongoing: 1;
+ uint16_t early_estimated_data: 1;
+ uint16_t validated_data: 1;
+ uint16_t fully_qualified_data: 1;
+ uint16_t data_from_measurement_storage: 1;
+ uint16_t data_for_demonstration: 1;
+ uint16_t data_for_testing: 1;
+ uint16_t calibration_ongoing: 1;
+ uint16_t measurement_unavailable: 1;
+ uint16_t questionable_measurement_detected: 1;
+ uint16_t invalid_measurement_detected: 1;
+} T_PLXS_MEASUREMENT_STATE;
+/** @brief device and sensor status bits*/
+typedef struct
+{
+ uint8_t extended_display_update_ongoing: 1;
+ uint8_t equipment_malfunction_detected: 1;
+ uint8_t signal_processing_irregularity_detected: 1;
+ uint8_t inadequate_signal_detected: 1;
+ uint8_t poor_signal_detected: 1;
+ uint8_t low_perfusion_detected: 1;
+ uint8_t erratic_signal_detected: 1;
+ uint8_t nonPulsatile_signal_detected: 1;
+ uint8_t questionable_pulse_detected: 1;
+ uint8_t signal_analysis_ongoing: 1;
+ uint8_t sensor_interference_detected: 1;
+ uint8_t sensor_unconnected_to_user: 1;
+ uint8_t unknown_sensor_connected: 1;
+ uint8_t sensor_displaced: 1;
+ uint8_t sensor_malfunctioning: 1;
+ uint8_t sensor_disconnected: 1;
+ uint8_t rfu: 8;
+} T_PLXS_DEVICE_AND_SENSOR_STATE;
+
+/** @brief typedef spot check measurement value*/
+typedef struct
+{
+ PLXS_SFLOAT spo2;
+ PLXS_SFLOAT pr;
+#if PLXS_SPOT_CHECK_MEASUREMENT_TIMESTAMP_SUPPORT
+ PLXS_TIMESTAMP time;
+#endif
+
+#if PLXS_MEASUREMENT_STATE_SUPPORT
+ T_PLXS_MEASUREMENT_STATE measurement_status;
+#endif
+
+#if PLXS_DEVICE_AND_SENSOR_STATUS_SUPPORT
+ T_PLXS_DEVICE_AND_SENSOR_STATE device_and_sensor_status;
+#endif
+
+#if PLXS_PULSE_AMPLITUDE_INDEX_SUPPORT
+ PLXS_SFLOAT pulse_amplitude_index;
+#endif
+} T_PLXS_SPOT_CHECK_MEASUREMENT_VALUE;
+
+/** @brief typedef spo2PR*/
+typedef struct
+{
+ PLXS_SFLOAT spo2;
+ PLXS_SFLOAT pr;
+} T_SPO2PR;
+
+/**@brief typedef continuous measurement value*/
+typedef struct
+{
+ T_SPO2PR spo2pr_normal;
+
+#if PLXS_CONTINUOUS_MEASUREMENT_SPO2PR_FAST_SUPPORT
+ T_SPO2PR spo2pr_fast;
+#endif
+
+#if PLXS_CONTINUOUS_MEASUREMENT_SPO2PR_SLOW_SUPPORT
+ T_SPO2PR spo2pr_slow;
+#endif
+
+#if PLXS_MEASUREMENT_STATE_SUPPORT
+ T_PLXS_MEASUREMENT_STATE measurement_status;
+#endif
+
+#if PLXS_DEVICE_AND_SENSOR_STATUS_SUPPORT
+ T_PLXS_DEVICE_AND_SENSOR_STATE device_and_sensor_status;
+#endif
+
+#if PLXS_PULSE_AMPLITUDE_INDEX_SUPPORT
+ PLXS_SFLOAT pulse_amplitude_index;
+#endif
+} T_PLXS_CONTINUOUS_MEASUREMENT_VALUE;
+
+/** @brief typedef features value */
+typedef struct
+{
+ uint16_t supported_features;
+
+#if PLXS_MEASUREMENT_STATE_SUPPORT
+ uint16_t measurement_status_support_bits;
+#endif
+
+#if PLXS_DEVICE_AND_SENSOR_STATUS_SUPPORT
+ uint32_t device_and_sensor_status_support_bits;
+#endif
+} T_PLXS_FEATURES_VALUE;
+
+/** @} End of PLXS_Exported_Types */
+
+/** @defgroup PLXS_Callback_Data PLXS Callback Data
+ * @brief PLXS data struct for notification data to application.
+ * @{
+ */
+typedef union
+{
+ uint8_t notify_indicate_index;
+} T_PLXS_UPSTREAM_MSG_DATA;
+
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_PLXS_UPSTREAM_MSG_DATA msg_data;
+} T_PLXS_CALLBACK_DATA;
+/** @} End of PLXS_Callback_Data */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup PLXS_Exported_Functions PLXS Exported Functions
+ * @brief
+ * @{
+ */
+/**
+ * @brief Add PLX service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_le_profile_init()
+ {
+ server_init(1);
+ plxs_srv_id = plxs_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID plxs_add_service(void *p_func);
+/**
+ * @brief get plxs parameters such as spot check measurement flags,continuous measurement flags or features supports @ref T_PLXS_PARAM_TYPE
+ *
+ * @param[in] param_type @ref T_PLXS_PARAM_TYPE
+ * @param[in,out] p_value get spot check measurement flags,continuous measurement flags or features supports
+ * @return plxs_get_parameter result
+ * @retval PLXS_APP_RESULT_SUCCESS Operation success.
+ * @retval others Operation fail.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ static T_USER_CMD_PARSE_RESULT cmd_plxs_feature_flags_set(T_USER_CMD_PARSED_VALUE *p_parse_value)
+ {
+ T_PLXS_FEATURES_VALUE plxs_features;
+ plxs_get_parameter(PLXS_PARAM_FEATURE_FLAGS, &plxs_features);
+ if (p_parse_value->dw_param[0] == 1)
+ {
+ //both measurement status and device sensor status not support
+ plxs_features.supported_features = plxs_features.supported_features & 0xFFFC;
+ }
+ ......
+ }
+ * \endcode
+ */
+T_PLXS_APP_RESULT plxs_get_parameter(T_PLXS_PARAM_TYPE param_type, void *p_value);
+/**
+ * @brief send plxs spot check measurement characteristic indication
+ *
+ * @param[in] conn_id connection index
+ * @param[in] Service_id generated by the BLE stack: @ref T_SERVER_ID.
+ * @param[in] p_spot_check_measurement_value @ref T_PLXS_SPOT_CHECK_MEASUREMENT_VALUE
+ * @return plxs_spot_check_measurement_value_indicate result
+ * @retval PLXS_APP_RESULT_SUCCESS Operation success.
+ * @retval others Operation fail.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test_plxs(void)
+ {
+ T_PLXS_SPOT_CHECK_MEASUREMENT_VALUE plxs_spot_check_measure_value;
+ ......//plxs_spot_check_measure_value initialization
+ bool result = plxs_spot_check_measurement_value_indicate(conn_id,plxs_srv_id,&plxs_spot_check_measure_value);
+ if(result == PLXS_APP_RESULT_SUCCESS)
+ {
+ }
+ }
+ * \endcode
+ */
+#if PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT
+T_PLXS_APP_RESULT plxs_spot_check_measurement_value_indicate(uint8_t conn_id, uint8_t service_id,
+ T_PLXS_SPOT_CHECK_MEASUREMENT_VALUE *p_spot_check_measurement_value);
+#endif
+/**
+ * @brief send plxs continuous measurement characteristic notification
+ *
+ * @param[in] conn_id connection index
+ * @param[in] Service_id generated by the BLE stack: @ref T_SERVER_ID.
+ * @param[in] plxs_continuous_measurement_value @ref T_PLXS_CONTINUOUS_MEASUREMENT_VALUE
+ * @return plxs_continuous_measurement_value_notify result
+ * @retval PLXS_APP_RESULT_SUCCESS Operation success.
+ * @retval others Operation fail.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test_plxs(void)
+ {
+ ......//plxs_continuous_measurement_value initialization
+ bool result = plxs_continuous_measurement_value_notify( conn_id, plxs_srv_id,&plxs_continuous_measurement_value);
+ if(result == PLXS_APP_RESULT_SUCCESS)
+ {
+ PROFILE_PRINT_INFO0("plxs_continuous_measurement_value_notify notify data send success!");
+ }
+ }
+ * \endcode
+ */
+#if PLXS_CONTINUOUS_MEASUREMENT_SUPPORT
+T_PLXS_APP_RESULT plxs_continuous_measurement_value_notify(uint8_t conn_id, T_SERVER_ID service_id,
+ T_PLXS_CONTINUOUS_MEASUREMENT_VALUE *p_plxs_continuous_measurement_value);
+#endif
+
+/**
+ * @brief clear flags if procedure fail or disconnect
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void app_handle_conn_state_evt(uint8_t conn_id, T_GAP_CONN_STATE new_state, uint16_t disc_cause)
+ {
+ APP_PRINT_INFO4("app_handle_conn_state_evt: conn_id %d old_state %d new_state %d, disc_cause 0x%x",
+ conn_id, gap_conn_state, new_state, disc_cause);
+ switch (new_state)
+ {
+ case GAP_CONN_STATE_DISCONNECTED:
+ {
+ if ((disc_cause != (HCI_ERR | HCI_ERR_REMOTE_USER_TERMINATE))&& (disc_cause != (HCI_ERR | HCI_ERR_LOCAL_HOST_TERMINATE)))
+ {
+ APP_PRINT_ERROR1("app_handle_conn_state_evt: connection lost cause 0x%x", disc_cause);
+ }
+ plxs_flags_clear();//when disconnect clear plxs flags
+ le_adv_start();
+ }
+ break;
+ }
+ }
+ * \endcode
+ */
+void plxs_flags_clear(void);
+/**
+ * @brief plxs check report data send procedure to enable flow control of notification or indication
+ * @param[in] conn_id connection index
+ * @param[in] Service_id generated by the BLE stack: @ref T_SERVER_ID.
+ * @param[in] attribute_index attribute_index
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ T_APP_RESULT app_handle_profile_message(T_SERVER_ID service_id, void *p_data)
+ {
+ T_APP_RESULT result = APP_RESULT_SUCCESS;
+ if (service_id == SERVICE_PROFILE_GENERAL_ID)
+ {
+ T_SERVER_APP_CB_DATA *p_para = (T_SERVER_APP_CB_DATA *)p_data;
+ switch (p_para->eventId)
+ {
+ ......
+ case PROFILE_EVT_SEND_DATA_COMPLETE:
+ ......
+ else if (p_para->event_data.send_data_result.service_id == plxs_srv_id)
+ {
+ uint8_t conn_id = p_para->event_data.send_data_result.conn_id;
+ if (p_para->event_data.send_data_result.cause == GAP_SUCCESS)
+ {
+ plxs_check_report_data_send_procedure(conn_id, plxs_srv_id,p_para->event_data.send_data_result.attrib_idx);
+ }
+ else
+ {
+ APP_PRINT_ERROR1("PROFILE_EVT_SEND_DATA_COMPLETE failed,cause %x", p_para->event_data.send_data_result.cause);
+ }
+ }
+ break;
+ }
+ }
+ }
+ * \endcode
+ */
+void plxs_check_report_data_send_procedure(uint8_t conn_id, T_SERVER_ID service_id,
+ uint16_t attribute_index);
+/** @} End of PLXS_Exported_Functions */
+/** @} End of PLXS */
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* PULSE_OXIMETER_SERVICE_H */
diff --git a/inc/bluetooth/profile/server/plxs_config.h b/inc/bluetooth/profile/server/plxs_config.h
new file mode 100644
index 0000000..9fe6a00
--- /dev/null
+++ b/inc/bluetooth/profile/server/plxs_config.h
@@ -0,0 +1,128 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2018, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file plxs_config.h
+ * @brief Pulse Oximeter Service configuration file.
+ * @details Configure the optional characteristic and fields in the Pulse Oximeter Service.
+ * @author danni
+ * @date 2018-12-27
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion **/
+#ifndef _PLXS_CONFIG_H_
+#define _PLXS_CONFIG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/** @defgroup PLXS Pulse Oximeter Service
+* @brief Pulse Oximeter Service
+* @{
+*/
+
+/** @defgroup PLXS_Service_CONFIG PLXS Service Config
+* @brief PLXS service configuration file
+* @{
+*/
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup PLXS_Common_Exported_Macros PLXS Common Exported Macros
+ * @{
+ */
+#define PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT 1 /**< if this value set to 1 means PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT*/
+#define PLXS_STORE_SPOT_CHECK_MEASUREMENT_SUPPORT (PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT && 1) /**< if PLXS_STORE_SPOT_CHECK_MEASUREMENT_SUPPORT is set to 1 then PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT and PLXS_SPOT_CHECK_MEASUREMENT_TIMESTAMP_SUPPORT must be set to 1*/
+#define PLXS_SPOT_CHECK_MEASUREMENT_TIMESTAMP_SUPPORT (PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT && 1) /**< flags to show timestamp field support or not*/
+#define PLXS_DEVICE_CLOCK_NOT_SET (PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT && 1) /**< flags to show clock set or not*/
+
+#define PLXS_MEASUREMENT_STATE_SUPPORT 1 /**< flags to show measurement status field support or not*/
+#define PLXS_DEVICE_AND_SENSOR_STATUS_SUPPORT 1 /**< flags to show device and sensor status field support or not*/
+#define PLXS_PULSE_AMPLITUDE_INDEX_SUPPORT 1 /**< flags to show pulse amplitude index field support or not*/
+#define PLXS_MULTIPLE_BONDS_SUPPORT 0 /**< flags to show multiple bonds field support or not*/
+
+#define PLXS_CONTINUOUS_MEASUREMENT_SUPPORT 1 /**< if this value set to 1 means PLXS_CONTINUOUS_MEASUREMENT_SUPPORT*/
+#define PLXS_CONTINUOUS_MEASUREMENT_SPO2PR_FAST_SUPPORT (PLXS_CONTINUOUS_MEASUREMENT_SUPPORT && 1)/**< flags to show spo2pr fast measurement field support or not*/
+#define PLXS_CONTINUOUS_MEASUREMENT_SPO2PR_SLOW_SUPPORT (PLXS_CONTINUOUS_MEASUREMENT_SUPPORT && 1)/**< flags to show spo2pr slow measurement field support or not*/
+
+#define PLXS_RACP_MAX_NBR_OF_STORED_RECS 30 /**< the maximum records to be stored*/
+
+/** @brief The Measurement Status Support field*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_ONGOING_SUPPORT 0x0020 /**< Measurement Ongoing bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_EARLY_ESTIMATED_DATA_SUPPORT 0x0040 /**< Early Estimated Data bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_VALIDATED_DATA_SUPPORT 0x0080 /**< Validated Data bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_FULLY_QUALIFIED_DATA_SUPPORT 0x0100 /**< Fully Qualified Data bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_DATA_FROM_MEASUREMENT_STORAGE_SUPPORT 0x0200 /**< Data from Measurement Storage bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_DATA_FOR_DEMONSTRATION_SUPPORT 0x0400 /**< Data for Demonstration bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_DATA_FOR_TEST_SUPPORT 0x0800 /**< Data for Testing bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_CALIBRATION_ONGOING_SUPPORT 0x1000 /**< Calibration Ongoing bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_MEASUREMENT_UNAVAILABLE_SUPPORT 0x2000 /**< Measurement Unavailable bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_QUESTIONABLE_MEASUREMENT_DETECTED_SUPPORT 0x4000 /**< Questionable Measurement Detected bit supported*/
+#define PLXS_FEATURES_MEASUREMENT_STATUS_INVALID_MEASUREMENT_DETECTED_SUPPORT 0x8000 /**< Invalid Measurement Detected bit supported*/
+
+/** @brief define plx service features which measurement status are supported. this macro according user needs to add,
+ * for example:
+ * #define PLXS_FEATURES_MEASUREMENT_STATUS_SUPPORTS PLXS_FEATURES_MEASUREMENT_STATUS_ONGOING_SUPPORT|PLXS_FEATURES_MEASUREMENT_STATUS_FULLY_QUALIFIED_DATA_SUPPORT
+ * means both support PLXS_FEATURES_MEASUREMENT_STATUS_ONGOING_SUPPORT and PLXS_FEATURES_MEASUREMENT_STATUS_FULLY_QUALIFIED_DATA_SUPPORT,if you want add other supports,
+ * please @ref The Measurement Status Support field above
+ */
+#define PLXS_FEATURES_MEASUREMENT_STATUS_SUPPORTS (PLXS_FEATURES_MEASUREMENT_STATUS_ONGOING_SUPPORT | PLXS_FEATURES_MEASUREMENT_STATUS_FULLY_QUALIFIED_DATA_SUPPORT)
+
+/** @brief Device and Sensor Status Support field*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_EXTENDED_DISPLAY_UPDATE_ONGOING_SUPPORT 0x000001 /**< Extended Display Update Ongoing bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_EQUIPMENT_MALFUNCTION_DETECTED_SUPPORT 0x000002 /**< Equipment Malfunction Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SIGNAL_PROCESSING_IRREGULARITY_DETECTED_SUPPORT 0x000004 /**< Signal Processing Irregularity Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_INADEQUATE_SIGNAL_DETECTED_SUPPORT 0x000008 /**< Inadequate Signal Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_POOR_SIGNAL_DETECTED_SUPPORT 0x000010 /**< Poor Signal Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_LOW_PERFUSION_DETECTED_SUPPORT 0x000020 /**< Low Perfusion Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_ERRATIC_SIGNAL_DETECTED_SUPPORT 0x000040 /**< Erratic Signal Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_NONPULSATILE_SIGNAL_DETECTED_SUPPORT 0x000080 /**< Nonpulsatile Signal Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_QUESTIONABLE_PULSE_DETECTED_SUPPORT 0x000100 /**< Questionable Pulse Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SIGNAL_ANALYSIS_ONGOING_SUPPORT 0x000200 /**< Signal Analysis Ongoing bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_INTERFERENCE_DETECTED_SUPPORT 0x000400 /**< Sensor Interference Detected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_UNCONNECTED_USER_SUPPORT 0x000800 /**< Sensor Unconnected to User bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_UNKNOWN_SENSOR_CONNECTED_SUPPORT 0x001000 /**< Unknown Sensor Connected bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_DISPLACED_SUPPORT 0x002000 /**< Sensor Displaced bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_MALFUNCTIONING_SUPPORT 0x004000 /**< Sensor Malfunctioning bit supported*/
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_DISCONNECTED_SUPPORT 0x008000 /**< Sensor Disconnected bit supported*/
+
+/** @brief define plx service features which device and sensor status are supported.according user needs to add,
+ * for example:
+ * #define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SUPPORTS PLXS_FEATURES_DEVICE_SENSOR_STATUS_EXTENDED_DISPLAY_UPDATE_ONGOING_SUPPORT|PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_DISCONNECTED_SUPPORT
+ * means both support PLXS_FEATURES_DEVICE_SENSOR_STATUS_EXTENDED_DISPLAY_UPDATE_ONGOING_SUPPORT and PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_DISCONNECTED_SUPPORT,if you want add other supports,
+ * please @ref Device and Sensor Status Support field above
+ */
+#define PLXS_FEATURES_DEVICE_SENSOR_STATUS_SUPPORTS (PLXS_FEATURES_DEVICE_SENSOR_STATUS_EXTENDED_DISPLAY_UPDATE_ONGOING_SUPPORT | PLXS_FEATURES_DEVICE_SENSOR_STATUS_SENSOR_DISCONNECTED_SUPPORT)
+
+/** @defgroup PLXS_Service_ATTI_INDEX PLXS Service attribute index
+* @brief PLXS Service attribute index
+* @{
+*/
+#if PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT
+#define PLXS_CHAR_SPOT_CHECK_MENSUREMENT_INDEX 0x02
+#define PLXS_CHAR_SPOT_CHECK_MENSUREMENT_CCCD_INDEX 0x03
+#endif
+
+#if PLXS_CONTINUOUS_MEASUREMENT_SUPPORT
+#define PLXS_CHAR_CONTINUOUS_MEASUREMENT_INDEX ((PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT*3) + 2 )//0x05
+#define PLXS_CHAR_CONTINUOUS_MEASUREMENT_CCCD_INDEX ((PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT*3) + 3 )//0x06
+#endif
+
+#define PLXS_CHAR_FEATURE_INDEX ((PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT*3) + (PLXS_CONTINUOUS_MEASUREMENT_SUPPORT*3)+ 2)//0x05//0x08
+
+#if PLXS_STORE_SPOT_CHECK_MEASUREMENT_SUPPORT
+#define PLXS_CHAR_RECORS_ACCESS_CONTROL_POINT_INDEX ((PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT*3) + (PLXS_CONTINUOUS_MEASUREMENT_SUPPORT*3)+ 4)//0x07//0x0A
+#define PLXS_CHAR_RECORS_ACCESS_CONTROL_POINT_CCCD_INDEX ((PLXS_SPOT_CHECK_MEASUREMENT_SUPPORT*3) + (PLXS_CONTINUOUS_MEASUREMENT_SUPPORT*3)+ 5)//0x08//0x0B
+#endif
+/** @} End of PLXS_Service_ATTI_INDEX */
+/** @} End of PLXS_Common_Exported_Macros */
+/** @} End of PLXS_Service_CONFIG */
+/** @} End of PLXS */
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/inc/bluetooth/profile/server/rcu_dfu_service.h b/inc/bluetooth/profile/server/rcu_dfu_service.h
new file mode 100644
index 0000000..02a522e
--- /dev/null
+++ b/inc/bluetooth/profile/server/rcu_dfu_service.h
@@ -0,0 +1,256 @@
+/**
+*********************************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+**********************************************************************************************************
+* @file dfu_service.h
+* @brief
+* @details
+* @author ken_mei
+* @date 02-09-2016
+* @version v1.0.0
+******************************************************************************
+* @attention
+* <h2><center>&copy; COPYRIGHT 2015 Realtek Semiconductor Corporation</center></h2>
+******************************************************************************
+*/
+
+#ifndef _DFU_SERVICE_H_
+#define _DFU_SERVICE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+#include "flash_device.h"
+
+#define GATT_UUID128_DFU_PACKET 0x12, 0xA2, 0x4D, 0x2E, 0xFE, 0x14, 0x48, 0x8e, 0x93, 0xD2, 0x17, 0x3C, 0x87, 0x63, 0x00, 0x00
+#define GATT_UUID128_DFU_CONTROL_POINT 0x12, 0xA2, 0x4D, 0x2E, 0xFE, 0x14, 0x48, 0x8e, 0x93, 0xD2, 0x17, 0x3C, 0x87, 0x64, 0x00, 0x00
+
+#define DFU_OPCODE_MIN 0x00
+#define DFU_OPCODE_START_DFU 0x01
+#define DFU_OPCODE_RECEIVE_FW_IMAGE_INFO 0x02
+#define DFU_OPCODE_VALID_FW 0x03
+#define DFU_OPCODE_ACTIVE_IMAGE_RESET 0x04
+#define DFU_OPCODE_SYSTEM_RESET 0x05
+#define DFU_OPCODE_REPORT_TARGET_INFO 0x06
+#define DFU_OPCODE_CONN_PARA_TO_UPDATE_REQ 0x07
+
+#define DFU_OPCODE_PKT_RX_NOTIFICATION_VOICE 0x08
+#define DFU_OPCODE_BUFFER_CHECK_EN 0x09 /*report current ota function version information*/
+#define DFU_OPCODE_REPORT_BUFFER_CRC 0x0a /*report current buffer CRC*/
+
+#define DFU_OPCODE_RECEIVE_IC_TYPE 0x0b
+#define DFU_OPCODE_COPY_IMG 0x0c
+#define DFU_OPCODE_MAX 0x0d
+
+
+#define DFU_OPCODE_NOTIF 0x10
+
+/*length of each control point procedure*/
+#define DFU_LENGTH_START_DFU (1+12)
+#define DFU_LENGTH_RECEIVE_FW_IMAGE_INFO (1+2+4)
+#define DFU_LENGTH_VALID_FW (1+2)
+#define DFU_LENGTH_ACTIVE_IMAGE_RESET 0x01
+#define DFU_LENGTH_SYSTEM_RESET 0x01
+#define DFU_LENGTH_REPORT_TARGET_INFO (1+2)
+#define DFU_LENGTH_PKT_RX_NOTIF_REQ (1+2)
+#define DFU_LENGTH_CONN_PARA_TO_UPDATE_REQ (1+2+2+2+2)
+
+#define DFU_NOTIFY_LENGTH_ARV 3
+#define DFU_NOTIFY_LENGTH_REPORT_TARGET_INFO (3+2+4)
+#define DFU_NOTIFY_LENGTH_PKT_RX_NOTIF (3+2)
+
+
+#define INDEX_DFU_PACKET_VALUE 0x02
+#define INDEX_DFU_CONTROL_POINT_CHAR_VALUE 0x04
+
+#define DFU_OPCODE_MIN 0x00
+#define DFU_OPCODE_START_DFU 0x01
+#define DFU_OPCODE_RECEIVE_FW_IMAGE_INFO 0x02
+#define DFU_OPCODE_VALID_FW 0x03
+#define DFU_OPCODE_ACTIVE_IMAGE_RESET 0x04
+#define DFU_OPCODE_SYSTEM_RESET 0x05
+#define DFU_OPCODE_REPORT_TARGET_INFO 0x06
+#define DFU_OPCODE_CONN_PARA_TO_UPDATE_REQ 0x07
+#define DFU_OPCODE_PKT_RX_NOTIFICATION_VOICE 0x08
+#define DFU_OPCODE_REPORT_FUNCTION_TYPE 0x09 /*report current ota function version information*/
+#define DFU_OPCODE_REPORT_BUFFER_SIZE 0x0a /*report current buffer size information*/
+//#define DFU_OPCODE_REPORT_BUFFER_CRC 0x0b /*report current buffer CRC*/
+#define DFU_OPCODE_INDICATE_BUFFER_IS_VALID 0x0c /*indicate current buffer data if valid*/
+//#define DFU_OPCODE_RECEIVE_IC_TYPE 0x0d
+
+//#define DFU_OPCODE_MAX 0x0e
+
+#define INDEX_DFU_PACKET_VALUE 0x02
+#define INDEX_DFU_CONTROL_POINT_CHAR_VALUE 0x04
+#define INDEX_DFU_CHAR_CCCD_INDEX 0x05
+
+#define DFU_OPCODE_NOTIFICATION 0x10
+//------------------------DFU_LENGTH DEFINE------------------------------
+
+#define DFU_ARV_SUCCESS 0x01
+#define DFU_ARV_FAIL_INVALID_PARAMETER 0x02
+#define DFU_ARV_FAIL_OPERATION 0x03
+#define DFU_ARV_FAIL_DATA_SIZE_EXCEEDS_LIMIT 0x04
+#define DFU_ARV_FAIL_CRC_ERROR 0x05
+#define DFU_ARV_FAIL_LENGTH_ERROR 0x06
+#define DFU_ARV_FAIL_PROG_ERROR 0x07
+#define DFU_ARV_FAIL_ERASE_ERROR 0x08
+#define DFU_ARV_FAIL_SYS_STATE_ERROR 0x09
+
+
+#define DFU_NOTIFY_LENGTH_FUNC_VERSION (1+1+1+2)
+#define DFU_NOTIFY_LENGTH_BUFFER_SIZE (1+1+1+4)
+#define DFU_NOTIFY_LENGTH_BUFFER_CRC (1+1+1+2)
+#define DFU_NOTIFY_LENGTH_BUFFER_IS_VALID (1+1)/*opCode + valid flag*/
+
+typedef struct _T_START_DFU_PARA
+{
+ uint8_t ic_type;
+ uint8_t secure_version;
+ union
+ {
+ uint16_t value;
+ struct
+ {
+ uint16_t xip: 1; // payload is executed on flash
+ uint16_t enc: 1; // all the payload is encrypted
+ uint16_t load_when_boot: 1; // load image when boot
+ uint16_t enc_load: 1; // encrypt load part or not
+ uint16_t enc_key_select: 3; // referenced to ENC_KEY_SELECT
+ uint16_t not_ready : 1; //for copy image in ota
+ uint16_t not_obsolete : 1; //for copy image in ota
+ uint16_t rsvd: 7;
+ };
+ } ctrl_flag;
+ uint16_t signature;
+ uint16_t crc16;
+ uint32_t image_length;
+} T_START_DFU_PARA;
+
+typedef struct _T_PKT_RX_NOTIF_REQ
+{
+ uint16_t packet_num;
+} T_PKT_RX_NOTIF_REQ;
+
+
+typedef struct _T_DFU_CTRL_POINT
+{
+ uint8_t opcode;
+ union
+ {
+ T_START_DFU_PARA start_dfu;
+ T_PKT_RX_NOTIF_REQ pkt_rx_notify_req;
+ } p;
+} T_DFU_CTRL_POINT, * P_DFU_CTRL_POINT;
+
+/**
+* @note: the definition of this struct is accordant with rom define, and if you
+* change the order of members, it will cause crc error when ota complete.
+*/
+typedef struct
+{
+ uint32_t origin_image_version;
+
+ uint32_t nCurOffSet;
+ uint32_t image_total_length;
+
+ uint8_t ic_type;
+ uint8_t secure_version;
+ union
+ {
+ uint16_t value;
+ struct
+ {
+ uint16_t xip: 1; // payload is executed on flash
+ uint16_t enc: 1; // all the payload is encrypted
+ uint16_t load_when_boot: 1; // load image when boot
+ uint16_t enc_load: 1; // encrypt load part or not
+ uint16_t enc_key_select: 3; // referenced to ENC_KEY_SELECT
+ uint16_t not_ready : 1; //for copy image in ota
+ uint16_t not_obsolete : 1; //for copy image in ota
+ uint16_t rsvd: 7;
+ };
+ } ctrl_flag;
+ uint16_t signature;
+ uint16_t crc16;
+ uint32_t image_length;
+
+ bool ota_conn_para_upd_in_progress;
+ uint8_t mtu_size;
+ bool is_dfu_progressing;
+} TDFU_CB;
+
+
+/*Notifications defined here*/
+
+typedef struct _TNOTIFICATION_TARGET_IMAGE_INFO
+{
+
+ uint16_t nOrigFwVersion;
+ uint32_t nImageUpdateOffset;
+} TNOTIFICATION_TARGET_IMAGE_INFO;
+
+typedef struct _TNOTIFICATION_REPORT_PKT_NUM
+{
+ uint16_t PacketNum;
+} TNOTIFICATION_REPORT_PKT_NUM;
+
+typedef struct _TNOTIFICATION_REPORT_OTA_FUNC
+{
+ uint16_t OtaFuncVersion;
+ uint32_t invalid;
+} TNOTIFICATION_REPORT_OTA_FUNC;
+
+
+typedef enum _TNOTIFICATION_REPORT_FUNC_VERSION
+{
+ NORMAL_FUNCTION = 0x0000, /*normal function*/
+ IMAGE_CHECK_FUNCTION = 0x0001 /*image check function*/
+} TNOTIFICATION_REPORT_FUNC_VERSION;
+
+typedef enum _DFU_BUFFER_IS_VALID
+{
+ DFU_BUFFER_VALID = 0x00,
+ DFU_BUFFER_INVALID = 0x01
+} DFU_BUFFER_IS_VALID;
+
+typedef struct _DFUNotification
+{
+ uint8_t opCode;
+ uint8_t reqOpCode;
+ uint8_t respValue;
+ union
+ {
+ TNOTIFICATION_TARGET_IMAGE_INFO NotifyTargetImageInfo;
+ TNOTIFICATION_REPORT_PKT_NUM NotifyPktNum;
+ } p;
+} TDFUNotification, * PDFUNotification;
+
+#define DFU_NOTIFY_ENABLE 1
+#define DFU_NOTIFY_DISABLE 2
+typedef union _TDFU_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index;
+ uint8_t write_value_index;
+} TDFU_UPSTREAM_MSG_DATA;
+/** Dfu service data to inform application */
+typedef struct _TDFU_CALLBACK_DATA
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ TDFU_UPSTREAM_MSG_DATA msg_data;
+} TDFU_CALLBACK_DATA;
+
+/*============================================================================*
+ * Dfu Interface API
+ *============================================================================*/
+extern uint8_t dfu_add_service(void *p_func);
+extern bool dfu_check_working(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/server/rcu_ota_service.h b/inc/bluetooth/profile/server/rcu_ota_service.h
new file mode 100644
index 0000000..1f970c7
--- /dev/null
+++ b/inc/bluetooth/profile/server/rcu_ota_service.h
@@ -0,0 +1,153 @@
+/**
+*********************************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+**********************************************************************************************************
+* @file ota_service.h
+* @brief
+* @details
+* @author hunter_shuai
+* @date 14-July-2015
+* @version v1.0.0
+******************************************************************************
+* @attention
+* <h2><center>&copy; COPYRIGHT 2015 Realtek Semiconductor Corporation</center></h2>
+******************************************************************************
+*/
+
+#ifndef _OTA_SERVICE_H_
+#define _OTA_SERVICE_H_
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include "profile_server.h"
+/** @brief Demo Profile service related UUIDs. */
+
+#define GATT_UUID_CHAR_OTA 0xFFD1 //1
+#define GATT_UUID_CHAR_MAC 0xFFD2 //2
+#define GATT_UUID_CHAR_PATCH 0xFFD3 //3
+#define GATT_UUID_CHAR_APP_VERSION 0xFFD4 //4
+#define GATT_UUID_CHAR_PATCH_EXTENSION 0xFFD5 //5
+#define GATT_UUID_CHAR_TEST_MODE 0xFFD8 //6
+
+#define GATT_UUID_CHAR_DEVICE_INFO 0xFFF1 //7
+#define GATT_UUID_CHAR_IMAGE_COUNT_TO_UPDATE 0xFFF2 //8
+#define GATT_UUID_CHAR_IMAGE_VERSION 0xFFE0
+
+
+//vendor featture for some customers
+
+#define EFLASH_SAVE_OTA_PROCESSING_OFFSET 0x208
+
+
+
+
+/** @brief Index of each characteristic in Demo Profile service database. */
+#define BLE_SERVICE_CHAR_OTA_INDEX 0x02
+#define BLE_SERVICE_CHAR_MAC_ADDRESS_INDEX 0x04
+#define BLE_SERVICE_CHAR_PATCH_INDEX 0x06
+#define BLE_SERVICE_CHAR_APP_VERSION_INDEX 0x08
+#define BLE_SERVICE_CHAR_PATCH_EXTENSION_INDEX 0x0a
+#define BLE_SERVICE_CHAR_TEST_MODE_INDEX 0x0c
+#define BLE_SERVICE_CHAR_DEVICE_INFO_INDEX 0x0e
+#define BLE_SERVICE_CHAR_IMAGE_COUNT_INDEX 0x10
+#define BLE_SERVICE_CHAR_IMAGE_VERSION_INDEX 0x12
+
+/** @brief OTA Write callback data type definition.*/
+#define OTA_WRITE_CHAR_VAL 0x01
+#define OTA_WRITE_TEST_MODE_CHAR_VAL 0x02
+
+/** @brief OTA Write callback data type definition.*/
+#define OTA_WRITE_CHAR_VAL 0x01
+#define OTA_VALUE_ENTER 0x01
+
+#define OTA_WRITE_IMAGE_COUNT_VAL 0x02
+#define OTA_VALUE_IMAGE_COUNT_APP_ONLY 0x01
+#define OTA_VALUE_IMAGE_COUNT_PATCH_ONLY 0x02
+#define OTA_VALUE_IMAGE_COUNT_APP_AND_PATCH 0x03
+
+typedef struct _TOTA_UPDATE_IMAGE_INFO
+{
+ uint8_t image_count;
+ uint16_t update_patch_version;
+ uint16_t update_app_version;
+} TOTA_UPDATE_IMAGE_INFO;
+
+typedef struct _T_DFU_DEVICE_INFO
+{
+ uint8_t ictype;
+ uint8_t ota_version;
+ uint8_t secure_version;
+
+ union
+ {
+ uint8_t value;
+ struct
+ {
+ uint8_t buffercheck: 1; // 1:support, 0:don't support
+ uint8_t aesflg: 1; // 1:aes encrypt when ota, 0:not encrypt
+ uint8_t aesmode: 1; // 1:all data is encrypted, 0:only encrypt 16byte
+ //uint8_t verify_algo: 1; // 1:sha256, 0:crc
+ uint8_t copy_img: 1; //1:support ,0:don't support
+ uint8_t multi_img: 1; //1:support(update multi img at a time) ,0:don't support(one img at a time)
+ uint8_t rsvd: 3;
+ };
+ } mode;
+
+ uint16_t maxbuffersize;
+ uint16_t res;
+
+ uint32_t img_indicator;
+} T_DFU_DEVICE_INFO, * P_DFU_DEVICE_INFO;
+
+
+#define OTA_UPDATE_IMAGE_INFO_LEN 5
+
+#define CHAR2SHORT(p) (((*(p)) & 0xff) + ((*((p)+1)) << 8))
+
+typedef struct _TOTA_WRITE_MSG
+{
+ uint8_t opcode;
+ union
+ {
+ uint8_t value;
+ TOTA_UPDATE_IMAGE_INFO update_image_info;
+ } u;
+} TOTA_WRITE_MSG;
+
+typedef union _TOTA_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+ TOTA_WRITE_MSG write;
+} TOTA_UPSTREAM_MSG_DATA;
+
+/**
+ * @brief OTA servic data struct for notification data to application.
+ *
+ * OTA service data to inform application.
+*/
+typedef struct _TOTA_CALLBACK_DATA
+{
+ T_SERVICE_CALLBACK_TYPE msg_type; /**< @brief EventId defined upper */
+ TOTA_UPSTREAM_MSG_DATA msg_data;
+} TOTA_CALLBACK_DATA;
+
+
+extern uint8_t ota_add_service(void *p_func);
+
+typedef enum _BANK_NUM
+{
+ BANK0 = 0,
+ BANK1 = 1,
+ BANK_UNKNOWN = 2
+} BANK_NUM;
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/server/rscs.h b/inc/bluetooth/profile/server/rscs.h
new file mode 100644
index 0000000..cd7d324
--- /dev/null
+++ b/inc/bluetooth/profile/server/rscs.h
@@ -0,0 +1,446 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file rsc_service.h
+ * @brief Head file for using Running Speed and Cadence Service.
+ * @details RSC data structs and external functions declaration.
+ * @author ethan_su
+ * @date 2017-10-10
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _RSCS_SERVICE_DEF_H
+#define _RSCS_SERVICE_DEF_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+
+
+/** @defgroup RSCS Running Speed and Cadence Service
+ * @brief Running Speed and Cadence Service
+ * @details
+
+ The Running Speed and Cadence (RSC) Service exposes speed, cadence and other data related to fitness applications
+ such as the stride length and the total distance the user has traveled while using the Running Speed and Cadence sensor (Server).
+
+ Application shall register Running Speed and Cadence service when initialization through @ref rscs_add_service function.
+
+ The RSC Measurement characteristic is used to send speed and cadence measurements. Included in the characteristic value are
+ a Flags field (for showing the presence of optional fields and, if supported by the Server, whether the user is walking or running),
+ an Instantaneous Speed field, an Instantaneous Cadence field, depending upon the contents of the Flags field, an Instantaneous
+ Stride Length field and a Total Distance field.
+
+ The Server measures the instantaneous speed at which the user is moving. The cadence represents the number of times per minute
+ the foot with the sensor hits the ground. The stride length represents the distance between two successive contacts of the same foot
+ to the ground and the total distance represents the distance the user has travelled with the sensor since the last reset of the total
+ distance.
+
+ Application can set a running speed and cadence service parameter through @ref rscs_set_parameter function.
+
+ Application can get a running speed and cadence service parameter through @ref rscs_get_parameter function.
+
+ After set service parameter, running speed and cadence service can send notification data to client through @ref rscs_meas_value_notify function.
+
+ Running speed and cadence service can indicate result of calibration to client through @ref rscs_calib_result_indicate function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup RSCS_Exported_Macros RSCS Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup RSCS_Measurement_Flag_Bit_Mask RSC Measurement Flag Bit Mask
+ * @brief RSC measurement 'Flags' present bit mask.
+ * @{
+ */
+#define RSCS_INC_STRIDE_LENGTH_MASK (1) /**< Instantaneous Stride Length Present. */
+#define RSCS_INC_TOTAL_DISTANCE_MASK (1<<1) /**< Total Distance Present. */
+#define RSCS_INC_RUNNING_STATUS_MASK (1<<2) /**< Walking or Running Status bits. */
+#define RSCS_INC_ALL_PRESENTS (0x07)
+/** @} */
+
+/** @defgroup RSCS_Feature_Bit_Mask RSC Feature Bit Mask
+ * @brief RSC features bit mask.
+ * @{
+ */
+#define RSCS_SUPPORT_STRIDE_LENGTH_MASK (1)
+#define RSCS_SUPPORT_TOTAL_DISTANCE_MASK (1<<1)
+#define RSCS_SUPPORT_RUNNING_STATUS_MASK (1<<2)
+#define RSCS_SUPPORT_CALIBRATE_MASK (1<<3)
+#define RSCS_SUPPORT_MULTI_SENSOR_MASK (1<<4)
+#define RSCS_ALL_FEATURE_SUPPORTED (0x1F)
+/** @} */
+
+/** @defgroup RSCS_Sensor_Location_Bit_Mask RSC Sensor Location Bit Mask
+ * @brief RSC supported sensor location bit mask.
+ * @{
+ */
+#define RSCS_SENS_LOC_OTHER_MASK (1)
+#define RSCS_SENS_LOC_TOP_OF_SHOE_MASK (1<<1)
+#define RSCS_SENS_LOC_IN_SHOE_MASK (1<<2)
+#define RSCS_SENS_LOC_HIP_MASK (1<<3)
+#define RSCS_SENS_LOC_FRONT_WHEEL_MASK (1<<4)
+#define RSCS_SENS_LOC_LEFT_CRANK_MASK (1<<5)
+#define RSCS_SENS_LOC_RIGHT_CRANK_MASK (1<<6)
+#define RSCS_SENS_LOC_LEFT_PEDAL_MASK (1<<7)
+#define RSCS_SENS_LOC_RIGHT_PEDAL_MASK (1<<8)
+#define RSCS_SENS_LOC_FRONT_HUB_MASK (1<<9)
+#define RSCS_SENS_LOC_REAR_DROPOUT_MASK (1<<10)
+#define RSCS_SENS_LOC_CHAINSTAY_MASK (1<<11)
+#define RSCS_SENS_LOC_REAR_WHEEL_MASK (1<<12)
+#define RSCS_SENS_LOC_REAR_HUB_MASK (1<<13)
+#define RSCS_SENS_LOC_CHEST_MASK (1<<14)
+#define RSCS_ALL_SENS_LOC_SUPPORTED (0x7FFF)
+/** @} */
+
+/** @defgroup RSCS_Control_Point_OpCodes RSC Control Point OpCodes
+ * @brief Control Point OpCodes
+ * @{
+ */
+#define RSCS_CP_OPCODE_RESERVED 0x00
+#define RSCS_CP_OPCODE_SET_CUMULATIVE 0x01
+#define RSCS_CP_OPCODE_START_CALIBRATION 0x02
+#define RSCS_CP_OPCODE_UPDATE_SENS_LOC 0x03
+#define RSCS_CP_OPCODE_REQ_SENS_LOC_LIST 0x04
+#define RSCS_CP_OPCODE_RSP_CODE 0x10
+/** @} */
+
+/** @defgroup RSCS_Control_Point_Response_Codes RSC Control Point Response Codes
+ * @brief Control Point Response Codes
+ * @{
+ */
+#define RSCS_CP_RSPCODE_RESERVED 0x00
+#define RSCS_CP_RSPCODE_SUCCESS 0x01
+#define RSCS_CP_RSPCODE_OPCODE_UNSUPPORT 0x02
+#define RSCS_CP_RSPCODE_INVALID_PARAMETER 0x03
+#define RSCS_CP_RSPCODE_OPERATION_FAILED 0x04
+/** @} */
+
+/** @defgroup RSCS_Error_Codes RSC Error Codes
+ * @brief Error codes defined in RSC spec
+ * @{
+ */
+#define RSCS_ERR_PROC_ALREADY_IN_PROG 0x80
+#define RSCS_ERR_CCCD_IMPROPERLY_CFG 0x81
+/** @} */
+
+/** @defgroup RSCS_Data_Length RSC Data Length
+ * @brief Max bytes of RSC Measurement data and RSC Control Point data
+ * @{
+ */
+#define RSCS_MAX_MEASUREMENT_VALUE 10
+#define RSCS_MAX_CTL_PNT_VALUE 18
+/** @} */
+
+
+/** @defgroup RSCS_Read_Info RSC Read Info
+ * @brief Parameter for reading characteristic value.
+ * @{
+ */
+#define RSCS_READ_RSCS_FEATURE 1
+#define RSCS_READ_SENSOR_LOCATION 2
+/** @} */
+
+/** @defgroup RSCS_Notify_Indicate_Info RSCS Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define RSCS_NOTIFY_INDICATE_MEASUREMENT_ENABLE 1
+#define RSCS_NOTIFY_INDICATE_MEASUREMENT_DISABLE 2
+#define RSCS_NOTIFY_INDICATE_SC_CP_ENABLE 3
+#define RSCS_NOTIFY_INDICATE_SC_CP_DISABLE 4
+/** @} */
+
+/** End of RSCS_Exported_Macros
+* @}
+*/
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup RSCS_Exported_Types RSCS Exported Types
+ * @brief
+ * @{
+ */
+
+/**
+* @brief RSC service parameter type
+*/
+typedef enum
+{
+ RSCS_PARAM_CSCS_FEATURE = 0x01,
+ RSCS_PARAM_INC_FLAG,
+ RSCS_PARAM_SPEED,
+ RSCS_PARAM_CADENCE,
+ RSCS_PARAM_STRIDE_LENGTH,
+ RSCS_PARAM_TOTALDISTANCE,
+ RSCS_PARAM_CTL_PNT_PROG_CLR,
+ RSCS_PARAM_SENSOR_LOC,
+} T_RSCS_PARAM_TYPE;
+
+
+/** @defgroup RSCS_Sensor_Locations RSC Sensor Locations
+ * @brief All RSC sensor locations defined in spec
+ * @{
+ */
+typedef enum
+{
+ RSCS_SENSOR_LOC_OTHER = 0,
+ RSCS_SENSOR_LOC_TOP_OF_SHOE = 1,
+ RSCS_SENSOR_LOC_IN_SHOE = 2,
+ RSCS_SENSOR_LOC_HIP = 3,
+ RSCS_SENSOR_LOC_FRONT_WHEEL = 4,
+ RSCS_SENSOR_LOC_LEFT_CRANK = 5,
+ RSCS_SENSOR_LOC_RIGHT_CRANK = 6,
+ RSCS_SENSOR_LOC_LEFT_PEDAL = 7,
+ RSCS_SENSOR_LOC_RIGHT_PEDAL = 8,
+ RSCS_SENSOR_LOC_FRONT_HUB = 9,
+ RSCS_SENSOR_LOC_REAR_DROPOUT = 10,
+ RSCS_SENSOR_LOC_CHAINSTAY = 11,
+ RSCS_SENSOR_LOC_REAL_WHEEL = 12,
+ RSCS_SENSOR_LOC_REAL_HUB = 13,
+ RSCS_SENSOR_LOC_CHEST = 14,
+ RSCS_SENSOR_LOC_MAX
+} TRSCSensorLocation;
+/** @} */
+
+/** @defgroup RSCS_Measurement_Data RSC Measurement Data
+ * @brief RSC measurement data, variable length during connection, max can reach 10 bytes
+ * @{
+ */
+typedef struct
+{
+ uint8_t cur_length; /**< length of current RSC measurement data. */
+ uint8_t value[RSCS_MAX_MEASUREMENT_VALUE]; /**< value of current RSC measurement data. */
+} T_RSCS_MEASUREMENT;
+/** @} */
+
+/** @defgroup RSCS_Control_Point_Data RSC Control Point Data
+ * @brief RSC Control Point data, variable length during connection, max can reach 18 bytes
+ * @{
+ */
+typedef struct
+{
+ uint8_t cur_length; /**< length of current RSC Control Point data, . */
+ uint8_t value[RSCS_MAX_CTL_PNT_VALUE]; /**< value of current RSC Control Point data, . */
+} T_RSCS_CONTROL_POINT;
+/** @} */
+
+
+/** @defgroup RSCS_Callback_Data RSCS Callback Data
+ * @brief RSC data struct for notification data to application.
+ * @{
+ */
+typedef union
+{
+ uint8_t sensor_location_value;
+ uint32_t cumulative_value;
+} T_RSCS_CP_PARAMETER;
+
+typedef struct
+{
+ uint8_t opcode; //!< ref: @ref RSCS_Control_Point_OpCodes
+ T_RSCS_CP_PARAMETER cp_parameter;
+} T_RSCS_WRITE_MSG;
+
+typedef union
+{
+ uint8_t notification_indification_index; //!< ref: @ref RSCS_Notify_Indicate_Info
+ uint8_t read_value_index; //!< ref: @ref RSCS_Read_Info
+ T_RSCS_WRITE_MSG write;
+} T_RSCS_UPSTREAM_MSG_DATA;
+
+/** RSC service data to inform application */
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_RSCS_UPSTREAM_MSG_DATA msg_data;
+} T_RSCS_CALLBACK_DATA;
+/** @} */
+
+/** End of RSCS_Exported_Types
+* @}
+*/
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup RSCS_Exported_Functions RSCS Exported Functions
+ * @brief
+ * @{
+ */
+
+
+/**
+ * @brief Add Running Speed and Cadence Service.
+ *
+ * @param[in] p_func Callback when service attribute was read/write.
+ *
+ * @return service id @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ rscs_id = rscs_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID rscs_add_service(void *p_func);
+
+
+/**
+ * @brief Set a Running Speed and Cadence Service parameter.
+ *
+ * NOTE: You can call this function with a Running Speed and Cadence Service parameter type and it will set the
+ * Running Speed and Cadence Service parameter. Running Speed and Cadence Service parameters are defined
+ * in @ref T_RSCS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Running Speed and Cadence Service parameter type: @ref T_RSCS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint32_t total_distance = p_parse_value->dw_param[0];
+ bool op_result;
+
+ op_result = rscs_set_parameter(RSCS_PARAM_TOTALDISTANCE, 4, (uint8_t*)&total_distance);
+
+ if ( op_result )
+ {
+ rscs_get_parameter( RSCS_PARAM_TOTALDISTANCE, &total_distance );
+ data_uart_print("set total_distance = %d\r\n", total_distance);
+ }
+ else
+ {
+ data_uart_print("rscs_set_parameter total_distance failed\r\n");
+ }
+ }
+ * \endcode
+ */
+bool rscs_set_parameter(T_RSCS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Get a Running Speed and Cadence Service parameter.
+ *
+ * NOTE: You can call this function with a Running Speed and Cadence Service parameter type and it will get the
+ * parameter. Running Speed and Cadence Service parameters are defined in @ref T_RSCS_PARAM_TYPE.
+ *
+ * @param[in] param_type Running Speed and Cadence Service parameter type: @ref T_RSCS_PARAM_TYPE
+ * @param[in] p_value Pointer to data to read.
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t bFlag;
+
+ rscs_get_parameter(RSCS_PARAM_INC_FLAG, &bFlag);
+ }
+ * \endcode
+ */
+bool rscs_get_parameter(T_RSCS_PARAM_TYPE param_type, void *p_value);
+
+/**
+ * @brief Send Running Speed and Cadence Service value notification data.
+ * Application shall call @ref rscs_set_parameter to set value first,
+ * and then call this api to send the notication value.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ *
+ * @return service id @ref T_SERVER_ID.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ bool op_result;
+ uint8_t flag = RSCS_INC_ALL_PRESENTS;
+
+ rscs_set_parameter(RSCS_PARAM_INC_FLAG, 1, &flag);
+
+ op_result = rscs_meas_value_notify(p_parse_value->dw_param[0], rscs_id);
+
+ if ( op_result )
+ {
+ data_uart_print("Notify RSC measurement value succeed\r\n");
+ }
+ else
+ {
+ data_uart_print("Notify RSC measurement value failed\r\n");
+ }
+
+ }
+ * \endcode
+ */
+bool rscs_meas_value_notify(uint8_t conn_id, T_SERVER_ID service_id);
+
+/**
+ * @brief Send Running Speed and Cadence Service value indication data,
+ * send indication of result of calibration to client.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @param[in] result calibration result.
+ *
+ * @return none;
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t conn_id = p_parse_value->dw_param[0];
+ uint8_t result = p_parse_value->dw_param[1];
+ rscs_calib_result_indicate(conn_id, rscs_id, result);
+ data_uart_print("cmd_rscs_calib_result_indicate result= %d\r\n", result);
+ }
+ * \endcode
+ */
+void rscs_calib_result_indicate(uint8_t conn_id, T_SERVER_ID service_id, bool result);
+
+
+/** @} End of RSCS_Exported_Functions */
+
+
+/** @} End of RSCS */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _RSCS_DEF_H */
diff --git a/inc/bluetooth/profile/server/simple_ble_config.h b/inc/bluetooth/profile/server/simple_ble_config.h
new file mode 100644
index 0000000..04b7fb7
--- /dev/null
+++ b/inc/bluetooth/profile/server/simple_ble_config.h
@@ -0,0 +1,63 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2016, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file simple_ble_config.h
+ * @brief This file includes common constants or types for Simple BLE service/client.
+ * And some optional feature may be defined in this file.
+ * @details
+ * @author Ethan
+ * @date 2016-02-18
+ * @version v0.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion **/
+#ifndef _SIMPLE_BLE_CONFIG_H_
+#define _SIMPLE_BLE_CONFIG_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/** @defgroup SIMP_Service Simple Ble Service
+ * @brief Simple BLE service
+ * @{
+ */
+
+/** @defgroup SIMP_Service_CONFIG SIMP Service Config
+ * @brief Simple BLE service configuration file
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup SIMP_Common_Exported_Macros SIMP Service Config Exported Constants
+ * @brief
+ * @{
+ */
+
+/** @defgroup SIMP_UUIDs SIMP UUIDs
+ * @brief Simple BLE Profile UUID definitions
+ * @{
+ */
+#define GATT_UUID_SIMPLE_PROFILE 0xA00A
+#define GATT_UUID_CHAR_SIMPLE_V1_READ 0xB001
+#define GATT_UUID_CHAR_SIMPLE_V2_WRITE 0xB002
+#define GATT_UUID_CHAR_SIMPLE_V3_NOTIFY 0xB003
+#define GATT_UUID_CHAR_SIMPLE_V4_INDICATE 0xB004
+/** @} End of SIMP_UUIDs */
+
+/** @} End of SIMP_Common_Exported_Macros */
+
+/** @} End of SIMP_Service_CONFIG */
+
+/** @} End of SIMP_Service */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/server/simple_ble_service.h b/inc/bluetooth/profile/server/simple_ble_service.h
new file mode 100644
index 0000000..93d69b8
--- /dev/null
+++ b/inc/bluetooth/profile/server/simple_ble_service.h
@@ -0,0 +1,205 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file simple_ble_service.h
+ * @brief Demonstration of how to implement a self-definition service.
+ * @details Demonstration of different kinds of service interfaces.
+ * @author
+ * @date
+ * @version
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _SIMPLE_BLE_SERVICE_H_
+#define _SIMPLE_BLE_SERVICE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include <profile_server.h>
+#include <simple_ble_config.h>
+
+
+/** @defgroup SIMP_Service Simple Ble Service
+ * @brief Simple BLE service
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup SIMP_Service_Exported_Macros SIMP Service Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup SIMP_Service_Application_Parameters SIMP Service Application Parameters
+ * @brief Type of parameters set/got from application.
+ * @{
+ */
+typedef enum
+{
+ SIMPLE_BLE_SERVICE_PARAM_V1_READ_CHAR_VAL = 0x01,
+} T_SIMP_PARAM_TYPE;
+
+/** @} */
+
+
+
+/** @defgroup SIMP_Service_Upstream_Message SIMP Service Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+
+/** @defgroup SIMP_Service_Read_Info SIMP Service Read Info
+ * @brief Parameter for reading characteristic value.
+ * @{
+ */
+#define SIMP_READ_V1 1
+/** @} */
+
+/** @defgroup SIMP_Service_Write_Info SIMP Service Write Info
+ * @brief Parameter for writing characteristic value.
+ * @{
+ */
+#define SIMP_WRITE_V2 1
+
+/** @} */
+
+/** @defgroup SIMP_Service_Notify_Indicate_Info SIMP Service Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define SIMP_NOTIFY_INDICATE_V3_ENABLE 1
+#define SIMP_NOTIFY_INDICATE_V3_DISABLE 2
+#define SIMP_NOTIFY_INDICATE_V4_ENABLE 3
+#define SIMP_NOTIFY_INDICATE_V4_DISABLE 4
+
+
+/** @} */
+
+#define SIMP_READ_V1_MAX_LEN 300
+
+/** @} End of SIMP_Service_Upstream_Message */
+
+
+
+/** @} End of SIMP_Service_Exported_Macros */
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup SIMP_Service_Exported_Types SIMP Service Exported Types
+ * @brief
+ * @{
+ */
+
+/** @defgroup TSIMP_WRITE_MSG TSIMP_WRITE_MSG
+ * @brief Simple BLE service written msg to application.
+ * @{
+ */
+typedef struct
+{
+ uint8_t opcode; //!< ref: @ref SIMP_Service_Write_Info
+ T_WRITE_TYPE write_type;
+ uint16_t len;
+ uint8_t *p_value;
+} TSIMP_WRITE_MSG;
+/** @} End of TSIMP_WRITE_MSG */
+
+
+/** @defgroup TSIMP_UPSTREAM_MSG_DATA TSIMP_UPSTREAM_MSG_DATA
+ * @brief Simple BLE service callback message content.
+ * @{
+ */
+typedef union
+{
+ uint8_t notification_indification_index; //!< ref: @ref SIMP_Service_Notify_Indicate_Info
+ uint8_t read_value_index; //!< ref: @ref SIMP_Service_Read_Info
+ TSIMP_WRITE_MSG write;
+} TSIMP_UPSTREAM_MSG_DATA;
+/** @} End of TSIMP_UPSTREAM_MSG_DATA */
+
+/** @defgroup TSIMP_CALLBACK_DATA TSIMP_CALLBACK_DATA
+ * @brief Simple BLE service data to inform application.
+ * @{
+ */
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ TSIMP_UPSTREAM_MSG_DATA msg_data;
+} TSIMP_CALLBACK_DATA;
+/** @} End of TSIMP_CALLBACK_DATA */
+
+/** @} End of SIMP_Service_Exported_Types */
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup SIMP_Service_Exported_Functions SIMP Service Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add simple BLE service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ */
+T_SERVER_ID simp_ble_service_add_service(void *p_func);
+
+/**
+ * @brief Set service related data from application.
+ *
+ * @param[in] param_type parameter type to set.
+ * @param[in] len value length to be set.
+ * @param[in] p_value value to set.
+ * @return parameter set result.
+ * @retval 0 false
+ * @retval 1 true
+ */
+bool simp_ble_service_set_parameter(T_SIMP_PARAM_TYPE param_type, uint16_t len, void *p_value);
+
+/**
+ * @brief send notification of simple notify characteristic value.
+ *
+ * @param[in] conn_id connection id
+ * @param[in] service_id service ID of service.
+ * @param[in] p_value characteristic value to notify
+ * @param[in] length characteristic value length to notify
+ * @return notification action result
+ * @retval 1 true
+ * @retval 0 false
+ */
+bool simp_ble_service_send_v3_notify(uint8_t conn_id, T_SERVER_ID service_id,
+ void *p_value, uint16_t length);
+/**
+ * @brief send indication of simple indicate characteristic value.
+ *
+ * @param[in] conn_id connection id
+ * @param[in] service_id service ID of service.
+ * @param[in] p_value characteristic value to notify
+ * @param[in] length characteristic value length to notify
+ * @return notification action result
+ * @retval 1 true
+ * @retval 0 false
+ */
+bool simp_ble_service_send_v4_indicate(uint8_t conn_id, T_SERVER_ID service_id,
+ void *p_value, uint16_t length);
+
+/** @} End of SIMP_Service_Exported_Functions */
+
+/** @} End of SIMP_Service */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SIMPLE_BLE_SERVICE_H_ */
diff --git a/inc/bluetooth/profile/server/sps.h b/inc/bluetooth/profile/server/sps.h
new file mode 100644
index 0000000..a7ac4de
--- /dev/null
+++ b/inc/bluetooth/profile/server/sps.h
@@ -0,0 +1,219 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file sps.h
+ * @brief Head file for using scan parameters service.
+ * @details SPS data structs and external functions declaration.
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _SPS_H_
+#define _SPS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/* Add Includes here */
+#include "profile_server.h"
+
+
+/** @defgroup SPS Scan Parameters Service
+ * @brief Scan parameters service
+ * @details
+
+ The Scan Parameters Service enables a GATT Server device to expose a characteristic for the GATT Client
+ to write its scan interval and scan window on the GATT Server device, and enables a GATT Server to
+ request a refresh of the GATT Client scan interval and scan window.Scan Parameter Service makes up the
+ services of HID Device, together with HID Service. Its role is to implement the interaction of data
+ information when needing to change Scan parameters.
+
+ Scan Parameter Service contains two Characteristics: one is scan interval and scan window, and it is used
+ to store Scan Parameters of the Client; the other is Scan Refresh, and it is used to notify the Client to
+ update the value of Scan parameter according to recent data by notification.
+
+ The specific configuration can be achieved by modifying @ref sps_config.h.
+
+ Application shall register scan parameter service when initialization through @ref sps_add_service function.
+
+ Application can set the scan refresh value through @ref sps_set_parameter function.
+
+ Application can notify refresh value to client through @ref sps_scan_interval_window_value_notify function.
+
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup SPS_Exported_Macros SPS Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @defgroup SPS_Write_Info SPS Write Info
+ * @brief Parameter for writing characteristic value.
+ * @{
+ */
+#define SPS_WRITE_SCAN_INTERVAL_WINDOW 1
+/** @} */
+
+/** @defgroup SPS_Notify_Indicate_Info SPS Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define SPS_NOTIFY_INDICATE_SCAN_REFRESH_ENABLE 1
+#define SPS_NOTIFY_INDICATE_SCAN_REFRESH_DISABLE 2
+/** @} */
+
+/** @} End of SPS_Exported_Macros */
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup SPS_Exported_Types SPS Exported Types
+ * @brief
+ * @{
+ */
+
+/** @defgroup SPS_PARAM_TYPE SPS Parameter Types
+* @brief
+* @{
+*/
+typedef enum
+{
+ SPS_PARAM_SCAN_REFRESH
+} T_SPS_PARAM_TYPE;
+
+/** @} */
+
+/** SPS scan interval window structure*/
+typedef struct
+{
+ uint16_t scan_interval;
+ uint16_t scan_window;
+} T_SPS_SCAN_INTERVAL_WINDOW;
+
+
+/** SPS write parameter*/
+typedef union
+{
+ T_SPS_SCAN_INTERVAL_WINDOW scan;
+} T_SPS_WRITE_PARAMETER;
+
+/** SPS write message*/
+typedef struct
+{
+ uint8_t write_type;
+ T_SPS_WRITE_PARAMETER write_parameter;
+} T_SPS_WRITE_MSG;
+
+/** SPS upstream message data*/
+typedef union
+{
+ uint8_t notification_indification_index;
+ T_SPS_WRITE_MSG write;
+} T_SPS_UPSTREAM_MSG_DATA;
+
+/** SPS callback data*/
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_SPS_UPSTREAM_MSG_DATA msg_data;
+} T_SPS_CALLBACK_DATA;
+
+/** @} End of SPS_Exported_Types */
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup SPS_Exported_Functions SPS Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Set a scan parameter service parameter.
+ *
+ * NOTE: You can call this function with a scan parameter service parameter type and it will set the
+ * scan parameter service parameter. Scan parameter service parameters are defined in @ref T_SPS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Scan parameter service parameter type: @ref T_SPS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t refresh_value = 10;
+ sps_set_parameter(SPS_PARAM_SCAN_REFRESH, 1, &refresh_value);
+ }
+ * \endcode
+ */
+bool sps_set_parameter(T_SPS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+/**
+ * @brief Add scan parameters service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ sps_id = sps_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID sps_add_service(void *p_func);
+
+/**
+ * @brief send notification.
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service ID of service.
+ * @param[in] sps_refresh_value characteristic value to notify
+ * @return notification action result
+ * @retval 1 TRUE
+ * @retval 0 FALSE
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t sps_refresh_value = 10;
+ sps_scan_interval_window_value_notify(conn_id, sps_id, sps_refresh_value);
+ }
+ * \endcode
+ */
+bool sps_scan_interval_window_value_notify(uint8_t conn_id, uint8_t service_id,
+ uint8_t sps_refresh_value);
+/** @} End of SPS_Exported_Functions */
+
+/** @} End of SPS */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _SPS_H_ */
+
diff --git a/inc/bluetooth/profile/server/sps_config.h b/inc/bluetooth/profile/server/sps_config.h
new file mode 100644
index 0000000..df477ba
--- /dev/null
+++ b/inc/bluetooth/profile/server/sps_config.h
@@ -0,0 +1,35 @@
+#ifndef _SPS_CONFIG_H_
+#define _SPS_CONFIG_H_
+
+
+/** @defgroup SPS Scan Parameters Service
+ * @brief Scan parameters service
+ * @{
+ */
+
+/** @defgroup SPS_CONFIG Scan Parameters Service Config
+ * @brief Scan parameters service config
+ * @{
+ */
+
+/** @defgroup SPS_Exported_Macros SPS Exported Macros
+ * @brief
+ * @{
+ */
+
+/** @details
+ Set SPS_CHAR_SCAN_REFRESH_SUPPORT to 1 to support scan refresh characteristic,
+ otherwise set it to 0.
+*/
+#define SPS_CHAR_SCAN_REFRESH_SUPPORT 1
+
+
+/** @} End of SPS_Common_Exported_Macros */
+
+/** @} End of SPS_CONFIG */
+
+/** @} End of SPS */
+
+
+
+#endif
diff --git a/inc/bluetooth/profile/server/tps.h b/inc/bluetooth/profile/server/tps.h
new file mode 100644
index 0000000..48680c3
--- /dev/null
+++ b/inc/bluetooth/profile/server/tps.h
@@ -0,0 +1,158 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file tps.h
+ * @brief Head file for using TX power service.
+ * @details TPS data structs and external functions declaration.
+ * @author
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+#ifndef _TPS_H_
+#define _TPS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <stdint.h>
+#include "profile_server.h"
+
+
+/** @defgroup TPS Tx Power Service
+ * @brief Tx power service
+ * @details
+
+ The Tx Power service uses the Tx Power Level characteristic to expose the current transmit power level
+ of a device when in a connection.The Tx Power service contains only a Tx Power Level characteristic.
+ The Tx Power Service generally makes up a profile with some other services, such as Proximity, and its
+ role is to indicate a device's transmit power level when in a connection.
+
+ Application shall register Tx Power service when initialization through @ref tps_add_service function.
+
+ Application can set the TX power value through @ref tps_set_parameter function.
+
+ * @{
+ */
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup TPS_Exported_Macros TPS Exported Macros
+ * @brief
+ * @{
+ */
+/** @defgroup TPS_Read_Info TPS Read Info
+ * @brief Read characteristic value.
+ * @{
+ */
+#define TPS_READ_TX_POWER_VALUE 1
+/** @} */
+/** @} End of TPS_Exported_Macros */
+/*============================================================================*
+ * Types
+ *============================================================================*/
+/** @defgroup TPS_Exported_Types TPS Exported Types
+ * @brief
+ * @{
+ */
+/* Add all public types here */
+/** @defgroup TPS_Application_Parameters TPS Application Parameters
+ * @brief Type of parameters set/got from application.
+ * @{
+ */
+typedef enum
+{
+ TPS_PARAM_TX_POWER
+} T_TPS_PARAM_TYPE;
+/** @} */
+
+/** @defgroup TPS_Upstream_Message TPS Upstream Message
+ * @brief TPS data struct for notification data to application.
+ * @{
+ */
+/** Message content: @ref TPS_Upstream_Message */
+typedef union
+{
+ uint8_t read_value_index;
+} T_TPS_UPSTREAM_MSG_DATA;
+
+/** TPS service data to inform application. */
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_TPS_UPSTREAM_MSG_DATA msg_data;
+} T_TPS_CALLBACK_DATA;
+/** @} */
+
+/** @} End of TPS_Exported_Types */
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+/** @defgroup TPS_Exported_Functions TPS Exported Functions
+ * @{
+ */
+
+/**
+ * @brief Set a Tx power service parameter.
+ *
+ * NOTE: You can call this function with a tx power service parameter type and it will set the
+ * tx power service parameter. Tx power service parameters are defined in @ref T_TPS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Tx power service parameter type: @ref T_TPS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (example: data type of uint16 will be cast to
+ * uint16 pointer).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t tx_power = 0;
+ tps_set_parameter(TPS_PARAM_TX_POWER, 1, &tx_power);
+ }
+ * \endcode
+ */
+bool tps_set_parameter(T_TPS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+
+/**
+ * @brief Add tx power service to the BLE stack database.
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ tps_id = tps_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID tps_add_service(void *p_func);
+
+/** @} End of TPS_Exported_Functions */
+
+/** @} End of TPS */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _TPS_H_ */
diff --git a/inc/bluetooth/profile/server/vendor_service.h b/inc/bluetooth/profile/server/vendor_service.h
new file mode 100644
index 0000000..2f76295
--- /dev/null
+++ b/inc/bluetooth/profile/server/vendor_service.h
@@ -0,0 +1,80 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file vendor_service.h
+ * @brief Head file for using Vendor Service Remote Controller.
+ * @details Vendor service data structs and external functions declaration.
+ * @author Chenjie Jin
+ * @date 2018-5-7
+ * @version v1.1
+ * *************************************************************************************
+ */
+
+#ifndef _VENDOR_SERVICE_H_
+#define _VENDOR_SERVICE_H_
+
+#include "profile_server.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/** @brief Demo Profile service related UUIDs. */
+
+#define GATT_UUID_CHAR_VENDOR_HANDSHAKE 0xA001
+#define GATT_UUID_CHAR_VENDOR_TEST_MODE 0xA002
+
+/** @brief Index of each characteristic in Demo Profile service database. */
+#define BLE_SERVICE_CHAR_VENDOR_HANDSHAKE_INDEX 0x02
+#define GATT_SVC_VENDOR_HANDSHAKE_CHAR_CCCD_INDEX 0x03
+#define BLE_SERVICE_CHAR_VENDOR_TEST_MODE_INDEX 0x05
+
+#define VENDOR_WRITE_HANDSHAKE 1
+#define VENDOR_WRITE_TEST_MODE 2
+
+#define VENDOR_NOTIFY_ENABLE 1
+#define VENDOR_NOTIFY_DISABLE 2
+
+/** Message content */
+typedef union
+{
+ struct
+ {
+ uint8_t len;
+ uint8_t *report;
+ } report_data;
+} T_VENDOR_WRITE_PARAMETER;
+
+/** @struct _TATVV_WRITE_MSG
+ * @brief write message
+ */
+typedef struct
+{
+ uint8_t write_type; /**< ref: @ref Vendor_Write_Info */
+ T_VENDOR_WRITE_PARAMETER write_parameter;
+} T_VENDOR_WRITE_MSG;
+
+typedef union _TVENDOR_UPSTREAM_MSG_DATA
+{
+ uint8_t notification_indification_index;
+ T_VENDOR_WRITE_MSG write_msg;
+} TVENDOR_UPSTREAM_MSG_DATA;
+
+/** Vendor service data to inform application */
+typedef struct _T_VENDOR_CALLBACK_DATA
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ TVENDOR_UPSTREAM_MSG_DATA msg_data;
+} T_VENDOR_CALLBACK_DATA;
+
+extern uint8_t vendor_svc_handshake_values[16];
+
+uint8_t vendor_svc_add_service(void *pFunc);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/inc/bluetooth/profile/server/voice_service.h b/inc/bluetooth/profile/server/voice_service.h
new file mode 100644
index 0000000..88249d2
--- /dev/null
+++ b/inc/bluetooth/profile/server/voice_service.h
@@ -0,0 +1,155 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2015, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file hids_rmc.h
+ * @brief Head file for using Voice Service.
+ * @details Voice service data structs and external functions declaration.
+ * @author Chenjie Jin
+ * @date 2019-6-27
+ * @version v1.1
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _VOICE_SERVICE_H_
+#define _VOICE_SERVICE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Add Includes here */
+#include "profile_server.h"
+#include "board.h"
+#include "app_msg.h"
+
+/** @defgroup Voice_Service Voice Service
+ * @brief Voice Service based on GATT
+ * @{
+ */
+
+/** @defgroup Voice_Service_Exported_Constants Voice Service Exported Constants
+ * @brief macros that other .c files may use all defined here
+ * @{
+ */
+
+///@cond
+/** @brief Voice_Service related UUIDs. */
+#define GATT_UUID_VOICE_CHAR_CTL 0x3A40
+#define GATT_UUID_VOICE_CHAR_DATA 0x3A41
+#define GATT_UUID_VOICE_CHAR_CMD 0x3A42
+
+///@endcond
+
+/** @defgroup Voice_Service_Attribute_Index Voice Service Attribute Index
+ * @brief Index defines for Characteristic's value in Voice_Service
+ * @{
+ */
+#define GATT_SRV_VOICE_CHAR_CTL_VALUE_INDEX 2
+#define GATT_SRV_VOICE_CHAR_DATA_VALUE_INDEX 4
+#define GATT_SRV_VOICE_CHAR_DATA_CCCD_INDEX 5
+#define GATT_SRV_VOICE_CHAR_CMD_VALUE_INDEX 7
+#define GATT_SRV_VOICE_CHAR_CMD_CCCD_INDEX 8
+
+/** @} */
+
+/** @defgroup Voice_Service_Upstream_Message Voice Service Upstream Message
+ * @brief Upstream message used to inform application.
+ * @{
+ */
+
+/** @defgroup Voice_Service_Read_Info Voice Service Read Info
+ * @brief Parameter for read characteristic value.
+ * @{
+ */
+#define VOICE_SVC_READ_PARAM_VOICE_DATA 1
+#define VOICE_SVC_READ_PARAM_VOICE_CMD 2
+/** @} */
+
+/** @defgroup Voice_Service_Write_Info Voice Service Write Info
+ * @brief Parameter for write characteristic value.
+ * @{
+ */
+#define VOICE_SVC_WRITE_CHAR_CTL_INDEX 1
+/** @} */
+
+/** @defgroup Voice_Service_Notify_Indicate_Info Voice Service Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define VOICE_NOTIFY_DATA_ENABLE 1
+#define VOICE_NOTIFY_DATA_DISABLE 2
+#define VOICE_NOTIFY_CMD_ENABLE 3
+#define VOICE_NOTIFY_CMD_DISABLE 4
+/** @} */
+
+/** @} End of Voice_Service_Upstream_Message */
+
+/** @} End of Voice_Service_Exported_Constants */
+
+/** @defgroup Voice_Service_Exported_Types Voice Service Exported Types
+ * @brief types that other.c files may use all defined here
+ * @{
+ */
+
+/** Message content */
+typedef union
+{
+ struct
+ {
+ uint8_t len;
+ uint8_t *report;
+ } report_data;
+} T_VOICE_WRITE_PARAMETER;
+
+/** @struct T_VOICE_WRITE_MSG
+ * @brief write message
+ */
+typedef struct
+{
+ uint8_t write_type;
+ T_VOICE_WRITE_PARAMETER write_parameter;
+} T_VOICE_WRITE_MSG;
+
+/** @struct T_VOICE_UPSTREAM_MSG_DATA
+ * @brief upstream message
+ */
+typedef struct
+{
+ uint8_t notification_indification_index;
+ uint8_t read_value_index;
+ T_VOICE_WRITE_MSG write;
+} T_VOICE_UPSTREAM_MSG_DATA;
+
+/** @struct T_VOICE_CALLBACK_DATA
+ * @brief callback data
+ */
+typedef struct
+{
+ uint8_t conn_id;
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_VOICE_UPSTREAM_MSG_DATA msg_data;
+} T_VOICE_CALLBACK_DATA;
+
+
+/** @} End of Voice_Service_Exported_Types */
+
+
+
+/** @defgroup Voice_Service_Exported_Functions Voice Service Exported Functions
+ * @brief functions that other .c files may use all defined here.
+ * @{
+ */
+uint8_t voice_service_add_service(void *pfn);
+/** @} End of Voice_Service_Exported_Functions */
+
+/** @} End of Voice_Service */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _VOICE_SERVICE_H_ */
diff --git a/inc/bluetooth/profile/server/wss.h b/inc/bluetooth/profile/server/wss.h
new file mode 100644
index 0000000..fa2f853
--- /dev/null
+++ b/inc/bluetooth/profile/server/wss.h
@@ -0,0 +1,303 @@
+/**
+*****************************************************************************************
+* Copyright(c) 2017, Realtek Semiconductor Corporation. All rights reserved.
+*****************************************************************************************
+ * @file wss.h
+ * @brief Head file for using weight scale service.
+ * @details Weight scale data types and external functions declaration.
+ * @author Vera
+ * @date
+ * @version v1.0
+ * *************************************************************************************
+ */
+
+/* Define to prevent recursive inclusion */
+#ifndef _WSS_H_
+#define _WSS_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/* Add Includes here */
+#include "stdint.h"
+#include "profile_server.h"
+
+
+
+/** @defgroup WSS Weight Scale Service
+ * @brief Weight Scale Service
+ * @details
+
+ The Weight Scale (WS) Service exposes weight and related data from a weight scale (Server) intended for
+ consumer healthcare as well as sports/fitness applications.
+
+ Weight Scale Feature and Weight Measurement are exposed in the Weight Scale Service.
+ Only one instance of each characteristic is permitted within this service.
+ The Weight Scale Feature characteristic shall be used to describe the supported features of the Server.
+ When read, the Weight Scale Feature characteristic return a value that is used by a Client to determine
+ the supported features of the Server.
+ The Weight Measurement characteristic is used to send weight-related data to the Client.
+ Included in the characteristic value are a Flags field (for showing the presence of optional fields and
+ measurement units), a Weight field, and depending upon the contents of the Flags field, may include one or more optional fields.
+
+ Application shall register weight scale service when initialization through @ref wss_add_service function.
+
+ Application can set the weight scale service parameters through @ref wss_set_parameter function.
+
+ Application can send the weight-related data of WSS to the client through @ref wss_measurement_indicate function.
+
+ * @{
+ */
+
+
+/*============================================================================*
+ * Macros
+ *============================================================================*/
+/** @defgroup WSS_Exported_Macros WSS Exported Macros
+ * @brief
+ * @{
+ */
+
+/**
+* @brief Weight scale service parameter type
+*/
+typedef enum
+{
+ WSS_PARAM_MEASUREMENT_WEIGHTPARAM_FLAG = 0x01,
+ WSS_PARAM_MEASUREMENT_WEIGHT_VALUE,
+ WSS_PARAM_MEASUREMENT_TIME_STAMP,
+ WSS_PARAM_MEASUREMENT_USERID,
+ WSS_PARAM_MEASUREMENT_BMI,
+ WSS_PARAM_MEASUREMENT_HEIGHT_VALUE,
+ WSS_PARAM_FEATURE_READ_CHAR_VAL,
+} T_WSS_PARAM_TYPE;
+
+
+/** @defgroup WSS_Measurement_Flag WSS Measurement Flag
+ * @{
+ */
+#define WSS_FLAG_MEASUREMENT_UINT_BIT BIT0
+#define WSS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT BIT1
+#define WSS_FLAG_MEASUREMENT_USERID_PRESENT_BIT BIT2
+#define WSS_FLAG_MEASUREMENT_BMI_PRESENT_BIT BIT3
+
+/** @} */
+
+
+
+/** @defgroup WSS_Service_Read_Info WSS Service Read Info
+ * @brief Parameter for reading characteristic value.
+ * @{
+ */
+#define WEIGHT_SCALE_READ_FEATURE 1
+/** @} End of WSS_Service_Read_Info*/
+
+
+
+/** @defgroup WSS_Service_Notify_Indicate_Info WSS Service Notify Indicate Info
+ * @brief Parameter for enable or disable notification or indication.
+ * @{
+ */
+#define WSS_INDICATE_WEIGHT_MEASUREMENT_ENABLE 1
+#define WSS_INDICATE_WEIGHT_MEASUREMENT_DISABLE 2
+/** @} */
+
+/** @} End of WSS_Exported_Macros */
+
+
+/*============================================================================*
+ * Types
+ *============================================================================*/
+
+/** @defgroup WSS_Service_Exported_Types WSS Service Exported Types
+ * @brief
+ * @{
+ */
+
+/** @defgroup T_WSS_UPSTREAM_MSG_DATA TWS UPSTREAM MSG DATA
+ * @brief Weight scale service callback message content.
+ * @{
+ */
+typedef union
+{
+ uint8_t notification_indication_index; //!< ref: @ref WSS_Service_Notify_Indicate_Info
+ uint8_t read_value_index; //!< ref: @ref WSS_Service_Read_Info
+} T_WSS_UPSTREAM_MSG_DATA;
+/** @} End of T_WSS_UPSTREAM_MSG_DATA */
+
+/** @defgroup T_WSS_CALLBACK_DATA TWS CALLBACK DATA
+ * @brief Weight scale service data to inform application.
+ * @{
+ */
+typedef struct
+{
+ T_SERVICE_CALLBACK_TYPE msg_type;
+ T_WSS_UPSTREAM_MSG_DATA msg_data;
+} T_WSS_CALLBACK_DATA;
+/** @} End of T_WSS_CALLBACK_DATA */
+
+
+/** @defgroup T_WEIGHT_SCALE_FEATURE_VALUE WEIGHT SCALE FEATURE VALUE
+ * @brief Weight Scale Feature Value.
+ * @{
+ */
+typedef struct
+{
+ uint32_t time_stamp_supported: 1;
+ uint32_t multiple_users_supported: 1;
+ uint32_t bmi_supported: 1;
+ uint32_t weight_measurement_resolution: 4;
+ uint32_t height_measurement_resolution: 3;
+ uint32_t rfu: 22;
+} T_WEIGHT_SCALE_FEATURE_VALUE;
+/** @} End of T_WEIGHT_SCALE_FEATURE_VALUE */
+
+/** @defgroup T_WEIGHT_MEASUREMENT_VALUE_FLAG WEIGHT MEASUREMENT VALUE FLAG
+ * @brief Weight Measurement Value Flag.
+ * @{
+ */
+typedef struct
+{
+ uint8_t measurement_units: 1;
+ uint8_t time_stamp_present: 1;
+ uint8_t user_id_present: 1;
+ uint8_t bmi_and_height_present: 1;
+ uint8_t rfu: 4;
+} T_WEIGHT_MEASUREMENT_VALUE_FLAG;
+/** @} End of T_WEIGHT_MEASUREMENT_VALUE_FLAG */
+
+/** @defgroup T_WSS_TIME_STAMP WSS TIME STAMP
+ * @brief Weight Scale Feature Time Stamp.
+ * @{
+ */
+typedef struct
+{
+ uint16_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hours;
+ uint8_t minutes;
+ uint8_t seconds;
+} T_WSS_TIME_STAMP;
+/** @} End of T_WSS_TIME_STAMP */
+
+/** @defgroup T_WSS_MEASUREMENT WSS MEASUREMENT
+ * @brief Weight Measurement Value.
+ * @{
+ */
+typedef struct
+{
+ T_WEIGHT_MEASUREMENT_VALUE_FLAG flag;
+ uint16_t weight_si_value;
+ uint16_t weight_imperial_value;
+ T_WSS_TIME_STAMP time_stamp;
+ uint8_t user_id;
+ uint16_t bmi;
+ uint16_t height_si_value;
+ uint16_t height_imperial_value;
+} T_WSS_MEASUREMENT;
+/** @} End of T_WSS_MEASUREMENT */
+
+/** @} End of WSS_Service_Exported_Types */
+
+
+/*============================================================================*
+ * Functions
+ *============================================================================*/
+
+/** @defgroup WSS_Service_Exported_Functions WSS Service Exported Functions
+ * @brief
+ * @{
+ */
+
+/**
+ * @brief Add Weight scale service to the BLE stack database.
+ *
+ *
+ * @param[in] p_func Callback when service attribute was read, write or cccd update.
+ * @return Service id generated by the BLE stack: @ref T_SERVER_ID.
+ * @retval 0xFF Operation failure.
+ * @retval Others Service id assigned by stack.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void profile_init()
+ {
+ server_init(1);
+ wss_id = wss_add_service(app_handle_profile_message);
+ }
+ * \endcode
+ */
+T_SERVER_ID wss_add_service(void *p_func);
+
+/**
+ * @brief Set a weight scale service parameter.
+ *
+ * NOTE: You can call this function with a weight scale service parameter type and it will set the
+ * weight scale service parameter. Weight scale service parameters are defined in @ref T_WSS_PARAM_TYPE.
+ * If the "len" field sets to the size of a "uint16_t" ,the
+ * "p_value" field must point to a data with type of "uint16_t".
+ *
+ * @param[in] param_type Weight scale service parameter type: @ref T_WSS_PARAM_TYPE
+ * @param[in] len Length of data to write
+ * @param[in] p_value Pointer to data to write. This is dependent on
+ * the parameter type and WILL be cast to the appropriate
+ * data type (For example: if data type of param is uint16_t, p_value will be cast to
+ * pointer of uint16_t).
+ *
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint32_t weight_feature = 0x0000001f;
+ wss_set_parameter(WSS_PARAM_FEATURE_READ_CHAR_VAL, 4, &weight_feature);
+ }
+ * \endcode
+ */
+bool wss_set_parameter(T_WSS_PARAM_TYPE param_type, uint8_t len, void *p_value);
+
+
+/**
+ * @brief Send measurement indication data.
+ *
+ *
+ * @param[in] conn_id Connection id.
+ * @param[in] service_id Service id.
+ * @return Operation result.
+ * @retval true Operation success.
+ * @retval false Operation failure.
+ *
+ * <b>Example usage</b>
+ * \code{.c}
+ void test(void)
+ {
+ uint8_t wm_flag = WSS_FLAG_MEASUREMENT_UINT_BIT
+ | WSS_FLAG_MEASUREMENT_TIMESTAMP_PRESENT_BIT
+ | WSS_FLAG_MEASUREMENT_USERID_PRESENT_BIT
+ | WSS_FLAG_MEASUREMENT_BMI_PRESENT_BIT;
+
+ wss_set_parameter(WSS_PARAM_MEASUREMENT_WEIGHTPARAM_FLAG, sizeof(wm_flag), &wm_flag);
+ wss_set_parameter(WSS_PARAM_MEASUREMENT_TIME_STAMP, sizeof(wss_measure_time_stamp),
+ &wss_measure_time_stamp);
+ wss_measurement_indicate(p_parse_value->dw_param[0], wss_id);
+ }
+ * \endcode
+ */
+bool wss_measurement_indicate(uint8_t conn_id, T_SERVER_ID service_id);
+/** @} End of WSS_Service_Exported_Functions */
+
+/** @} End of WSS */
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WSS_H_ */