Microchip® Advanced Software Framework

alert_notification_profile.h File Reference

Alert Notification Profile declarations.

Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.

Macros

#define ADV_TYPE_LEN   (0x01)
 
#define ALERT_NOTI_CONTROL_CHAR_UUID   (0x2A44)
 
#define ANP_ADV_DATA_APPEARANCE_DATA   ("\x00\x40")
 
#define ANP_ADV_DATA_APPEARANCE_LEN   (2)
 Appearance type & Length. More...
 
#define ANP_ADV_DATA_APPEARANCE_TYPE   (0x19)
 
#define ANP_ADV_DATA_NAME_DATA   ("ATMEL-ANS")
 
#define ANP_ADV_DATA_NAME_LEN   (9)
 Advertisement Name Type Length & data. More...
 
#define ANP_ADV_DATA_NAME_TYPE   (0x09)
 
#define ANP_ADV_DATA_UUID_LEN   (2)
 ANCS Service Solicitation Info. More...
 
#define ANP_ADV_DATA_UUID_TYPE   (0x03)
 
#define APP_ANP_ADV_TIMEOUT   (655)
 APP_ANP_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x028F in seconds, 0x0000 disables time-out. More...
 
#define APP_ANP_FAST_ADV   (1600)
 Advertisement Interval. More...
 
#define AT_BLE_DISCOVERY_SUCCESS   (10)
 
#define CLIENT_CHAR_CONF_DESC_UUID   (0x2902)
 
#define NEW_ALERT_CHAR_UUID   (0x2A46)
 
#define SCAN_RESP_LEN   (10)
 Scan Response length. More...
 
#define SUPPORT_NEW_ALERT_CHAR_UUID   (0x2A47)
 
#define SUPPORT_UNREAD_ALERT_CHAR_UUID   (0x2A48)
 
#define UNREAD_ALERT_STATUS_CHAR_UUID   (0x2A45)
 

Typedefs

typedef void(* connected_callback_t )(bool)
 

Functions

at_ble_status_t alert_service_discovery (void)
 Discovering the services of Alert Notification. More...
 
void anp_client_adv (void)
 does all the profile initialization and starts the advertisement More...
 
void anp_client_char_changed_handler (at_ble_characteristic_changed_t *params)
 Handler for char changed handler. More...
 
at_ble_status_t anp_client_characteristic_found_handler (void *params)
 Handler for characteristic found event. More...
 
at_ble_status_t anp_client_descriptor_found_handler (void *params)
 Handler for descriptor found event. More...
 
void anp_client_disable_notification (void)
 invoked by app for disabling the notifications in gatt server More...
 
at_ble_status_t anp_client_disconnected_event_handler (void *params)
 Handler for disconnection event. More...
 
at_ble_status_t anp_client_discovery_complete_handler (void *params)
 Handler for discovery complete event. More...
 
void anp_client_init (void *params)
 Function used for profile initialization and also enable the advertisement. More...
 
at_ble_status_t anp_client_notification_handler (void *params)
 Handler for notification event. More...
 
at_ble_status_t anp_client_read_response_handler (void *params)
 Handler for read response handle. More...
 
at_ble_status_t anp_client_security_done_handler (void *param)
 invoked by ble manager for setting the notification More...
 
at_ble_status_t anp_client_service_found_handler (void *params)
 Handler for service found event. More...
 
void anp_client_write_notification_handler (void)
 Handler for enabling the notification. More...
 
at_ble_status_t anp_client_write_response_handler (void *params)
 Handler for write response. More...
 
at_ble_status_t anp_info_connect_handler (void *params)
 Connection handler callback. More...
 
void anp_info_init (void)
 Initialize the profile specific information. More...
 
at_ble_status_t anp_info_service_discover (void *params)
 Discovering the services of Alert Notification. More...
 
at_ble_status_t anp_write_to_ncp (uint8_t *value)
 char changed handler invoked by application More...
 
void register_connected_callback (connected_callback_t app_connected_cb)
 register the call back for application state More...
 

#define ADV_TYPE_LEN   (0x01)
#define ALERT_NOTI_CONTROL_CHAR_UUID   (0x2A44)
#define ANP_ADV_DATA_APPEARANCE_DATA   ("\x00\x40")
#define ANP_ADV_DATA_APPEARANCE_LEN   (2)

Appearance type & Length.

#define ANP_ADV_DATA_APPEARANCE_TYPE   (0x19)
#define ANP_ADV_DATA_NAME_DATA   ("ATMEL-ANS")
#define ANP_ADV_DATA_NAME_LEN   (9)

Advertisement Name Type Length & data.

#define ANP_ADV_DATA_NAME_TYPE   (0x09)
#define ANP_ADV_DATA_UUID_LEN   (2)

