smp protocal
android smp state machine
data structure
smp has two role initiator and responder, in aosp code correspond to master and slave :( so
there is a table smp_br_entry_table
, include master entry map and slave entry map. smp state is
in smp control block.
static const tSMP_BR_ENTRY_TBL smp_br_entry_table[] = {smp_br_master_entry_map,
smp_br_slave_entry_map};
the two table are similar, we first focus on master; the table are two-dimensional array, in smp_br_state_machine_event use entry_table[event - 1][curr_state]
, then lets look
smp_br_master_entry_map
, event is
static const uint8_t smp_br_master_entry_map[][SMP_BR_STATE_MAX] = {
/* br_state name: Idle WaitApp Pair Bond
Rsp ReqRsp Pend */
/* BR_PAIRING_REQ */ {0, 0, 0, 0},
/* BR_PAIRING_RSP */ {0, 0, 1, 0},
/* BR_CONFIRM */ {0, 0, 0, 0},
/* BR_RAND */ {0, 0, 0, 0},
/* BR_PAIRING_FAILED */ {0, 0x81, 0x81, 0},
/* BR_ENCRPTION_INFO */ {0, 0, 0, 0},
/* BR_MASTER_ID */ {0, 0, 0, 0},
/* BR_ID_INFO */ {0, 0, 0, 1},
/* BR_ID_ADDR */ {0, 0, 0, 2},
/* BR_SIGN_INFO */ {0, 0, 0, 3},
/* BR_SECURITY_REQ */ {0, 0, 0, 0},
/* BR_PAIR_PUBLIC_KEY_EVT */ {0, 0, 0, 0},
/* BR_PAIR_DHKEY_CHCK_EVT */ {0, 0, 0, 0},
/* BR_PAIR_KEYPR_NOTIF_EVT */ {0, 0, 0, 0},
/* BR_KEY_READY */ {0, 0, 0, 0},
/* BR_ENCRYPTED */ {0, 0, 0, 0},
/* BR_L2CAP_CONN */ {1, 0, 0, 0},
/* BR_L2CAP_DISCONN */ {2, 0x83, 0x83, 0x83},
/* BR_KEYS_RSP */ {0, 1, 0, 0},
/* BR_API_SEC_GRANT */ {0, 0, 0, 0},
/* BR_TK_REQ */ {0, 0, 0, 0},
/* BR_AUTH_CMPL */ {0, 0x82, 0x82, 0x82},
/* BR_ENC_REQ */ {0, 0, 0, 0},
/* BR_BOND_REQ */ {0, 0, 2, 0},
/* BR_DISCARD_SEC_REQ */ {0, 0, 0, 0}};
static const uint8_t smp_br_all_table[][SMP_BR_SM_NUM_COLS] = {
/* Event Action Next State */
/* BR_PAIRING_FAILED */
{SMP_PROC_PAIR_FAIL, SMP_BR_PAIRING_COMPLETE, SMP_BR_STATE_IDLE},
/* BR_AUTH_CMPL */
{SMP_SEND_PAIR_FAIL, SMP_BR_PAIRING_COMPLETE, SMP_BR_STATE_IDLE},
/* BR_L2CAP_DISCONN */
{SMP_PAIR_TERMINATE, SMP_BR_SM_NO_ACTION, SMP_BR_STATE_IDLE}};