Microchip® Advanced Software Framework

htpt_app.c File Reference

Health Thermometer Profile Application.

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

#include <asf.h>
#include "profiles.h"
#include "platform.h"
#include "at_ble_api.h"
#include "htpt_app.h"
#include "console_serial.h"
#include "device_info.h"
#include "timer_hw.h"
#include "conf_extint.h"
#include "conf_serialdrv.h"
#include "at_ble_trace.h"
#include "ble_utils.h"
#include "ble_manager.h"

Macros

#define APP_BUTTON_PRESS_ID   (2)
 
#define APP_INVALID_EVENT_ID   (0)
 
#define APP_TIMER_EVENT_ID   (1)
 
#define BLE_DEVICE_NAME   "ATMEL-HTP"
 

Functions

static at_ble_status_t app_connected_event_handler (void *params)
 app_connected_state blemanager notifies the application about state More...
 
static at_ble_status_t app_disconnected_event_handler (void *params)
 app_connected_state ble manager notifies the application about state More...
 
static at_ble_status_t app_encryption_status_changed_handler (void *params)
 
static at_ble_status_t app_htpt_cfg_indntf_ind_handler (void *params)
 
static at_ble_status_t app_htpt_create_db_cfm_handler (void *params)
 
static at_ble_status_t app_htpt_disable_ind_handler (void *params)
 
static at_ble_status_t app_htpt_enable_rsp_handler (void *params)
 
static at_ble_status_t app_htpt_error_ind_handler (void *params)
 
static at_ble_status_t app_htpt_meas_intv_chg_ind_handler (void *params)
 
static at_ble_status_t app_htpt_meas_intv_upd_rsp (void *params)
 
static at_ble_status_t app_htpt_temp_send_cfm (void *params)
 
static at_ble_status_t app_htptp_meas_intv_chg_req (void *params)
 
static at_ble_status_t app_pair_done_event_handler (void *params)
 
static void ble_data_sent_confim (void)
 
void ble_device_config (at_ble_addr_t *addr)
 
static void ble_init (void)
 
void button_cb (void)
 
static void htp_init (void)
 
static void htp_init_defaults (htp_app_t *htp_temp)
 
static void htp_temperature_send (htp_app_t *htp_temp)
 
static at_ble_status_t htpt_custom_event (void *param)
 
void htpt_set_advertisement_data (void)
 
int main (void)
 
static void timer_callback_handler (void)
 
static void update_temperature_type_location (void)
 

Variables

at_ble_LTK_t app_bond_info
 
user_custom_event_t app_custom_event [2]
 
bool app_device_bond = false
 
uint8_t app_exec = true
 
static const ble_gap_event_cb_t app_gap_handle
 
static const ble_htpt_event_cb_t app_htpt_handle
 
volatile bool app_init_done = false
 
volatile bool app_timer_done = false
 
at_ble_auth_t auth_info
 
volatile bool button_pressed = false
 
dis_gatt_service_handler_t dis_service_handler
 device information service handler More...
 
htp_app_t htp_data
 
at_ble_handle_t htpt_conn_handle
 
static const ble_custom_event_cb_t HTPT_custom_event_cb
 
static uint8_t scan_rsp_data [SCAN_RESP_LEN] = {0x09, 0xFF, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8}
 
static const char * temp_measurement_loc []
 
bool temp_send_notification = false
 

#define APP_BUTTON_PRESS_ID   (2)

Referenced by htpt_custom_event().

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

Referenced by htpt_custom_event().

#define BLE_DEVICE_NAME   "ATMEL-HTP"

Referenced by ble_device_config().

static at_ble_status_t app_connected_event_handler ( void *  params)
static

app_connected_state blemanager notifies the application about state

Parameters
[in]at_ble_connected_t

References at_ble_addr_t::addr, at_ble_htpt_enable(), AT_BLE_SUCCESS, DBG_LOG, at_ble_connected_t::handle, HTPT_CFG_STABLE_MEAS_IND, and at_ble_connected_t::peer_addr.

static at_ble_status_t app_disconnected_event_handler ( void *  params)
static

app_connected_state ble manager notifies the application about state

Parameters
[in]connected

References APP_HT_ADV_TIMEOUT, APP_HT_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_SUCCESS, DBG_LOG, hw_timer_stop(), NULL, and temp_send_notification.

static at_ble_status_t app_htpt_cfg_indntf_ind_handler ( void *  params)
static
static at_ble_status_t app_htpt_create_db_cfm_handler ( void *  params)
static
static at_ble_status_t app_htpt_enable_rsp_handler ( void *  params)
static
static at_ble_status_t app_htpt_error_ind_handler ( void *  params)
static
static at_ble_status_t app_htpt_meas_intv_chg_ind_handler ( void *  params)
static
static at_ble_status_t app_htpt_meas_intv_upd_rsp ( void *  params)
static

