Microchip® Advanced Software Framework

blp_sensor_app.c File Reference

Blood Pressure Sensor Application.

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

#include <asf.h>
#include "platform.h"
#include "at_ble_api.h"
#include "console_serial.h"
#include "timer_hw.h"
#include "conf_extint.h"
#include "ble_manager.h"
#include "ble_utils.h"
#include "blp_sensor_app.h"
#include "blp_sensor.h"
#include "profiles.h"

Macros

#define APP_BUTTON_EVENT_ID   (2)
 
#define APP_INVALID_EVENT_ID   (0)
 
#define APP_TIMER_EVENT_ID   (1)
 

Functions

static at_ble_status_t app_connected_state_handler (void *params)
 app_connected_state profile notifies the application about state More...
 
static at_ble_status_t app_disconnected_state_handler (void *param)
 
static at_ble_status_t app_indication_confirmation_handler (void *params)
 app_indication_confirmation_handler called by ble manager to give the status of notification sent More...
 
static void app_indication_handler (bool enable)
 indication handler function called by the profile More...
 
static at_ble_status_t app_notification_confirmation_handler (void *params)
 app_notification_confirmation_handler called by ble manager to give the status of notification sent More...
 
static void app_notification_handler (bool enable)
 notification handler function called by the profile More...
 
static void blp_char_indication (void)
 sends the characteristic data for the profile to send indication More...
 
static void blp_char_notification (void)
 sends the characteristic data for profile to send notification More...
 
static at_ble_status_t blp_sensor_app_custom_event (void *param)
 
static void blp_value_update (uint8_t *data, uint8_t idx, uint16_t value, uint8_t value_type)
 blp_value_update which will change the blood pressure measurement operations More...
 
void button_cb (void)
 Button Press Callback. More...
 
int main (void)
 Heart Rate Sensor Application main function. More...
 
static void time_stamp_init (void)
 initializes the time stamp with default time stamp More...
 
static void timer_callback_handler (void)
 Timer callback handler called on timer expiry. More...
 
static void update_blp_sensor_value (void)
 
static void update_time_stamp (void)
 Updating the time stamp. More...
 

Variables

user_custom_event_t app_custom_event [2]
 
static const ble_gap_event_cb_t app_gap_handle
 
static const
ble_gatt_server_event_cb_t 
app_gatt_server_handle
 
volatile bool app_init_done = false
 
volatile bool app_state
 flag to check the app state More...
 
static const ble_custom_event_cb_t blp_sensor_custom_event_cb
 
uint16_t diastolic_val_kpa = DIASTOLIC_MIN_KPA
 current diastolic value in kpa More...
 
uint16_t diastolic_val_mmhg = DIASTOLIC_MIN_MMHG
 Current diastolic value in mmhg. More...
 
volatile bool indication_flag = APP_DEFAULT_VAL
 flag to send indication More...
 
volatile bool indication_sent = true
 flag to check if indication has been sent successfully over the air More...
 
uint16_t interim_diastolic_kpa = DIASTOLIC_MIN_KPA
 
uint16_t interim_diastolic_mmhg = DIASTOLIC_MIN_MMHG
 
uint16_t interim_map_kpa = MAP_MIN_KPA
 
uint16_t interim_map_mmhg = MAP_MIN_MMHG
 
uint16_t interim_systolic_kpa = SYSTOLIC_MIN_KPA
 
uint16_t interim_systolic_mmhg = SYSTOLIC_MIN_MMHG
 
uint16_t map_val_kpa = MAP_MIN_KPA
 current map value in kpa More...
 
uint16_t map_val_mmhg = MAP_MIN_MMHG
 Current map value in mmhg. More...
 
volatile bool notification_flag = APP_DEFAULT_VAL
 flag to send notifications More...
 
volatile bool notification_sent = true
 flag to check if notification has been sent successfully over the air More...
 
volatile bool notify = 0
 flag to send one notification for one second More...
 
volatile int8_t operator[9]={1, 1, 1, 1, 1, 1, 1, 1, 1}
 flags for reversing the direction of characteristic* change for indication More...
 
uint16_t pulse_rate_val = PULSE_RATE_MIN
 Current pulse rate value in kpa. More...
 
uint16_t systolic_val_kpa = SYSTOLIC_MIN_KPA
 Current systolic in kpa. More...
 
