| Airoha M0 BLE API 1.0.5.4

sm_protocol.h
1 /******************************************************************************
2 Copyright (c) Airoha 2016 - All rights reserved
3
4 FILE NAME
5 sm_protocol.h
6 DESCRIPTION
7 NOTES
8 ********************************************************************************/
9 #ifndef __SM_PROTOCOL_H__
10 #define __SM_PROTOCOL_H__
11
12 /*************************************************************************
13 * Macro and Type define
14 *************************************************************************/
15 /* SM_PAIRING_FAIL_REASON */
16 #define SM_FAIL_RESERVED 0x00
17 #define SM_FAIL_PASSKEY_ENTRY_FAILED 0x01
18 #define SM_FAIL_OOB_NOT_AVAILABLE 0x02
19 #define SM_FAIL_AUTHENTHICATION_REQUIREMENTS 0x03
20 #define SM_FAIL_CONFIRM_VALUE 0x04
21 #define SM_FAIL_PAIRING_NOT_SUPPORTED 0x05
22 #define SM_FAIL_ENCRYPTION_KEY_SIZE 0x06
23 #define SM_FAIL_COMMAND_NOT_SUPPORTED 0x07
24 #define SM_FAIL_UNSPECIFIED_REASON 0x08
25 #define SM_FAIL_REPEATED_ATTEMPTS 0x09
26 #define SM_FAIL_INVALID_PARAMETERS 0x0A
27 #define SM_FAIL_DHKEY_CHECK_FAILED 0x0B
28 #define SM_FAIL_NUMERIC_COMPARISON_FAILED 0x0C
29 #define SM_FAIL_BR_EDR_PAIRING_IN_PROGRESS 0x0D
30 #define SM_FAIL_CROSS_TRANSPORT_KEY_NOT_ALLOWED 0x0E
31 //Note:If more failed reasons are added, also add BLE_SM_STATUS@ble_sm.h
32
33 /* SM_COMMAND_CODE */
34 #define SM_CMD_PAIRING_REQUEST 0x01
35 #define SM_CMD_PAIRING_RESPONSE 0x02
36 #define SM_CMD_PAIRING_CONFIRM 0x03
37 #define SM_CMD_PAIRING_RANDOM 0x04
38 #define SM_CMD_PAIRING_FAILED 0x05
39 #define SM_CMD_ENCRYPTION_INFORMATION 0x06
40 #define SM_CMD_MASTER_IDENTIFICATION 0x07
41 #define SM_CMD_IDENTITY_INFORMATION 0x08
42 #define SM_CMD_IDENTITY_ADDRESS_INFORMATION 0x09
43 #define SM_CMD_SIGNING_INFORMATION 0x0A
44 #define SM_CMD_SECURITY_REQUEST 0x0B
45 #define SM_CMD_PAIRING_PUBLIC_KEY 0x0C
46 #define SM_CMD_PAIRING_DHKEY_CHECK 0x0D
47 #define SM_CMD_PAIRING_KEYPRESS_NOTIFICATION 0x0E
48
49 /* SM_COMMAND_CODE Length*/
50 #define SM_CMD_FEATURE_EXCHANGE_LEN 7
51 #define SM_CMD_PAIRING_FAIL_LEN 2
52 #define SM_CMD_SECURITY_REQUEST_LEN 2
53 #define SM_CMD_EXCHANGE_VALUE_LEN 17
54 #define SM_CMD_ENC_INFO_LEN 17
55 #define SM_CMD_MASTER_ID_LEN 11
56 #define SM_CMD_ID_INFO_LEN 17
57 #define SM_CMD_ID_ADDR_INFO_LEN 8
58 #define SM_CMD_SIGNING_INFO_LEN 17
59 #define SM_CMD_PAIRING_PUBLIC_KEY_LEN 65
60 #define SM_CMD_KEY_NOTIFICATION_LEN 2
61
62 typedef bool (*SM_Protocol_cb)(uint8_t idx, uint8_t cmd, uint8_t *dataPtr);
63
64 /*************************************************************************
65 * API
66 *************************************************************************/
67 void SM_Protocol_RegisterCallback(uint8_t role, SM_Protocol_cb cb);
68
69 void SM_Protocol_PairingRequest(uint8_t idx, uint8_t *pReq);
70 void SM_Protocol_PairingResponse(uint8_t idx, uint8_t *pRes);
71 void SM_Protocol_PairingConfirm(uint8_t idx, uint8_t *confirm);
72 void SM_Protocol_PairingRandom(uint8_t idx, uint8_t *rand);
73 void SM_Protocol_PairingFailed(uint8_t idx, uint8_t failReason);
74 void SM_Protocol_EncryptionInfo(uint8_t idx, uint8_t *LTK);
75 void SM_Protocol_MasterID(uint8_t idx, uint8_t *MasterInfo);
76 void SM_Protocol_IdentityInfo(uint8_t idx, uint8_t *identityInfo);
77 void SM_Protocol_IdentityAddressInfo(uint8_t idx);
78 void SM_Protocol_SigningInfo(uint8_t idx, uint8_t *CSRK);
79 uint8_t SM_Protocol_SecurityRequest(uint8_t idx, uint8_t authFlag);
80 void SM_Protocol_PairingPublicKey(uint8_t idx, uint8_t *publicKey);
81 void SM_Protocol_PairingDHKeyCheck(uint8_t idx, uint8_t *DHKeyCheck);
82 void SM_Protocol_PairingKeypressNotify(uint8_t idx, uint8_t keyPress);
83 #endif