Microchip® Advanced Software Framework

alert_notification_profile.c File Reference

Alert Notification Profile.

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

#include <string.h>
#include "at_ble_api.h"
#include "ble_manager.h"
#include "ble_utils.h"
#include "alert_notification_profile.h"
#include "alert_notification.h"

Functions

at_ble_status_t alert_service_discovery (void)
 Discovering the services of Alert Notification. More...
 
void anp_client_adv (void)
 Sets the advertisements and starts the advertisement. More...
 
at_ble_status_t anp_client_characteristic_found_handler (void *params)
 characteristic found handler invoked by ble manager More...
 
at_ble_status_t anp_client_descriptor_found_handler (void *params)
 client descriptor found handler invoked by ble manager 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)
 disconnected event handler invoked by ble manager More...
 
at_ble_status_t anp_client_discovery_complete_handler (void *params)
 Discovery Complete handler invoked by ble manager. More...
 
void anp_client_init (void *params)
 invoked by ble manager for initializing the profile More...
 
at_ble_status_t anp_client_notification_handler (void *params)
 invoked by ble manager on receiving notification More...
 
at_ble_status_t anp_client_read_response_handler (void *params)
 char changed handler invoked by ble manager 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)
 Service found handler invoked by ble manager. 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)
 write response handler invoked by ble manager More...
 
at_ble_status_t anp_info_connect_handler (void *params)
 Connection handler callback. More...
 
void anp_info_init (void)
 Initializing and allocation of memory for respective service. 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 notification of ringer setting More...
 

Variables

uint8_t alert_np_char_data [ANS_ALERT_NP_READ_LENGTH]
 
at_ble_handle_t anp_conn_handle = 0
 
static const ble_gap_event_cb_t anp_gap_handle
 
static const
ble_gatt_client_event_cb_t 
anp_gatt_client_handle
 
gatt_anp_handler_t anp_handle
 
ble_connected_dev_info_t ble_dev_info [BLE_MAX_DEVICE_CONNECTION]
 Initialize the service with its included service, characteristics, and descriptors. More...
 
connected_callback_t connected_cb
 
uint8_t new_alert_char_data [ANS_NEW_ALERT_READ_LENGTH]
 
uint8_t start_notification = 0
 
uint8_t supp_new_char_data [ANS_SUP_NEW_READ_LENGTH]
 
uint8_t supp_unread_char_data [ANS_SUP_UNREA_READ_LENGTH]
 
uint8_t unread_alert_char_data [ANS_UNREA_ALERT_READ_LENGTH]
 

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  )

Sets the advertisements and starts the advertisement.

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.

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)

disconnected event handler invoked by ble manager

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)

invoked by ble manager for initializing the profile

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.

at_ble_status_t anp_client_notification_handler ( void *  params)

invoked by ble manager on receiving 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)

char changed handler invoked by ble manager

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().

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
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)

write response handler invoked by ble manager

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.

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_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 notification of ringer setting

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().

uint8_t alert_np_char_data[ANS_ALERT_NP_READ_LENGTH]

Referenced by anp_info_init().

at_ble_handle_t anp_conn_handle = 0
const ble_gap_event_cb_t anp_gap_handle
static
Initial value:
= {
.encryption_status_changed = anp_info_service_discover
}
at_ble_status_t anp_info_service_discover(void *params)
Discovering the services of Alert Notification.
Definition: alert_notification_profile.c:212
at_ble_status_t anp_client_disconnected_event_handler(void *params)
Handler for disconnection event.
Definition: ancs_profile.c:217
at_ble_status_t anp_info_connect_handler(void *params)
Connection handler callback.
Definition: alert_notification_profile.c:192
const ble_gatt_client_event_cb_t anp_gatt_client_handle
static
Initial value:
= {
.primary_service_found = anp_client_service_found_handler,
.characteristic_found = anp_client_characteristic_found_handler,
.characteristic_read_by_uuid_response = anp_client_read_response_handler,
.characteristic_write_response = anp_client_write_response_handler,
.notification_recieved = anp_client_notification_handler
}
at_ble_status_t anp_client_discovery_complete_handler(void *params)
Handler for discovery complete event.
Definition: ancs_profile.c:138
at_ble_status_t anp_client_read_response_handler(void *params)
char changed handler invoked by ble manager
Definition: alert_notification_profile.c:587
at_ble_status_t anp_client_notification_handler(void *params)
Handler for notification event.
Definition: ancs_profile.c:274
at_ble_status_t anp_client_write_response_handler(void *params)
Handler for write response.
Definition: ancs_profile.c:262
at_ble_status_t anp_client_service_found_handler(void *params)
Handler for service found event.
Definition: ancs_profile.c:169
at_ble_status_t anp_client_characteristic_found_handler(void *params)
Handler for characteristic found event.
Definition: ancs_profile.c:186
at_ble_status_t anp_client_descriptor_found_handler(void *params)
Handler for descriptor found event.
Definition: ancs_profile.c:230
gatt_anp_handler_t anp_handle
Initial value:
Invalid input argument to function.
Definition: at_ble_errno.h:364
Generic errors Success.
Definition: at_ble_errno.h:39
#define NULL
Definition: nm_bsp.h:64

Initialize the service with its included service, characteristics, and descriptors.

Parameters
[in]scan_paramgatt service information
Returns
none
connected_callback_t connected_cb
uint8_t new_alert_char_data[ANS_NEW_ALERT_READ_LENGTH]

Referenced by anp_info_init().

uint8_t start_notification = 0
uint8_t supp_new_char_data[ANS_SUP_NEW_READ_LENGTH]

Referenced by anp_info_init().

uint8_t supp_unread_char_data[ANS_SUP_UNREA_READ_LENGTH]

Referenced by anp_info_init().

uint8_t unread_alert_char_data[ANS_UNREA_ALERT_READ_LENGTH]

Referenced by anp_info_init().