nRF51 SDK
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages

Proximity Sample Application main file. More...

Macros

#define SIGNAL_ALERT_BUTTON   NRF6310_BUTTON_0
 
#define BONDMNGR_DELETE_BUTTON_PIN_NO   NRF6310_BUTTON_1
 
#define ALERT_LEVEL_MILD_LED_PIN_NO   NRF6310_LED_2
 
#define ALERT_LEVEL_HIGH_LED_PIN_NO   NRF6310_LED_3
 
#define ADV_INTERVAL_SLOW_LED_PIN_NO   NRF6310_LED_4
 
#define PEER_SRV_DISC_LED_PIN_NO   NRF6310_LED_5
 
#define ADV_WHITELIST_LED_PIN_NO   NRF6310_LED_6
 
#define DEVICE_NAME   "Nordic_Prox"
 
#define APP_ADV_INTERVAL_FAST   0x0028
 
#define APP_ADV_INTERVAL_SLOW   0x0C80
 
#define APP_SLOW_ADV_TIMEOUT   180
 
#define APP_FAST_ADV_TIMEOUT   40
 
#define APP_FAST_ADV_WHITELIST_TIMEOUT   20
 
#define APP_TIMER_PRESCALER   0
 
#define APP_TIMER_MAX_TIMERS   3
 
#define APP_TIMER_OP_QUEUE_SIZE   4
 
#define BATTERY_LEVEL_MEAS_INTERVAL   APP_TIMER_TICKS(2000, APP_TIMER_PRESCALER)
 
#define MIN_BATTERY_LEVEL   81
 
#define MAX_BATTERY_LEVEL   100
 
#define BATTERY_LEVEL_INCREMENT   1
 
#define MIN_CONN_INTERVAL   MSEC_TO_UNITS(500, UNIT_1_25_MS)
 
#define MAX_CONN_INTERVAL   MSEC_TO_UNITS(1000, UNIT_1_25_MS)
 
#define SLAVE_LATENCY   0
 
#define CONN_SUP_TIMEOUT   MSEC_TO_UNITS(4000, UNIT_10_MS)
 
#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(20 * 1000, APP_TIMER_PRESCALER)
 
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5 * 1000, APP_TIMER_PRESCALER)
 
#define MAX_CONN_PARAMS_UPDATE_COUNT   3
 
#define APP_GPIOTE_MAX_USERS   1
 
#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)
 
#define SEC_PARAM_TIMEOUT   30
 
#define SEC_PARAM_BOND   1
 
#define SEC_PARAM_MITM   0
 
#define SEC_PARAM_IO_CAPABILITIES   BLE_GAP_IO_CAPS_NONE
 
#define SEC_PARAM_OOB   0
 
#define SEC_PARAM_MIN_KEY_SIZE   7
 
#define SEC_PARAM_MAX_KEY_SIZE   16
 
#define INITIAL_LLS_ALERT_LEVEL   BLE_CHAR_ALERT_LEVEL_NO_ALERT
 
#define TX_POWER_LEVEL   (-8)
 
#define FLASH_PAGE_SYS_ATTR   (BLE_FLASH_PAGE_END - 3)
 
#define FLASH_PAGE_BOND   (BLE_FLASH_PAGE_END - 1)
 
#define DEAD_BEEF   0xDEADBEEF
 
#define SIGNAL_ALERT_BUTTON   EVAL_BOARD_BUTTON_0
 
#define STOP_ALERTING_BUTTON   EVAL_BOARD_BUTTON_1
 
#define BONDMNGR_DELETE_BUTTON_PIN_NO   EVAL_BOARD_BUTTON_1
 
#define ALERT_PIN_NO   EVAL_BOARD_LED_1
 
#define DEVICE_NAME   "Nordic_Prox"
 
#define APP_ADV_INTERVAL_FAST   0x0028
 
#define APP_ADV_INTERVAL_SLOW   0x0C80
 
#define APP_SLOW_ADV_TIMEOUT   180
 
#define APP_FAST_ADV_TIMEOUT   30
 
