Microchip® Advanced Software Framework

pas_client.c File Reference

Phone Alert Status 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 "pas_client.h"
#include "pas_service.h"

Functions

void pas_client_adv (void)
 sets the advertisement data and triggers advertisement More...
 
at_ble_status_t pas_client_char_read_response_handler (void *event_params)
 called by the ble manager after receiving the read response event More...
 
at_ble_status_t pas_client_char_write_response_handler (void *event_params)
 invoked by ble manager for setting the write response handler More...
 
at_ble_status_t pas_client_characteristic_found_handler (void *params)
 characteristic found handler invoked by ble manager More...
 
at_ble_status_t pas_client_descriptor_found_handler (void *param)
 client descriptor found handler invoked by ble manager More...
 
at_ble_status_t pas_client_disconnected_event_handler (void *params)
 disconnected event handler invoked by ble manager More...
 
at_ble_status_t pas_client_discovery_complete_handler (void *params)
 Discovery Complete handler invoked by ble manager. More...
 
at_ble_status_t pas_client_enable_char_notification (bool char_id, bool enable)
 invoked by ble manager for setting the notification of characteristics More...
 
void pas_client_init (void *params)
 invoked by ble manager for initializing the profile More...
 
at_ble_status_t pas_client_notification_handler (void *params)
 invoked by ble manager on receiving notification More...
 
at_ble_status_t pas_client_read_alert_status_char (void)
 invoked by app to read the alert status characteristic More...
 
at_ble_status_t pas_client_read_ringer_setting_char (void)
 invoked by app to read the write status characteristic More...
 
at_ble_status_t pas_client_service_discovery (void *params)
 to perform the service discovery More...
 
at_ble_status_t pas_client_service_found_handler (void *params)
 Service found handler invoked by ble manager. More...
 
at_ble_status_t pas_client_start_service_discovery (void)
 starts the service discovery More...
 
at_ble_status_t pas_client_write_notifications (void *params)
 invoked by ble manager for setting the notification More...
 
at_ble_status_t pas_client_write_ringer_control_point (uint8_t ringer)
 invoked by app to read the write ringer control point characteristic More...
 
void pas_data_init (void)
 
void register_alert_status_notification_callback (notification_callback_t app_notify_cb)
 register the call back for notification of alert status More...
 
void register_alert_status_read_callback (read_callback_t app_read_cb)
 register the call back for reading alert status More...
 
void register_ringer_setting_notification_callback (notification_callback_t app_notify_cb)
 register the call back for notification of ringer setting More...
 
void register_ringer_setting_read_callback (read_callback_t app_read_cb)
 register the call back for reading ringer setting More...
 

Variables

notification_callback_t alert_status_notification_cb
 
read_callback_t alert_status_read_cb
 
static const ble_gap_event_cb_t pas_gap_handle
 
static const
ble_gatt_client_event_cb_t 
pas_gatt_client_handle
 
pas_service_handler_t pas_service_data
 
notification_callback_t ringer_setting_notification_cb
 
read_callback_t ringer_setting_read_cb
 

void pas_client_adv ( void  )

sets the advertisement data and triggers advertisement

Parameters
[in]none
Returns
none

References APP_PAS_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_disconnected_event_handler(), and main().

at_ble_status_t pas_client_char_read_response_handler ( void *  event_params)
at_ble_status_t pas_client_char_write_response_handler ( void *  event_params)
at_ble_status_t pas_client_disconnected_event_handler ( void *  params)

disconnected event handler invoked by ble manager

Parameters
[in]at_ble_disconnected_tcontains the disconnection info

References ALL_UNUSED, and AT_BLE_SUCCESS.

at_ble_status_t pas_client_enable_char_notification ( bool  char_id,
bool  enable 
)

invoked by ble manager for setting the notification of characteristics

Parameters
[in]char_idrepresents the characteristic,1 for alert status,0 for ringer setting
[in]enableweather notifications has to enabled or disabled.1 for enable 0 for disable
Returns
AT_BLE_SUCCESS for success or refer at_ble_err_status_t

References pas_service_handler::alert_status_desc, pas_service_handler::conn_handle, desc_info::desc_handle, pas_char_write_notification(), and pas_service_handler::ringer_setting_desc.

Referenced by pas_client_write_notifications().

void pas_client_init ( void *  params)

invoked by ble manager for initializing the profile

Parameters
[in]none
Returns
none

References AT_BLE_SUCCESS, ble_advertisement_data_set(), BLE_GAP_EVENT_TYPE, BLE_GATT_CLIENT_EVENT_TYPE, ble_mgr_events_callback_handler(), DBG_LOG, pas_data_init(), REGISTER_CALL_BACK, status, and UNUSED.

Referenced by main().

at_ble_status_t pas_client_read_alert_status_char ( void  )

invoked by app to read the alert status characteristic

invoked by ble manager to read the alert status characteristic

