Microchip® Advanced Software Framework

multirole_peripheral_multiconnect.c File Reference

Multi-Role Peripheral Multi-connection Application.

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

#include <asf.h>
#include "platform.h"
#include "multirole_peripheral_multiconnect.h"
#include "console_serial.h"
#include "ble_manager.h"
#include "at_ble_api.h"
#include "find_me_locator.h"
#include "immediate_alert.h"
#include "timer_hw.h"
#include "conf_extint.h"
#include "battery.h"

Macros

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

Functions

at_ble_status_t app_connect_request (at_ble_scan_info_t *scan_buffer, uint8_t index)
 Connect to a peer device. More...
 
static uint16_t app_no_device_found_handler (void)
 
static at_ble_status_t bas_encryption_status_changed_app_event (void *param)
 
static at_ble_status_t bas_paired_app_event (void *param)
 
static at_ble_status_t bas_send_notification (void *param)
 
static at_ble_status_t battery_set_advertisement_data (void)
 
static at_ble_status_t battery_simulation_task (void *param)
 
static at_ble_status_t battery_start_advertisement (void)
 
static at_ble_status_t ble_adv_report_app_event (void *param)
 
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_notification_confirmed_app_event (void *param)
 
static at_ble_status_t ble_scan_report_app_event (void *param)
 Handles AT_BLE_SCAN_REPORT event from stack. More...
 
void button_cb (void)
 
static void fmp_simulation_task (void)
 
int main (void)
 
static at_ble_status_t multirole_app_custom_event (void *param)
 
static void rssi_update (at_ble_handle_t conn_handle)
 Check for Link Loss and Path Loss alert check for Low Alert value if crossed write Low Alert value to Immediate Alert Service. More...
 
static void simulate_battery_level (void)
 
static void timer_callback_handler (void)
 

Variables

fmp_locator_alert_level_t alert_level = FMP_NO_ALERT
 
user_custom_event_t app_custom_event [2]
 
volatile bool app_init_done = false
 
bas_app_state_t bas_app_info [BAS_MAX_DEVICE_CONNECTION]
 
bat_gatt_service_handler_t bas_service_handler
 
bool volatile bat_device_adv = false
 
bool volatile bat_timer_done = false
 
static const ble_gap_event_cb_t battery_app_gap_cb
 
static const
ble_gatt_server_event_cb_t 
battery_app_gatt_server_cb
 
uint8_t battery_level = BATTERY_MIN_LEVEL
 
bool volatile battery_level_flag = true
 
ble_connected_dev_info_t ble_dev_info [BLE_MAX_DEVICE_CONNECTION]
 Initialize the service with its included service, characteristics, and descriptors. More...
 
bool volatile findme_timer_done = false
 
fmp_app_state_t fmp_app_info
 
volatile fmp_scan_state_t fmp_app_scan_state = FMP_IDLE
 
uint8_t fmp_supp_scan_index [MAX_SCAN_DEVICE]
 
gatt_ias_char_handler_t ias_handle
 
static const ble_custom_event_cb_t multirole_custom_event_cb
 
at_ble_scan_info_t scan_info [MAX_SCAN_DEVICE]
 
volatile uint8_t scan_response_count
 

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

at_ble_status_t app_connect_request ( at_ble_scan_info_t scan_buffer,
uint8_t  index 
)
static uint16_t app_no_device_found_handler ( void  )
static
static at_ble_status_t battery_set_advertisement_data ( void  )
static
void button_cb ( void  )
static void fmp_simulation_task ( void  )
static
static void rssi_update ( at_ble_handle_t  conn_handle)
static

Check for Link Loss and Path Loss alert check for Low Alert value if crossed write Low Alert value to Immediate Alert Service.

High Alert value if crossed write High Alert value to IAS service

Parameters
[in]conn_handleConnection handle of a connected device

References alert_level, at_ble_rx_power_get(), AT_BLE_SUCCESS, gatt_ias_char_handler::char_handle, DBG_LOG, DBG_LOG_CONT, FMP_HIGH_ALERT, FMP_HIGH_ALERT_RANGE, FMP_LOW_ALERT_RANGE, FMP_MID_ALERT, FMP_NO_ALERT, ias_alert_level_write(), IAS_HIGH_ALERT, IAS_MID_ALERT, IAS_NO_ALERT, and rssi_power.

Referenced by fmp_simulation_task().

static void simulate_battery_level ( void  )
static
static void timer_callback_handler ( void  )
static

user_custom_event_t app_custom_event[2]
Initial value:
= {
{
.bptr = NULL,
},
{
.bptr = NULL
}
}
#define APP_TIMER_EVENT_ID
Definition: multirole_peripheral_multiconnect.c:67
#define APP_BUTTON_EVENT_ID
Definition: multirole_peripheral_multiconnect.c:68
#define NULL
Definition: nm_bsp.h:64
volatile bool app_init_done = false
Initial value:
#define BLE_INVALID_CONNECTION_HANDLE
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.h:636
Definition: multirole_peripheral_multiconnect.h:45
bat_gatt_service_handler_t bas_service_handler
bool volatile bat_timer_done = false
const ble_gap_event_cb_t battery_app_gap_cb
static
Initial value:
= {
.adv_report = ble_adv_report_app_event,
.scan_report = ble_scan_report_app_event,
.disconnected = ble_disconnected_app_event,
.pair_done = bas_paired_app_event,
.encryption_status_changed = bas_encryption_status_changed_app_event
}
static at_ble_status_t bas_encryption_status_changed_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:481
static at_ble_status_t ble_scan_report_app_event(void *param)
Handles AT_BLE_SCAN_REPORT event from stack.
Definition: multirole_peripheral_multiconnect.c:335
static at_ble_status_t ble_disconnected_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:502
static at_ble_status_t bas_paired_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:460
static at_ble_status_t ble_connected_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:168
static at_ble_status_t ble_adv_report_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:248
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_char_changed_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:618
static at_ble_status_t ble_notification_confirmed_app_event(void *param)
Definition: multirole_peripheral_multiconnect.c:596
uint8_t battery_level = BATTERY_MIN_LEVEL
bool volatile battery_level_flag = true

Referenced by simulate_battery_level().

Initialize the service with its included service, characteristics, and descriptors.

Parameters
[in]scan_paramgatt service information
Returns
none
bool volatile findme_timer_done = false
fmp_app_state_t fmp_app_info
Initial value:
= {{AT_BLE_ADDRESS_PUBLIC, {0x00,0x00,0x00,0x00,0x00,0x00}},
#define BLE_INVALID_CONNECTION_HANDLE
Definition: ble_sdk/ble_services/ble_mgr/ble_manager.h:636
a public static address
Definition: at_ble_api.h:697
uint8_t fmp_supp_scan_index[MAX_SCAN_DEVICE]
const ble_custom_event_cb_t multirole_custom_event_cb
static
Initial value:
= {
}
static at_ble_status_t multirole_app_custom_event(void *param)
Definition: multirole_peripheral_multiconnect.c:787
volatile uint8_t scan_response_count