#define APP_TIMER_PRESCALER   0
 
#define APP_TIMER_MAX_TIMERS   5
 
#define APP_TIMER_OP_QUEUE_SIZE   6
 
#define BATTERY_LEVEL_MEAS_INTERVAL   APP_TIMER_TICKS(120000, APP_TIMER_PRESCALER)
 
#define ADV_LED_ON_TIME   APP_TIMER_TICKS(100, APP_TIMER_PRESCALER)
 
#define ADV_LED_OFF_TIME   APP_TIMER_TICKS(900, APP_TIMER_PRESCALER)
 
#define MILD_ALERT_LED_ON_TIME   APP_TIMER_TICKS(100, APP_TIMER_PRESCALER)
 
#define MILD_ALERT_LED_OFF_TIME   APP_TIMER_TICKS(900, APP_TIMER_PRESCALER)
 
#define MIN_CONN_INTERVAL   MSEC_TO_UNITS(500, UNIT_1_25_MS)
 
#define MAX_CONN_INTERVAL   MSEC_TO_UNITS(1000, UNIT_1_25_MS)
 
#define SLAVE_LATENCY   0
 
#define CONN_SUP_TIMEOUT   MSEC_TO_UNITS(4000, UNIT_10_MS)
 
#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5 * 1000, APP_TIMER_PRESCALER)
 
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5 * 1000, APP_TIMER_PRESCALER)
 
#define MAX_CONN_PARAMS_UPDATE_COUNT   3
 
#define APP_GPIOTE_MAX_USERS   1
 
#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)
 
#define SEC_PARAM_TIMEOUT   30
 
#define SEC_PARAM_BOND   1
 
#define SEC_PARAM_MITM   0
 
#define SEC_PARAM_IO_CAPABILITIES   BLE_GAP_IO_CAPS_NONE
 
#define SEC_PARAM_OOB   0
 
#define SEC_PARAM_MIN_KEY_SIZE   7
 
#define SEC_PARAM_MAX_KEY_SIZE   16
 
#define INITIAL_LLS_ALERT_LEVEL   BLE_CHAR_ALERT_LEVEL_NO_ALERT
 
#define TX_POWER_LEVEL   (-8)
 
#define FLASH_PAGE_SYS_ATTR   (BLE_FLASH_PAGE_END - 3)
 
#define FLASH_PAGE_BOND   (BLE_FLASH_PAGE_END - 1)
 
#define ADC_REF_VOLTAGE_IN_MILLIVOLTS   1200
 
#define ADC_PRE_SCALING_COMPENSATION   3
 
#define DIODE_FWD_VOLT_DROP_MILLIVOLTS   270
 
#define DEAD_BEEF   0xDEADBEEF
 
#define ADC_RESULT_IN_MILLI_VOLTS(ADC_VALUE)   ((((ADC_VALUE) * ADC_REF_VOLTAGE_IN_MILLIVOLTS) / 255) * ADC_PRE_SCALING_COMPENSATION)
 Macro to convert the result of ADC conversion in millivolts. More...
 

Enumerations

enum  ble_advertising_mode_t {
  BLE_NO_ADVERTISING,
  BLE_SLOW_ADVERTISING,
  BLE_FAST_ADVERTISING,
  BLE_NO_ADV,
  BLE_DIRECTED_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP,
  BLE_NO_ADV,
  BLE_DIRECTED_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP,
  BLE_NO_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP,
  BLE_NO_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP
}
 
enum  ble_advertising_mode_t {
  BLE_NO_ADVERTISING,
  BLE_SLOW_ADVERTISING,
  BLE_FAST_ADVERTISING,
  BLE_NO_ADV,
  BLE_DIRECTED_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP,
  BLE_NO_ADV,
  BLE_DIRECTED_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP,
  BLE_NO_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP,
  BLE_NO_ADV,
  BLE_FAST_ADV_WHITELIST,
  BLE_FAST_ADV,
  BLE_SLOW_ADV,
  BLE_SLEEP
}
 Advertisement states. More...
 