Returns
AT_BLE_SUCCESS for success or refer at_ble_err_status_t

References pas_service_handler::alert_status_char, pas_service_handler::conn_handle, pas_read_alert_status_char(), and char_info::value_handle.

Referenced by main().

at_ble_status_t pas_client_read_ringer_setting_char ( void  )

invoked by app to read the write status characteristic

invoked by ble manager to read the write status characteristic

Returns
AT_BLE_SUCCESS for success or refer at_ble_err_status_t

References pas_service_handler::conn_handle, pas_read_ringer_setting_char(), pas_service_handler::ringer_setting_char, and char_info::value_handle.

Referenced by main().

at_ble_status_t pas_client_service_discovery ( void *  params)

to perform the service discovery

Parameters
[in]connectionparameters
Returns
AT_BLE_SUCCESS for success and AT_BLE_FAILURE for failure
Precondition
Called after connection by the ble manager

References AT_BLE_SUCCESS, pas_service_handler::conn_handle, at_ble_connected_t::conn_status, at_ble_connected_t::handle, and pas_client_start_service_discovery().

at_ble_status_t pas_client_start_service_discovery ( void  )
at_ble_status_t pas_client_write_notifications ( void *  params)

invoked by ble manager for setting the notification

References ALL_UNUSED, AT_BLE_SUCCESS, DBG_LOG, pas_client_enable_char_notification(), and status.

Referenced by pas_client_discovery_complete_handler().

at_ble_status_t pas_client_write_ringer_control_point ( uint8_t  ringer)

invoked by app to read the write ringer control point characteristic

invoked by ble manager to read the write ringer control point characteristic

Returns
AT_BLE_SUCCESS for success or refer at_ble_err_status_t

References pas_service_handler::conn_handle, pas_char_set_ringer_control_point(), pas_service_handler::ringer_control_point_char, and char_info::value_handle.

Referenced by main().

void pas_data_init ( void  )

Referenced by pas_client_init().

void register_alert_status_notification_callback ( notification_callback_t  app_notify_cb)

register the call back for notification of alert status

Parameters
[in]notification_callback_ttype application callback
Returns
none

References alert_status_notification_cb.

Referenced by main().

void register_alert_status_read_callback ( read_callback_t  app_read_cb)

register the call back for reading alert status

Parameters
[in]read_callback_ttype application callback
Returns
none

References alert_status_read_cb.

Referenced by main().

void register_ringer_setting_notification_callback ( notification_callback_t  app_notify_cb)

register the call back for notification of ringer setting

Parameters
[in]notification_callback_ttype application callback
Returns
none

References ringer_setting_notification_cb.

Referenced by main().

void register_ringer_setting_read_callback ( read_callback_t  app_read_cb)

register the call back for reading ringer setting

Parameters
[in]read_callback_ttype application callback
Returns
none

References ringer_setting_read_cb.

Referenced by main().

const ble_gap_event_cb_t pas_gap_handle
static
Initial value:
= {
.encryption_status_changed = pas_client_write_notifications
}
at_ble_status_t pas_client_service_discovery(void *params)
to perform the service discovery
Definition: pas_client.c:181
at_ble_status_t pas_client_write_notifications(void *params)
invoked by ble manager for setting the notification
Definition: pas_client.c:510
at_ble_status_t pas_client_disconnected_event_handler(void *params)
disconnected event handler invoked by ble manager
Definition: pas_client.c:384
const ble_gatt_client_event_cb_t pas_gatt_client_handle
static
Initial value:
= {
.primary_service_found = pas_client_service_found_handler,
.characteristic_found = pas_client_characteristic_found_handler,
.characteristic_read_by_uuid_response = pas_client_char_read_response_handler,
.characteristic_write_response = pas_client_char_write_response_handler,
.notification_recieved = pas_client_notification_handler
}
at_ble_status_t pas_client_notification_handler(void *params)
invoked by ble manager on receiving notification
Definition: pas_client.c:397
at_ble_status_t pas_client_service_found_handler(void *params)
Service found handler invoked by ble manager.
Definition: pas_client.c:245
at_ble_status_t pas_client_descriptor_found_handler(void *param)
client descriptor found handler invoked by ble manager
Definition: pas_client.c:350
at_ble_status_t pas_client_char_write_response_handler(void *event_params)
invoked by ble manager for setting the write response handler
Definition: pas_client.c:418
at_ble_status_t pas_client_characteristic_found_handler(void *params)
characteristic found handler invoked by ble manager
Definition: pas_client.c:276
at_ble_status_t pas_client_char_read_response_handler(void *event_params)
called by the ble manager after receiving the read response event
Definition: pas_client.c:440
at_ble_status_t pas_client_discovery_complete_handler(void *params)
Discovery Complete handler invoked by ble manager.
Definition: pas_client.c:199
pas_service_handler_t pas_service_data