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

HID Keyboard Sample Application main file. More...

Macros

#define KEY_PRESS_BUTTON_PIN_NO   NRF6310_BUTTON_0
 
#define BONDMNGR_DELETE_BUTTON_PIN_NO   NRF6310_BUTTON_1
 
#define CAPS_ON_LED_PIN_NO   NRF6310_LED_2
 
#define ADV_DIRECTED_LED_PIN_NO   NRF6310_LED_4
 
#define ADV_WHITELIST_LED_PIN_NO   NRF6310_LED_5
 
#define ADV_INTERVAL_SLOW_LED_PIN_NO   NRF6310_LED_6
 
#define DEVICE_NAME   "Nordic_Keyboard"
 
#define MANUFACTURER_NAME   "NordicSemiconductor"
 
#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 PNP_ID_VENDOR_ID_SOURCE   0x02
 
#define PNP_ID_VENDOR_ID   0x1915
 
#define PNP_ID_PRODUCT_ID   0xEEEE
 
#define PNP_ID_PRODUCT_VERSION   0x0001
 
#define APP_ADV_INTERVAL_FAST   MSEC_TO_UNITS(25, UNIT_0_625_MS)
 
#define APP_ADV_INTERVAL_SLOW   MSEC_TO_UNITS(2000, UNIT_0_625_MS)
 
#define APP_FAST_ADV_TIMEOUT   30
 
#define APP_SLOW_ADV_TIMEOUT   180
 
#define APP_DIRECTED_ADV_TIMEOUT   5
 
#define MIN_CONN_INTERVAL   MSEC_TO_UNITS(7.5, UNIT_1_25_MS)
 
#define MAX_CONN_INTERVAL   MSEC_TO_UNITS(30, UNIT_1_25_MS)
 
#define SLAVE_LATENCY   6
 
#define CONN_SUP_TIMEOUT   MSEC_TO_UNITS(300, UNIT_10_MS)
 
#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000, APP_TIMER_PRESCALER)
 
#define NEXT_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(30000, 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 FLASH_PAGE_SYS_ATTR   (BLE_FLASH_PAGE_END - 3)
 
#define FLASH_PAGE_BOND   (BLE_FLASH_PAGE_END - 1)
 
#define OUTPUT_REPORT_INDEX   0
 
#define OUTPUT_REPORT_MAX_LEN   1
 
#define INPUT_REPORT_KEYS_INDEX   0
 
#define OUTPUT_REPORT_BIT_MASK_CAPS_LOCK   0x02
 
#define INPUT_REP_REF_ID   0
 
#define OUTPUT_REP_REF_ID   0
 
#define MAX_BUFFER_ENTRIES   5
 
#define BASE_USB_HID_SPEC_VERSION   0x0101
 
#define INPUT_REPORT_KEYS_MAX_LEN   8
 
#define DEAD_BEEF   0xDEADBEEF
 
#define SCHED_MAX_EVENT_DATA_SIZE
 
#define SCHED_QUEUE_SIZE   10
 

Typedefs

typedef struct hid_key_buffer buffer_entry_t
 

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
}
 

Functions

 STATIC_ASSERT (sizeof(buffer_entry_t)%4==0)
 
 STATIC_ASSERT (sizeof(buffer_list_t)%4==0)
 
static void on_hids_evt (ble_hids_t *p_hids, ble_hids_evt_t *p_evt)
 Function for handling HID events. 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 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 advertising_init (uint8_t adv_flags)
 Function for initializing the Advertising functionality. More...
 
static void dis_init (void)
 Function for initializing Device Information Service.
 
static void bas_init (void)
 Function for initializing Battery Service.
 
static void hids_init (void)
 Function for initializing HID Service.
 
static void services_init (void)
 Function for initializing 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 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 timers_start (void)
 Function for starting timers.
 
static void advertising_start (void)
 Function for starting advertising.
 
uint32_t send_key_scan_press_release (ble_hids_t *p_instance, uint8_t *p_key_pattern, uint16_t pattern_len, uint16_t pattern_offset, uint16_t *actual_len)
 Function for transmitting a key scan Press & Release Notification. More...
 
void buffer_init (void)
 Initializes the buffer queue used to key events that could not be transmitted. More...
 