Functions

static void on_ias_evt (ble_ias_t *p_ias, ble_ias_evt_t *p_evt)
 Function for handling Immediate Alert events. More...
 
static void on_lls_evt (ble_lls_t *p_lls, ble_lls_evt_t *p_evt)
 Function for handling Link Loss events. More...
 
static void on_ias_c_evt (ble_ias_c_t *p_ias_c, ble_ias_c_evt_t *p_evt)
 Function for handling IAS Client events. More...
 
static void advertising_init (uint8_t adv_flags)
 Function for initializing the Advertising functionality. More...
 
void app_error_handler (uint32_t error_code, uint32_t line_num, const uint8_t *p_file_name)
 Function for error handling, which is called when an error has occurred. More...
 
void assert_nrf_callback (uint16_t line_num, const uint8_t *p_file_name)
 Callback function for asserts in the SoftDevice. More...
 
static void service_error_handler (uint32_t nrf_error)
 Function for handling Service errors. More...
 
static void advertising_start (void)
 Function for starting advertising.
 
static void battery_level_update (void)
 Function for performing a battery measurement, and update the Battery Level characteristic in the Battery Service.
 
static void battery_level_meas_timeout_handler (void *p_context)
 Function for handling the Battery measurement timer timeout. More...
 
static void leds_init (void)
 Function for the LEDs initialization. More...
 
static void timers_init (void)
 Function for the Timer initialization. More...
 
static void gap_params_init (void)
 Function for the GAP initialization. More...
 
static void tps_init (void)
 Function for initializing the Tx Power Service.
 
static void ias_init (void)
 Function for initializing the Immediate Alert Service.
 
static void lls_init (void)
 Function for initializing the Link Loss Service.
 
static void bas_init (void)
 Function for initializing the Battery Service.
 
static void ias_client_init (void)
 Function for initializing the immediate alert service client. More...
 
static void services_init (void)
 Function for initializing the services that will be used by the application.
 
static void sensor_sim_init (void)
 Function for initializing the battery sensor simulator.
 
static void sec_params_init (void)
 Function for initializing the security parameters.
 
static void conn_params_error_handler (uint32_t nrf_error)
 Function for handling a Connection Parameters error. More...
 
static void conn_params_init (void)
 Function for initializing the Connection Parameters module.
 
static void alert_signal (uint8_t alert_level)
 Function for signaling alert event from Immediate Alert or Link Loss services. More...
 
static void on_ble_evt (ble_evt_t *p_ble_evt)
 Function for handling the Application's BLE Stack events. More...
 
static void ble_evt_dispatch (ble_evt_t *p_ble_evt)
 Function for dispatching a BLE stack event to all modules with a BLE stack event handler. More...
 
static void ble_stack_init (void)
 Function for initializing the BLE stack. More...
 
static void bond_manager_error_handler (uint32_t nrf_error)
 Function for handling a Bond Manager error. More...
 
static void bond_manager_init (void)
 Function for the Bond Manager initialization.
 
static void radio_notification_init (void)
 Function for initializing the Radio Notification event.
 
static void button_event_handler (uint8_t pin_no)
 Function for handling button events. More...
 
static void gpiote_init (void)
 Function for initializing the GPIOTE handler module.
 
static void buttons_init (void)
 Function for initializing the button handler module.
 
static void power_manage (void)
 Function for the Power manager.
 
int main (void)
 Function for application main entry.
 
static void on_bas_evt (ble_bas_t *p_bas, ble_bas_evt_t *p_evt)
 Function for handling the Battery Service events. More...
 
void ADC_IRQHandler (void)
 Function for handling the ADC interrupt. More...
 
static void adc_start (void)
 Function for making the ADC start a battery level conversion.
 
static void adv_led_blink_start (void)
 Function for starting the blinking of the Advertisement LED.
 
static void adv_led_blink_stop (void)
 Function for stopping the blinking of the Advertisement LED.
 
static void alert_led_blink_start (void)
 Function for starting the blinking of the Alert LED.
 
