Time Information Profile.
Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
#include <string.h>
#include "at_ble_errno.h"
#include "at_ble_api.h"
#include "current_time.h"
#include "ble_manager.h"
#include "ble_utils.h"
#include "time_info.h"
#include "next_dst.h"
#include "reference_time.h"
Functions | |
void | time_info_adv () |
time info advertisement data and start of advertisement data More... | |
at_ble_status_t | time_info_characteristic_found_handler (void *param) |
characteristic found handler invoked by ble manager More... | |
at_ble_status_t | time_info_characteristic_read_response (void *param) |
time read response handler invoked by ble manager More... | |
at_ble_status_t | time_info_connected_state_handler (void *param) |
Handler for connection event. More... | |
at_ble_status_t | time_info_descriptor_found_handler (void *param) |
characteristic found handler invoked by ble manager More... | |
at_ble_status_t | time_info_disconnected_event_handler (void *param) |
disconnected event handler invoked by ble manager More... | |
at_ble_status_t | time_info_discovery_complete_handler (void *param) |
Discovery Complete handler invoked by ble manager. More... | |
void | time_info_encryption_status_changed_handler (at_ble_encryption_status_changed_t *param) |
Handler for AT_BLE_ENCRYPTION_STATUS_CHANGED event from stack. More... | |
void | time_info_init (void) |
Time Information profile initializations and setting of device in advertising mode. More... | |
at_ble_status_t | time_info_notification_handler (void *param) |
char notification received handler invoked by ble manager More... | |
at_ble_status_t | time_info_pair_done_handler (void *param) |
Handler for AT_BLE_PAIR_DONE event from stack. More... | |
void | time_info_register_bonding_callback (bonding_complete_t bonding_complete_cb) |
Application registering callback for both paired done event encryption status changed event. More... | |
void | time_info_register_read_response_callback (read_response_callback_t read_response_cb) |
Application registering callback for characteristic read response received. More... | |
at_ble_status_t | time_info_service_discover (void *param) |
Discovering the services of time server. More... | |
at_ble_status_t | time_info_service_discovery (void) |
Discovering the services of time server used by applications. More... | |
at_ble_status_t | time_info_service_found_handler (void *param) |
Service found handler invoked by ble manager. More... | |
void | time_info_write_notification_handler (uint16_t value) |
write notification handler invoked by ble manager More... | |
void time_info_adv | ( | void | ) |
time info advertisement data and start of advertisement data
setting time profile advertisement data and triggering of advertisement
References APP_TP_ADV_TIMEOUT, APP_TP_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_SUCCESS, ble_advertisement_data_set(), DBG_LOG, and NULL.
Referenced by time_info_init().
at_ble_status_t time_info_characteristic_found_handler | ( | void * | param | ) |
characteristic found handler invoked by ble manager
Handler for characteristic found event.
References AT_BLE_SUCCESS, at_ble_characteristic_found_t::char_handle, at_ble_characteristic_found_t::char_uuid, gatt_cts_handler::curr_char_handle, current_time_char_found, CURRENT_TIME_CHAR_UUID, DBG_LOG_PTS, gatt_cts_handler::desc_discovery, gatt_dst_handler::dst_char_handle, local_time_char_found, LOCAL_TIME_CHAR_UUID, gatt_cts_handler::lti_char_handle, at_ble_characteristic_found_t::properties, ref_time_char_found, REF_TIME_CHAR_UUID, gatt_cts_handler::rti_char_handle, time_update_cp_char_found, TIME_UPDATE_CP_CHAR_UUID, time_update_state_char_found, TIME_UPDATE_STATE_CHAR_UUID, time_with_dst_char_found, TIME_WITH_DST_CHAR_UUID, gatt_rtu_handler::tp_control_char_handle, gatt_rtu_handler::tp_state_char_handle, at_ble_uuid_t::uuid, and at_ble_characteristic_found_t::value_handle.
at_ble_status_t time_info_characteristic_read_response | ( | void * | param | ) |
time read response handler invoked by ble manager
Handler for characteristic read.
References at_ble_disconnect(), AT_BLE_GAP_TIMEOUT, AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, at_ble_characteristic_read_response_t::conn_handle, DBG_LOG, read_response_callback, at_ble_characteristic_read_response_t::status, tis_current_time_read_response(), tis_dst_change_read_response(), and tis_rtu_update_read_response().
at_ble_status_t time_info_connected_state_handler | ( | void * | param | ) |
Handler for connection event.
[in] | connected | event parameter containing details like handle |
References AT_BLE_FAILURE, AT_BLE_SUCCESS, ble_send_slave_sec_request(), at_ble_connected_t::conn_status, DBG_LOG, DBG_LOG_DEV, and at_ble_connected_t::handle.
at_ble_status_t time_info_descriptor_found_handler | ( | void * | param | ) |
characteristic found handler invoked by ble manager
Handler for descriptor found event.
References AT_BLE_SUCCESS, CTS_CLIENT_CHAR_DESCRIPTOR, gatt_cts_handler::curr_desc_handle, DBG_LOG_PTS, Desc_found, at_ble_descriptor_found_t::desc_handle, at_ble_descriptor_found_t::desc_uuid, and at_ble_uuid_t::uuid.
at_ble_status_t time_info_disconnected_event_handler | ( | void * | param | ) |
disconnected event handler invoked by ble manager
Handler for disconnection event.
References APP_TP_ADV_TIMEOUT, APP_TP_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_INVALID_PARAM, AT_BLE_SUCCESS, gatt_dst_handler::char_discovery, gatt_rtu_handler::char_discovery, gatt_cts_handler::char_discovery, current_time_char_found, DBG_LOG, gatt_cts_handler::desc_discovery, Desc_found, local_time_char_found, NULL, ref_time_char_found, time_update_cp_char_found, time_update_state_char_found, time_with_dst_char_found, and UNUSED.
at_ble_status_t time_info_discovery_complete_handler | ( | void * | param | ) |
Discovery Complete handler invoked by ble manager.
Handler for discovery complete event.
References at_ble_characteristic_discover_all(), at_ble_descriptor_discover_all(), at_ble_disconnect(), AT_BLE_DISCOVER_SUCCESS, AT_BLE_FAILURE, AT_BLE_INVALID_PARAM, AT_BLE_INVALID_STATE, AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, gatt_dst_handler::char_discovery, gatt_rtu_handler::char_discovery, gatt_cts_handler::char_discovery, at_ble_cmd_complete_event_t::conn_handle, DBG_LOG, DBG_LOG_DEV, gatt_cts_handler::desc_discovery, gatt_dst_handler::end_handle, gatt_rtu_handler::end_handle, gatt_cts_handler::end_handle, gatt_dst_handler::start_handle, gatt_rtu_handler::start_handle, gatt_cts_handler::start_handle, and at_ble_cmd_complete_event_t::status.
void time_info_encryption_status_changed_handler | ( | at_ble_encryption_status_changed_t * | param | ) |
Handler for AT_BLE_ENCRYPTION_STATUS_CHANGED event from stack.
[in] | param | at_ble_encryption_status_changed_t |
References bonding_cb, and UNUSED.
void time_info_init | ( | void | ) |
Time Information profile initializations and setting of device in advertising mode.
Initialize the Time information Profile.
References BLE_GAP_EVENT_TYPE, BLE_GATT_CLIENT_EVENT_TYPE, ble_mgr_events_callback_handler(), curr_char_data, gatt_cts_handler::curr_char_data, gatt_dst_handler::dst_char_data, dst_char_data, lti_char_data, gatt_cts_handler::lti_char_data, REGISTER_CALL_BACK, rti_char_data, gatt_cts_handler::rti_char_data, time_info_adv(), gatt_rtu_handler::tp_control_char_data, tp_control_char_data, gatt_rtu_handler::tp_state_char_data, and tp_state_char_data.
Referenced by main().
at_ble_status_t time_info_notification_handler | ( | void * | param | ) |
char notification received handler invoked by ble manager
Handler for notification received found event.
References AT_BLE_SUCCESS, at_ble_characteristic_read_response_t::char_handle, at_ble_notification_recieved_t::char_handle, at_ble_characteristic_read_response_t::char_len, at_ble_notification_recieved_t::char_len, at_ble_characteristic_read_response_t::char_value, at_ble_notification_recieved_t::char_value, tis_current_time_read_response(), tis_dst_change_read_response(), and tis_rtu_update_read_response().
at_ble_status_t time_info_pair_done_handler | ( | void * | param | ) |
Handler for AT_BLE_PAIR_DONE event from stack.
[in] | pair_done_param | at_ble_pair_done_t |
References AT_BLE_SUCCESS, bonding_cb, and UNUSED.
void time_info_register_bonding_callback | ( | bonding_complete_t | bonding_complete_cb | ) |
Application registering callback for both paired done event encryption status changed event.
[in] | read_response_cb | callback of application read_response_callback_t |
References bonding_cb.
void time_info_register_read_response_callback | ( | read_response_callback_t | read_response_cb | ) |
Application registering callback for characteristic read response received.
[in] | read_response_cb | callback of application read_response_callback_t |
References read_response_callback.
at_ble_status_t time_info_service_discover | ( | void * | param | ) |
Discovering the services of time server.
[in] | connection | parameter which includes the connection handle device address |
References AT_BLE_SUCCESS, at_ble_connected_t::conn_status, at_ble_connected_t::handle, time_info_conn_handle, and time_info_service_discovery().
at_ble_status_t time_info_service_discovery | ( | void | ) |
Discovering the services of time server used by applications.
References AT_BLE_FAILURE, at_ble_primary_service_discover_all(), AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, GATT_DISCOVERY_ENDING_HANDLE, GATT_DISCOVERY_STARTING_HANDLE, and time_info_conn_handle.
Referenced by time_info_service_discover(), and tip_app_custom_event().
at_ble_status_t time_info_service_found_handler | ( | void * | param | ) |
Service found handler invoked by ble manager.
Handler for service found event.
References AT_BLE_SUCCESS, AT_BLE_UUID_16, gatt_dst_handler::char_discovery, gatt_rtu_handler::char_discovery, gatt_cts_handler::char_discovery, CURRENT_TIME_SERVICE_UUID, DBG_LOG_PTS, gatt_dst_handler::end_handle, gatt_rtu_handler::end_handle, gatt_cts_handler::end_handle, at_ble_primary_service_found_t::end_handle, NEXT_DST_SERVICE_UUID, REFERENCE_TIME_SERVICE_UUID, at_ble_primary_service_found_t::service_uuid, gatt_dst_handler::start_handle, gatt_rtu_handler::start_handle, gatt_cts_handler::start_handle, at_ble_primary_service_found_t::start_handle, at_ble_uuid_t::type, and at_ble_uuid_t::uuid.
void time_info_write_notification_handler | ( | uint16_t | value | ) |
write notification handler invoked by ble manager
Handler for write notification found event.
References AT_BLE_SUCCESS, gatt_cts_handler::curr_desc_handle, DBG_LOG, Desc_found, and tis_current_time_noti().
Referenced by tip_app_custom_event().
ble_connected_dev_info_t ble_dev_info[BLE_MAX_DEVICE_CONNECTION] |
Peer Connected device info
Peer Connected device info
[in] | scan_param | gatt service information |
|
static |
bonding_complete_t bonding_cb = NULL |
gatt_cts_handler_t cts_handle |
CTS Service Handle.
uint8_t curr_char_data[CTS_READ_LENGTH] |
CTS Characteristic Value array.
Referenced by time_info_init().
uint8_t dst_char_data[DST_READ_LENGTH] |
Time with DST Characteristic Value array.
Referenced by time_info_init().
gatt_dst_handler_t dst_handle = {0, 0, 0, AT_BLE_INVALID_PARAM, NULL} |
Next DST Change Service Handle.
uint8_t lti_char_data[CTS_READ_LENGTH] |
CTS Characteristic Value array.
Referenced by time_info_init().
read_response_callback_t read_response_callback = NULL |
Referenced by time_info_characteristic_read_response(), and time_info_register_read_response_callback().
uint8_t rti_char_data[CTS_READ_LENGTH] |
CTS Characteristic Value array.
Referenced by time_info_init().
gatt_rtu_handler_t rtu_handle = {0, 0, AT_BLE_INVALID_PARAM, 0, NULL, 0, NULL} |
Reference Time Update Service Handle.
|
static |
Referenced by time_info_service_discover(), and time_info_service_discovery().
|
static |
Referenced by time_info_characteristic_found_handler(), and time_info_disconnected_event_handler().
uint8_t tp_control_char_data[RTU_TP_CP_READ_LENGTH] |
Time Update Control Point Characteristic Value array.
Referenced by time_info_init().
uint8_t tp_state_char_data[RTU_TP_CP_READ_LENGTH] |
Time Update State Characteristic Value array.
Referenced by time_info_init().