ans.h
Go to the documentation of this file.
1
58 #ifndef __ANS_H__
59 #define __ANS_H__
60
61 #include "gr55xx_sys.h"
62 #include "custom_config.h"
63 #include <stdint.h>
64 #include <stdbool.h>
65
70 #define ANS_CONNECTION_MAX (10 < CFG_MAX_CONNECTIONS ?\
71 10 : CFG_MAX_CONNECTIONS)
72 #define ANS_ERROR_CMD_NOT_SUP 0xa0
73 #define ANS_UTF_8_STR_LEN_MAX 18
74 #define ANS_SUP_NEW_ALERT_CAT_VAL_LEN 2
75 #define ANS_NEWS_ALERT_VAL_LEN (ANS_UTF_8_STR_LEN_MAX + 2)
76 #define ANS_SUP_UNREAD_ALERT_CAT_VAL_LEN 2
77 #define ANS_UNREAD_ALERT_STA_VAL_LEN 2
78 #define ANS_ALERT_NTF_CTRL_PT_VAL_LEN 2
85 #define ANS_SMPL_ALERT_SUP (0x01 << 0)
86 #define ANS_EMAIL_SUP (0x01 << 1)
87 #define ANS_NEWS_SUP (0x01 << 2)
88 #define ANS_CALL_SUP (0x01 << 3)
89 #define ANS_MISSED_CALL_SUP (0x01 << 4)
90 #define ANS_SMS_MMS_SUP (0x01 << 5)
91 #define ANS_VOICE_MAIL_SUP (0x01 << 6)
92 #define ANS_SCHEDULE_SUP (0x01 << 7)
93 #define ANS_HG_PRIO_ALERT_SUP (0x01 << 8)
94 #define ANS_INSTANT_MES (0x01 << 9)
95 #define ANS_ALL_CAT_SUP (0x03ff)
104 typedef enum
105 {
106 ANS_CAT_ID_SMPL_ALERT,
107 ANS_CAT_ID_EMAIL,
108 ANS_CAT_ID_NEWS,
109 ANS_CAT_ID_CALL,
110 ANS_CAT_ID_MISSED_CALL,
111 ANS_CAT_ID_SMS_MMS,
112 ANS_CAT_ID_VOICE_MAIL,
113 ANS_CAT_ID_SCHEDULE,
114 ANS_CAT_ID_HG_PRIO_ALERT,
115 ANS_CAT_ID_INSTANT_MES,
116 ANS_CAT_ID_NB,
117 ANS_CAT_ID_ALL = 0xff,
118 } ans_alert_cat_id_t;
119
121 typedef enum
122 {
123 ANS_CTRL_PT_EN_NEW_INC_ALERT_NTF,
124 ANS_CTRL_PT_EN_UNREAD_CAT_STA_NTF,
125 ANS_CTRL_PT_DIS_NEW_INC_ALERT_NTF,
126 ANS_CTRL_PT_DIS_UNREAD_CAT_STA_NTF,
127 ANS_CTRL_PT_NTF_NEW_INC_ALERT_IMME,
128 ANS_CTRL_PT_NTF_UNREAD_CAT_STA_IMME,
129 } ans_ctrl_pt_id_t;
130
132 typedef enum
133 {
134 ANS_EVT_INVALID,
135 ANS_EVT_NEW_ALERT_NTF_ENABLE,
136 ANS_EVT_NEW_ALERT_NTF_DISABLE,
137 ANS_EVT_UNREAD_ALERT_STA_NTF_ENABLE,
138 ANS_EVT_UNREAD_ALERT_STA_NTF_DISABLE,
139 ANS_EVT_NEW_ALERT_IMME_NTF_REQ,
140 ANS_EVT_Unread_ALERT_IMME_NTF_REQ,
141 } ans_evt_type_t;
149 typedef struct
150 {
151 ans_alert_cat_id_t cat_id;
152 uint8_t alert_num;
153 uint8_t str_info[ANS_UTF_8_STR_LEN_MAX];
154 uint8_t length;
155 } ans_new_alert_t;
156
158 typedef struct
159 {
160 ans_alert_cat_id_t cat_id;
161 uint8_t unread_num;
162 } ans_unread_alert_t;
163
165 typedef struct
166 {
167 ans_ctrl_pt_id_t cmd_id;
168 ans_alert_cat_id_t cat_id;
169 } ans_ctrl_pt_t;
170
172 typedef struct
173 {
174 uint8_t conn_idx;
175 ans_evt_type_t evt_type;
176 uint16_t cat_ids;
177 } ans_evt_t;
185 typedef void (*ans_evt_handler_t)(ans_evt_t *p_evt);
193 typedef struct
194 {
195 ans_evt_handler_t evt_handler;
196 uint16_t sup_new_alert_cat;
197 uint16_t sup_unread_alert_sta;
198 } ans_init_t;
214 sdk_err_t ans_service_init(ans_init_t *p_ans_init);
215
226 sdk_err_t ans_new_alert_send(uint8_t conn_idx, ans_new_alert_t *p_new_alert);
227
238 sdk_err_t ans_unread_alert_send(uint8_t conn_idx, ans_unread_alert_t *p_unread_alert);
241 #endif
242
ans_new_alert_t::cat_id
ans_alert_cat_id_t cat_id
Definition: ans.h:151
ANS_EVT_INVALID
@ ANS_EVT_INVALID
Definition: ans.h:134
ans_unread_alert_t::cat_id
ans_alert_cat_id_t cat_id
Definition: ans.h:160
ANS_CAT_ID_SCHEDULE
@ ANS_CAT_ID_SCHEDULE
Definition: ans.h:113
ANS_CTRL_PT_EN_UNREAD_CAT_STA_NTF
@ ANS_CTRL_PT_EN_UNREAD_CAT_STA_NTF
Definition: ans.h:124
ANS_CAT_ID_EMAIL
@ ANS_CAT_ID_EMAIL
Definition: ans.h:107
ANS_CTRL_PT_NTF_UNREAD_CAT_STA_IMME
@ ANS_CTRL_PT_NTF_UNREAD_CAT_STA_IMME
Definition: ans.h:128
ans_new_alert_t::alert_num
uint8_t alert_num
Definition: ans.h:152
ANS_CAT_ID_CALL
@ ANS_CAT_ID_CALL
Definition: ans.h:109
ans_ctrl_pt_id_t
ans_ctrl_pt_id_t
Alert Notification Service Control point.
Definition: ans.h:122
ans_evt_t
Alert Notification Service event.
Definition: ans.h:173
ans_unread_alert_t::unread_num
uint8_t unread_num
Definition: ans.h:161
ans_evt_t::cat_ids
uint16_t cat_ids
Definition: ans.h:176
ANS_CAT_ID_NB
@ ANS_CAT_ID_NB
Definition: ans.h:116
ans_service_init
sdk_err_t ans_service_init(ans_init_t *p_ans_init)
Initialize an Alert Notification Service instance and add to the DB.
ANS_CAT_ID_HG_PRIO_ALERT
@ ANS_CAT_ID_HG_PRIO_ALERT
Definition: ans.h:114
ANS_CAT_ID_SMS_MMS
@ ANS_CAT_ID_SMS_MMS
Definition: ans.h:111
ANS_EVT_UNREAD_ALERT_STA_NTF_ENABLE
@ ANS_EVT_UNREAD_ALERT_STA_NTF_ENABLE
Definition: ans.h:137
ANS_CAT_ID_INSTANT_MES
@ ANS_CAT_ID_INSTANT_MES
Definition: ans.h:115
ans_unread_alert_t
Alert Notification Service Unread Alert Status value.
Definition: ans.h:159
ANS_CAT_ID_MISSED_CALL
@ ANS_CAT_ID_MISSED_CALL
Definition: ans.h:110
ANS_CTRL_PT_DIS_UNREAD_CAT_STA_NTF
@ ANS_CTRL_PT_DIS_UNREAD_CAT_STA_NTF
Definition: ans.h:126
gr55xx_sys.h
GR55XX System API.
ans_new_alert_send
sdk_err_t ans_new_alert_send(uint8_t conn_idx, ans_new_alert_t *p_new_alert)
Send New Alert if its notification has been enabled.
ANS_EVT_NEW_ALERT_IMME_NTF_REQ
@ ANS_EVT_NEW_ALERT_IMME_NTF_REQ
Definition: ans.h:139
ANS_EVT_Unread_ALERT_IMME_NTF_REQ
@ ANS_EVT_Unread_ALERT_IMME_NTF_REQ
Definition: ans.h:140
ans_evt_type_t
ans_evt_type_t
Alert Notification Service Event type.
Definition: ans.h:133
ans_new_alert_t::length
uint8_t length
Definition: ans.h:154
ANS_CAT_ID_VOICE_MAIL
@ ANS_CAT_ID_VOICE_MAIL
Definition: ans.h:112
ans_ctrl_pt_t::cat_id
ans_alert_cat_id_t cat_id
Definition: ans.h:168
ans_unread_alert_send
sdk_err_t ans_unread_alert_send(uint8_t conn_idx, ans_unread_alert_t *p_unread_alert)
Send Unread Alert Status if its notification has been enabled.
ANS_CAT_ID_ALL
@ ANS_CAT_ID_ALL
Definition: ans.h:117
ans_evt_t::evt_type
ans_evt_type_t evt_type
Definition: ans.h:175
ANS_CTRL_PT_NTF_NEW_INC_ALERT_IMME
@ ANS_CTRL_PT_NTF_NEW_INC_ALERT_IMME
Definition: ans.h:127
sdk_err_t
uint16_t sdk_err_t
SDK API result type.
Definition: ble_error.h:243
ANS_UTF_8_STR_LEN_MAX
#define ANS_UTF_8_STR_LEN_MAX
Definition: ans.h:73
ans_ctrl_pt_t
Alert Notification Service Control Point value.
Definition: ans.h:166
ans_init_t
Alert Notification Service init stucture. This contains all options and data needed for initializatio...
Definition: ans.h:194
ANS_CAT_ID_NEWS
@ ANS_CAT_ID_NEWS
Definition: ans.h:108
ans_init_t::evt_handler
ans_evt_handler_t evt_handler
Definition: ans.h:195
ans_new_alert_t
Alert Notification Service New Alert value.
Definition: ans.h:150
ans_alert_cat_id_t
ans_alert_cat_id_t
Alert Notification Service Categories of alerts/messages.
Definition: ans.h:105
ANS_CTRL_PT_EN_NEW_INC_ALERT_NTF
@ ANS_CTRL_PT_EN_NEW_INC_ALERT_NTF
Definition: ans.h:123
ANS_CAT_ID_SMPL_ALERT
@ ANS_CAT_ID_SMPL_ALERT
Definition: ans.h:106
ANS_EVT_NEW_ALERT_NTF_DISABLE
@ ANS_EVT_NEW_ALERT_NTF_DISABLE
Definition: ans.h:136
ANS_EVT_UNREAD_ALERT_STA_NTF_DISABLE
@ ANS_EVT_UNREAD_ALERT_STA_NTF_DISABLE
Definition: ans.h:138
ANS_CTRL_PT_DIS_NEW_INC_ALERT_NTF
@ ANS_CTRL_PT_DIS_NEW_INC_ALERT_NTF
Definition: ans.h:125
ans_init_t::sup_new_alert_cat
uint16_t sup_new_alert_cat
Definition: ans.h:196
ans_evt_t::conn_idx
uint8_t conn_idx
Definition: ans.h:174
ans_ctrl_pt_t::cmd_id
ans_ctrl_pt_id_t cmd_id
Definition: ans.h:167
ans_evt_handler_t
void(* ans_evt_handler_t)(ans_evt_t *p_evt)
Alert Notification Service event handler type.
Definition: ans.h:185
ANS_EVT_NEW_ALERT_NTF_ENABLE
@ ANS_EVT_NEW_ALERT_NTF_ENABLE
Definition: ans.h:135
ans_init_t::sup_unread_alert_sta
uint16_t sup_unread_alert_sta
Definition: ans.h:197