Template project main file.
More...
This file contains a template for creating a new application. It has the code necessary to wakeup from button, advertise, get a connection restart advertising on disconnect and if no new connection created go back to system-off mode. It can easily be used as a starting point for creating a new application, the comments identified with 'YOUR_JOB' indicates where and how you can customize.
#define WAKEUP_BUTTON_PIN NRF6310_BUTTON_0 |
Button used to wake up the application.
#define DEVICE_NAME "Nordic_Template" |
Name of device. Will be included in the advertising data.
#define APP_ADV_INTERVAL 64 |
The advertising interval (in units of 0.625 ms. This value corresponds to 40 ms).
#define APP_ADV_TIMEOUT_IN_SECONDS 180 |
The advertising timeout (in units of seconds).
#define APP_TIMER_PRESCALER 0 |
Value of the RTC1 PRESCALER register.
#define APP_TIMER_MAX_TIMERS 2 |
Maximum number of simultaneously created timers.
#define APP_TIMER_OP_QUEUE_SIZE 4 |
Size of timer operation queues.
Minimum acceptable connection interval (0.5 seconds).
Maximum acceptable connection interval (1 second).
Connection supervisory timeout (4 seconds).
Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (15 seconds).
Time between each call to sd_ble_gap_conn_param_update after the first (5 seconds).
#define MAX_CONN_PARAMS_UPDATE_COUNT 3 |
Number of attempts before giving up the connection parameter negotiation.
#define APP_GPIOTE_MAX_USERS 1 |
Maximum number of users of the GPIOTE handler.
Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks).
#define SEC_PARAM_TIMEOUT 30 |
Timeout for Pairing Request or Security Request (in seconds).
Man In The Middle protection not required.
Out Of Band data not available.
#define SEC_PARAM_MIN_KEY_SIZE 7 |
Minimum encryption key size.
#define SEC_PARAM_MAX_KEY_SIZE 16 |
Maximum encryption key size.
#define DEAD_BEEF 0xDEADBEEF |
Value used as error code on stack dump, can be used to identify stack location on stack unwind.
#define SCHED_MAX_EVENT_DATA_SIZE sizeof(app_timer_event_t) |
Maximum size of scheduler events. Note that scheduler BLE stack events do not contain any data, as the events are being pulled from the stack in the event handler.
#define SCHED_QUEUE_SIZE 10 |
Maximum number of events in the scheduler queue.
void app_error_handler |
( |
uint32_t |
error_code, |
|
|
uint32_t |
line_num, |
|
|
const uint8_t * |
p_file_name |
|
) |
| |
- Warning
- This handler is an example only and does not fit a final product. You need to analyze how your product is supposed to react in case of error.
- Parameters
-
[in] | error_code | Error code supplied to the handler. |
[in] | line_num | Line number where the handler is called. |
[in] | p_file_name | Pointer to the file name. |
void assert_nrf_callback |
( |
uint16_t |
line_num, |
|
|
const uint8_t * |
p_file_name |
|
) |
| |
This function will be called in case of an assert in the SoftDevice.
- Warning
- This handler is an example only and does not fit a final product. You need to analyze how your product is supposed to react in case of Assert.
-
On assert from the SoftDevice, the system can only recover on reset.
- Parameters
-
[in] | line_num | Line number of the failing ASSERT call. |
[in] | file_name | File name of the failing ASSERT call. |
static void leds_init |
( |
void |
| ) |
|
|
static |
A pointer to this function will be passed to each service which may need to inform the application about an error.
- Parameters
-
[in] | nrf_error | Error code containing information about what went wrong.Function for the LEDs initialization. |
Initializes all LEDs used by the application.
static void timers_init |
( |
void |
| ) |
|
|
static |
Initializes the timer module.
static void gap_params_init |
( |
void |
| ) |
|
|
static |
This function shall be used to setup all the necessary GAP (Generic Access Profile) parameters of the device. It also sets the permissions and appearance.
static void advertising_init |
( |
void |
| ) |
|
|
static |
Encodes the required advertising data and passes it to the stack. Also builds a structure to be passed to the stack when starting advertising.
This function will be called for all events in the Connection Parameters Module which are passed to the application.
- Note
- All this function does is to disconnect. This could have been done by simply setting the disconnect_on_fail config parameter, but instead we use the event handler mechanism to demonstrate its use.
- Parameters
-
[in] | p_evt | Event received from the Connection Parameters Module. |
static void conn_params_error_handler |
( |
uint32_t |
nrf_error | ) |
|
|
static |
- Parameters
-
[in] | nrf_error | Error code containing information about what went wrong. |
static void on_ble_evt |
( |
ble_evt_t * |
p_ble_evt | ) |
|
|
static |
- Parameters
-
[in] | p_ble_evt | Bluetooth stack event. |
static void ble_evt_dispatch |
( |
ble_evt_t * |
p_ble_evt | ) |
|
|
static |
This function is called from the scheduler in the main loop after a BLE stack event has been received.
- Parameters
-
[in] | p_ble_evt | Bluetooth stack event. |
static void ble_stack_init |
( |
void |
| ) |
|
|
static |
Initializes the SoftDevice and the BLE event interrupt.
Security requirements for this application.
Handle of the current connection.