References ALL_UNUSED, and AT_BLE_SUCCESS.

static at_ble_status_t app_htptp_meas_intv_chg_req ( void *  params)
static

References ALL_UNUSED, and AT_BLE_SUCCESS.

static void ble_data_sent_confim ( void  )
static

Referenced by app_htpt_temp_send_cfm().

static void ble_init ( void  )
static

References ble_device_init(), and NULL.

Referenced by main().

void button_cb ( void  )
static void timer_callback_handler ( void  )
static
static void update_temperature_type_location ( void  )
static

at_ble_LTK_t app_bond_info
user_custom_event_t app_custom_event[2]
Initial value:
= {
{
.bptr = NULL
},
{
.bptr = NULL
}
}
#define APP_TIMER_EVENT_ID
Definition: htpt_app.c:164
#define NULL
Definition: def.h:47
#define APP_BUTTON_PRESS_ID
Definition: htpt_app.c:165

Referenced by anp_custom_event(), and ble_observer_custom_event().

bool app_device_bond = false
uint8_t app_exec = true
const ble_gap_event_cb_t app_gap_handle
static
Initial value:
= {
.encryption_status_changed = app_encryption_status_changed_handler
}
static at_ble_status_t app_connected_event_handler(void *params)
app_connected_state blemanager notifies the application about state
Definition: htpt_app.c:328
static at_ble_status_t app_encryption_status_changed_handler(void *params)
Definition: htpt_app.c:418
static at_ble_status_t app_pair_done_event_handler(void *params)
Definition: htpt_app.c:384
static at_ble_status_t app_disconnected_event_handler(void *params)
app_connected_state ble manager notifies the application about state
Definition: htpt_app.c:357
const ble_htpt_event_cb_t app_htpt_handle
static
Initial value:
= {
.htpt_create_db_cfm = app_htpt_create_db_cfm_handler,
.htpt_error_ind = app_htpt_error_ind_handler,
.htpt_disable_ind = app_htpt_disable_ind_handler,
.htpt_temp_send_cfm = app_htpt_temp_send_cfm,
.htpt_meas_intv_chg_ind = app_htpt_meas_intv_chg_ind_handler,
.htpt_cfg_indntf_ind = app_htpt_cfg_indntf_ind_handler,
.htpt_enable_rsp = app_htpt_enable_rsp_handler,
.htpt_meas_intv_upd_rsp = app_htpt_meas_intv_upd_rsp,
.htpt_meas_intv_chg_req = app_htptp_meas_intv_chg_req
}
static at_ble_status_t app_htpt_enable_rsp_handler(void *params)
Definition: htpt_app.c:523
static at_ble_status_t app_htpt_meas_intv_upd_rsp(void *params)
Definition: htpt_app.c:535
static at_ble_status_t app_htpt_disable_ind_handler(void *params)
Definition: htpt_app.c:461
static at_ble_status_t app_htptp_meas_intv_chg_req(void *params)
Definition: htpt_app.c:541
static at_ble_status_t app_htpt_temp_send_cfm(void *params)
Definition: htpt_app.c:474
static at_ble_status_t app_htpt_error_ind_handler(void *params)
Definition: htpt_app.c:450
static at_ble_status_t app_htpt_create_db_cfm_handler(void *params)
Definition: htpt_app.c:440
static at_ble_status_t app_htpt_cfg_indntf_ind_handler(void *params)
Definition: htpt_app.c:505
static at_ble_status_t app_htpt_meas_intv_chg_ind_handler(void *params)
Definition: htpt_app.c:496
volatile bool app_init_done = false
at_ble_auth_t auth_info
volatile bool button_pressed = false
dis_gatt_service_handler_t dis_service_handler

device information service handler

htp_app_t htp_data
at_ble_handle_t htpt_conn_handle

Referenced by htp_init().

const ble_custom_event_cb_t HTPT_custom_event_cb
static
Initial value:
= {
.custom_event = htpt_custom_event
}
static at_ble_status_t htpt_custom_event(void *param)
Definition: htpt_app.c:699
uint8_t scan_rsp_data[SCAN_RESP_LEN] = {0x09, 0xFF, 0x00, 0x06, 0xd6, 0xb2, 0xf0, 0x05, 0xf0, 0xf8}
static
const char* temp_measurement_loc[]
static
Initial value:
=
{"Armpit", "Body", "Ear", "Finger", "Gastro-intestinal Tract",
"Mouth", "Rectum","Toe","Tympanum"}

Referenced by htp_temperature_send().