-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.c
108 lines (95 loc) · 3.92 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
/***************************************************************************//**
* @file main.c
* @brief Silicon Labs BT Mesh Sensor Client Example Project
* This example implements mesh sensor client node.
*******************************************************************************
* # License
* <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
*******************************************************************************
*
* The licensor of this software is Silicon Laboratories Inc. Your use of this
* software is governed by the terms of Silicon Labs Master Software License
* Agreement (MSLA) available at
* www.silabs.com/about-us/legal/master-software-license-agreement. This
* software is distributed to you in Source Code format and is governed by the
* sections of the MSLA applicable to Source Code.
*
******************************************************************************/
/* Board headers */
#include "init_mcu.h"
#include "init_board.h"
#include "init_app.h"
/* Bluetooth stack headers */
#include "gatt_db.h"
#include <mesh_sizes.h>
/* Device initialization header */
#include "hal-config.h"
/* Application code */
#include "src/app.h"
/***************************************************************************//**
* @addtogroup Application
* @{
******************************************************************************/
/***************************************************************************//**
* @addtogroup app
* @{
******************************************************************************/
/// Maximum number of simultaneous Bluetooth connections
#define MAX_CONNECTIONS 2
/// Heap for Bluetooth stack
uint8_t bluetooth_stack_heap[DEFAULT_BLUETOOTH_HEAP(MAX_CONNECTIONS) + BTMESH_HEAP_SIZE + 1760];
/// Bluetooth advertisement set configuration
///
/// At minimum the following is required:
/// * One advertisement set for Bluetooth LE stack (handle number 0)
/// * One advertisement set for Mesh data (handle number 1)
/// * One advertisement set for Mesh unprovisioned beacons (handle number 2)
/// * One advertisement set for Mesh unprovisioned URI (handle number 3)
/// * N advertisement sets for Mesh GATT service advertisements
/// (one for each network key, handle numbers 4 .. N+3)
///
#define MAX_ADVERTISERS (4 + MESH_CFG_MAX_NETKEYS)
/// Priorities for bluetooth link layer operations
static gecko_bluetooth_ll_priorities linklayer_priorities = GECKO_BLUETOOTH_PRIORITIES_DEFAULT;
/// Bluetooth stack configuration
static gecko_configuration_t config =
{
.bluetooth.max_connections = MAX_CONNECTIONS,
.bluetooth.max_advertisers = MAX_ADVERTISERS,
.bluetooth.heap = bluetooth_stack_heap,
.bluetooth.heap_size = sizeof(bluetooth_stack_heap) - BTMESH_HEAP_SIZE,
.bluetooth.sleep_clock_accuracy = 100,
.bluetooth.linklayer_priorities = &linklayer_priorities,
.gattdb = &bg_gattdb_data,
.btmesh_heap_size = BTMESH_HEAP_SIZE,
#if (HAL_PA_ENABLE)
.pa.config_enable = 1, // Set this to be a valid PA config
#if defined(FEATURE_PA_INPUT_FROM_VBAT)
.pa.input = GECKO_RADIO_PA_INPUT_VBAT, // Configure PA input to VBAT
#else
.pa.input = GECKO_RADIO_PA_INPUT_DCDC,
#endif // defined(FEATURE_PA_INPUT_FROM_VBAT)
#endif // (HAL_PA_ENABLE)
.max_timers = 16,
.rf.flags = GECKO_RF_CONFIG_ANTENNA, // Enable antenna configuration.
.rf.antenna = GECKO_RF_ANTENNA, // Select antenna path!
};
/***************************************************************************//**
* Main function.
******************************************************************************/
int main(void)
{
// Initialize device
initMcu();
// Initialize board
initBoard();
// Initialize application
initApp();
// Minimize advertisement latency by allowing the advertiser to always
// interrupt the scanner.
linklayer_priorities.scan_max = linklayer_priorities.adv_min + 1;
// Start application
appMain(&config);
}
/** @} (end addtogroup app) */
/** @} (end addtogroup Application) */