uint16_t systolic_val_mmhg = SYSTOLIC_MIN_MMHG
 Current systolic value in mmhg. More...
 
prf_date_time_t time_stamp
 Current time stamp. More...
 
volatile uint8_t timer_count = APP_DEFAULT_VAL
 Counter to maintain interval of indication. More...
 
volatile bool units = APP_DEFAULT_VAL
 Flag to change the events from mmgh to kpa and vice versa. More...
 
volatile bool user_request_flag = APP_DEFAULT_VAL
 Flag to identify user request for indication and notification. More...
 

#define APP_BUTTON_EVENT_ID   (2)
#define APP_INVALID_EVENT_ID   (0)
#define APP_TIMER_EVENT_ID   (1)

static at_ble_status_t app_connected_state_handler ( void *  params)
static

app_connected_state profile notifies the application about state

Parameters
[in]connected

References ALL_UNUSED, app_state, and AT_BLE_SUCCESS.

static at_ble_status_t app_indication_confirmation_handler ( void *  params)
static

app_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

References AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, indication_sent, status, timer_count, and user_request_flag.

static void app_indication_handler ( bool  enable)
static

indication handler function called by the profile

Parameters
[in]enablewill give weather indication has to enabled or disabled.

References BLOOD_PRESSURE_PULSE_FLAG_MASK, BLP_DATA_LEN, blp_sensor_send_indication(), DBG_LOG, diastolic_val_kpa, diastolic_val_mmhg, indication_flag, map_val_kpa, map_val_mmhg, pulse_rate_val, systolic_val_kpa, systolic_val_mmhg, and units.

Referenced by main().

static at_ble_status_t app_notification_confirmation_handler ( void *  params)
static

app_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

References AT_BLE_SUCCESS, DBG_LOG_DEV, notification_sent, and status.

static void app_notification_handler ( bool  enable)
static

notification handler function called by the profile

Parameters
[in]enablewill give weather notification has to enabled or disabled.

References DBG_LOG, INDICATION_TIMER_VAL, notification_flag, and timer_count.

Referenced by main().

static void blp_char_indication ( void  )
static
static void blp_char_notification ( void  )
static

sends the characteristic data for profile to send notification

Units in mmhg

Units in kpa

Appending diastolic in kpa

Appending map in kpa

Appending User id

References BLOOD_PRESSURE_UNITS_FLAG_MASK, BLOOD_PRESSURE_USERID_FLAG_MASK, BLP_DATA_LEN, blp_sensor_send_notification(), blp_value_update(), DBG_LOG, INTERIM_SYS_KPA, INTERIM_SYS_MMHG, interim_systolic_kpa, interim_systolic_mmhg, units, USERID_1, and USERID_2.

Referenced by update_blp_sensor_value().

static at_ble_status_t blp_sensor_app_custom_event ( void *  param)
static
static void blp_value_update ( uint8_t *  data,
uint8_t  idx,
uint16_t  value,
uint8_t  value_type 
)
static

blp_value_update which will change the blood pressure measurement operations

Parameters
[in]datato which the blood pressure parameter value to be appended
[in]idxindex where the value has to be updated
[in]value_typewhich will determine which blood pressure parameter

References DIASTOLIC_KPA, DIASTOLIC_MAX_KPA, DIASTOLIC_MAX_MMHG, DIASTOLIC_MIN_KPA, DIASTOLIC_MIN_MMHG, DIASTOLIC_MMHG, INTERIM_SYS_KPA, INTERIM_SYS_MMHG, MAP_KPA, MAP_MAX_KPA, MAP_MAX_MMHG, MAP_MIN_KPA, MAP_MIN_MMHG, MAP_MMHG, PULSE_RATE, PULSE_RATE_MAX, PULSE_RATE_MIN, SYSTOLIC_KPA, SYSTOLIC_MAX_KPA, SYSTOLIC_MAX_MMHG, SYSTOLIC_MIN_KPA, SYSTOLIC_MIN_MMHG, and SYSTOLIC_MMHG.

Referenced by blp_char_indication(), and blp_char_notification().

void button_cb ( void  )

Button Press Callback.

References app_init_done, and at_ble_event_user_defined_post().

static void time_stamp_init ( void  )
static

initializes the time stamp with default time stamp