uint32_t buffer_enqueue (ble_hids_t *p_hids, uint8_t *p_key_pattern, uint16_t pattern_len, uint16_t offset)
 Function to enqueue key scan patterns that could not be tranmisted either completely of partically. More...
 
uint32_t buffer_dequeue (bool tx_flag)
 Function to dequeue key scan patterns that could not be tranmisted either completely of partically. More...
 
static void keys_send (uint8_t key_pattern_len, uint8_t *p_key_pattern)
 Function for sending sample key presses to the peer. More...
 
static void on_hid_rep_char_write (ble_hids_evt_t *p_evt)
 Function for handling the HID Report Characteristic Write event. 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 scheduler_init (void)
 Function for the Event Scheduler initialization.
 
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 bond_manager_error_handler (uint32_t nrf_error)
 Function for handling a Bond Manager error. More...
 
static void bond_evt_handler (ble_bondmngr_evt_t *p_evt)
 Function for handling the Bond Manager events. 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 power_manage (void)
 Function for the Power manager.
 
int main (void)
 Function for application main entry.
 

Variables

static ble_hids_t m_hids
 
static ble_bas_t m_bas
 
static ble_gap_sec_params_t m_sec_params
 
static bool m_in_boot_mode = false
 
static ble_sensorsim_cfg_t m_battery_sim_cfg
 
static ble_sensorsim_state_t m_battery_sim_state
 
static app_timer_id_t m_battery_timer_id
 
static ble_advertising_mode_t m_advertising_mode
 
static int8_t m_last_connected_master
 
static uint8_t m_direct_adv_cnt
 
static uint8_t m_sample_key_press_scan_str []
 
static uint8_t m_caps_on_key_scan_str []
 
static uint8_t m_caps_off_key_scan_str []
 
static uint8_t m_sample_key_release_pattern [INPUT_REPORT_KEYS_MAX_LEN]
 
static buffer_list_t buffer_list
 
#define BUFFER_LIST_INIT()
 
#define BUFFER_LIST_FULL()   ((MAX_BUFFER_ENTRIES == buffer_list.count) ? true : false)
 
#define BUFFER_LIST_EMPTY()   ((0 == buffer_list.count) ? true : false)
 
#define BUFFER_INIT_ELEMENT(i)
 

Detailed Description

This file contains is the source code for a sample application using the HID, Battery and Device Information Services for implementing a simple keyboard functionality. Pressing Button 0 will send text 'hello' to the connected peer. On receiving output report, it toggles the state of LED 2 on the mother board based on whether or not Caps Lock is on. This application uses the Scheduler.

Also it would accept pairing requests from any peer device.

Macro Definition Documentation

#define KEY_PRESS_BUTTON_PIN_NO   NRF6310_BUTTON_0

Button used for sending keyboard text.

#define BONDMNGR_DELETE_BUTTON_PIN_NO   NRF6310_BUTTON_1

Button used for deleting all bonded masters during startup.

#define CAPS_ON_LED_PIN_NO   NRF6310_LED_2

Pin for indicating that CAPS LOCK is on.

#define ADV_DIRECTED_LED_PIN_NO   NRF6310_LED_4

Is on when we are doing directed advertisement.

#define ADV_WHITELIST_LED_PIN_NO   NRF6310_LED_5

Is on when we are doing advertising with whitelist.

#define ADV_INTERVAL_SLOW_LED_PIN_NO   NRF6310_LED_6

Is on when we are doing slow advertising.

#define DEVICE_NAME   "Nordic_Keyboard"

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

#define MANUFACTURER_NAME   "NordicSemiconductor"

Manufacturer. Will be passed to Device Information Service.

#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 PNP_ID_VENDOR_ID_SOURCE   0x02

Vendor ID Source.

#define PNP_ID_VENDOR_ID   0x1915

Vendor ID.

#define PNP_ID_PRODUCT_ID   0xEEEE

Product ID.

#define PNP_ID_PRODUCT_VERSION   0x0001

Product Version.

#define APP_ADV_INTERVAL_FAST   MSEC_TO_UNITS(25, UNIT_0_625_MS)

Fast advertising interval (25 ms.).

#define APP_ADV_INTERVAL_SLOW   MSEC_TO_UNITS(2000, UNIT_0_625_MS)

Slow advertising interval (2 seconds).

#define APP_FAST_ADV_TIMEOUT   30

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