static void alert_led_blink_stop (void)
 Function for stopping the blinking of the Alert LED.
 
static void mild_alert_timeout_handler (void *p_context)
 Function for handling the timeout that is responsible for toggling the Alert LED. More...
 
static void adv_led_blink_timeout_handler (void *p_context)
 Function for handling the timeout that is responsible for toggling the Advertisement LED. More...
 

Variables

static ble_tps_t m_tps
 
static ble_ias_t m_ias
 
static ble_lls_t m_lls
 
static bool m_is_link_loss_alerting
 
static ble_bas_t m_bas
 
static ble_ias_c_t m_ias_c
 
static ble_gap_sec_params_t m_sec_params
 
static ble_advertising_mode_t m_advertising_mode
 
static ble_sensorsim_cfg_t m_battery_sim_cfg
 
static ble_sensorsim_state_t m_battery_sim_state
 
static volatile bool m_is_high_alert_signalled
 
static app_timer_id_t m_battery_timer_id
 
static ble_tps_t m_tps
 
static ble_ias_t m_ias
 
static ble_lls_t m_lls
 
static bool m_is_link_loss_alerting
 
static bool m_is_alert_led_blinking
 
static bool m_is_adv_led_blinking
 
static ble_bas_t m_bas
 
static ble_ias_c_t m_ias_c
 
static ble_gap_sec_params_t m_sec_params
 
static ble_advertising_mode_t m_advertising_mode
 
static volatile bool m_is_high_alert_signalled
 
static app_timer_id_t m_battery_timer_id
 
static app_timer_id_t m_alert_led_blink_timer_id
 
static app_timer_id_t m_adv_led_blink_timer_id
 

Detailed Description

Proximity Application main file.

This file contains is the source code for a sample proximity application using the Immediate Alert, Link Loss and Tx Power services.

This application would accept pairing requests from any peer device.

It demonstrates the use of fast and slow advertising intervals.

Macro Definition Documentation

#define SIGNAL_ALERT_BUTTON   NRF6310_BUTTON_0

Button used for send or cancel High Alert to the peer.

#define BONDMNGR_DELETE_BUTTON_PIN_NO   NRF6310_BUTTON_1

Button used for deleting all bonded masters during startup.

#define ALERT_LEVEL_MILD_LED_PIN_NO   NRF6310_LED_2

Is on when we are in Mild Alert state.

#define ALERT_LEVEL_HIGH_LED_PIN_NO   NRF6310_LED_3

Is on when we are in High Alert state.

#define ADV_INTERVAL_SLOW_LED_PIN_NO   NRF6310_LED_4

Is on when we are doing slow advertising.

#define PEER_SRV_DISC_LED_PIN_NO   NRF6310_LED_5

Is on when the Immediate Alert Service has been discovered at the peer.

#define ADV_WHITELIST_LED_PIN_NO   NRF6310_LED_6

Is on when we are doing advertising with whitelist.

#define DEVICE_NAME   "Nordic_Prox"

Name of device. Will be included in the advertising data.

#define APP_ADV_INTERVAL_FAST   0x0028

Fast advertising interval (in units of 0.625 ms. This value corresponds to 25 ms.).

#define APP_ADV_INTERVAL_SLOW   0x0C80

Slow advertising interval (in units of 0.625 ms. This value corrsponds to 2 seconds).

#define APP_SLOW_ADV_TIMEOUT   180

The duration of the slow advertising period (in seconds).

#define APP_FAST_ADV_TIMEOUT   40

The duration of the fast advertising period (in seconds).

#define APP_FAST_ADV_WHITELIST_TIMEOUT   20

The duration of the fast advertising with whitelist period (in seconds).

#define APP_TIMER_PRESCALER   0

Value of the RTC1 PRESCALER register.

#define APP_TIMER_MAX_TIMERS   3

Maximum number of simultaneously created timers.

#define APP_TIMER_OP_QUEUE_SIZE   4

Size of timer operation queues.

