Microchip® Advanced Software Framework

blp_sensor.c File Reference

Blood Pressure Sensor Profile.

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

#include <asf.h>
#include <string.h>
#include "timer_hw.h"
#include "at_ble_api.h"
#include "ble_manager.h"
#include "device_info.h"
#include "blood_pressure.h"
#include "blp_sensor.h"
#include "ble_utils.h"

Functions

void blp_disconnection (void)
 blp_disconnection called by the application to disconnect More...
 
at_ble_status_t blp_indication_confirmation_handler (void *params)
 blp_indication_confirmation_handler called by ble manager to give the status of notification sent More...
 
at_ble_status_t blp_notification_confirmation_handler (void *params)
 blp_notification_confirmation_handler called by ble manager to give the status of notification sent More...
 
void blp_sensor_adv (void)
 blp_sensor_adv starts advertisement More...
 
at_ble_status_t blp_sensor_char_changed_handler (void *char_handle)
 blp_sensor_char_changed_handler called by the ble manager after a change in the characteristic More...
 
at_ble_status_t blp_sensor_connected_state_handler (void *conn_params)
 blp_sensor_connected_state_handler called by ble manager after a change in characteristic More...
 
at_ble_status_t blp_sensor_disconnect_event_handler (void *disconnect)
 blp_sensor_disconnect_event_handler called by ble manager after disconnection event received More...
 
void blp_sensor_init (void *param)
 blp_sensor_init initializes and defines the services of the hr profile More...
 
void blp_sensor_send_indication (uint8_t *blp_data, uint8_t length)
 blp_sensor_send_indication adds the new characteristic value and sends the indication More...
 
void blp_sensor_send_notification (uint8_t *blp_data, uint8_t length)
 blp_sensor_send_notification adds the new characteristic value and sends the notification More...
 
void blp_sensor_service_define (void)
 blp_sensor_service_define defines the services of the profile More...
 
void blp_sensor_service_init (void)
 Initialization of profile services. More...
 
void register_blp_indication_handler (blp_indication_callback_t blp_indication_handler)
 register_blp_indication_handler registers the indication handler passed by the application More...
 
void register_blp_notification_handler (blp_notification_callback_t blp_notificaton_handler)
 register_blp_notification_handler registers the notification handler passed by the application More...
 

Variables

static const ble_gap_event_cb_t blp_sensor_gap_handle
 
static const
ble_gatt_server_event_cb_t 
blp_sensor_gatt_server_handle
 
blp_gatt_service_handler_t blp_service_handler
 blood pressure measurement service handler More...
 
at_ble_handle_t connection_handle
 contains the connection handle functions More...
 
dis_gatt_service_handler_t dis_service_handler
 device information service handler More...
 
blp_indication_callback_t indication_cb
 
blp_notification_callback_t notification_cb
 callback functions pointers contains the address of application functions More...
 
uint8_t scan_rsp_data [SCAN_RESP_LEN] = {0x09, 0xff, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8}
 Scan response data. More...
 

void blp_disconnection ( void  )

blp_disconnection called by the application to disconnect

References at_ble_disconnect(), AT_BLE_SUCCESS, AT_BLE_TERMINATED_BY_USER, connection_handle, DBG_LOG, and status.

Referenced by update_blp_sensor_value().

at_ble_status_t blp_indication_confirmation_handler ( void *  params)

blp_indication_confirmation_handler called by ble manager to give the status of notification sent

Parameters
[in]at_ble_cmd_complete_event_taddress of the cmd completion
Returns
AT_BLE_SUCCESS on success

References AT_BLE_SUCCESS, DBG_LOG_DEV, and at_ble_cmd_complete_event_t::status.

at_ble_status_t blp_notification_confirmation_handler ( void *  params)

blp_notification_confirmation_handler called by ble manager to give the status of notification sent

Parameters
[in]at_ble_cmd_complete_event_taddress of the cmd completion
Returns
AT_BLE_SUCCESS on success

References AT_BLE_SUCCESS, DBG_LOG_DEV, and at_ble_cmd_complete_event_t::status.

void blp_sensor_adv ( void  )

blp_sensor_adv starts advertisement

blp_sensor_adv adds the advertisement data of the profile and starts advertisement

References AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_SUCCESS, BLP_SENSOR_ADV_TIMEOUT, BLP_SENSOR_FAST_ADV, DBG_LOG, NULL, and status.

Referenced by app_disconnected_state_handler(), and main().

at_ble_status_t blp_sensor_char_changed_handler ( void *  char_handle)

blp_sensor_char_changed_handler called by the ble manager after a change in the characteristic

Parameters
[in]at_ble_characteristic_changed_twhich contains handle of characteristic and new value
Returns
AT_BLE_SUCCESS

References AT_BLE_SUCCESS, blp_char_change_handler(), BLP_INDICATION_DISABLE, BLP_INDICATION_ENABLE, BLP_NOTIFICATION_DISABLE, BLP_NOTIFICATION_ENABLE, indication_cb, and notification_cb.