References prf_date_time::day, prf_date_time::month, and prf_date_time::year.

Referenced by main().

static void timer_callback_handler ( void  )
static

Timer callback handler called on timer expiry.

References at_ble_event_user_defined_post().

static void update_time_stamp ( void  )
static

user_custom_event_t app_custom_event[2]
Initial value:
= {
{
.bptr = NULL,
},
{
.bptr = NULL
}
}
#define NULL
Definition: def.h:47
#define APP_BUTTON_EVENT_ID
Definition: blp_sensor_app.c:173
#define APP_TIMER_EVENT_ID
Definition: blp_sensor_app.c:172
const ble_gap_event_cb_t app_gap_handle
static
Initial value:
= {
}
static at_ble_status_t app_disconnected_state_handler(void *param)
Definition: blp_sensor_app.c:288
static at_ble_status_t app_connected_state_handler(void *params)
app_connected_state profile notifies the application about state
Definition: blp_sensor_app.c:281
const ble_gatt_server_event_cb_t app_gatt_server_handle
static
Initial value:
= {
.notification_confirmed = app_notification_confirmation_handler,
.indication_confirmed = app_indication_confirmation_handler
}
static at_ble_status_t app_indication_confirmation_handler(void *params)
app_indication_confirmation_handler called by ble manager to give the status of notification sent ...
Definition: blp_sensor_app.c:410
static at_ble_status_t app_notification_confirmation_handler(void *params)
app_notification_confirmation_handler called by ble manager to give the status of notification sent ...
Definition: blp_sensor_app.c:391
volatile bool app_init_done = false
volatile bool app_state

flag to check the app state

const ble_custom_event_cb_t blp_sensor_custom_event_cb
static
Initial value:
= {
}
static at_ble_status_t blp_sensor_app_custom_event(void *param)
Definition: blp_sensor_app.c:760
uint16_t diastolic_val_kpa = DIASTOLIC_MIN_KPA

current diastolic value in kpa

Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().

uint16_t diastolic_val_mmhg = DIASTOLIC_MIN_MMHG

Current diastolic value in mmhg.

Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().

volatile bool indication_sent = true

flag to check if indication has been sent successfully over the air

Referenced by app_disconnected_state_handler(), app_indication_confirmation_handler(), and update_blp_sensor_value().

uint16_t interim_diastolic_kpa = DIASTOLIC_MIN_KPA
uint16_t interim_diastolic_mmhg = DIASTOLIC_MIN_MMHG
uint16_t interim_map_kpa = MAP_MIN_KPA
uint16_t interim_map_mmhg = MAP_MIN_MMHG
uint16_t interim_systolic_kpa = SYSTOLIC_MIN_KPA
uint16_t interim_systolic_mmhg = SYSTOLIC_MIN_MMHG
uint16_t map_val_kpa = MAP_MIN_KPA
uint16_t map_val_mmhg = MAP_MIN_MMHG

Current map value in mmhg.

Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().

volatile bool notification_flag = APP_DEFAULT_VAL

flag to send notifications

flag to start notification

flag to show notification

volatile bool notification_sent = true

flag to check if notification has been sent successfully over the air

volatile bool notify = 0

flag to send one notification for one second

Referenced by app_disconnected_state_handler(), blp_sensor_app_custom_event(), and update_blp_sensor_value().

volatile int8_t operator[9]={1, 1, 1, 1, 1, 1, 1, 1, 1}

flags for reversing the direction of characteristic* change for indication

uint16_t pulse_rate_val = PULSE_RATE_MIN

Current pulse rate value in kpa.

Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().

uint16_t systolic_val_kpa = SYSTOLIC_MIN_KPA
uint16_t systolic_val_mmhg = SYSTOLIC_MIN_MMHG

Current systolic value in mmhg.

Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().

prf_date_time_t time_stamp

Current time stamp.

volatile bool units = APP_DEFAULT_VAL

Flag to change the events from mmgh to kpa and vice versa.

Referenced by app_disconnected_state_handler(), app_indication_handler(), blp_char_indication(), blp_char_notification(), and blp_sensor_app_custom_event().

volatile bool user_request_flag = APP_DEFAULT_VAL

Flag to identify user request for indication and notification.

Referenced by app_disconnected_state_handler(), app_indication_confirmation_handler(), blp_sensor_app_custom_event(), and update_blp_sensor_value().