#define BATTERY_LEVEL_MEAS_INTERVAL   APP_TIMER_TICKS(2000, APP_TIMER_PRESCALER)

Battery level measurement interval (ticks).

#define MIN_BATTERY_LEVEL   81

Minimum simulated battery level.

#define MAX_BATTERY_LEVEL   100

Maximum simulated battery level.

#define BATTERY_LEVEL_INCREMENT   1

Increment between each simulated battery level measurement.

#define MIN_CONN_INTERVAL   MSEC_TO_UNITS(500, UNIT_1_25_MS)

Minimum acceptable connection interval (0.5 seconds).

#define MAX_CONN_INTERVAL   MSEC_TO_UNITS(1000, UNIT_1_25_MS)

Maximum acceptable connection interval (1 second).

#define SLAVE_LATENCY   0

Slave latency.

#define CONN_SUP_TIMEOUT   MSEC_TO_UNITS(4000, UNIT_10_MS)

Connection supervisory timeout (4 seconds).

#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(20 * 1000, APP_TIMER_PRESCALER)

Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds).

#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5 * 1000, APP_TIMER_PRESCALER)

Time between each call to sd_ble_gap_conn_param_update after the first (30 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.

#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)

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).

#define SEC_PARAM_BOND   1

Perform bonding.

#define SEC_PARAM_MITM   0

Man In The Middle protection not required.

#define SEC_PARAM_IO_CAPABILITIES   BLE_GAP_IO_CAPS_NONE

No I/O capabilities.

#define SEC_PARAM_OOB   0

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 INITIAL_LLS_ALERT_LEVEL   BLE_CHAR_ALERT_LEVEL_NO_ALERT

Initial value for the Alert Level characteristic in the Link Loss service.

#define TX_POWER_LEVEL   (-8)

TX Power Level value. This will be set both in the TX Power service, in the advertising data, and also used to set the radio transmit power.

#define FLASH_PAGE_SYS_ATTR   (BLE_FLASH_PAGE_END - 3)

Flash page used for bond manager system attribute information.

#define FLASH_PAGE_BOND   (BLE_FLASH_PAGE_END - 1)

Flash page used for bond manager bonding information.

#define DEAD_BEEF   0xDEADBEEF

Value used as error code on stack dump, can be used to identify stack location on stack unwind.

#define SIGNAL_ALERT_BUTTON   EVAL_BOARD_BUTTON_0

Button used for send or cancel High Alert to the peer.

#define STOP_ALERTING_BUTTON   EVAL_BOARD_BUTTON_1

Button used for clearing the Alert LED that may be blinking or turned ON because of alerts from the master.

#define BONDMNGR_DELETE_BUTTON_PIN_NO   EVAL_BOARD_BUTTON_1

Button used for deleting all bonded masters during startup.

#define ALERT_PIN_NO   EVAL_BOARD_LED_1

Pin used as LED to signal an alert.

#define DEVICE_NAME   "Nordic_Prox"

Name of device. Will be included in the advertising data.

#define APP_ADV_INTERVAL_FAST   0x0028

Fast advertising interval (in units of 0.625 ms. This value corresponds to 25 ms.).

#define APP_ADV_INTERVAL_SLOW   0x0C80

Slow advertising interval (in units of 0.625 ms. This value corresponds to 2 seconds).

#define APP_SLOW_ADV_TIMEOUT   180

The duration of the slow advertising period (in seconds).

#define APP_FAST_ADV_TIMEOUT   30

The duration of the fast advertising period (in seconds).

#define APP_TIMER_PRESCALER   0

Value of the RTC1 PRESCALER register.

#define APP_TIMER_MAX_TIMERS   5

Maximum number of simultaneously created timers. 1 for Battery measurement, 2 for flashing Advertising LED and Alert LED, 1 for connection parameters module, 1 for button polling timer needed by the app_button module,

#define APP_TIMER_OP_QUEUE_SIZE   6

Size of timer operation queues.

#define BATTERY_LEVEL_MEAS_INTERVAL   APP_TIMER_TICKS(120000, APP_TIMER_PRESCALER)