at_ble_status_t blp_sensor_connected_state_handler ( void *  conn_params)

blp_sensor_connected_state_handler called by ble manager after a change in characteristic

Parameters
[in]at_ble_connected_twhich has connection handle and the peer device address

References AT_BLE_SUCCESS, and connection_handle.

at_ble_status_t blp_sensor_disconnect_event_handler ( void *  disconnect)

blp_sensor_disconnect_event_handler called by ble manager after disconnection event received

@param[in] at_ble_disconnected_t    which has connection handle and

reason for disconnection

References ALL_UNUSED, and AT_BLE_SUCCESS.

void blp_sensor_send_indication ( uint8_t *  blp_data,
uint8_t  length 
)

blp_sensor_send_indication adds the new characteristic value and sends the indication

Parameters
[in]blpthe new blp characteristic value needs to be updated
[in]lengthlength of new characteristic value

Updating the new characteristic value

Sending the indication for the updated characteristic

References at_ble_characteristic_value_set(), at_ble_indication_send(), AT_BLE_SUCCESS, at_ble_characteristic_t::char_val_handle, connection_handle, DBG_LOG, hr_gatt_service_handler::serv_chars, and status.

Referenced by app_indication_handler(), and blp_char_indication().

void blp_sensor_send_notification ( uint8_t *  blp_data,
uint8_t  length 
)

blp_sensor_send_notification adds the new characteristic value and sends the notification

blp_sensor_send_notification disconnects with the peer device called by the application

Parameters
[in]blp_datathe new hr characteristic value needs to be updated
[in]lengthlength of new characteristic value

Updating the new characteristic value

Sending the notification for the updated characteristic

References at_ble_characteristic_value_set(), at_ble_notification_send(), AT_BLE_SUCCESS, at_ble_characteristic_t::char_val_handle, connection_handle, DBG_LOG, hr_gatt_service_handler::serv_chars, and status.

Referenced by blp_char_notification().

void blp_sensor_service_define ( void  )

blp_sensor_service_define defines the services of the profile

References AT_BLE_SUCCESS, blp_primary_service_define(), DBG_LOG, dis_primary_service_define(), and status.

Referenced by blp_sensor_init().

void blp_sensor_service_init ( void  )

Initialization of profile services.

blp_sensor_service_init initializes the services of the profile

References blp_init_service(), and dis_init_service().

Referenced by blp_sensor_init().

void register_blp_indication_handler ( blp_indication_callback_t  blp_indication_handler)

register_blp_indication_handler registers the indication handler passed by the application

Parameters
[in]blp_indication_callback_taddress of the indication handler function to be called

References indication_cb.

Referenced by main().

void register_blp_notification_handler ( blp_notification_callback_t  blp_notificaton_handler)

register_blp_notification_handler registers the notification handler passed by the application

Parameters
[in]blp_notification_callback_taddress of the notification handler function to be called

References notification_cb.

Referenced by main().

const ble_gap_event_cb_t blp_sensor_gap_handle
static
Initial value:
= {
}
at_ble_status_t blp_sensor_connected_state_handler(void *conn_params)
blp_sensor_connected_state_handler called by ble manager after a change in characteristic ...
Definition: blp_sensor.c:264
at_ble_status_t blp_sensor_disconnect_event_handler(void *disconnect)
blp_sensor_disconnect_event_handler called by ble manager after disconnection event received ...
Definition: blp_sensor.c:252
const ble_gatt_server_event_cb_t blp_sensor_gatt_server_handle
static
Initial value:
= {
.notification_confirmed = blp_notification_confirmation_handler,
.indication_confirmed = blp_indication_confirmation_handler,
.characteristic_changed = blp_sensor_char_changed_handler
}
at_ble_status_t blp_notification_confirmation_handler(void *params)
blp_notification_confirmation_handler called by ble manager to give the status of notification sent ...
Definition: blp_sensor.c:121
at_ble_status_t blp_sensor_char_changed_handler(void *char_handle)
blp_sensor_char_changed_handler called by the ble manager after a change in the characteristic ...
Definition: blp_sensor.c:217
at_ble_status_t blp_indication_confirmation_handler(void *params)
blp_indication_confirmation_handler called by ble manager to give the status of notification sent ...
Definition: blp_sensor.c:139
blp_gatt_service_handler_t blp_service_handler

blood pressure measurement service handler

dis_gatt_service_handler_t dis_service_handler

device information service handler

blp_notification_callback_t notification_cb

callback functions pointers contains the address of application functions

Referenced by blp_sensor_char_changed_handler(), hr_sensor_char_changed_handler(), register_blp_notification_handler(), and register_hr_notification_handler().

uint8_t scan_rsp_data[SCAN_RESP_LEN] = {0x09, 0xff, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8}

Scan response data.