Apple Notification Center Service Client module. More...
Data Structures |
|
| struct | ble_ancs_c_notif_flags_t |
|
Flags for iOS notifications.
More...
|
|
| struct | ble_ancs_c_evt_notif_t |
|
iOS notification structure.
More...
|
|
| struct | ble_ancs_c_attr_t |
|
iOS attribute structure. This type is used for both notification attributes and app attributes.
More...
|
|
| struct | ble_ancs_c_evt_attr_t |
|
iOS notification attribute structure for incoming attributes.
More...
|
|
| struct | ble_ancs_c_evt_app_attr_t |
| struct | ble_ancs_c_attr_list_t |
|
iOS notification attribute content requested by the application.
More...
|
|
| struct | ble_ancs_c_service_t |
|
Structure used for holding the Apple Notification Center Service found during the discovery process.
More...
|
|
| struct | ble_ancs_c_evt_t |
|
ANCS client module event structure.
More...
|
|
| struct | ble_ancs_parse_sm_t |
| struct | ble_ancs_c_t |
|
iOS notification structure, which contains various status information for the client.
More...
|
|
| struct | ble_ancs_c_init_t |
|
Apple Notification client init structure, which contains all options and data needed for initialization of the client.
More...
|
|
Macros |
|
| #define | BLE_ANCS_WRITE_MAX_MSG_LENGTH 20 |
| #define | BLE_ANCS_C_DEF (_name) |
|
Macro for defining a ble_ancs_c instance.
More...
|
|
| #define | BLE_ANCS_C_ARRAY_DEF (_name, _cnt) |
|
Macro for defining multiple ble_ancs_c instances.
More...
|
|
| #define | BLE_ANCS_ATTR_DATA_MAX 32 |
|
Maximum data length of an iOS notification attribute.
|
|
| #define | BLE_ANCS_NB_OF_CATEGORY_ID 12 |
|
Number of iOS notification categories: Other, Incoming Call, Missed Call, Voice Mail, Social, Schedule, Email, News, Health and Fitness, Business and Finance, Location, Entertainment.
|
|
| #define | BLE_ANCS_NB_OF_NOTIF_ATTR 8 |
|
Number of iOS notification attributes: AppIdentifier, Title, Subtitle, Message, MessageSize, Date, PositiveActionLabel, NegativeActionLabel.
|
|
| #define | BLE_ANCS_NB_OF_APP_ATTR 1 |
|
Number of iOS application attributes: DisplayName.
|
|
| #define | BLE_ANCS_NB_OF_EVT_ID 3 |
|
Number of iOS notification events: Added, Modified, Removed.
|
|
| #define | BLE_ANCS_NOTIFICATION_DATA_LENGTH 8 |
|
Length of the iOS notification data.
More...
|
|
| #define | ANCS_UUID_SERVICE 0xF431 |
|
16-bit service UUID for the Apple Notification Center Service.
|
|
| #define | ANCS_UUID_CHAR_CONTROL_POINT 0xD8F3 |
|
16-bit control point UUID.
|
|
| #define | ANCS_UUID_CHAR_DATA_SOURCE 0xC6E9 |
|
16-bit data source UUID.
|
|
| #define | ANCS_UUID_CHAR_NOTIFICATION_SOURCE 0x120D |
|
16-bit notification source UUID.
|
|
| #define | BLE_ANCS_EVENT_FLAG_SILENT 0 |
|
0b.......1 Silent: First (LSB) bit is set. All flags can be active at the same time.
|
|
| #define | BLE_ANCS_EVENT_FLAG_IMPORTANT 1 |
|
0b......1. Important: Second (LSB) bit is set. All flags can be active at the same time.
|
|
| #define | BLE_ANCS_EVENT_FLAG_PREEXISTING 2 |
|
0b.....1.. Pre-existing: Third (LSB) bit is set. All flags can be active at the same time.
|
|
| #define | BLE_ANCS_EVENT_FLAG_POSITIVE_ACTION 3 |
|
0b....1... Positive action: Fourth (LSB) bit is set. All flags can be active at the same time.
|
|
| #define | BLE_ANCS_EVENT_FLAG_NEGATIVE_ACTION 4 |
|
0b...1.... Negative action: Fifth (LSB) bit is set. All flags can be active at the same time.
|
|
Typedefs |
|
| typedef void(* | ble_ancs_c_evt_handler_t )( ble_ancs_c_evt_t *p_evt) |
|
iOS notification event handler type.
|
|
Functions |
|
| uint32_t | ancs_c_app_attr_request ( ble_ancs_c_t *p_ancs, const uint8_t *app_id, uint32_t len) |
|
Function for requesting attributes for an app.
More...
|
|
| void | ancs_parse_get_attrs_response ( ble_ancs_c_t *p_ancs, const uint8_t *p_data_src, const uint16_t hvx_data_len) |
|
Function for parsing notification or app attribute response data.
More...
|
|
| void | ble_ancs_c_on_ble_evt ( ble_evt_t const *p_ble_evt, void *p_context) |
|
Function for handling BLE stack events of the application.
More...
|
|
| void | ble_ancs_c_on_db_disc_evt ( ble_ancs_c_t *p_ancs, ble_db_discovery_evt_t *p_evt) |
|
Function for handling events from the Database Discovery module.
More...
|
|
| ret_code_t | ble_ancs_c_init ( ble_ancs_c_t *p_ancs, ble_ancs_c_init_t const *p_ancs_init) |
|
Function for initializing the ANCS client.
More...
|
|
| ret_code_t | ble_ancs_c_notif_source_notif_enable ( ble_ancs_c_t const *p_ancs) |
|
Function for writing to the CCCD to enable notifications from the Apple Notification Service.
More...
|
|
| ret_code_t | ble_ancs_c_data_source_notif_enable ( ble_ancs_c_t const *p_ancs) |
|
Function for writing to the CCCD to enable data source notifications from the ANCS.
More...
|
|
| ret_code_t | ble_ancs_c_notif_source_notif_disable ( ble_ancs_c_t const *p_ancs) |
|
Function for writing to the CCCD to disable notifications from the ANCS.
More...
|
|
| ret_code_t | ble_ancs_c_data_source_notif_disable ( ble_ancs_c_t const *p_ancs) |
|
Function for writing to the CCCD to disable data source notifications from the ANCS.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_attr_add ( ble_ancs_c_t *p_ancs, ble_ancs_c_notif_attr_id_val_t const id, uint8_t *p_data, uint16_t const len) |
|
Function for registering attributes that will be requested when
nrf_ble_ancs_c_request_attrs
is called.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_attr_remove ( ble_ancs_c_t *p_ancs, ble_ancs_c_notif_attr_id_val_t const id) |
|
Function for removing attributes, so that they are no longer requested when
nrf_ble_ancs_c_request_attrs
is called.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_app_attr_remove ( ble_ancs_c_t *p_ancs, ble_ancs_c_app_attr_id_val_t const id) |
|
Function for removing attributes, so that they are no longer requested when
nrf_ble_ancs_c_app_attr_request
is called.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_app_attr_add ( ble_ancs_c_t *p_ancs, ble_ancs_c_app_attr_id_val_t const id, uint8_t *p_data, uint16_t const len) |
|
Function for registering attributes that will be requested when
nrf_ble_ancs_c_app_attr_request
is called.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_attr_req_clear_all ( ble_ancs_c_t *p_ancs) |
|
Function for clearing the list of notification attributes and app attributes that would be requested from NP.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_request_attrs ( ble_ancs_c_t *p_ancs, ble_ancs_c_evt_notif_t const *p_notif) |
|
Function for requesting attributes for a notification.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_app_attr_request ( ble_ancs_c_t *p_ancs, uint8_t const *p_app_id, uint32_t len) |
|
Function for requesting attributes for a given app.
More...
|
|
| ret_code_t | nrf_ancs_perform_notif_action ( ble_ancs_c_t *p_ancs, uint32_t uuid, ble_ancs_c_action_id_values_t action_id) |
|
Function for performing a notification action.
More...
|
|
| ret_code_t | nrf_ble_ancs_c_handles_assign ( ble_ancs_c_t *p_ancs, uint16_t const conn_handle, ble_ancs_c_service_t const *p_service) |
|
Function for assigning a handle to this instance of ancs_c.
More...
|
|
Variables |
|
| const ble_uuid128_t | ble_ancs_base_uuid128 |
|
Apple Notification Center Service UUIDs.
More...
|
|
| const ble_uuid128_t | ble_ancs_cp_base_uuid128 |
|
Control Point UUID.
|
|
| const ble_uuid128_t | ble_ancs_ns_base_uuid128 |
|
Notification Source UUID.
|
|
| const ble_uuid128_t | ble_ancs_ds_base_uuid128 |
|
Data Source UUID.
|
|
Detailed Description
Apple Notification Center Service Client module.
Disclaimer: This client implementation of the Apple Notification Center Service can be changed at any time by Nordic Semiconductor ASA. Server implementations such as the ones found in iOS can be changed at any time by Apple and may cause this client implementation to stop working.
This module implements the Apple Notification Center Service (ANCS) client. This client can be used as a Notification Consumer (NC) that receives data notifications from a Notification Provider (NP). The NP is typically an iOS device that is acting as a server. For terminology and up-to-date specs, see http://developer.apple.com .
The term "notification" is used in two different meanings:
- An iOS notification is the data received from the Notification Provider.
- A GATTC notification is a way to transfer data with Bluetooth Smart. In this module, iOS notifications are received through the GATTC notifications. The full term (iOS notification or GATTC notification) is used where required to avoid confusion.
Upon initializing the module, you must add the different iOS notification attributes you would like to receive for iOS notifications (see nrf_ble_ancs_c_attr_add ).
Once a connection is established with a central device, the module does a service discovery to discover the ANCS server handles. If this succeeds ( BLE_ANCS_C_EVT_DISCOVERY_COMPLETE ), the handles for the ANCS server are part of the ble_ancs_c_evt_t structure and must be assigned to an ANCS_C instance using the nrf_ble_ancs_c_handles_assign function. For more information about service discovery, see the Database Discovery Module documentation.
The application can now subscribe to iOS notifications with ble_ancs_c_notif_source_notif_enable . The notifications arrive in the BLE_ANCS_C_EVT_NOTIF event. nrf_ble_ancs_c_request_attrs can be used to request attributes for the notifications. The attributes arrive in the BLE_ANCS_C_EVT_NOTIF_ATTRIBUTE event. Use nrf_ble_ancs_c_app_attr_request to request attributes of the app that issued the notifications. The app attributes arrive in the BLE_ANCS_C_EVT_APP_ATTRIBUTE event. Use nrf_ancs_perform_notif_action to make the Notification Provider perform an action based on the provided notification.
- Note
-
The application must register this module as the BLE event observer by using the NRF_SDH_BLE_OBSERVER macro. Example:
ble_ancs_c_t instance;NRF_SDH_BLE_OBSERVER (anything, BLE_ANCS_C_BLE_OBSERVER_PRIO ,ble_ancs_c_on_ble_evt , &instance);
Macro Definition Documentation
| #define BLE_ANCS_C_ARRAY_DEF | ( | _name, | |
| _cnt | |||
| ) |
Macro for defining multiple ble_ancs_c instances.
- Parameters
-
_name Name of the array of instances. _cnt Number of instances to define.
| #define BLE_ANCS_C_DEF | ( | _name | ) |
Macro for defining a ble_ancs_c instance.
- Parameters
-
_name Name of the instance.
| #define BLE_ANCS_NOTIFICATION_DATA_LENGTH 8 |
Length of the iOS notification data.
8 bytes:
| Event ID | Event flags | Category ID | Category count | Notification UID |
|---|---|---|---|---|
| 1 byte | 1 byte | 1 byte | 1 byte | 4 bytes |
| #define BLE_ANCS_WRITE_MAX_MSG_LENGTH 20 |
Maximum GATTC write length.
Enumeration Type Documentation
Category IDs for iOS notifications.
Control point command IDs that the Notification Consumer can send to the Notification Provider.
Event types that are passed from client to application on an event.
IDs for iOS notification attributes.
Parsing states for received iOS notification and app attributes.
Function Documentation
| uint32_t ancs_c_app_attr_request | ( | ble_ancs_c_t * | p_ancs , |
| const uint8_t * | app_id , | ||
| uint32_t | len | ||
| ) |
Function for requesting attributes for an app.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use. [in] app_id App identifier of the app for which to request app attributes. [in] len Length of the app identifier.
- Return values
-
NRF_SUCCESS If all operations were successful. Otherwise, an error code is returned.
| void ancs_parse_get_attrs_response | ( | ble_ancs_c_t * | p_ancs , |
| const uint8_t * | p_data_src , | ||
| const uint16_t | hvx_data_len | ||
| ) |
Function for parsing notification or app attribute response data.
The data that comes from the Notification Provider can be much longer than what would fit in a single GATTC notification. Therefore, this function relies on a state-oriented switch case. UID and command ID will be received only once at the beginning of the first GATTC notification of a new attribute request for a given iOS notification. After this, we can loop several ATTR_ID > LENGTH > DATA > ATTR_ID > LENGTH > DATA until we have received all attributes we wanted as a Notification Consumer. The Notification Provider can also simply stop sending attributes.
| 1 byte | 4 bytes | 1 byte | 2 bytes | ... X bytes ... | 1 bytes | 2 bytes | ... X bytes ... |
|---|---|---|---|---|---|---|---|
| CMD_ID | NOTIF_UID | ATTR_ID | LENGTH | DATA | ATTR_ID | LENGTH | DATA |
- Parameters
-
[in] p_ancs Pointer to an ANCS instance to which the event belongs. [in] p_data_src Pointer to data that was received from the Notification Provider. [in] hvx_data_len Length of the data that was received from the Notification Provider.
| ret_code_t ble_ancs_c_data_source_notif_disable | ( | ble_ancs_c_t const * | p_ancs | ) |
Function for writing to the CCCD to disable data source notifications from the ANCS.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use.
- Return values
-
NRF_SUCCESS If writing to the CCCD was successful. Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add .
| ret_code_t ble_ancs_c_data_source_notif_enable | ( | ble_ancs_c_t const * | p_ancs | ) |
Function for writing to the CCCD to enable data source notifications from the ANCS.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use.
- Return values
-
NRF_SUCCESS If writing to the CCCD was successful. Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add .
| ret_code_t ble_ancs_c_init | ( | ble_ancs_c_t * | p_ancs , |
| ble_ancs_c_init_t const * | p_ancs_init | ||
| ) |
Function for initializing the ANCS client.
- Parameters
-
[out] p_ancs ANCS client structure. This structure must be supplied by the application. It is initialized by this function and will later be used to identify this particular client instance. [in] p_ancs_init Information needed to initialize the client.
- Return values
-
NRF_SUCCESS If the client was initialized successfully. Otherwise, an error code is returned.
| ret_code_t ble_ancs_c_notif_source_notif_disable | ( | ble_ancs_c_t const * | p_ancs | ) |
Function for writing to the CCCD to disable notifications from the ANCS.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use.
- Return values
-
NRF_SUCCESS If writing to the CCCD was successful. Otherwise this API propagates the error code returned by function nrf_ble_gq_item_add .
| ret_code_t ble_ancs_c_notif_source_notif_enable | ( | ble_ancs_c_t const * | p_ancs | ) |
Function for writing to the CCCD to enable notifications from the Apple Notification Service.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use.
- Return values
-
NRF_SUCCESS If writing to the CCCD was successful. Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add .
| void ble_ancs_c_on_ble_evt | ( | ble_evt_t const * | p_ble_evt , |
| void * | p_context | ||
| ) |
Function for handling BLE stack events of the application.
Handles all events from the BLE stack that are of interest to the ANCS client.
- Parameters
-
[in] p_ble_evt Event received from the BLE stack. [in] p_context ANCS client structure.
| void ble_ancs_c_on_db_disc_evt | ( | ble_ancs_c_t * | p_ancs , |
| ble_db_discovery_evt_t * | p_evt | ||
| ) |
Function for handling events from the Database Discovery module.
This function handles an event from the Database Discovery module and determines whether it relates to the discovery of ANCS at the peer. If it does, this function calls the application's event handler to indicate that ANCS was discovered at the peer. The function also populates the event with service-related information before providing it to the application.
- Parameters
-
[in] p_ancs Pointer to the ANCS client structure. [in] p_evt Pointer to the event received from the Database Discovery module.
| ret_code_t nrf_ancs_perform_notif_action | ( | ble_ancs_c_t * | p_ancs , |
| uint32_t | uuid , | ||
| ble_ancs_c_action_id_values_t | action_id | ||
| ) |
Function for performing a notification action.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use. [in] uuid The UUID of the notification for which to perform the action. [in] action_id Perform a positive or negative action.
- Return values
-
NRF_SUCCESS If the operation is successful. NRF_ERROR_NULL If p_ancsis a NULL pointer.err_code Otherwise, this API propagates the error code returned by function nrf_ble_gq_item_add .
| ret_code_t nrf_ble_ancs_c_app_attr_add | ( | ble_ancs_c_t * | p_ancs , |
| ble_ancs_c_app_attr_id_val_t const | id , | ||
| uint8_t * | p_data , | ||
| uint16_t const | len | ||
| ) |
Function for registering attributes that will be requested when nrf_ble_ancs_c_app_attr_request is called.
- Parameters
-
[in] p_ancs ANCS client instance on which the attribute is registered. [in] id ID of the attribute that is added. [in] p_data Pointer to the buffer where the data of the attribute can be stored. [in] len Length of the buffer where the data of the attribute can be stored.
- Return values
-
NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned.
| ret_code_t nrf_ble_ancs_c_app_attr_remove | ( | ble_ancs_c_t * | p_ancs , |
| ble_ancs_c_app_attr_id_val_t const | id | ||
| ) |
Function for removing attributes, so that they are no longer requested when nrf_ble_ancs_c_app_attr_request is called.
- Parameters
-
[in] p_ancs ANCS client instance on which the attribute is removed. [in] id ID of the attribute that is removed.
- Return values
-
NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned.
| ret_code_t nrf_ble_ancs_c_app_attr_request | ( | ble_ancs_c_t * | p_ancs , |
| uint8_t const * | p_app_id , | ||
| uint32_t | len | ||
| ) |
Function for requesting attributes for a given app.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use. [in] p_app_id App identifier of the app for which the app attributes are requested. [in] len Length of the app identifier.
- Return values
-
NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned.
| ret_code_t nrf_ble_ancs_c_attr_add | ( | ble_ancs_c_t * | p_ancs , |
| ble_ancs_c_notif_attr_id_val_t const | id , | ||
| uint8_t * | p_data , | ||
| uint16_t const | len | ||
| ) |
Function for registering attributes that will be requested when nrf_ble_ancs_c_request_attrs is called.
- Parameters
-
[in] p_ancs ANCS client instance on which the attribute is registered. [in] id ID of the attribute that is added. [in] p_data Pointer to the buffer where the data of the attribute can be stored. [in] len Length of the buffer where the data of the attribute can be stored.
- Return values
-
NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned.
| ret_code_t nrf_ble_ancs_c_attr_remove | ( | ble_ancs_c_t * | p_ancs , |
| ble_ancs_c_notif_attr_id_val_t const | id | ||
| ) |
Function for removing attributes, so that they are no longer requested when nrf_ble_ancs_c_request_attrs is called.
- Parameters
-
[in] p_ancs ANCS client instance on which the attribute is removed. [in] id ID of the attribute that is removed.
- Return values
-
NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned.
| ret_code_t nrf_ble_ancs_c_attr_req_clear_all | ( | ble_ancs_c_t * | p_ancs | ) |
Function for clearing the list of notification attributes and app attributes that would be requested from NP.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use.
| ret_code_t nrf_ble_ancs_c_handles_assign | ( | ble_ancs_c_t * | p_ancs , |
| uint16_t const | conn_handle , | ||
| ble_ancs_c_service_t const * | p_service | ||
| ) |
Function for assigning a handle to this instance of ancs_c.
Call this function when a link has been established with a peer to associate the link to this instance of the module. This makes it possible to handle several links and associate each link to a particular instance of this module. The connection handle and attribute handles are provided from the discovery event BLE_ANCS_C_EVT_DISCOVERY_COMPLETE .
- Parameters
-
[in] p_ancs Pointer to the ANCS client structure instance for associating the link. [in] conn_handle Connection handle to associated with the given ANCS instance. [in] p_service Attribute handles on the ANCS server that you want this ANCS client to interact with.
- Return values
-
NRF_SUCCESS If the operation is successful. NRF_ERROR_NULL If p_ancsis a NULL pointer.err_code Otherwise, this API propagates the error code returned by function nrf_ble_gq_conn_handle_register .
| ret_code_t nrf_ble_ancs_c_request_attrs | ( | ble_ancs_c_t * | p_ancs , |
| ble_ancs_c_evt_notif_t const * | p_notif | ||
| ) |
Function for requesting attributes for a notification.
- Parameters
-
[in] p_ancs iOS notification structure. This structure must be supplied by the application. It identifies the particular client instance to use. [in] p_notif Pointer to the notification whose attributes will be requested from the Notification Provider.
- Return values
-
NRF_SUCCESS If all operations are successful. Otherwise, an error code is returned.
Variable Documentation
| const ble_uuid128_t ble_ancs_base_uuid128 |
Apple Notification Center Service UUIDs.
Service UUID.