ANCS Service Solicitation Info.

#define ANP_ADV_DATA_UUID_TYPE   (0x03)
#define APP_ANP_ADV_TIMEOUT   (655)

APP_ANP_ADV_TIMEOUT Advertising time-out between 0x0001 and 0x028F in seconds, 0x0000 disables time-out.

#define APP_ANP_FAST_ADV   (1600)

Advertisement Interval.

Preface

This is the reference manual for the Time Information Profile

#define AT_BLE_DISCOVERY_SUCCESS   (10)
#define CLIENT_CHAR_CONF_DESC_UUID   (0x2902)
#define NEW_ALERT_CHAR_UUID   (0x2A46)
#define SCAN_RESP_LEN   (10)

Scan Response length.

#define SUPPORT_NEW_ALERT_CHAR_UUID   (0x2A47)
#define SUPPORT_UNREAD_ALERT_CHAR_UUID   (0x2A48)
#define UNREAD_ALERT_STATUS_CHAR_UUID   (0x2A45)

typedef void(* connected_callback_t)(bool)

at_ble_status_t alert_service_discovery ( void  )

Discovering the services of Alert Notification.

Returns
at_ble_status_t which return AT_BLE_SUCCESS on success

References anp_conn_handle, AT_BLE_FAILURE, at_ble_primary_service_discover_all(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, GATT_DISCOVERY_ENDING_HANDLE, and GATT_DISCOVERY_STARTING_HANDLE.

Referenced by anp_custom_event(), anp_info_connect_handler(), and anp_info_service_discover().

void anp_client_adv ( void  )

does all the profile initialization and starts the advertisement

Note
Called by the ble_manager

does all the profile initialization and starts the advertisement

References APP_ANP_ADV_TIMEOUT, APP_ANP_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_SUCCESS, DBG_LOG, and NULL.

Referenced by app_connected_state(), app_disconnected_event_handler(), and main().

void anp_client_char_changed_handler ( at_ble_characteristic_changed_t params)

Handler for char changed handler.

Parameters
[in]characteristicchanged event parameter containing details like characteristic handle,value
Note
Called by the ble_manager after receiving characteristic change event
at_ble_status_t anp_client_descriptor_found_handler ( void *  params)

Handler for descriptor found event.

Parameters
[in]descriptorfound event parameter containing details like descriptor handle,uuid
Note
Called by the ble_manager after receiving descriptor found event

Handler for descriptor found event.

Parameters
[in]at_ble_descriptor_found_tconsists the descriptor handle

References AT_BLE_SUCCESS, AT_BLE_UUID_16, CLIENT_CHAR_CONF_DESC_UUID, at_ble_descriptor_found_t::conn_handle, DBG_LOG, DBG_LOG_DEV, DBG_LOG_PTS, at_ble_descriptor_found_t::desc_handle, at_ble_descriptor_found_t::desc_uuid, gatt_anp_handler::new_alert_char_handle, gatt_anp_handler::new_alert_desc_handle, ancs_prf::notification_source_desc, at_ble_uuid_t::type, gatt_anp_handler::unread_alert_char_handle, gatt_anp_handler::unread_alert_desc_handle, and at_ble_uuid_t::uuid.

void anp_client_disable_notification ( void  )

invoked by app for disabling the notifications in gatt server

Parameters
[in]none
Returns
none

References anp_alert_noti(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, gatt_anp_handler::new_alert_desc_handle, and gatt_anp_handler::unread_alert_desc_handle.

Referenced by anp_custom_event().

at_ble_status_t anp_client_disconnected_event_handler ( void *  params)

Handler for disconnection event.

Parameters
[in]disconnectedevent parameter containing details like handle
Note
Called by the ble_manager after receiving disconnection event

Handler for disconnection event.

Parameters
[in]at_ble_disconnected_tconsists connection handle and reason return none

References ALL_UNUSED, AT_BLE_SUCCESS, connected_cb, app_anp_data::devicedb, and FALSE.

void anp_client_init ( void *  params)

Function used for profile initialization and also enable the advertisement.

Note
Called by the ble_manager

Function used for profile initialization and also enable the advertisement.

Function used for profile initialization and also enable the advertisement.

Parameters
[in]voidparams passed by the blemanager,app may use it or may not
Returns
none

References ancs_init(), anp_info_init(), AT_BLE_SUCCESS, ble_advertisement_data_set(), BLE_GAP_EVENT_TYPE, BLE_GATT_CLIENT_EVENT_TYPE, ble_mgr_events_callback_handler(), DBG_LOG, REGISTER_CALL_BACK, and UNUSED.

Referenced by main().

at_ble_status_t anp_client_notification_handler ( void *  params)

Handler for notification event.

Parameters
[in]notificationreceived parameter containing the notification value
Note
Called by the ble_manager after receiving the notification

Handler for notification event.

Parameters
[in]at_ble_notification_recieved_tconsists the char handle

References anp_alert_notify_response(), AT_BLE_SUCCESS, CATEGORY_ID_INCOMINGCALL, at_ble_notification_recieved_t::char_value, DBG_LOG, NOTIFICATION_ADDED, and NOTIFICATION_REMOVED.

at_ble_status_t anp_client_read_response_handler ( void *  params)

Handler for read response handle.

Note
Called by the ble_manager for read response in the gatt server

Handler for read response handle.

Parameters
[in]at_ble_characteristic_read_response_tconsists of characteristic handle value handle

References anp_alert_read_response(), anp_client_write_notification_handler(), AT_BLE_SUCCESS, start_notification, SUPPORTED_NEW_ALERT_READ, and SUPPORTED_UNREAD_ALERT_READ.

at_ble_status_t anp_client_security_done_handler ( void *  param)

invoked by ble manager for setting the notification

Parameters
[in]param'spassed by the ble manager which may or may not be used

References anp_alert_read(), AT_BLE_SUCCESS, DBG_LOG_DEV, start_notification, gatt_anp_handler::supp_new_char_handle, gatt_anp_handler::supp_unread_char_handle, and UNUSED.

Referenced by anp_client_discovery_complete_handler().

at_ble_status_t anp_client_service_found_handler ( void *  params)

Handler for service found event.

Parameters
[in]servicefound event parameter containing details like service handle,uuid
Note
Called by the ble_manager after receiving service found event

Handler for service found event.

Parameters
[in]at_ble_primary_service_found_twhich consists of starting and ending handle of service
Returns
none

References ancs_prf::ancs_serv, ANP_SERVICE_UUID, AT_BLE_SUCCESS, AT_BLE_UUID_16, gatt_anp_handler::char_discovery, at_ble_primary_service_found_t::conn_handle, DBG_LOG, DBG_LOG_DEV, DBG_LOG_PTS, gatt_anp_handler::end_handle, at_ble_primary_service_found_t::end_handle, at_ble_primary_service_found_t::service_uuid, gatt_anp_handler::start_handle, at_ble_primary_service_found_t::start_handle, at_ble_uuid_t::type, and at_ble_uuid_t::uuid.

void anp_client_write_notification_handler ( void  )

Handler for enabling the notification.

Note
Called by the ble_manager for enabling the notification in the gatt server
Called by the ble_manager for enabling the notification in the gatt server
Parameters
[in]none
Returns
none

References anp_alert_noti(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, gatt_anp_handler::new_alert_desc_handle, and gatt_anp_handler::unread_alert_desc_handle.

at_ble_status_t anp_client_write_response_handler ( void *  params)

Handler for write response.

Parameters
[in]writeresponse parameter contacting the result of write request
Note
Called by the ble_manager after receiving write response event

Handler for write response.

Parameters
[in]at_ble_characteristic_write_response_tconsists the char
Returns
none

References AT_BLE_SUCCESS, at_ble_characteristic_write_response_t::char_handle, DBG_LOG_DEV, gatt_anp_handler::new_alert_desc_handle, and gatt_anp_handler::unread_alert_desc_handle.

at_ble_status_t anp_info_connect_handler ( void *  params)

Connection handler callback.

Parameters
[in]at_ble_connected_twhich consists of connection handle
Returns
at_ble_status_t which return AT_BLE_SUCCESS on success

References alert_service_discovery(), anp_conn_handle, AT_BLE_SUCCESS, at_ble_connected_t::conn_status, connected_cb, DBG_LOG, and at_ble_connected_t::handle.

void anp_info_init ( void  )
at_ble_status_t anp_info_service_discover ( void *  params)

Discovering the services of Alert Notification.

Parameters
[in]at_ble_connected_twhich consists of connection handle
Returns
at_ble_status_t which return AT_BLE_SUCCESS on success

References alert_service_discovery(), and ALL_UNUSED.

at_ble_status_t anp_write_to_ncp ( uint8_t *  value)

char changed handler invoked by application

Parameters
[in]uint8_tarray consists of value to be written to alert notification control point
[in]uint8_tconsists of value to be written to alert notification control point

References gatt_anp_handler::alert_np_char_handle, and at_ble_characteristic_write().

Referenced by anp_custom_event().

void register_connected_callback ( connected_callback_t  app_connected_cb)

register the call back for application state

Parameters
[in]@returnnone

register the call back for application state

Parameters
[in]app_connected_cbapplication callback function
Returns
none

References app_connected_cb(), and connected_cb.

Referenced by main().