Battery level measurement interval (ticks). This value corresponds to 120 seconds.

#define ADV_LED_ON_TIME   APP_TIMER_TICKS(100, APP_TIMER_PRESCALER)

Advertisement LED ON period when in blinking state.

#define ADV_LED_OFF_TIME   APP_TIMER_TICKS(900, APP_TIMER_PRESCALER)

Advertisement LED OFF period when in blinking state.

#define MILD_ALERT_LED_ON_TIME   APP_TIMER_TICKS(100, APP_TIMER_PRESCALER)

Alert LED ON period when in blinking state.

#define MILD_ALERT_LED_OFF_TIME   APP_TIMER_TICKS(900, APP_TIMER_PRESCALER)

Alert LED OFF period when in blinking state.

#define MIN_CONN_INTERVAL   MSEC_TO_UNITS(500, UNIT_1_25_MS)

Minimum acceptable connection interval (0.5 seconds).

#define MAX_CONN_INTERVAL   MSEC_TO_UNITS(1000, UNIT_1_25_MS)

Maximum acceptable connection interval (1 second).

#define SLAVE_LATENCY   0

Slave latency.

#define CONN_SUP_TIMEOUT   MSEC_TO_UNITS(4000, UNIT_10_MS)

Connection supervisory timeout (4 seconds).

#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5 * 1000, APP_TIMER_PRESCALER)

Time from initiating event (connect or start of notification) to first time sd_ble_gap_conn_param_update is called (5 seconds).

#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5 * 1000, APP_TIMER_PRESCALER)

Time between each call to sd_ble_gap_conn_param_update after the first (30 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.

#define BUTTON_DETECTION_DELAY   APP_TIMER_TICKS(50, APP_TIMER_PRESCALER)

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).

#define SEC_PARAM_BOND   1

Perform bonding.

#define SEC_PARAM_MITM   0

Man In The Middle protection not required.

#define SEC_PARAM_IO_CAPABILITIES   BLE_GAP_IO_CAPS_NONE

No I/O capabilities.

#define SEC_PARAM_OOB   0

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 INITIAL_LLS_ALERT_LEVEL   BLE_CHAR_ALERT_LEVEL_NO_ALERT

Initial value for the Alert Level characteristic in the Link Loss service.

#define TX_POWER_LEVEL   (-8)

TX Power Level value. This will be set both in the TX Power service, in the advertising data, and also used to set the radio transmit power.

#define FLASH_PAGE_SYS_ATTR   (BLE_FLASH_PAGE_END - 3)

Flash page used for bond manager system attribute information.

#define FLASH_PAGE_BOND   (BLE_FLASH_PAGE_END - 1)

Flash page used for bond manager bonding information.

#define ADC_REF_VOLTAGE_IN_MILLIVOLTS   1200

Reference voltage (in milli volts) used by ADC while doing conversion.

#define ADC_PRE_SCALING_COMPENSATION   3

The ADC is configured to use VDD with 1/3 prescaling as input. And hence the result of conversion is to be multiplied by 3 to get the actual value of the battery voltage.

#define DIODE_FWD_VOLT_DROP_MILLIVOLTS   270

Typical forward voltage drop of the diode (Part no: SD103ATW-7-F) that is connected in series with the voltage supply. This is the voltage drop when the forward current is 1mA. Source: Data sheet of 'SURFACE MOUNT SCHOTTKY BARRIER DIODE ARRAY' available at www.diodes.com.

#define DEAD_BEEF   0xDEADBEEF

Value used as error code on stack dump, can be used to identify stack location on stack unwind.

#define ADC_RESULT_IN_MILLI_VOLTS (   ADC_VALUE)    ((((ADC_VALUE) * ADC_REF_VOLTAGE_IN_MILLIVOLTS) / 255) * ADC_PRE_SCALING_COMPENSATION)
Parameters
[in]ADC_VALUEADC result.
Return values
Resultconverted to millivolts.

Enumeration Type Documentation

