| Airoha M0 BLE API 1.0.5.4

Data Structures | Enumerations | Functions
ble_gap_sm.h

## Data Structures
struct | ble_sm_security_param_t
| Parameters for BLE_gap_sm_set_security_param function. More...

## Enumerations
enum | ble_sm_keypress_type { bt_sm_passkey_started = 0, bt_sm_passkey_digit_entered, bt_sm_passkey_digit_erased, bt_sm_passkey_cleared, bt_sm_passkey_complete }

## Functions
bool | BLE_gap_sm_authenticate (uint16_t conn_handle, ble_sm_security_param_t *param)
| To start authentication procedure. More...
bool | BLE_gap_sm_set_security_param (uint16_t conn_handle, uint8_t status, ble_sm_security_param_t *param)
| To set security parameter for pairing information exchange. More...
bool | BLE_gap_sm_delete_paired_record (ble_addr_t *addr)
| To delete bonded device information in flash. More...
bool | BLE_gap_sm_is_device_bonded (ble_addr_t *addr, uint8_t *flashIdx)
| To check if device information exists in flash. More...
bool | BLE_gap_sm_get_last_paired_device (ble_addr_t *addr)
| To obtain last paired device information in flash. More...
bool | BLE_gap_sm_set_passkey_for_display (uint32_t passkey)
| To set passkey for display, security manager will use 000000 as default if passkey is not set. More...
bool | BLE_gap_sm_passkey_response (uint16_t conn_handle, uint32_t passkey)
| To send passkey input to security manager. More...
bool | BLE_gap_sm_send_keypress_notification_request (uint16_t conn_handle, ble_sm_keypress_type type)
| To send a key notification command. More...
bool | BLE_gap_sm_get_ltk (uint8_t *peerAddr, uint8_t *ltk)
| Get LTK in flash by peer address. More...
bool | BLE_gap_sm_get_peer_ltk (uint8_t *peerAddr, uint8_t *peerLtk)
| Get peer LTK in flash by peer address. More...

## SM_IO_CAPABILITY
IO capability used to assign ble_sm_security_param_t.ioCapability .
#define | SM_IO_DISPLAY_ONLY 0x00
#define | SM_IO_DISPLAY_YES_NO 0x01
#define | SM_IO_KEYBOARD_ONLY 0x02
#define | SM_IO_NO_INPUT_NO_OUTPUT 0x03
#define | SM_IO_KEYBOARD_DISPLAY 0x04

## SM_OOB_DATA_FLAG
Out of band data flag used to assign ble_sm_security_param_t::oobData .
#define | SM_OOB_DATA_NOT_PRESENT 0x00
#define | SM_OOB_DATA_FROM_REMOTE 0x01

## SM_BONDING_FLAG
Bonding flag used to assign ble_sm_security_param_t::authReq .
#define | SM_NO_BONDING 0x00
#define | SM_BONDING 0x01

## SM_MITM_FLAG
Man in the middle protection flag used to assign ble_sm_security_param_t::authReq .
#define | SM_NO_MITM_PROTECTION 0x00
#define | SM_MITM_PROTECTION 0x04

## SM_SC_FLAG
Secure connection flag used to assign ble_sm_security_param_t::authReq .
#define | SM_SC_DISABLE 0x00
#define | SM_SC_ENABLE 0x08

## SM_KEYPRESS_FLAG
Keypress notifications flag used to assign ble_sm_security_param_t::authReq .
#define | SM_KEY_PRESS_NOTI_DISABLE 0x00
#define | SM_KEY_PRESS_NOTI_ENABLE 0x10

## Detailed Description

### ble_gap_sm.h

ble_gap_sm.h provides security manger related GAP APIs for feature defined in BLE spec.
The red circle was added in 1.0.4 version.

## Enumeration Type Documentation

## ◆ ble_sm_keypress_type

enum ble_sm_keypress_type

Press-key notification type.

Enumerator
bt_sm_passkey_started | User started entering passkey.
bt_sm_passkey_digit_entered | User entered digit.
bt_sm_passkey_digit_erased | User erased digit.
bt_sm_passkey_cleared | User cleared entire passkey.
bt_sm_passkey_complete | User completed passkey entry.

## Function Documentation

## ◆ BLE_gap_sm_authenticate()

bool BLE_gap_sm_authenticate | ( | uint16_t | conn_handle,
|  | ble_sm_security_param_t * | param
| ) |  |

To start authentication procedure.

Parameters

  conn_handle | connection handle.
  param | security parameter format ble_sm_security_param_t.

Returns
  bool : whether authentication command is sent successfully.

## ◆ BLE_gap_sm_set_security_param()

bool BLE_gap_sm_set_security_param | ( | uint16_t | conn_handle,
|  | uint8_t | status,
|  | ble_sm_security_param_t * | param
| ) |  |

To set security parameter for pairing information exchange.

Parameters

  conn_handle | connection handle.
  status | security status.
  param | security parameter format ble_sm_security_param_t.

## ◆ BLE_gap_sm_delete_paired_record()

bool BLE_gap_sm_delete_paired_record | ( | ble_addr_t * | addr | ) |

To delete bonded device information in flash.

Parameters

  addr | BD addr to be deleted or NULL for all record.

## ◆ BLE_gap_sm_is_device_bonded()

bool BLE_gap_sm_is_device_bonded | ( | ble_addr_t * | addr,
|  | uint8_t * | flashIdx
| ) |  |

To check if device information exists in flash.

Parameters

  addr | BD addr to be checked or NULL for any record.
  flashIdx | flash index.

Returns
  true : device is bonded
  false : device is not bonded

## ◆ BLE_gap_sm_get_last_paired_device()

bool BLE_gap_sm_get_last_paired_device | ( | ble_addr_t * | addr | ) |

To obtain last paired device information in flash.

Parameters

  addr | BD addr of last paired device.

Returns
  true : last device exists
  false : last device does not exist

## ◆ BLE_gap_sm_set_passkey_for_display()

bool BLE_gap_sm_set_passkey_for_display | ( | uint32_t | passkey | ) |

To set passkey for display, security manager will use 000000 as default if passkey is not set.

Parameters

  passkey | Passkey display value

## ◆ BLE_gap_sm_passkey_response()

bool BLE_gap_sm_passkey_response | ( | uint16_t | conn_handle,
|  | uint32_t | passkey
| ) |  |

To send passkey input to security manager.

Parameters

  conn_handle | connection handle.
  passkey | Passkey input value

## ◆ BLE_gap_sm_send_keypress_notification_request()

bool BLE_gap_sm_send_keypress_notification_request | ( | uint16_t | conn_handle,
|  | ble_sm_keypress_type | type
| ) |  |

To send a key notification command.

Parameters

  conn_handle | connection handle.
  type | key type ble_sm_keypress_type.

## ◆ BLE_gap_sm_get_ltk()

bool BLE_gap_sm_get_ltk | ( | uint8_t * | peerAddr,
|  | uint8_t * | ltk
| ) |  |

Get LTK in flash by peer address.

Parameters

  peerAddr | peer address.
  ltk | 16-byte long term key.

## ◆ BLE_gap_sm_get_peer_ltk()

bool BLE_gap_sm_get_peer_ltk | ( | uint8_t * | peerAddr,
|  | uint8_t * | peerLtk
| ) |  |

Get peer LTK in flash by peer address.

Parameters

  peerAddr | peer address.
  peerLtk | 16-byte peer long term key.