ans_c.h
Go to the documentation of this file.
1
57 #ifndef __ANS_C_H__
58 #define __ANS_C_H__
59
60 #include "gr55xx_sys.h"
61 #include "ble_prf_types.h"
62 #include "custom_config.h"
63 #include <stdint.h>
64 #include <stdbool.h>
65
70 #define ANS_C_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
71 10 : CFG_MAX_CONNECTIONS)
72 #define ANS_C_ERROR_CMD_NOT_SUP 0xa0
73 #define ANS_C_UTF_8_STR_LEN_MAX 18
74 #define ANS_C_ALERT_NTF_CTRL_PT_VAL_LEN 2
81 #define ANS_SMPL_ALERT_SUP (0x01 << 0)
82 #define ANS_EMAIL_SUP (0x01 << 1)
83 #define ANS_NEWS_SUP (0x01 << 2)
84 #define ANS_CALL_SUP (0x01 << 3)
85 #define ANS_MISSED_CALL_SUP (0x01 << 4)
86 #define ANS_SMS_MMS_SUP (0x01 << 5)
87 #define ANS_VOICE_MAIL_SUP (0x01 << 6)
88 #define ANS_SCHEDULE_SUP (0x01 << 7)
89 #define ANS_HG_PRIO_ALERT_SUP (0x01 << 8)
90 #define ANS_INSTANT_MES (0x01 << 9)
91 #define ANS_ALL_CAT_SUP (0x03ff)
100 typedef enum
101 {
102 ANS_C_CAT_ID_SMPL_ALERT,
103 ANS_C_CAT_ID_EMAIL,
104 ANS_C_CAT_ID_NEWS,
105 ANS_C_CAT_ID_CALL,
106 ANS_C_CAT_ID_MISSED_CALL,
107 ANS_C_CAT_ID_SMS_MMS,
108 ANS_C_CAT_ID_VOICE_MAIL,
109 ANS_C_CAT_ID_SCHEDULE,
110 ANS_C_CAT_ID_HG_PRIO_ALERT,
111 ANS_C_CAT_ID_INSTANT_MES,
112 AANS_C_CAT_ID_NB,
113 ANS_C_CAT_ID_ALL = 0xff,
114 } ans_c_alert_cat_id_t;
115
117 typedef enum
118 {
119 ANS_C_CTRL_PT_EN_NEW_INC_ALERT_NTF,
120 ANS_C_CTRL_PT_EN_UNREAD_CAT_STA_NTF,
121 ANS_C_CTRL_PT_DIS_NEW_INC_ALERT_NTF,
122 ANS_C_CTRL_PT_DIS_UNREAD_CAT_STA_NTF,
123 ANS_C_CTRL_PT_NTF_NEW_INC_ALERT_IMME,
124 ANS_C_CTRL_PT_NTF_UNREAD_CAT_STA_IMME,
125 } ans_c_ctrl_pt_id_t;
126
128 typedef enum
129 {
130 ANS_C_EVT_INVALID,
131 ANS_C_EVT_DISCOVERY_COMPLETE,
132 ANS_C_EVT_DISCOVERY_FAIL ,
133 ANS_C_EVT_NEW_ALERT_NTF_SET_SUCCESS,
134 ANS_C_EVT_UNREAD_ALERT_STA_NTF_SET_SUCCESS,
135 ANS_C_EVT_SUP_NEW_ALERT_CAT_RECEIV,
136 ANS_C_EVT_SUP_UNREAD_ALERT_CAT_REC,
137 ANS_C_EVT_NEW_ALERT_RECEIVE,
138 ANS_C_EVT_UNREAD_ALERT_RECEIVE,
139 ANS_C_EVT_CTRL_POINT_SET_SUCCESS,
140 ANS_C_EVT_WRITE_OP_ERR,
141 } ans_c_evt_type_t;
149 typedef struct
150 {
151 ans_c_alert_cat_id_t cat_id;
152 uint8_t alert_num;
153 uint8_t str_info[ANS_C_UTF_8_STR_LEN_MAX];
154 uint8_t length;
155 } ans_c_new_alert_t;
156
158 typedef struct
159 {
160 ans_c_alert_cat_id_t cat_id;
161 uint8_t unread_num;
162 } ans_c_unread_alert_t;
163
165 typedef struct
166 {
167 ans_c_ctrl_pt_id_t cmd_id;
168 ans_c_alert_cat_id_t cat_id;
169 } ans_c_ctrl_pt_t;
170
172 typedef struct
173 {
174 uint16_t ans_srvc_start_handle;
175 uint16_t ans_srvc_end_handle;
176 uint16_t ans_sup_new_alert_cat_handle;
177 uint16_t ans_new_alert_handle;
178 uint16_t ans_new_alert_cccd_handle;
179 uint16_t ans_sup_unread_alert_cat_handle;
180 uint16_t ans_unread_alert_handle;
181 uint16_t ans_unread_alert_cccd_handle;
182 uint16_t ans_ctrl_pt_handle;
183 } ans_c_handles_t;
184
186 typedef struct
187 {
188 uint8_t conn_idx;
189 ans_c_evt_type_t evt_type;
190 union
191 {
192 uint16_t sup_new_alert_cat_ids;
193 uint16_t sup_unread_alert_cat_ids;
194 ans_c_new_alert_t new_alert;
195 ans_c_unread_alert_t unread_alert;
196 } value;
197 } ans_c_evt_t;
205 typedef void (*ans_c_evt_handler_t)(ans_c_evt_t *p_evt);
221 sdk_err_t ans_client_init(ans_c_evt_handler_t evt_handler);
222
232 sdk_err_t ans_c_disc_srvc_start(uint8_t conn_idx);
233
244 sdk_err_t ans_c_new_alert_notify_set(uint8_t conn_idx, bool is_enable);
245
256 sdk_err_t ans_c_unread_alert_notify_set(uint8_t conn_idx, bool is_enable);
257
267 sdk_err_t ans_c_sup_new_alert_cat_read(uint8_t conn_idx);
268
278 sdk_err_t ans_c_sup_unread_alert_cat_read(uint8_t conn_idx);
279
290 sdk_err_t ans_c_ctrl_point_set(uint8_t conn_idx, ans_c_ctrl_pt_t *p_ctrl_pt);
293 #endif
294
ANS_C_EVT_UNREAD_ALERT_RECEIVE
@ ANS_C_EVT_UNREAD_ALERT_RECEIVE
Definition: ans_c.h:138
ANS_C_CTRL_PT_DIS_NEW_INC_ALERT_NTF
@ ANS_C_CTRL_PT_DIS_NEW_INC_ALERT_NTF
Definition: ans_c.h:121
ans_c_handles_t::ans_new_alert_cccd_handle
uint16_t ans_new_alert_cccd_handle
Definition: ans_c.h:178
ans_c_evt_t
Alert Notification Service Client event.
Definition: ans_c.h:187
ans_c_handles_t::ans_ctrl_pt_handle
uint16_t ans_ctrl_pt_handle
Definition: ans_c.h:182
ANS_C_EVT_DISCOVERY_COMPLETE
@ ANS_C_EVT_DISCOVERY_COMPLETE
Definition: ans_c.h:131
ANS_C_EVT_INVALID
@ ANS_C_EVT_INVALID
Definition: ans_c.h:130
ans_c_new_alert_t::length
uint8_t length
Definition: ans_c.h:154
ANS_C_EVT_SUP_UNREAD_ALERT_CAT_REC
@ ANS_C_EVT_SUP_UNREAD_ALERT_CAT_REC
Definition: ans_c.h:136
ans_c_ctrl_pt_id_t
ans_c_ctrl_pt_id_t
Alert Notification Service Client Control point ID.
Definition: ans_c.h:118
ans_c_ctrl_pt_t::cat_id
ans_c_alert_cat_id_t cat_id
Definition: ans_c.h:168
ANS_C_CAT_ID_SMS_MMS
@ ANS_C_CAT_ID_SMS_MMS
Definition: ans_c.h:107
ANS_C_CAT_ID_INSTANT_MES
@ ANS_C_CAT_ID_INSTANT_MES
Definition: ans_c.h:111
ANS_C_EVT_DISCOVERY_FAIL
@ ANS_C_EVT_DISCOVERY_FAIL
Definition: ans_c.h:132
ANS_C_CAT_ID_ALL
@ ANS_C_CAT_ID_ALL
Definition: ans_c.h:113
ans_c_evt_t::unread_alert
ans_c_unread_alert_t unread_alert
Definition: ans_c.h:195
ANS_C_EVT_WRITE_OP_ERR
@ ANS_C_EVT_WRITE_OP_ERR
Definition: ans_c.h:140
ans_c_new_alert_t::alert_num
uint8_t alert_num
Definition: ans_c.h:152
ans_c_new_alert_notify_set
sdk_err_t ans_c_new_alert_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer New Alert characteristic notify.
ANS_C_CTRL_PT_NTF_NEW_INC_ALERT_IMME
@ ANS_C_CTRL_PT_NTF_NEW_INC_ALERT_IMME
Definition: ans_c.h:123
ans_c_alert_cat_id_t
ans_c_alert_cat_id_t
Alert Notification Service Categories of alerts/messages.
Definition: ans_c.h:101
ANS_C_CAT_ID_EMAIL
@ ANS_C_CAT_ID_EMAIL
Definition: ans_c.h:103
gr55xx_sys.h
GR55XX System API.
ans_c_evt_t::evt_type
ans_c_evt_type_t evt_type
Definition: ans_c.h:189
ans_c_handles_t::ans_sup_new_alert_cat_handle
uint16_t ans_sup_new_alert_cat_handle
Definition: ans_c.h:176
ans_c_evt_t::sup_new_alert_cat_ids
uint16_t sup_new_alert_cat_ids
Definition: ans_c.h:192
ANS_C_EVT_UNREAD_ALERT_STA_NTF_SET_SUCCESS
@ ANS_C_EVT_UNREAD_ALERT_STA_NTF_SET_SUCCESS
Definition: ans_c.h:134
ans_c_handles_t::ans_unread_alert_handle
uint16_t ans_unread_alert_handle
Definition: ans_c.h:180
ANS_C_CTRL_PT_EN_UNREAD_CAT_STA_NTF
@ ANS_C_CTRL_PT_EN_UNREAD_CAT_STA_NTF
Definition: ans_c.h:120
ans_c_unread_alert_notify_set
sdk_err_t ans_c_unread_alert_notify_set(uint8_t conn_idx, bool is_enable)
Enable or disable peer Unread Alert characteristic notify.
ans_c_handles_t::ans_sup_unread_alert_cat_handle
uint16_t ans_sup_unread_alert_cat_handle
Definition: ans_c.h:179
ans_c_handles_t::ans_srvc_end_handle
uint16_t ans_srvc_end_handle
Definition: ans_c.h:175
ans_c_ctrl_pt_t
Alert Notification Service Client Control Point value.
Definition: ans_c.h:166
ANS_C_EVT_CTRL_POINT_SET_SUCCESS
@ ANS_C_EVT_CTRL_POINT_SET_SUCCESS
Definition: ans_c.h:139
ANS_C_EVT_NEW_ALERT_NTF_SET_SUCCESS
@ ANS_C_EVT_NEW_ALERT_NTF_SET_SUCCESS
Definition: ans_c.h:133
AANS_C_CAT_ID_NB
@ AANS_C_CAT_ID_NB
Definition: ans_c.h:112
ans_c_unread_alert_t
Alert Notification Service Client decoded Unread Alert Status value.
Definition: ans_c.h:159
ANS_C_CTRL_PT_EN_NEW_INC_ALERT_NTF
@ ANS_C_CTRL_PT_EN_NEW_INC_ALERT_NTF
Definition: ans_c.h:119
ANS_C_CAT_ID_SCHEDULE
@ ANS_C_CAT_ID_SCHEDULE
Definition: ans_c.h:109
ans_c_evt_t::conn_idx
uint8_t conn_idx
Definition: ans_c.h:188
ANS_C_CAT_ID_MISSED_CALL
@ ANS_C_CAT_ID_MISSED_CALL
Definition: ans_c.h:106
ans_c_handles_t::ans_new_alert_handle
uint16_t ans_new_alert_handle
Definition: ans_c.h:177
ANS_C_CAT_ID_CALL
@ ANS_C_CAT_ID_CALL
Definition: ans_c.h:105
ANS_C_CAT_ID_SMPL_ALERT
@ ANS_C_CAT_ID_SMPL_ALERT
Definition: ans_c.h:102
ans_c_sup_new_alert_cat_read
sdk_err_t ans_c_sup_new_alert_cat_read(uint8_t conn_idx)
Read Supported New Alert Category characteristic value.
ans_c_handles_t::ans_srvc_start_handle
uint16_t ans_srvc_start_handle
Definition: ans_c.h:174
ans_client_init
sdk_err_t ans_client_init(ans_c_evt_handler_t evt_handler)
Register ANS Client event handler.
ans_c_new_alert_t::cat_id
ans_c_alert_cat_id_t cat_id
Definition: ans_c.h:151
ble_prf_types.h
Profile/Service Common Types.
ans_c_evt_t::sup_unread_alert_cat_ids
uint16_t sup_unread_alert_cat_ids
Definition: ans_c.h:193
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
ANS_C_CAT_ID_HG_PRIO_ALERT
@ ANS_C_CAT_ID_HG_PRIO_ALERT
Definition: ans_c.h:110
ans_c_evt_handler_t
void(* ans_c_evt_handler_t)(ans_c_evt_t *p_evt)
Alert Notification Service Client event handler type.
Definition: ans_c.h:205
ans_c_handles_t::ans_unread_alert_cccd_handle
uint16_t ans_unread_alert_cccd_handle
Definition: ans_c.h:181
ans_c_sup_unread_alert_cat_read
sdk_err_t ans_c_sup_unread_alert_cat_read(uint8_t conn_idx)
Read Supported Unread Alert Category characteristic value.
ans_c_handles_t
Handles on the connected peer device needed to interact with it.
Definition: ans_c.h:173
ANS_C_EVT_SUP_NEW_ALERT_CAT_RECEIV
@ ANS_C_EVT_SUP_NEW_ALERT_CAT_RECEIV
Definition: ans_c.h:135
ans_c_unread_alert_t::cat_id
ans_c_alert_cat_id_t cat_id
Definition: ans_c.h:160
ANS_C_CTRL_PT_DIS_UNREAD_CAT_STA_NTF
@ ANS_C_CTRL_PT_DIS_UNREAD_CAT_STA_NTF
Definition: ans_c.h:122
ans_c_evt_type_t
ans_c_evt_type_t
Alert Notification Service Client Event type.
Definition: ans_c.h:129
ans_c_disc_srvc_start
sdk_err_t ans_c_disc_srvc_start(uint8_t conn_idx)
Discover Alert Notification Service on peer.
ANS_C_CAT_ID_VOICE_MAIL
@ ANS_C_CAT_ID_VOICE_MAIL
Definition: ans_c.h:108
ANS_C_CTRL_PT_NTF_UNREAD_CAT_STA_IMME
@ ANS_C_CTRL_PT_NTF_UNREAD_CAT_STA_IMME
Definition: ans_c.h:124
ans_c_ctrl_point_set
sdk_err_t ans_c_ctrl_point_set(uint8_t conn_idx, ans_c_ctrl_pt_t *p_ctrl_pt)
Set Control Point characteristic value.
ANS_C_EVT_NEW_ALERT_RECEIVE
@ ANS_C_EVT_NEW_ALERT_RECEIVE
Definition: ans_c.h:137
ans_c_new_alert_t
Alert Notification Service Client decoded New Alert value.
Definition: ans_c.h:150
ans_c_unread_alert_t::unread_num
uint8_t unread_num
Definition: ans_c.h:161
ANS_C_CAT_ID_NEWS
@ ANS_C_CAT_ID_NEWS
Definition: ans_c.h:104
ans_c_evt_t::new_alert
ans_c_new_alert_t new_alert
Definition: ans_c.h:194
ans_c_ctrl_pt_t::cmd_id
ans_c_ctrl_pt_id_t cmd_id
Definition: ans_c.h:167
ANS_C_UTF_8_STR_LEN_MAX
#define ANS_C_UTF_8_STR_LEN_MAX
Definition: ans_c.h:73