Enumerator
BLE_NO_ADVERTISING 

No advertising running.

BLE_SLOW_ADVERTISING 

Slow advertising running.

BLE_FAST_ADVERTISING 

Fast advertising running.

BLE_NO_ADV 

No advertising running.

BLE_DIRECTED_ADV 

Direct advertising to the latest master.

BLE_FAST_ADV_WHITELIST 

Advertising whith whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

BLE_NO_ADV 

No advertising running.

BLE_DIRECTED_ADV 

Direct advertising to the latest master.

BLE_FAST_ADV_WHITELIST 

Advertising whith whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

BLE_NO_ADV 

No advertising running.

BLE_FAST_ADV_WHITELIST 

Advertising whith whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

BLE_NO_ADV 

No advertising running.

BLE_FAST_ADV_WHITELIST 

Advertising with whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

Enumerator
BLE_NO_ADVERTISING 

No advertising running.

BLE_SLOW_ADVERTISING 

Slow advertising running.

BLE_FAST_ADVERTISING 

Fast advertising running.

BLE_NO_ADV 

No advertising running.

BLE_DIRECTED_ADV 

Direct advertising to the latest master.

BLE_FAST_ADV_WHITELIST 

Advertising whith whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

BLE_NO_ADV 

No advertising running.

BLE_DIRECTED_ADV 

Direct advertising to the latest master.

BLE_FAST_ADV_WHITELIST 

Advertising whith whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

BLE_NO_ADV 

No advertising running.

BLE_FAST_ADV_WHITELIST 

Advertising whith whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

BLE_NO_ADV 

No advertising running.

BLE_FAST_ADV_WHITELIST 

Advertising with whitelist.

BLE_FAST_ADV 

Fast advertising running.

BLE_SLOW_ADV 

Slow advertising running.

BLE_SLEEP 

Go to system-off.

Function Documentation

static void on_ias_evt ( ble_ias_t p_ias,
ble_ias_evt_t p_evt 
)
static

This function will be called for all Immediate Alert events which are passed to the application.

Parameters
[in]p_iasImmediate Alert stucture.
[in]p_evtEvent received from the Immediate Alert service.
static void on_lls_evt ( ble_lls_t p_lls,
ble_lls_evt_t p_evt 
)
static

This function will be called for all Link Loss events which are passed to the application.

Parameters
[in]p_llsLink Loss stucture.
[in]p_evtEvent received from the Link Loss service.
static void on_ias_c_evt ( ble_ias_c_t p_ias_c,
ble_ias_c_evt_t p_evt 
)
static

This function will be called for all IAS Client events which are passed to the application.

Parameters
[in]p_ias_cIAS Client stucture.
[in]p_evtEvent received.
static void advertising_init ( uint8_t  adv_flags)
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.

Parameters
[in]adv_flagsIndicates which type of advertisement to use, see GAP Discovery modes.
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_codeError code supplied to the handler.
[in]line_numLine number where the handler is called.
[in]p_file_namePointer 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_numLine number of the failing ASSERT call.
[in]file_nameFile name of the failing ASSERT call.
static void service_error_handler ( uint32_t  nrf_error)
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_errorError code containing information about what went wrong.
static void battery_level_meas_timeout_handler ( void *  p_context)
static

This function will be called each time the battery level measurement timer expires.

Parameters
[in]p_contextPointer used for passing some arbitrary information (context) from the app_start_timer() call to the timeout handler.
static void leds_init ( void  )
static

Initializes all LEDs used by this application.

static void timers_init ( void  )
static

Initializes the timer module. This creates and starts application timers.

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 ias_client_init ( void  )
static

This will initialize the client side functionality of the Find Me profile.

static void conn_params_error_handler ( uint32_t  nrf_error)
static
Parameters
[in]nrf_errorError code containing information about what went wrong.
static void alert_signal ( uint8_t  alert_level)
static
Parameters
[in]alert_levelRequested alert level.
static void on_ble_evt ( ble_evt_t p_ble_evt)
static
Parameters
[in]p_ble_evtBluetooth stack event.
static void ble_evt_dispatch ( ble_evt_t p_ble_evt)
static

