Airoha M0 BLE API  1.0.5.4
ble_sm.h
1 /******************************************************************************
2 Copyright (c) Airoha 2016 - All rights reserved
3 
4 FILE NAME
5  ble_sm.h
6 DESCRIPTION
7 NOTES
8 ********************************************************************************/
9 
10 #ifndef __BLE_SM_H__
11 #define __BLE_SM_H__
12 
22 #include "bt_constants.h"
23 
24 
25 /******************************************************************************
26  * Macros
27  ******************************************************************************/
32 #define SM_PASSKEY_MAX_BYTE_LEN 3
33 
42 #define BLE_SM_STATUS_SUCCESS 0x00
43 #define BLE_SM_STATUS_TIMEOUT 0x01
44 #define BLE_SM_STATUS_LINK_DISCONNECTED 0x02
45 #define BLE_SM_STATUS_LTK_NEGATIVE 0x03
46 #define BLE_SM_STATUS_RFU_RANGE1_BEGIN 0x04
47 #define BLE_SM_STATUS_RFU_RANGE1_END 0x80
48 
49 #define BLE_SM_STATUS_PAIRING_FAIL_REASON_MASK 0x80
50 #define BLE_SM_STATUS_PASSKEY_ENTRY_FAILED 0x81
51 #define BLE_SM_STATUS_OOB_NOT_AVAILABLE 0x82
52 #define BLE_SM_STATUS_AUTHENTHICATION_REQUIREMENTS 0x83
53 #define BLE_SM_STATUS_CONFIRM_VALUE 0x84
54 #define BLE_SM_STATUS_PAIRING_NOT_SUPPORTED 0x85
55 #define BLE_SM_STATUS_ENCRYPTION_KEY_SIZE 0x86
56 #define BLE_SM_STATUS_COMMAND_NOT_SUPPORTED 0x87
57 #define BLE_SM_STATUS_UNSPECIFIED_REASON 0x88
58 #define BLE_SM_STATUS_REPEATED_ATTEMPTS 0x89
59 #define BLE_SM_STATUS_INVALID_PARAMETERS 0x8A
60 #define BLE_SM_DHKEY_CHECK_FAILED 0x8B
61 #define BLE_SM_NUMERIC_COMPARISON_FAILED 0x8C
62 #define BLE_SM_BR_EDR_PAIRING_IN_PROGRESS 0x8D
63 #define BLE_SM_CROSS_TRANSPORT_KEY_NOT_ALLOWED 0x8E
64 #define BLE_SM_STATUS_RFU_RANGE2_BEGIN 0x8F
65 #define BLE_SM_STATUS_RFU_RANGE2_END 0xFF
66 
75 #define BLE_GAP_AUTH_KEY_TYPE_NONE 0x00
76 #define BLE_GAP_AUTH_KEY_TYPE_PASSKEY 0x01
77 #define BLE_GAP_AUTH_KEY_TYPE_OOB 0x02
78 
82 #ifdef _MSC_VER
83 __pragma(pack(push, 1))
84 #define __attribute__(x)
85 #endif
86 
87 
91 typedef struct
92 {
93  uint8_t passkey[SM_PASSKEY_MAX_BYTE_LEN];
94  uint8_t match_request;
95 } __attribute__((packed)) ble_sm_evt_passkey_display_t;
96 
112 typedef struct
113 {
114  uint8_t sm : 4;
115  uint8_t lv : 4;
116  uint8_t encr_key_size;
117 } __attribute__((packed)) ble_sm_conn_sec_t;
118 
122 typedef struct
123 {
124  uint8_t auth_status;
125 } __attribute__((packed)) ble_sm_evt_auth_status_t;
126 
130 typedef struct
131 {
132  uint8_t bond : 1;
133  uint8_t mitm : 1;
134 } __attribute__((packed)) ble_sm_evt_sec_request_t;
135 
139 typedef struct
140 {
142  uint8_t status;
143 } __attribute__((packed)) ble_sm_evt_conn_sec_update_t;
144 
148 typedef struct
149 {
150  uint8_t keyType;
151 } __attribute__((packed)) ble_sm_evt_auth_key_request_t;
152 
156 typedef struct
157 {
158  uint8_t r[BLE_GAP_SEC_KEY_LEN];
159  uint8_t c[BLE_GAP_SEC_KEY_LEN];
160 }__attribute__((packed)) ble_lesc_oob_data_t;
161 
165 typedef struct
166 {
167  uint16_t connHdl;
168  union
169  {
176  } __attribute__((packed)) params;
177 }__attribute__((packed)) ble_sm_evt_t;
178 
179 #ifdef _MSC_VER
180 __pragma(pack(pop))
181 #undef __attribute__
182 #endif
183 
187 typedef enum
188 {
197 
203 #endif
ble_sm_evt_sec_request_t sec_request
Definition: ble_sm.h:174
Definition: ble_sm.h:193
uint8_t encr_key_size
Definition: ble_sm.h:116
Event structure.
Definition: ble_sm.h:165
ble_sm_evt_auth_status_t auth_status
Definition: ble_sm.h:173
SM event.
Definition: bt_constants.h:44
uint8_t lv
Definition: ble_sm.h:115
ble_sm_event_id
Security manager event ID.
Definition: ble_sm.h:187
Event structure for BLE_SM_EVT_AUTH_KEY_REQUEST.
Definition: ble_sm.h:148
Event structure for BLE_SM_EVT_SEC_REQUEST.
Definition: ble_sm.h:130
Definition: ble_sm.h:194
ble_sm_evt_conn_sec_update_t conn_sec_update
Definition: ble_sm.h:171
ble_sm_evt_auth_key_request_t auth_key_request
Definition: ble_sm.h:172
uint8_t sm
Definition: ble_sm.h:114
Event structure for BLE_SM_EVT_PASSKEY_DISPLAY.
Definition: ble_sm.h:91
uint8_t mitm
Definition: ble_sm.h:133
uint8_t keyType
Definition: ble_sm.h:150
Event structure for BLE_SM_EVT_AUTH_STATUS.
Definition: ble_sm.h:122
uint8_t bond
Definition: ble_sm.h:132
Definition: ble_sm.h:191
ble_sm_conn_sec_t conn_sec
Definition: ble_sm.h:141
Definition: ble_sm.h:190
Definition: ble_sm.h:195
Definition: ble_sm.h:192
Connection security modes.
Definition: ble_sm.h:112
LE SC OOB data structure.
Definition: ble_sm.h:156
ble_sm_evt_passkey_display_t passkey_display
Definition: ble_sm.h:170
uint16_t connHdl
Definition: ble_sm.h:167
uint8_t status
Definition: ble_sm.h:142
#define BLE_GAP_SEC_KEY_LEN
GAP Security Key Length.
Definition: bt_constants.h:67
ble_lesc_oob_data_t oob_data_response
Definition: ble_sm.h:175
Event structure for BLE_SM_EVT_CONN_SEC_UPDATE.
Definition: ble_sm.h:139
uint8_t auth_status
Definition: ble_sm.h:124
Definition: ble_sm.h:189