#define APP_SLOW_ADV_TIMEOUT   180

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

#define APP_DIRECTED_ADV_TIMEOUT   5

number of direct advertisement (each lasting 1.28seconds).

#define MIN_CONN_INTERVAL   MSEC_TO_UNITS(7.5, UNIT_1_25_MS)

Minimum connection interval (7.5 ms)

#define MAX_CONN_INTERVAL   MSEC_TO_UNITS(30, UNIT_1_25_MS)

Maximum connection interval (30 ms).

#define SLAVE_LATENCY   6

Slave latency.

#define CONN_SUP_TIMEOUT   MSEC_TO_UNITS(300, UNIT_10_MS)

Connection supervisory timeout (300 ms).

#define FIRST_CONN_PARAMS_UPDATE_DELAY   APP_TIMER_TICKS(5000, 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(30000, 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 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 OUTPUT_REPORT_INDEX   0

Index of Output Report.

#define OUTPUT_REPORT_MAX_LEN   1

Maximum length of Output Report.

#define INPUT_REPORT_KEYS_INDEX   0

Index of Input Report.

#define OUTPUT_REPORT_BIT_MASK_CAPS_LOCK   0x02

CAPS LOCK bit in Output Report (based on 'LED Page (0x08)' of the Universal Serial Bus HID Usage Tables).

#define INPUT_REP_REF_ID   0

Id of reference to Keyboard Input Report.

#define OUTPUT_REP_REF_ID   0

Id of reference to Keyboard Output Report.

#define MAX_BUFFER_ENTRIES   5

Number of elements that can be enqueued

#define BASE_USB_HID_SPEC_VERSION   0x0101

Version number of base USB HID Specification implemented by this application.

#define INPUT_REPORT_KEYS_MAX_LEN   8

Maximum length of the Input Report characteristic.

#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
Value:

Maximum size of scheduler events.

#define SCHED_QUEUE_SIZE   10

Maximum number of events in the scheduler queue.

#define BUFFER_LIST_INIT ( )
Value:
do \
{ \
buffer_list.rp = 0; \
buffer_list.wp = 0; \
buffer_list.count = 0; \
} while (0)

Buffer queue access macrosInitialization of buffer list

#define BUFFER_LIST_FULL ( )    ((MAX_BUFFER_ENTRIES == buffer_list.count) ? true : false)

Provide status of data list is full or not

#define BUFFER_LIST_EMPTY ( )    ((0 == buffer_list.count) ? true : false)

Provides status of buffer list is empty or not

#define BUFFER_INIT_ELEMENT (   i)
Value:
do \
{ \
buffer_list.buffer[(i)].p_data = NULL; \
} while (0)

Typedef Documentation

typedef struct hid_key_buffer buffer_entry_t

Abstracts buffer element

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.

Function Documentation

static void on_hids_evt ( ble_hids_t p_hids,
ble_hids_evt_t p_evt 
)
static

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

