Battery Information Service - Application.
Copyright (c) 2017-2018 Microchip Technology Inc. and its subsidiaries.
#include <asf.h>
#include "console_serial.h"
#include "at_ble_api.h"
#include "platform.h"
#include "battery.h"
#include "timer_hw.h"
#include "ble_utils.h"
#include "battery_info.h"
#include "ble_manager.h"
#include "conf_extint.h"
Macros | |
#define | APP_TIMER_EVENT_ID (1) |
#define | BATTERY_MAX_LEVEL (100) |
#define | BATTERY_MIN_LEVEL (0) |
#define | BATTERY_UPDATE_INTERVAL (1) |
Functions | |
static at_ble_status_t | bat_custom_event (void *param) |
static at_ble_status_t | battery_service_advertise (void) |
static at_ble_status_t | ble_char_changed_app_event (void *param) |
static at_ble_status_t | ble_connected_app_event (void *param) |
static at_ble_status_t | ble_disconnected_app_event (void *param) |
static at_ble_status_t | ble_enc_status_changed_app_event (void *param) |
static at_ble_status_t | ble_notification_confirmed_app_event (void *param) |
static at_ble_status_t | ble_paired_app_event (void *param) |
void | button_cb (void) |
int | main (void) |
Service Application main function More... | |
static void | timer_callback_handler (void) |
callback handler called on timer expiry More... | |
Variables | |
user_custom_event_t | app_timer_event |
bat_gatt_service_handler_t | bas_service_handler |
at_ble_handle_t | bat_connection_handle |
static const ble_gap_event_cb_t | battery_app_gap_cb |
static const ble_gatt_server_event_cb_t | battery_app_gatt_server_cb |
static const ble_custom_event_cb_t | battery_custom_event_cb |
bool volatile | battery_flag = true |
uint8_t | battery_level = BATTERY_MIN_LEVEL |
bool volatile | notification_flag = true |
bool volatile | timer_cb_done = false |
#define APP_TIMER_EVENT_ID (1) |
Referenced by bat_custom_event().
#define BATTERY_MAX_LEVEL (100) |
Referenced by bat_custom_event(), and simulate_battery_level().
#define BATTERY_MIN_LEVEL (0) |
Referenced by bat_custom_event(), and simulate_battery_level().
#define BATTERY_UPDATE_INTERVAL (1) |
|
static |
|
static |
References APP_BAS_ADV_TIMEOUT, APP_BAS_FAST_ADV, AT_BLE_ADV_FP_ANY, AT_BLE_ADV_GEN_DISCOVERABLE, at_ble_adv_start(), AT_BLE_ADV_TYPE_UNDIRECTED, AT_BLE_FAILURE, AT_BLE_SUCCESS, ble_advertisement_data_set(), DBG_LOG, and NULL.
Referenced by ble_disconnected_app_event(), and main().
|
static |
References AT_BLE_PRF_NTF_DISABLED, AT_BLE_SUCCESS, bat_char_changed_event(), and notification_flag.
|
static |
References ALL_UNUSED, AT_BLE_SUCCESS, bat_connection_handle, ble_paired_app_event(), and at_ble_connected_t::handle.
|
static |
|
static |
|
static |
References AT_BLE_SUCCESS, DBG_LOG_DEV, notification_flag, and at_ble_cmd_complete_event_t::status.
|
static |
References ALL_UNUSED, AT_BLE_SUCCESS, BATTERY_UPDATE_INTERVAL, hw_timer_start(), and at_ble_pair_done_t::status.
Referenced by ble_connected_app_event().
void button_cb | ( | void | ) |
int main | ( | void | ) |
Service Application main function
References AT_BLE_SUCCESS, bat_init_service(), bat_primary_service_define(), battery_level, battery_service_advertise(), BLE_CUSTOM_EVENT_TYPE, ble_device_init(), ble_event_task(), BLE_GAP_EVENT_TYPE, BLE_GATT_SERVER_EVENT_TYPE, ble_mgr_events_callback_handler(), ble_remove_bonding_info(), board_init(), DBG_LOG, hw_timer_init(), hw_timer_register_callback(), NULL, pds_module_init(), REGISTER_CALL_BACK, serial_console_init(), system_init(), and timer_callback_handler().
|
static |
callback handler called on timer expiry
References at_ble_event_user_defined_post(), and timer_cb_done.
user_custom_event_t app_timer_event |
bat_gatt_service_handler_t bas_service_handler |
at_ble_handle_t bat_connection_handle |
Referenced by bat_custom_event(), and ble_connected_app_event().
|
static |
|
static |
|
static |
Referenced by bat_custom_event().
uint8_t battery_level = BATTERY_MIN_LEVEL |
Referenced by app_disconnected_event_handler(), app_disconnected_state_handler(), app_notification_handler(), bat_custom_event(), ble_char_changed_app_event(), ble_disconnected_app_event(), ble_notification_confirmed_app_event(), blp_sensor_app_custom_event(), hr_sensor_app_custom_event(), timer_callback_handler(), and update_blp_sensor_value().
Referenced by bat_custom_event(), ble_disconnected_app_event(), l2cap_custom_event(), main(), and timer_callback_handler().