Microchip® Advanced Software Framework

battery_info.c File Reference

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)
#define BATTERY_MIN_LEVEL   (0)

static at_ble_status_t ble_char_changed_app_event ( void *  param)
static
static at_ble_status_t ble_connected_app_event ( void *  param)
static
static at_ble_status_t ble_enc_status_changed_app_event ( void *  param)
static
static at_ble_status_t ble_notification_confirmed_app_event ( void *  param)
static
static at_ble_status_t ble_paired_app_event ( void *  param)
static
void button_cb ( void  )
static void timer_callback_handler ( void  )
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
Initial value:
=
{
.bptr = NULL
}
#define NULL
Definition: nm_bsp.h:64
#define APP_TIMER_EVENT_ID
Definition: battery_info.c:154
bat_gatt_service_handler_t bas_service_handler
at_ble_handle_t bat_connection_handle
const ble_gap_event_cb_t battery_app_gap_cb
static
Initial value:
= {
.disconnected = ble_disconnected_app_event,
.pair_done = ble_paired_app_event,
.encryption_status_changed = ble_enc_status_changed_app_event
}
static at_ble_status_t ble_connected_app_event(void *param)
Definition: battery_info.c:258
static at_ble_status_t ble_enc_status_changed_app_event(void *param)
Definition: battery_info.c:217
static at_ble_status_t ble_disconnected_app_event(void *param)
Definition: battery_info.c:230
static at_ble_status_t ble_paired_app_event(void *param)
Definition: battery_info.c:204
const ble_gatt_server_event_cb_t battery_app_gatt_server_cb
static
Initial value:
= {
.notification_confirmed = ble_notification_confirmed_app_event,
.characteristic_changed = ble_char_changed_app_event
}
static at_ble_status_t ble_notification_confirmed_app_event(void *param)
Definition: battery_info.c:271
static at_ble_status_t ble_char_changed_app_event(void *param)
Definition: battery_info.c:283
const ble_custom_event_cb_t battery_custom_event_cb
static
Initial value:
= {
.custom_event = bat_custom_event
}
static at_ble_status_t bat_custom_event(void *param)
Definition: battery_info.c:304
bool volatile battery_flag = true

Referenced by bat_custom_event().