Parameters
[in]p_hidsHID service stucture.
[in]p_evtEvent received from the HID service.
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.

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 ( 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.
static void conn_params_error_handler ( uint32_t  nrf_error)
static
Parameters
[in]nrf_errorError code containing information about what went wrong.
uint32_t send_key_scan_press_release ( ble_hids_t p_instance,
uint8_t *  p_key_pattern,
uint16_t  pattern_len,
uint16_t  pattern_offset,
uint16_t *  actual_len 
)
Warning
This handler is an example only. You need to analyze how you wish to send the key release.
Parameters
[in]p_instanceIdentifies the service for which Key Notifications are requested.
[in]p_key_patternPointer to key pattern.
[in]pattern_lenLength of key pattern. 0 < pattern_len < 7.
[in]pattern_offsetOffset applied to Key Pattern for transmission.
[out]actual_lenProvides acutal length of Key Pattern transmitted, making buffering of rest possible if needed.
Returns
NRF_SUCCESS on sucess, BLE_ERROR_NO_TX_BUFFERS in case tranmission could not be completed due to lack of transmission buffer or other error codes indicating reason for failure.
Note
In case of BLE_ERROR_NO_TX_BUFFERS, remaining patter that could not be tramsitted can be enqueued buffer_enqueue function. In case a pattern of 'cofFEe' is the p_key_pattern, with pattern_len as 6 and pattern_offset as 0, the notifications as observed on the peer side would be 1> 'c', 'o', 'f', 'F', 'E', 'e' 2> - , 'o', 'f', 'F', 'E', 'e' 3> - , -, 'f', 'F', 'E', 'e' 4> - , -, -, 'F', 'E', 'e' 5> - , -, -, -, 'E', 'e' 6> - , -, -, -, -, 'e' 7> - , -, -, -, -, - Here, - referes to release, 'c' refers to the key character being transmitted. Therefore 7 notifications will be sent. In case an offset of 4 was provided, the pattern notifications sent will be from 5-7 will be transmitted.
void buffer_init ( void  )
Warning
This handler is an example only. You need to analyze how you wish to buffer or buffer at all.
Note
In case pf HID keyboard, a temporary buffering could be employed to handle scenarios where encryption is not yet enabled or therewas a momentary link loss or there were no Transmit buffers.
uint32_t buffer_enqueue ( ble_hids_t p_hids,
uint8_t *  p_key_pattern,
uint16_t  pattern_len,
uint16_t  offset 
)
Warning
This handler is an example only. You need to analyze how you wish to send the key release.
Parameters
[in]p_hidsIdentifies the service for which Key Notifications are buffered.
[in]p_key_patternPointer to key pattern.
[in]pattern_lenLength of key pattern.
[in]offsetOffset applied to Key Pattern when requesting a transmission on dequeue, buffer_dequeue.
Returns
NRF_SUCCESS on sucess, else an error code indicating reason for failure.
uint32_t buffer_dequeue ( bool  tx_flag)
Warning
This handler is an example only. You need to analyze how you wish to send the key release.
Parameters
[in]tx_flagIndicative of whether the dequeue should result in transmission or not.
Note
A typical example when all keys are dequeued with tranmission is when link is disconnected.
Returns
NRF_SUCCESS on sucess, else an error code indicating reason for failure.
static void keys_send ( uint8_t  key_pattern_len,
uint8_t *  p_key_pattern 
)
static
Parameters
[in]key_pattern_lenPattern length.
[in]p_key_patternPattern to be sent.
static void on_hid_rep_char_write ( ble_hids_evt_t p_evt)
static
Parameters
[in]p_evtHID service event.
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 scheduler in the main loop 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 button_event_handler ( uint8_t  pin_no)
static
Parameters
[in]pin_noThe pin number of the button pressed.
static void bond_manager_error_handler ( uint32_t  nrf_error)
static
Parameters
[in]nrf_errorError code containing information about what went wrong.
static void bond_evt_handler ( ble_bondmngr_evt_t p_evt)
static
Parameters
[in]p_evtData associated to the bond manager event.

Variable Documentation

ble_hids_t m_hids
static

Structure used to identify the HID service.

ble_bas_t m_bas
static

Structure used to identify the battery service.

ble_gap_sec_params_t m_sec_params
static

Security requirements for this application.

bool m_in_boot_mode = false
static

Current protocol mode.

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.

app_timer_id_t m_battery_timer_id
static

Battery timer.

ble_advertising_mode_t m_advertising_mode
static

Variable to keep track of when we are advertising.

int8_t m_last_connected_master
static

BondManager reference handle to the last connected master.

uint8_t m_direct_adv_cnt
static

Counter of direct advertisements.

uint8_t m_sample_key_press_scan_str[]
static
Initial value:
=
{
0x0b,
0x08,
0x0f,
0x0f,
0x12,
0x28
}

Key pattern to be sent when the key press button has been pushed.

uint8_t m_caps_on_key_scan_str[]
static
Initial value:
=
{
0x06,
0x04,
0x13,
0x16,
0x12,
0x11,
}

Key pattern to be sent when the output report has been written with the CAPS LOCK bit set.

uint8_t m_caps_off_key_scan_str[]
static
Initial value:
=
{
0x06,
0x04,
0x13,
0x16,
0x12,
0x09,
}

Key pattern to be sent when the output report has been written with the CAPS LOCK bit cleared.

uint8_t m_sample_key_release_pattern[INPUT_REPORT_KEYS_MAX_LEN]
static
Initial value:
=
{
0x00
}

Key pattern to be sent to simulate releasing keys.

buffer_list_t buffer_list
static

List to enqueue not just data to be sent, but also related information like the handle, connection handle etc