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.
typedef struct button_state_t button_state_t |
Button state information.
|
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 |
Initialize the Eddystone application.
References app_error(), AT_BLE_SUCCESS, BLE_CUSTOM_EVENT_TYPE, BLE_GAP_EVENT_TYPE, BLE_GATT_SERVER_EVENT_TYPE, ble_mgr_events_callback_handler(), DBG_LOG, eddystone_init(), eddystone_uid_frame_send(), eddystone_url_frame_send(), esurl_conf_gap_cb, esurl_conf_gatt_server_cb, esurl_conf_service, esurl_conf_service_init(), and REGISTER_CALL_BACK.
Referenced by main().
|
static |
References APP_TIMER_EVENT_ID, AT_BLE_FAILURE, AT_BLE_SUCCESS, beacon_frame_type, DBG_LOG, EDDYSTONE_BEACON_MODE, eddystone_get_mode(), EDDYSTONE_IDLE_MODE, EDDYSTONE_URL, eddystone_url_frame_send(), ESURL_CONF_ADV_INTERVAL, esurl_conf_adv_start(), button_state_t::long_pressed, and reset_button_state().
int main | ( | void | ) |
Application main function.
References APP_TIMER_TIMEOUT_MS, AT30TSE_CONFIG_RES, AT30TSE_CONFIG_RES_12_bit, at30tse_init(), at30tse_write_config_register(), at_ble_get_adv_cnt(), AT_BLE_SUCCESS, beacon_frame_type, ble_device_init(), ble_event_task(), board_init(), DBG_LOG, eddystone_app_init(), EDDYSTONE_BEACON_MODE, eddystone_get_mode(), EDDYSTONE_TLM, eddystone_tlm_frame_send(), EDDYSTONE_UID, eddystone_uid_frame_send(), EDDYSTONE_URL, eddystone_url_frame_send(), hw_timer_init(), hw_timer_register_callback(), hw_timer_start_ms(), NULL, read_temperature_fix88(), serial_console_init(), system_init(), eddystone_tlm_data_t::temperature, timer_callback_handler(), uid_to_tlm_frame_ratio, UNUSED, and url_to_tlm_frame_ratio.
|
static |
Read temperature in 8:8 fixed point format.
References at30tse_read_temperature(), and FLOAT_2_FIX88.
Referenced by main().
|
static |
Reset the button state to idle.
References BUTTON_LONG_PRESS_INTERVAL_MS, button_state_t::long_press_interval_ms, button_state_t::long_pressed, and button_state_t::pressed.
Referenced by eddystone_custom_event(), and timer_callback_handler().
|
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] |
uint8_t beacon_frame_type = EDDYSTONE_URL |
Referenced by eddystone_custom_event(), and main().
|
static |
Initial button state values.
|
static |
|
static |
TLM data that needs to be updated for every TLM frame.
|
static |
UID to TLM frame ratio; Change this value to control the frequency of sending TLM frames.
Referenced by main().
|
static |
URL to TLM frame ratio; Change this value to control the frequency of sending TLM frames.
Referenced by main().