nRF Connect SDK API 0.1.0
Loading...
Searching...
No Matches
ancs_client.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2021 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
6
7#ifndef BT_ANCS_CLIENT_H_
8#define BT_ANCS_CLIENT_H_
9
18#include <zephyr/bluetooth/gatt.h>
19#include <zephyr/bluetooth/conn.h>
20#include <bluetooth/gatt_dm.h>
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
27#define BT_UUID_ANCS_VAL \
28 BT_UUID_128_ENCODE(0x7905f431, 0xb5ce, 0x4e99, 0xa40f, 0x4b1e122d00d0)
29
31#define BT_UUID_ANCS_NOTIFICATION_SOURCE_VAL \
32 BT_UUID_128_ENCODE(0x9fbf120d, 0x6301, 0x42d9, 0x8c58, 0x25e699a21dbd)
33
35#define BT_UUID_ANCS_CONTROL_POINT_VAL \
36 BT_UUID_128_ENCODE(0x69d1d8f3, 0x45e1, 0x49a8, 0x9821, 0x9bbdfdaad9d9)
37
39#define BT_UUID_ANCS_DATA_SOURCE_VAL \
40 BT_UUID_128_ENCODE(0x22eac6e9, 0x24d6, 0x4bb5, 0xbe44, 0xb36ace7c7bfb)
41
42#define BT_UUID_ANCS BT_UUID_DECLARE_128(BT_UUID_ANCS_VAL)
43#define BT_UUID_ANCS_NOTIFICATION_SOURCE \
44 BT_UUID_DECLARE_128(BT_UUID_ANCS_NOTIFICATION_SOURCE_VAL)
45#define BT_UUID_ANCS_CONTROL_POINT \
46 BT_UUID_DECLARE_128(BT_UUID_ANCS_CONTROL_POINT_VAL)
47#define BT_UUID_ANCS_DATA_SOURCE BT_UUID_DECLARE_128(BT_UUID_ANCS_DATA_SOURCE_VAL)
48
50#define BT_ANCS_ATTR_DATA_MAX 32
55#define BT_ANCS_CATEGORY_ID_COUNT 12
59#define BT_ANCS_NOTIF_ATTR_COUNT 8
61#define BT_ANCS_APP_ATTR_COUNT 1
63#define BT_ANCS_EVT_ID_COUNT 3
64
66#define BT_ANCS_NOTIF_DATA_LENGTH 8
67
71#define BT_ANCS_EVENT_FLAG_SILENT 0
75#define BT_ANCS_EVENT_FLAG_IMPORTANT 1
79#define BT_ANCS_EVENT_FLAG_PREEXISTING 2
83#define BT_ANCS_EVENT_FLAG_POSITIVE_ACTION 3
87#define BT_ANCS_EVENT_FLAG_NEGATIVE_ACTION 4
88
93#define BT_ATT_ERR_ANCS_NP_UNKNOWN_COMMAND 0xA0
95#define BT_ATT_ERR_ANCS_NP_INVALID_COMMAND 0xA1
97#define BT_ATT_ERR_ANCS_NP_INVALID_PARAMETER 0xA2
99#define BT_ATT_ERR_ANCS_NP_ACTION_FAILED 0xA3
129
139
157
165
174
194
198 uint8_t silent : 1;
200 uint8_t important : 1;
202 uint8_t pre_existing : 1;
204 uint8_t positive_action : 1;
206 uint8_t negative_action : 1;
207};
208
230
234 uint32_t notif_uid;
247};
248
254 uint16_t attr_len;
256 uint32_t attr_id;
258 uint8_t *attr_data;
259};
260
266 bool get;
271 uint32_t attr_id;
275 uint16_t attr_len;
277 uint8_t *attr_data;
278};
279
280struct bt_ancs_client;
281
291 uint32_t notif_uid;
294};
295
303typedef void (*bt_ancs_ns_notif_cb)(struct bt_ancs_client *ancs_c, int err,
304 const struct bt_ancs_evt_notif *notif);
305
311typedef void (*bt_ancs_ds_notif_cb)(struct bt_ancs_client *ancs_c,
312 const struct bt_ancs_attr_response *response);
313
319typedef void (*bt_ancs_write_cb)(struct bt_ancs_client *ancs_c,
320 uint8_t err);
321
331 uint32_t attr_count;
344 uint8_t *data_dest;
349};
350
354 struct bt_conn *conn;
355
357 atomic_t state;
358
360 uint16_t handle_cp;
361
363 uint16_t handle_ns;
364
367
369 uint16_t handle_ds;
370
373
375 struct bt_gatt_write_params cp_write_params;
376
379
381 uint8_t cp_data[CONFIG_BT_ANCS_CLIENT_CP_BUFF_SIZE];
382
384 struct bt_gatt_subscribe_params ns_notif_params;
385
388
390 struct bt_gatt_subscribe_params ds_notif_params;
391
394
399 struct bt_ancs_attr_list
401
406 struct bt_ancs_attr_list
408
413
418
422};
423
435
447
458
467
476
489 const enum bt_ancs_notif_attr_id_val id,
490 uint8_t *data, const uint16_t len);
491
504 const enum bt_ancs_app_attr_id_val id,
505 uint8_t *data, const uint16_t len);
506
518 const struct bt_ancs_evt_notif *notif,
519 bt_ancs_write_cb func);
520
532 const uint8_t *app_id, uint32_t len,
533 bt_ancs_write_cb func);
534
545int bt_ancs_notification_action(struct bt_ancs_client *ancs_c, uint32_t uuid,
546 enum bt_ancs_action_id_values action_id,
547 bt_ancs_write_cb func);
548
562int bt_ancs_handles_assign(struct bt_gatt_dm *dm,
563 struct bt_ancs_client *ancs_c);
564
565#ifdef __cplusplus
566}
567#endif
568
573#endif /* BT_ANCS_CLIENT_H_ */
void(* bt_ancs_write_cb)(struct bt_ancs_client *ancs_c, uint8_t err)
Write response callback function.
Definition: ancs_client.h:319
void(* bt_ancs_ns_notif_cb)(struct bt_ancs_client *ancs_c, int err, const struct bt_ancs_evt_notif *notif)
Notification Source notification callback function.
Definition: ancs_client.h:303
int bt_ancs_unsubscribe_data_source(struct bt_ancs_client *ancs_c)
Function for writing to the CCCD to disable data source notifications from the ANCS.
#define BT_ANCS_NOTIF_ATTR_COUNT
Definition: ancs_client.h:59
int bt_ancs_subscribe_data_source(struct bt_ancs_client *ancs_c, bt_ancs_ds_notif_cb func)
Function for writing to the CCCD to enable data source notifications from the ANCS.
int bt_ancs_register_attr(struct bt_ancs_client *ancs_c, const enum bt_ancs_notif_attr_id_val id, uint8_t *data, const uint16_t len)
Function for registering attributes that will be requested when bt_ancs_request_attrs is called.
bt_ancs_app_attr_id_val
App attribute ID values.
Definition: ancs_client.h:170
@ BT_ANCS_APP_ATTR_ID_DISPLAY_NAME
Definition: ancs_client.h:172
#define BT_ANCS_ATTR_DATA_MAX
Definition: ancs_client.h:50
int bt_ancs_register_app_attr(struct bt_ancs_client *ancs_c, const enum bt_ancs_app_attr_id_val id, uint8_t *data, const uint16_t len)
Function for registering attributes that will be requested when bt_ancs_request_app_attr is called.
int bt_ancs_request_attrs(struct bt_ancs_client *ancs_c, const struct bt_ancs_evt_notif *notif, bt_ancs_write_cb func)
Function for requesting attributes for a notification.
bt_ancs_category_id_val
Category IDs for iOS notifications.
Definition: ancs_client.h:103
@ BT_ANCS_CATEGORY_ID_ENTERTAINMENT
Definition: ancs_client.h:127
@ BT_ANCS_CATEGORY_ID_BUSINESS_AND_FINANCE
Definition: ancs_client.h:123
@ BT_ANCS_CATEGORY_ID_LOCATION
Definition: ancs_client.h:125
@ BT_ANCS_CATEGORY_ID_OTHER
Definition: ancs_client.h:105
@ BT_ANCS_CATEGORY_ID_INCOMING_CALL
Definition: ancs_client.h:107
@ BT_ANCS_CATEGORY_ID_MISSED_CALL
Definition: ancs_client.h:109
@ BT_ANCS_CATEGORY_ID_SCHEDULE
Definition: ancs_client.h:115
@ BT_ANCS_CATEGORY_ID_SOCIAL
Definition: ancs_client.h:113
@ BT_ANCS_CATEGORY_ID_NEWS
Definition: ancs_client.h:119
@ BT_ANCS_CATEGORY_ID_VOICE_MAIL
Definition: ancs_client.h:111
@ BT_ANCS_CATEGORY_ID_HEALTH_AND_FITNESS
Definition: ancs_client.h:121
@ BT_ANCS_CATEGORY_ID_EMAIL
Definition: ancs_client.h:117
bt_ancs_action_id_values
IDs for actions that can be performed for iOS notifications.
Definition: ancs_client.h:159
@ BT_ANCS_ACTION_ID_POSITIVE
Definition: ancs_client.h:161
@ BT_ANCS_ACTION_ID_NEGATIVE
Definition: ancs_client.h:163
int bt_ancs_notification_action(struct bt_ancs_client *ancs_c, uint32_t uuid, enum bt_ancs_action_id_values action_id, bt_ancs_write_cb func)
Function for performing a notification action.
bt_ancs_notif_attr_id_val
IDs for iOS notification attributes.
Definition: ancs_client.h:176
@ BT_ANCS_NOTIF_ATTR_ID_MESSAGE
Definition: ancs_client.h:184
@ BT_ANCS_NOTIF_ATTR_ID_MESSAGE_SIZE
Definition: ancs_client.h:186
@ BT_ANCS_NOTIF_ATTR_ID_SUBTITLE
Definition: ancs_client.h:182
@ BT_ANCS_NOTIF_ATTR_ID_POSITIVE_ACTION_LABEL
Definition: ancs_client.h:190
@ BT_ANCS_NOTIF_ATTR_ID_NEGATIVE_ACTION_LABEL
Definition: ancs_client.h:192
@ BT_ANCS_NOTIF_ATTR_ID_TITLE
Definition: ancs_client.h:180
@ BT_ANCS_NOTIF_ATTR_ID_DATE
Definition: ancs_client.h:188
@ BT_ANCS_NOTIF_ATTR_ID_APP_IDENTIFIER
Definition: ancs_client.h:178
bt_ancs_evt_id_values
Event IDs for iOS notifications.
Definition: ancs_client.h:131
@ BT_ANCS_EVENT_ID_NOTIFICATION_MODIFIED
Definition: ancs_client.h:135
@ BT_ANCS_EVENT_ID_NOTIFICATION_ADDED
Definition: ancs_client.h:133
@ BT_ANCS_EVENT_ID_NOTIFICATION_REMOVED
Definition: ancs_client.h:137
bt_ancs_parse_state
Parsing states for received iOS notification and app attributes.
Definition: ancs_client.h:210
@ BT_ANCS_PARSE_STATE_DONE
Definition: ancs_client.h:228
@ BT_ANCS_PARSE_STATE_ATTR_SKIP
Definition: ancs_client.h:226
@ BT_ANCS_PARSE_STATE_ATTR_LEN1
Definition: ancs_client.h:220
@ BT_ANCS_PARSE_STATE_NOTIF_UID
Definition: ancs_client.h:214
@ BT_ANCS_PARSE_STATE_ATTR_ID
Definition: ancs_client.h:218
@ BT_ANCS_PARSE_STATE_ATTR_LEN2
Definition: ancs_client.h:222
@ BT_ANCS_PARSE_STATE_APP_ID
Definition: ancs_client.h:216
@ BT_ANCS_PARSE_STATE_ATTR_DATA
Definition: ancs_client.h:224
@ BT_ANCS_PARSE_STATE_COMMAND_ID
Definition: ancs_client.h:212
int bt_ancs_client_init(struct bt_ancs_client *ancs_c)
Function for initializing the ANCS client.
int bt_ancs_unsubscribe_notification_source(struct bt_ancs_client *ancs_c)
Function for writing to the CCCD to disable notifications from the ANCS.
void(* bt_ancs_ds_notif_cb)(struct bt_ancs_client *ancs_c, const struct bt_ancs_attr_response *response)
Data Source notification callback function.
Definition: ancs_client.h:311
int bt_ancs_request_app_attr(struct bt_ancs_client *ancs_c, const uint8_t *app_id, uint32_t len, bt_ancs_write_cb func)
Function for requesting attributes for a given app.
#define BT_ANCS_APP_ATTR_COUNT
Definition: ancs_client.h:61
bt_ancs_cmd_id_val
Control point command IDs that the Notification Consumer can send to the Notification Provider.
Definition: ancs_client.h:143
@ BT_ANCS_COMMAND_ID_GET_APP_ATTRIBUTES
Definition: ancs_client.h:151
@ BT_ANCS_COMMAND_ID_PERFORM_NOTIF_ACTION
Definition: ancs_client.h:155
@ BT_ANCS_COMMAND_ID_GET_NOTIF_ATTRIBUTES
Definition: ancs_client.h:147
int bt_ancs_subscribe_notification_source(struct bt_ancs_client *ancs_c, bt_ancs_ns_notif_cb func)
Function for writing to the CCCD to enable notifications from the Apple Notification Service.
int bt_ancs_handles_assign(struct bt_gatt_dm *dm, struct bt_ancs_client *ancs_c)
Function for assigning handles to ANCS client instance.
uint16_t attr_len
Definition: ancs_client.h:275
uint32_t attr_id
Definition: ancs_client.h:271
uint8_t * attr_data
Definition: ancs_client.h:277
bool get
Definition: ancs_client.h:266
iOS notification attribute content requested by the application.
Definition: ancs_client.h:262
struct bt_ancs_attr attr
Definition: ancs_client.h:289
uint32_t notif_uid
Definition: ancs_client.h:291
enum bt_ancs_cmd_id_val command_id
Definition: ancs_client.h:285
uint8_t app_id[32]
Definition: ancs_client.h:293
Attribute response structure.
Definition: ancs_client.h:283
uint32_t attr_id
Definition: ancs_client.h:256
uint8_t * attr_data
Definition: ancs_client.h:258
uint16_t attr_len
Definition: ancs_client.h:254
iOS attribute structure. This type is used for both notification attributes and app attributes.
Definition: ancs_client.h:252
struct bt_conn * conn
Definition: ancs_client.h:354
struct bt_gatt_subscribe_params ns_notif_params
Definition: ancs_client.h:384
bt_ancs_ds_notif_cb ds_notif_cb
Definition: ancs_client.h:393
bt_ancs_ns_notif_cb ns_notif_cb
Definition: ancs_client.h:387
bt_ancs_write_cb cp_write_cb
Definition: ancs_client.h:378
struct bt_ancs_attr_list ancs_app_attr_list[1]
Definition: ancs_client.h:406
uint16_t handle_ds
Definition: ancs_client.h:369
uint8_t cp_data[CONFIG_BT_ANCS_CLIENT_CP_BUFF_SIZE]
Definition: ancs_client.h:381
struct bt_ancs_attr_list ancs_notif_attr_list[8]
Definition: ancs_client.h:399
atomic_t state
Definition: ancs_client.h:357
struct bt_gatt_subscribe_params ds_notif_params
Definition: ancs_client.h:390
struct bt_ancs_parse_sm parse_info
Definition: ancs_client.h:417
uint16_t handle_ds_ccc
Definition: ancs_client.h:372
uint16_t handle_ns_ccc
Definition: ancs_client.h:366
uint16_t handle_ns
Definition: ancs_client.h:363
struct bt_gatt_write_params cp_write_params
Definition: ancs_client.h:375
uint16_t handle_cp
Definition: ancs_client.h:360
uint32_t number_of_requested_attr
Definition: ancs_client.h:412
struct bt_ancs_attr_response attr_response
Definition: ancs_client.h:421
ANCS client instance, which contains various status information.
Definition: ancs_client.h:352
uint8_t category_count
Definition: ancs_client.h:246
enum bt_ancs_evt_id_values evt_id
Definition: ancs_client.h:236
struct bt_ancs_notif_flags evt_flags
Definition: ancs_client.h:240
enum bt_ancs_category_id_val category_id
Definition: ancs_client.h:244
uint32_t notif_uid
Definition: ancs_client.h:234
iOS notification structure.
Definition: ancs_client.h:232
uint8_t pre_existing
Definition: ancs_client.h:202
uint8_t negative_action
Definition: ancs_client.h:206
uint8_t silent
Definition: ancs_client.h:198
uint8_t positive_action
Definition: ancs_client.h:204
uint8_t important
Definition: ancs_client.h:200
Flags for iOS notifications.
Definition: ancs_client.h:196
struct bt_ancs_attr_list * attr_list
Definition: ancs_client.h:327
uint8_t * data_dest
Definition: ancs_client.h:344
enum bt_ancs_cmd_id_val command_id
Definition: ancs_client.h:342
uint32_t attr_count
Definition: ancs_client.h:331
uint16_t current_attr_index
Definition: ancs_client.h:346
uint32_t current_app_id_index
Definition: ancs_client.h:348
uint32_t expected_number_of_attrs
Definition: ancs_client.h:335
enum bt_ancs_parse_state parse_state
Definition: ancs_client.h:337
Definition: ancs_client.h:322