This function is called from the BLE Stack event interrupt handler after a BLE stack event has been received.

Parameters
[in]p_ble_evtBluetooth stack event.
static void ble_stack_init ( void  )
static

Initializes the SoftDevice and the BLE event interrupt.

static void bond_manager_error_handler ( uint32_t  nrf_error)
static
Parameters
[in]nrf_errorError code containing information about what went wrong.
static void button_event_handler ( uint8_t  pin_no)
static
Parameters
[in]pin_noThe pin number of the button pressed.
static void on_bas_evt ( ble_bas_t p_bas,
ble_bas_evt_t p_evt 
)
static

This function will be called for all Battery Service events which are passed to the | application.

Parameters
[in]p_basBattery Service stucture.
[in]p_evtEvent received from the Battery Service.
void ADC_IRQHandler ( void  )

This function will fetch the conversion result from the ADC, convert the value into percentage and send it to peer.

static void mild_alert_timeout_handler ( void *  p_context)
static

This function will be called each time the timer that was started for the sake of blinking the Alert LED expires. This function toggle the state of the Alert LED.

Parameters
[in]p_contextPointer used for passing some arbitrary information (context) from the app_start_timer() call to the timeout handler.
static void adv_led_blink_timeout_handler ( void *  p_context)
static

This function will be called each time the timer that was started for the sake of blinking the Advertisement LED expires. This function toggle the state of the Advertisement LED.

Parameters
[in]p_contextPointer used for passing some arbitrary information (context) from the app_start_timer() call to the timeout handler.

Variable Documentation

ble_tps_t m_tps
static

Structure used to identify the TX Power service.

ble_ias_t m_ias
static

Structure used to identify the Immediate Alert service.

ble_lls_t m_lls
static

Structure used to identify the Link Loss service.

bool m_is_link_loss_alerting
static

Variable to indicate if a link loss has been detected.

ble_bas_t m_bas
static

Structure used to identify the battery service.

ble_ias_c_t m_ias_c
static

Structure used to identify the client to the Immediate Alert Service at peer.

ble_gap_sec_params_t m_sec_params
static

Security requirements for this application.

ble_advertising_mode_t m_advertising_mode
static

Variable to keep track of when we are advertising.

ble_sensorsim_cfg_t m_battery_sim_cfg
static

Battery Level sensor simulator configuration.

ble_sensorsim_state_t m_battery_sim_state
static

Battery Level sensor simulator state.

volatile bool m_is_high_alert_signalled
static

Variable to indicate whether or not high alert is signalled to the peer.

app_timer_id_t m_battery_timer_id
static

Battery timer.

ble_tps_t m_tps
static

Structure used to identify the TX Power service.

ble_ias_t m_ias
static

Structure used to identify the Immediate Alert service.

ble_lls_t m_lls
static

Structure used to identify the Link Loss service.

bool m_is_link_loss_alerting
static

Variable to indicate if a link loss has been detected.

bool m_is_alert_led_blinking
static

Variable to indicate if the alert LED is blinking (indicating a mild alert).

bool m_is_adv_led_blinking
static

Variable to indicate if the advertising LED is blinking.

ble_bas_t m_bas
static

Structure used to identify the battery service.

ble_ias_c_t m_ias_c
static

Structure used to identify the client to the Immediate Alert Service at peer.

ble_gap_sec_params_t m_sec_params
static

Security requirements for this application.

ble_advertising_mode_t m_advertising_mode
static

Variable to keep track of when we are advertising.

volatile bool m_is_high_alert_signalled
static

Variable to indicate whether or not high alert is signalled to the peer.

app_timer_id_t m_battery_timer_id
static

Battery measurement timer.

app_timer_id_t m_alert_led_blink_timer_id
static

Timer to realize the blinking of Alert LED.

app_timer_id_t m_adv_led_blink_timer_id
static

Timer to realize the blinking of Advertisement LED.