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) |
Referenced by blp_sensor_app_custom_event().
#define APP_INVALID_EVENT_ID (0) |
#define APP_TIMER_EVENT_ID (1) |
Referenced by blp_sensor_app_custom_event().
|
static |
app_connected_state profile notifies the application about state
[in] | connected |
References ALL_UNUSED, app_state, and AT_BLE_SUCCESS.
|
static |
References ALL_UNUSED, APP_DEFAULT_VAL, app_state, AT_BLE_SUCCESS, blp_sensor_adv(), DIASTOLIC_MIN_KPA, DIASTOLIC_MIN_MMHG, diastolic_val_kpa, diastolic_val_mmhg, indication_flag, indication_sent, interim_diastolic_kpa, interim_diastolic_mmhg, interim_map_kpa, interim_map_mmhg, interim_systolic_kpa, interim_systolic_mmhg, MAP_MIN_KPA, MAP_MIN_MMHG, map_val_kpa, map_val_mmhg, notification_flag, notification_sent, notify, PULSE_RATE_MIN, pulse_rate_val, SYSTOLIC_MIN_KPA, SYSTOLIC_MIN_MMHG, systolic_val_kpa, systolic_val_mmhg, timer_count, units, and user_request_flag.
|
static |
app_indication_confirmation_handler called by ble manager to give the status of notification sent
[in] | at_ble_cmd_complete_event_t | address of the cmd completion |
References AT_BLE_SUCCESS, DBG_LOG, DBG_LOG_DEV, indication_sent, status, timer_count, and user_request_flag.
|
static |
indication handler function called by the profile
[in] | enable | will 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 |
app_notification_confirmation_handler called by ble manager to give the status of notification sent
[in] | at_ble_cmd_complete_event_t | address of the cmd completion |
References AT_BLE_SUCCESS, DBG_LOG_DEV, notification_sent, and status.
|
static |
notification handler function called by the profile
[in] | enable | will give weather notification has to enabled or disabled. |
References DBG_LOG, INDICATION_TIMER_VAL, notification_flag, and timer_count.
Referenced by main().
|
static |
sends the characteristic data for the profile to send indication
Blood pressure measurement flags
Units in mmhg
Units in kpa
Appending the flags for time stamp , pulse rate, user id , mm status
Appending User id
Appending Measurement status field
References BLOOD_PRESSURE_MMT_STATUS_FLAG_MASK, BLOOD_PRESSURE_PULSE_FLAG_MASK, BLOOD_PRESSURE_TIME_FLAG_MASK, BLOOD_PRESSURE_UNITS_FLAG_MASK, BLOOD_PRESSURE_USERID_FLAG_MASK, BLP_DATA_LEN, blp_sensor_send_indication(), blp_value_update(), prf_date_time::day, DBG_LOG, DBG_LOG_CONT, DIASTOLIC_KPA, DIASTOLIC_MMHG, diastolic_val_kpa, diastolic_val_mmhg, prf_date_time::hour, MAP_KPA, MAP_MMHG, map_val_kpa, map_val_mmhg, prf_date_time::min, prf_date_time::month, PULSE_RATE, pulse_rate_val, prf_date_time::sec, SYSTOLIC_KPA, SYSTOLIC_MMHG, systolic_val_kpa, systolic_val_mmhg, units, USERID_1, USERID_2, and prf_date_time::year.
Referenced by update_blp_sensor_value().
|
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 |
For changing the units for each button press
To trigger the blood pressure indication
References APP_BUTTON_EVENT_ID, app_state, APP_TIMER_EVENT_ID, AT_BLE_FAILURE, AT_BLE_SUCCESS, DBG_LOG, indication_flag, notification_flag, notify, status, timer_count, units, update_blp_sensor_value(), update_time_stamp(), and user_request_flag.
|
static |
blp_value_update which will change the blood pressure measurement operations
[in] | data | to which the blood pressure parameter value to be appended |
[in] | idx | index where the value has to be updated |
[in] | value_type | which 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().
int main | ( | void | ) |
Heart Rate Sensor Application main function.
Initializing the application time stamp
Start the timer
References app_indication_handler(), app_init_done, app_notification_handler(), BLE_CUSTOM_EVENT_TYPE, ble_device_init(), ble_event_task(), BLE_GAP_EVENT_TYPE, BLE_GATT_SERVER_EVENT_TYPE, ble_mgr_events_callback_handler(), blp_sensor_adv(), blp_sensor_init(), board_init(), DBG_LOG, hw_timer_init(), hw_timer_register_callback(), hw_timer_start(), NULL, register_blp_indication_handler(), register_blp_notification_handler(), REGISTER_CALL_BACK, serial_console_init(), system_init(), time_stamp_init(), timer_callback_handler(), and TIMER_INTERVAL.
|
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 |
Timer callback handler called on timer expiry.
References at_ble_event_user_defined_post().
|
static |
|
static |
Updating the time stamp.
References prf_date_time::day, DAY_MAX, prf_date_time::hour, HOUR_MAX, prf_date_time::min, MINUTE_MAX, prf_date_time::month, MONTH_MAX, prf_date_time::sec, SECOND_MAX, prf_date_time::year, and YEAR_MAX.
Referenced by blp_sensor_app_custom_event().
user_custom_event_t app_custom_event[2] |
|
static |
|
static |
volatile bool app_state |
flag to check the app state
|
static |
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_flag = APP_DEFAULT_VAL |
flag to send indication
Referenced by app_disconnected_state_handler(), app_indication_handler(), blp_sensor_app_custom_event(), and update_blp_sensor_value().
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 |
Referenced by app_disconnected_state_handler().
uint16_t interim_diastolic_mmhg = DIASTOLIC_MIN_MMHG |
Referenced by app_disconnected_state_handler().
uint16_t interim_map_kpa = MAP_MIN_KPA |
Referenced by app_disconnected_state_handler().
uint16_t interim_map_mmhg = MAP_MIN_MMHG |
Referenced by app_disconnected_state_handler().
uint16_t interim_systolic_kpa = SYSTOLIC_MIN_KPA |
Referenced by app_disconnected_state_handler(), and blp_char_notification().
uint16_t interim_systolic_mmhg = SYSTOLIC_MIN_MMHG |
Referenced by app_disconnected_state_handler(), and blp_char_notification().
uint16_t map_val_kpa = MAP_MIN_KPA |
current map value in kpa
Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().
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
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 |
Current systolic in kpa.
Referenced by app_disconnected_state_handler(), app_indication_handler(), and blp_char_indication().
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 uint8_t timer_count = APP_DEFAULT_VAL |
Counter to maintain interval of indication.
Referenced by app_disconnected_state_handler(), app_indication_confirmation_handler(), app_notification_handler(), blp_sensor_app_custom_event(), and update_blp_sensor_value().
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().