nRF51 SDK - S130 SoftDevice
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Current Time Service client

Current Time Service client module. More...

Data Structures

struct  day_date_time_t
 "Day Date Time" field of the "Exact Time 256" field of the Current Time Characteristic. More...
 
struct  exact_time_256_t
 "Exact Time 256" field of the Current Time Characteristic. More...
 
struct  adjust_reason_t
 "Adjust Reason" field of the Current Time Characteristic. More...
 
struct  current_time_char_t
 Data structure for the Current Time Characteristic. More...
 
struct  ble_cts_c_evt_t
 Current Time Service client event. More...
 
struct  ble_cts_c_s
 Current Time Service client structure. This structure contains status information for the client. More...
 
struct  ble_cts_c_init_t
 Current Time Service client init structure. This structure contains all options and data needed for initialization of the client. More...
 

Typedefs

typedef struct ble_cts_c_s ble_cts_c_t
 
typedef void(* ble_cts_c_evt_handler_t )(ble_cts_c_t *p_cts, ble_cts_c_evt_t *p_evt)
 Current Time Service client event handler type.
 

Enumerations

enum  ble_cts_c_evt_type_t {
  BLE_CTS_C_EVT_SERVICE_NOT_FOUND,
  BLE_CTS_C_EVT_DISCOVERY_COMPLETE,
  BLE_CTS_C_EVT_DISCONN_COMPLETE,
  BLE_CTS_C_EVT_CURRENT_TIME,
  BLE_CTS_C_EVT_INVALID_TIME
}
 Current Time Service client event type. More...
 

Functions

uint32_t ble_cts_c_init (ble_cts_c_t *p_cts, const ble_cts_c_init_t *p_cts_init)
 Function for initializing the Current Time Service client. More...
 
void ble_cts_c_on_ble_evt (ble_cts_c_t *p_cts, const ble_evt_t *p_ble_evt)
 Function for handling the application's BLE stack events. More...
 
static __INLINE bool ble_cts_c_is_cts_discovered (const ble_cts_c_t *p_cts)
 Function for checking whether the peer's Current Time Service instance and the Current Time Characteristic have been discovered. More...
 
uint32_t ble_cts_c_current_time_read (ble_cts_c_t const *p_cts)
 Function for reading the peer's Current Time Service Current Time Characteristic. More...
 

Detailed Description

Current Time Service client module.

This module implements the Current Time Service (CTS) client-peripheral role of the Time Profile. After security is established, the module tries to discover the Current Time Service and Characteristic on the central side. If this succeeds, the application can trigger a read of the current time from the connected server.

The module informs the application about a successful discovery using the BLE_CTS_C_EVT_DISCOVERY_COMPLETE event. The application can then use the function ble_cts_c_current_time_read to read the current time. Calling this function triggers either a BLE_CTS_C_EVT_CURRENT_TIME event or a BLE_CTS_C_EVT_INVALID_TIME event, which is sent to the application. The current time is then available in the params field of the passed ble_cts_evt_t structure.

Note
The application must propagate BLE stack events to this module by calling ble_cts_c_on_ble_evt() from the SoftDevice Event Handler callback function.

Enumeration Type Documentation

Current Time Service client event type.

Enumerator
BLE_CTS_C_EVT_SERVICE_NOT_FOUND 

The Current Time Service was not found at the peer.

BLE_CTS_C_EVT_DISCOVERY_COMPLETE 

The Current Time Service was found at the peer.

BLE_CTS_C_EVT_DISCONN_COMPLETE 

Event indicating that the Current Time Service client module has finished processing the BLE_GAP_EVT_DISCONNECTED event. This event is raised only if a valid instance of the Current Time Service was found at the server. The event can be used by the application to do clean up related to the Current Time Service client.

BLE_CTS_C_EVT_CURRENT_TIME 

A new current time reading has been received.

BLE_CTS_C_EVT_INVALID_TIME 

The current time value received from the peer is invalid.

Function Documentation

uint32_t ble_cts_c_current_time_read ( ble_cts_c_t const *  p_cts)

Function for reading the peer's Current Time Service Current Time Characteristic.

Parameters
[in]p_ctsCurrent Time Service client structure.
Return values
NRF_SUCCESSIf the operation is successful. Otherwise, an error code is returned.
uint32_t ble_cts_c_init ( ble_cts_c_t p_cts,
const ble_cts_c_init_t p_cts_init 
)

Function for initializing the Current Time Service client.

This function must be used by the application to initialize the Current Time Service client.

Parameters
[out]p_ctsCurrent Time Service client structure. This structure must be supplied by the application. It is initialized by this function and can later be used to identify this particular client instance.
[in]p_cts_initInformation needed to initialize the Current Time Service client.
Return values
NRF_SUCCESSIf the service was initialized successfully.
static __INLINE bool ble_cts_c_is_cts_discovered ( const ble_cts_c_t p_cts)
static

Function for checking whether the peer's Current Time Service instance and the Current Time Characteristic have been discovered.

Parameters
[in]p_ctsCurrent Time Service client structure.
void ble_cts_c_on_ble_evt ( ble_cts_c_t p_cts,
const ble_evt_t p_ble_evt 
)

Function for handling the application's BLE stack events.

This function handles all events from the BLE stack that are of interest to the Current Time Service client. This is a callback function that must be dispatched from main application context.

Parameters
[in]p_ctsCurrent Time Service client structure.
[in]p_ble_evtEvent received from the BLE stack.