Microchip® Advanced Software Framework

app.c File Reference

Eddystone Beacon Application.

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

#include <asf.h>
#include <string.h>
#include "console_serial.h"
#include "platform.h"
#include "timer_hw.h"
#include "conf_extint.h"
#include "eddystone.h"

Data Structures

struct  button_state_t
 Button state information. More...
 

Macros

#define APP_BUTTON_EVENT_ID   (2)
 
#define APP_INVALID_EVENT_ID   (0)
 
#define APP_TIMER_EVENT_ID   (1)
 
#define APP_TIMER_TIMEOUT_MS   (100)
 Application timer timeout in ms. More...
 
#define APP_TYPE   (EDDYSTONE_URL_APP)
 Switch to compile two different Eddystone applications; One for UID+TLM frames and another for URL+TLM frames, the configuration service is enabled for the URL app. More...
 
#define BUTTON_LONG_PRESS_INTERVAL_MS   (3000)
 Button timeout to detect long press event. More...
 
#define EDDYSTONE_UID_APP   (0x02)
 
#define EDDYSTONE_URL_APP   (0x01)
 Define to support different Eddystone apps. More...
 

Typedefs

typedef struct button_state_t button_state_t
 Button state information. More...
 

Functions

static void app_error (void)
 Non-return function to handle fatal application error. More...
 
void button_cb (void)
 Button press callback handler. More...
 
static void eddystone_app_init (void)
 Initialize the Eddystone application. More...
 
static at_ble_status_t eddystone_custom_event (void *param)
 
int main (void)
 Application main function. More...
 
static int16_t read_temperature_fix88 (void)
 Read temperature in 8:8 fixed point format. More...
 
static void reset_button_state (void)
 Reset the button state to idle. More...
 
static void timer_callback_handler (void)
 Timer callback handler - called every 100ms. More...
 

Variables

user_custom_event_t app_custom_event [2]
 
uint8_t beacon_frame_type = EDDYSTONE_URL
 
static volatile button_state_t button_state
 Initial button state values. More...
 
static const ble_custom_event_cb_t eddystone_custom_event_cb
 
static eddystone_tlm_data_t tlm_data
 TLM data that needs to be updated for every TLM frame. More...
 
static const uint32_t uid_to_tlm_frame_ratio = 20
 UID to TLM frame ratio; Change this value to control the frequency of sending TLM frames. More...
 
static const uint32_t url_to_tlm_frame_ratio = 20
 URL to TLM frame ratio; Change this value to control the frequency of sending TLM frames. More...
 

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

Referenced by eddystone_custom_event().

#define APP_TIMER_TIMEOUT_MS   (100)

Application timer timeout in ms.

Referenced by main().

#define APP_TYPE   (EDDYSTONE_URL_APP)

Switch to compile two different Eddystone applications; One for UID+TLM frames and another for URL+TLM frames, the configuration service is enabled for the URL app.

#define BUTTON_LONG_PRESS_INTERVAL_MS   (3000)

Button timeout to detect long press event.

Referenced by reset_button_state().

#define EDDYSTONE_UID_APP   (0x02)
#define EDDYSTONE_URL_APP   (0x01)

Define to support different Eddystone apps.

Button state information.

static void app_error ( void  )
static

Non-return function to handle fatal application error.

References DBG_LOG.

Referenced by eddystone_app_init().

void button_cb ( void  )

Button press callback handler.

References button_state_t::pressed.

static int16_t read_temperature_fix88 ( void  )
static

Read temperature in 8:8 fixed point format.

References at30tse_read_temperature(), and FLOAT_2_FIX88.

Referenced by main().

static void reset_button_state ( void  )
static
static void timer_callback_handler ( void  )
static

Timer callback handler - called every 100ms.

It increments Eddystone 100ms counter and also times-out long press for the button

References at_ble_event_user_defined_post(), eddystone_100ms_counter, button_state_t::long_press_interval_ms, button_state_t::long_pressed, button_state_t::pressed, and reset_button_state().

user_custom_event_t app_custom_event[2]
Initial value:
= {
{
.bptr = NULL,
},
{
.bptr = NULL
}
}
#define APP_TIMER_EVENT_ID
Definition: app.c:176
#define APP_BUTTON_EVENT_ID
Definition: app.c:177
#define NULL
Definition: nm_bsp.h:64
uint8_t beacon_frame_type = EDDYSTONE_URL

Referenced by eddystone_custom_event(), and main().

volatile button_state_t button_state
static
Initial value:
= {
.pressed = 0,
.long_pressed = 0,
.long_press_interval_ms = BUTTON_LONG_PRESS_INTERVAL_MS,
}
#define BUTTON_LONG_PRESS_INTERVAL_MS
Button timeout to detect long press event.
Definition: app.c:164

Initial button state values.

const ble_custom_event_cb_t eddystone_custom_event_cb
static
Initial value:
= {
.custom_event = eddystone_custom_event
}
static at_ble_status_t eddystone_custom_event(void *param)
Definition: app.c:343
eddystone_tlm_data_t tlm_data
static
Initial value:
=
{
.battery_voltage_mV = 3300,
.temperature = FLOAT_2_FIX88(35.4),
}
#define FLOAT_2_FIX88(a)
Conversion between float and 8:8 fixed point format.
Definition: eddystone.h:85

TLM data that needs to be updated for every TLM frame.

const uint32_t uid_to_tlm_frame_ratio = 20
static

UID to TLM frame ratio; Change this value to control the frequency of sending TLM frames.

Referenced by main().

const uint32_t url_to_tlm_frame_ratio = 20
static

URL to TLM frame ratio; Change this value to control the frequency of sending TLM frames.

Referenced by main().