Microchip® Advanced Software Framework

time_info.c File Reference

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

Variables

ble_connected_dev_info_t ble_dev_info [BLE_MAX_DEVICE_CONNECTION]
 Peer Connected device info More...
 
static const ble_gap_event_cb_t ble_mgr_gap_handle
 
bonding_complete_t bonding_cb = NULL
 
gatt_cts_handler_t cts_handle
 CTS Service Handle. More...
 
uint8_t curr_char_data [CTS_READ_LENGTH]
 CTS Characteristic Value array. More...
 
volatile bool current_time_char_found = false
 
volatile bool Desc_found = false
 
uint8_t dst_char_data [DST_READ_LENGTH]
 Time with DST Characteristic Value array. More...
 
gatt_dst_handler_t dst_handle = {0, 0, 0, AT_BLE_INVALID_PARAM, NULL}
 Next DST Change Service Handle. More...
 
volatile bool local_time_char_found = false
 
uint8_t lti_char_data [CTS_READ_LENGTH]
 CTS Characteristic Value array. More...
 
read_response_callback_t read_response_callback = NULL
 
volatile bool ref_time_char_found = false
 
uint8_t rti_char_data [CTS_READ_LENGTH]
 CTS Characteristic Value array. More...
 
gatt_rtu_handler_t rtu_handle = {0, 0, AT_BLE_INVALID_PARAM, 0, NULL, 0, NULL}
 Reference Time Update Service Handle. More...
 
static at_ble_handle_t time_info_conn_handle = 0
 
static const
ble_gatt_client_event_cb_t 
time_info_gatt_client_handle
 
volatile bool time_update_cp_char_found = false
 
volatile bool time_update_state_char_found = false
 
volatile bool time_with_dst_char_found = false
 
uint8_t tp_control_char_data [RTU_TP_CP_READ_LENGTH]
 Time Update Control Point Characteristic Value array. More...
 
uint8_t tp_state_char_data [RTU_TP_CP_READ_LENGTH]
 Time Update State Characteristic Value array. 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, NULL, and status.

Referenced by time_info_init().

at_ble_status_t time_info_connected_state_handler ( void *  param)

Handler for connection event.

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

References AT_BLE_FAILURE, AT_BLE_SUCCESS, ble_send_slave_sec_request(), at_ble_connected_t::conn_status, DBG_LOG, DBG_LOG_DEV, at_ble_connected_t::handle, and status.

at_ble_status_t time_info_descriptor_found_handler ( void *  param)
void time_info_encryption_status_changed_handler ( at_ble_encryption_status_changed_t param)

Handler for AT_BLE_ENCRYPTION_STATUS_CHANGED event from stack.

Parameters
[in]paramat_ble_encryption_status_changed_t
Returns
None

References bonding_cb, and UNUSED.

at_ble_status_t time_info_pair_done_handler ( void *  param)

Handler for AT_BLE_PAIR_DONE event from stack.

Parameters
[in]pair_done_paramat_ble_pair_done_t
Returns
at_ble_status_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.

Parameters
[in]read_response_cbcallback of application read_response_callback_t
Returns
None

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.

Parameters
[in]read_response_cbcallback of application read_response_callback_t
Returns
None

References read_response_callback.

at_ble_status_t time_info_service_discover ( void *  param)

Discovering the services of time server.

Parameters
[in]connectionparameter 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  )
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().

Peer Connected device info

Peer Connected device info

Parameters
[in]scan_paramgatt service information
Returns
none
const ble_gap_event_cb_t ble_mgr_gap_handle
static
Initial value:
= {
}
at_ble_status_t time_info_service_discover(void *param)
Discovering the services of time server.
Definition: time_info.c:203
at_ble_status_t time_info_disconnected_event_handler(void *param)
disconnected event handler invoked by ble manager
Definition: time_info.c:532
gatt_cts_handler_t cts_handle
Initial value:
0, NULL, 0, 0, NULL, 0, NULL}
#define NULL
Definition: def.h:47
Input Parameter invalid.
Definition: common/components/wifi/winc3400/ble/atmel_ble_api/include/at_ble_api.h:125

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

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.

at_ble_handle_t time_info_conn_handle = 0
static
const ble_gatt_client_event_cb_t time_info_gatt_client_handle
static
Initial value:
= {
.primary_service_found = time_info_service_found_handler,
.characteristic_found = time_info_characteristic_found_handler,
.discovery_complete = time_info_discovery_complete_handler,
.characteristic_read_by_uuid_response = time_info_characteristic_read_response
}
at_ble_status_t time_info_characteristic_found_handler(void *param)
characteristic found handler invoked by ble manager
Definition: time_info.c:412
at_ble_status_t time_info_characteristic_read_response(void *param)
time read response handler invoked by ble manager
Definition: time_info.c:474
at_ble_status_t time_info_discovery_complete_handler(void *param)
Discovery Complete handler invoked by ble manager.
Definition: time_info.c:295
at_ble_status_t time_info_service_found_handler(void *param)
Service found handler invoked by ble manager.
Definition: time_info.c:237
at_ble_status_t time_info_descriptor_found_handler(void *param)
characteristic found handler invoked by ble manager
Definition: time_info.c:394
volatile bool time_update_cp_char_found = false
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().