藍芽LMP剖析(二)
阿新 • • 發佈:2018-12-21
#include "bt_lmp.h"LMP_Core *LMP_Core_M;int LMP_Init(uint8_t role,uint8_t local_name[14],uint64_t local_feature,uint32_t local_clock,uint8_t min_power,uint8_t max_power,uint8_t default_power){ if(LMP_Core_M == NULL) { LMP_Core_M = malloc(sizeof(LMP_Core)); } else { BT_LMP_DEBUG(("WARNING:LMP_Core_M already has malloc memory\n" )); return -1; } if(LMP_Core_M == NULL) { BT_LMP_DEBUG(("WARING:LMP INIT FAULT\n")); return -1; } memset(LMP_Core_M,0,sizeof(LMP_Core)); LMP_Core_M->has_commite_setup_complete = 0; memset(LMP_Core_M->K_init,0,16); memset(LMP_Core_M->link_key,0,16); LMP_Core_M->local_role = role; LMP_Core_M->local_feature = local_feature; LMP_Core_M->AFH_mode = 0 ; LMP_Core_M->local_clock = local_clock; LMP_Core_M->remote_clock = 0; LMP_Core_M->offset = 0; LMP_Core_M->CQDDR = 0; LMP_Core_M->min_power = min_power; LMP_Core_M->max_power = max_power; LMP_Core_M->now_power = default_power; LMP_Core_M->hold_status = 0; LMP_Core_M->hold_time = 0 ; LMP_Core_M->hold_instant = 0; LMP_Core_M->max_slot = 0; memcpy(LMP_Core_M->local_name,local_name,14);}/* SEND PDU*/int LMP_Send_Feature_req(uint8_t role,uint64_t feature){ LMP_features_req_format PDU; memset(&PDU,0,sizeof(LMP_features_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_features_req); PDU.feature = feature; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_features_req_format));}int LMP_Send_Feature_rsp(uint8_t role,uint64_t feature){ LMP_features_rsp_format PDU; memset(&PDU,0,sizeof(LMP_features_rsp_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_features_rsp); PDU.feature = feature; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_features_rsp));}int LMP_Send_host_connection_req(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_host_connection_req\n")); LMP_host_connection_req_format PDU; memset(&PDU,0,sizeof(LMP_host_connection_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_host_connection_req); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_host_connection_req_format));}int LMP_Send_accepted(uint8_t role,uint8_t accept,uint8_t opcode){ BT_LMP_DEBUG(("LMP_Send_accepted\n")); LMP_accepted_format PDU; memset(&PDU,0,sizeof(LMP_accepted_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_accepted); PDU.opcode = opcode; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_accepted_format));}int LMP_Send_not_accepted(uint8_t role,uint8_t accept,uint8_t opcode,uint8_t errcode){ BT_LMP_DEBUG(("LMP_Send_not_accepted\n")); LMP_not_accepted_format PDU; memset(&PDU,0,sizeof(LMP_not_accepted_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_not_accepted); PDU.opcode = opcode; PDU.errcode = errcode; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_not_accepted_format));}int LMP_Send_LMP_version_req(uint8_t role,uint8_t vernr,uint16_t comid,uint16_t subvernr){ BT_LMP_DEBUG(("LMP_Send_LMP_version_req\n")); LMP_version_req_format PDU; memset(&PDU,0,sizeof(LMP_version_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_version_req); PDU.versnr = vernr; PDU.compid = comid; PDU.subvernr = subvernr; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_version_req_format));}int LMP_Send_LMP_version_rsp(uint8_t role,uint8_t vernr,uint16_t comid,uint16_t subvernr){ BT_LMP_DEBUG(("LMP_Send_LMP_version_rsp\n")); LMP_version_rsp_format PDU; memset(&PDU,0,sizeof(LMP_version_rsp_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_version_rsp); PDU.versnr = vernr; PDU.compid = comid; PDU.subvernr = subvernr; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_version_rsp_format));}int LMP_Send_set_AFH(uint8_t role,uint32_t AFH_instant,uint8_t AFH_mode,uint8_t AFH_channel_map[10]){ BT_LMP_DEBUG(("LMP_Send_set_AFH\n")); LMP_set_AFH_format PDU; memset(&PDU,0,sizeof(LMP_set_AFH_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_set_AFH); PDU.AFH_instant = AFH_instant; PDU.AFH_mode = AFH_mode; memcpy(&(PDU.AFH_channel_map),AFH_channel_map,10); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_set_AFH_format));}int LMP_Send_setup_complete(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_setup_complete\n")); LMP_setup_complete_format PDU; memset(&PDU,0,sizeof(LMP_setup_complete_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_setup_complete); LMP_Core_M->has_commite_setup_complete = 1; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_setup_complete_format));}int LMP_Send_in_rand(uint8_t role,uint8_t random[16]){ BT_LMP_DEBUG(("LMP_Send_in_rand\n")); LMP_in_rand_format PDU; memset(&PDU,0,sizeof(LMP_in_rand_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_in_rand); memcpy(&(PDU.random_nub),random,16); memcpy(LMP_Core_M->K_init,random,16); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_in_rand_format));}int LMP_Send_comb_key(uint8_t role,uint8_t random[16]){ BT_LMP_DEBUG(("LMP_Send_comb_key\n")); LMP_comb_key_format PDU; memset(&PDU,0,sizeof(LMP_comb_key_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_comb_key); memcpy(&(PDU.random_nub),random,16); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_comb_key_format));}int LMP_Send_au_rand(uint8_t role,uint8_t random[16]){ BT_LMP_DEBUG(("LMP_Send_au_rand\n")); LMP_au_rand_format PDU; memset(&PDU,0,sizeof(LMP_au_rand_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_au_rand); memcpy(&(PDU.random_nub),random,16); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_au_rand_format));}int LMP_Send_sres(uint8_t role,uint8_t auth_rsp[4]){ BT_LMP_DEBUG(("LMP_Send_sres\n")); LMP_sres_format PDU; memset(&PDU,0,sizeof(LMP_sres_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_sres); memcpy(&(PDU.auth_rsp),auth_rsp,4); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_sres_format));}int LMP_Send_auto_rate(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_auto_rate\n")); LMP_auto_rate_format PDU; memset(&PDU,0,sizeof(LMP_auto_rate_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_auto_rate); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_auto_rate_format));}int LMP_Send_clkoffset_req(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_clkoffset_req\n")); LMP_clkoffset_req_format PDU; memset(&PDU,0,sizeof(LMP_clkoffset_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_clkoffset_req); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_clkoffset_req_format));}int LMP_Send_clkoffset_rsp(uint8_t role,uint16_t clock_offset){ BT_LMP_DEBUG(("LMP_Send_clkoffset_rsp\n")); LMP_clkoffset_rsp_format PDU; memset(&PDU,0,sizeof(LMP_clkoffset_rsp_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_clkoffset_rsp); PDU.clock_offset = clock_offset; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_clkoffset_rsp_format));}int LMP_Send_incr_power_req(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_incr_power_req\n")); LMP_incr_power_req_format PDU; memset(&PDU,0,sizeof(LMP_incr_power_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_incr_power_req); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_incr_power_req_format));}int LMP_Send_decr_power_req(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_decr_power_req\n")); LMP_decr_power_req_format PDU; memset(&PDU,0,sizeof(LMP_decr_power_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_decr_power_req); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_decr_power_req_format));}int LMP_Send_min_power(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_min_power\n")); LMP_min_power_format PDU; memset(&PDU,0,sizeof(LMP_min_power_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_min_power); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_min_power_format));}int LMP_Send_max_power(uint8_t role){ BT_LMP_DEBUG(("LMP_Send_max_power\n")); LMP_max_power_format PDU; memset(&PDU,0,sizeof(LMP_max_power_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_max_power); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_max_power_format));}int LMP_Send_detach(uint8_t role,uint8_t errcode){ BT_LMP_DEBUG(("LMP_Send_detach\n")); LMP_detach_format PDU; memset(&PDU,0,sizeof(LMP_detach_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_detach); PDU.errcode = errcode; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_detach_format));}int LMP_Send_hold(uint8_t role,uint16_t hold_time,uint32_t hold_instant){ BT_LMP_DEBUG(("LMP_Send_LMP_hold\n")); LMP_hold_format PDU; memset(&PDU,0,sizeof(LMP_hold_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_hold); PDU.hold_time = hold_time; PDU.hold_instant = hold_instant; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_hold_format));}int LMP_Send_hold_req(uint8_t role,uint16_t hold_time,uint32_t hold_instant){ BT_LMP_DEBUG(("LMP_Send_LMP_hold_req\n")); LMP_hold_req_format PDU; memset(&PDU,0,sizeof(LMP_hold_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_hold_req); PDU.hold_time = hold_time; PDU.hold_instant = hold_instant; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_hold_req_format));}int LMP_Send_max_slot(uint8_t role,uint8_t max_slot){ BT_LMP_DEBUG(("LMP_max_slot\n")); LMP_max_slot_format PDU; memset(&PDU,0,sizeof(LMP_max_slot_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_max_slot); PDU.max_slot = max_slot; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_max_slot_format));}int LMP_Send_max_slot_req(uint8_t role,uint8_t max_slot){ BT_LMP_DEBUG(("LMP_Send_max_slot_req\n")); LMP_max_slot_req_format PDU; memset(&PDU,0,sizeof(LMP_max_slot_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_max_slot_req); PDU.max_slot = max_slot; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_max_slot_req_format));}int LMP_Send_name_req(uint8_t role,uint8_t name_offset){ BT_LMP_DEBUG(("LMP_Send_name_req\n")); LMP_name_req_format PDU; memset(&PDU,0,sizeof(LMP_name_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_name_req); PDU.name_offset = name_offset; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_name_req_format));}int LMP_Send_name_rsp(uint8_t role,uint8_t name_offset,uint8_t name_length,uint8_t name[14]){ BT_LMP_DEBUG(("LMP_Send_name_rsp\n")); LMP_name_rsp_format PDU; memset(&PDU,0,sizeof(LMP_name_rsp_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_name_rsp); PDU.name_offset = name_offset; PDU.name_length = name_length; if(name_length > 13) { memcpy(&(PDU.name),name,13); } else { memcpy(&(PDU.name),name,name_length); } LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_name_req_format));}int LMP_Send_page_mode_req(uint8_t role,uint8_t paging_scheme,uint8_t paging_scheme_settings){ BT_LMP_DEBUG(("LMP_Send_page_mode_req\n")); LMP_page_mode_req_format PDU; memset(&PDU,0,sizeof(LMP_page_mode_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_page_mode_req); PDU.paging_scheme = paging_scheme; PDU.paging_scheme_settings = paging_scheme_settings; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_page_mode_req_format));}int LMP_Send_page_scan_mode_req(uint8_t role,uint8_t paging_scheme,uint8_t paging_scheme_settings){ BT_LMP_DEBUG(("LMP_Send_page_scan_mode_req\n")); LMP_page_scan_mode_req_format PDU; memset(&PDU,0,sizeof(LMP_page_scan_mode_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_page_scan_mode_req); PDU.paging_scheme = paging_scheme; PDU.paging_scheme_settings = paging_scheme_settings; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_page_scan_mode_req_format));}int LMP_Send_preferred_rate(uint8_t role,uint8_t data_rate){ BT_LMP_DEBUG(("LMP_Send_preferred_rate\n")); LMP_preferred_rate_format PDU; memset(&PDU,0,sizeof(LMP_preferred_rate_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_preferred_rate); PDU.data_rate = data_rate; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_preferred_rate_format));}int LMP_Send_quality_of_service(uint8_t role,uint16_t poll_interval,uint8_t NBC){ BT_LMP_DEBUG(("LMP_Send_quality_of_service\n")); LMP_quality_of_service_format PDU; memset(&PDU,0,sizeof(LMP_quality_of_service_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_quality_of_service); PDU.poll_interval = poll_interval; PDU.NBC = NBC; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_quality_of_service_format));}int LMP_Send_quality_of_service_req(uint8_t role,uint16_t poll_interval,uint8_t NBC){ BT_LMP_DEBUG(("LMP_Send_quality_of_service_req\n")); LMP_quality_of_service_req_format PDU; memset(&PDU,0,sizeof(LMP_quality_of_service_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_quality_of_service_req); PDU.poll_interval = poll_interval; PDU.NBC = NBC; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_quality_of_service_req_format));}int LMP_Send_remove_SCO_link_req(uint8_t role,uint8_t SCO_handle,uint8_t errcode){ BT_LMP_DEBUG(("LMP_Send_remove_SCO_link_req\n")); LMP_remove_SCO_link_req_format PDU; memset(&PDU,0,sizeof(LMP_remove_SCO_link_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_remove_SCO_link_req); PDU.SCO_handle = SCO_handle; PDU.errcode = errcode; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_remove_SCO_link_req_format));}int LMP_Send_SCO_link_req(uint8_t role,uint8_t SCO_handle,uint8_t timing_control_flags,uint8_t Dsco,uint8_t Tsco,uint8_t SCO_packe,uint8_t air_mode){ BT_LMP_DEBUG(("LMP_Send_SCO_link_req\n")); LMP_SCO_link_req_format PDU; memset(&PDU,0,sizeof(LMP_SCO_link_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_SCO_link_req); PDU.SCO_handle = SCO_handle; PDU.timing_control_flags = timing_control_flags; PDU.Dsco = Dsco; PDU.SCO_packe = SCO_packe; PDU.air_mode = air_mode; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_SCO_link_req_format));}int LMP_Send_Simple_Pairing_Confirm(uint8_t role,uint8_t Commitment_Value[16]){ BT_LMP_DEBUG(("LMP_Send_Simple_Pairing_Confirm\n")); LMP_Simple_Pairing_Confirm_format PDU; memset(&PDU,0,sizeof(LMP_Simple_Pairing_Confirm_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_Simple_Pairing_Confirm); memcpy(&(PDU.Commitment_Value),Commitment_Value,16); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_Simple_Pairing_Confirm_format));}int LMP_Send_Simple_Pairing_Number(uint8_t role,uint8_t Nonce_Value[16]){ BT_LMP_DEBUG(("LMP_Send_Simple_Pairing_Number\n")); LMP_Simple_Pairing_Number_format PDU; memset(&PDU,0,sizeof(LMP_Simple_Pairing_Number_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_Simple_Pairing_Number); memcpy(&(PDU.Nonce_Value),Nonce_Value,16); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_Simple_Pairing_Number_format));}int LMP_Send_slot_offset(uint8_t role,uint16_t slot_offset,uint8_t BD_ADDR[6]){ BT_LMP_DEBUG(("LMP_Send_slot_offset\n")); LMP_slot_offset_format PDU; memset(&PDU,0,sizeof(LMP_slot_offset_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_slot_offset); PDU.slot_offset = slot_offset; memcpy(PDU.BD_ADDR,BD_ADDR,6); LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_slot_offset_format));}int LMP_Send_sniff_req(uint8_t role,uint8_t timing_control_flags,uint16_t Dsniff,uint16_t Tsniffe,uint16_t sniff_attempt,uint16_t sniff_timeout){ BT_LMP_DEBUG(("LMP_Send_sniff_req\n")); LMP_sniff_req_format PDU; memset(&PDU,0,sizeof(LMP_sniff_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_sniff_req); PDU.timing_control_flags = timing_control_flags; PDU.Dsniff = Dsniff; PDU.Tsniffe = Tsniffe; PDU.sniff_attempt = sniff_attempt; PDU.sniff_timeout = sniff_timeout; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_sniff_req_format));}int LMP_Send_supervision_timeout(uint8_t role,uint16_t supervision_timeout){ BT_LMP_DEBUG(("LMP_Send_supervision_timeout\n")); LMP_supervision_timeout_format PDU; memset(&PDU,0,sizeof(LMP_supervision_timeout_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_supervision_timeout); PDU.supervision_timeout = supervision_timeout; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_supervision_timeout_format));}int LMP_Send_switch_req(uint8_t role,uint32_t switch_instant){ BT_LMP_DEBUG(("LMP_Send_switch_req_\n")); LMP_switch_req_format PDU; memset(&PDU,0,sizeof(LMP_switch_req_format)); LMP_SET_S_HDR(&(PDU.hdr),role,LMP_switch_req); PDU.switch_instant = switch_instant; LMP_Send_PDU((uint8_t *)&PDU,sizeof(LMP_switch_req_format));}int LMP_Send_PDU(uint8_t *PDU,uint32_t length){ LMP_Parse_PDU(PDU,length);}int LMP_Parse_PDU(uint8_t *PDU,uint32_t length){ uint32_t PDU_ID; if(LMP_GET_TID(PDU) == LMP_MASTER_ROLE || LMP_GET_TID(PDU) == LMP_SLAVE_ROLE); else { BT_LMP_DEBUG(("WARING:INVALID ROLE\n")); return -1; } PDU_ID = LMP_GET_S_OPC(PDU); BT_LMP_DEBUG(("PDU ID = %d\n",PDU_ID)); switch(PDU_ID) { case LMP_accepted: { BT_LMP_DEBUG(("PDU_ID is LMP_accepted\n")); LMP_Parse_Send_accepted(PDU,length); //TODO break; } case LMP_not_accepted: { BT_LMP_DEBUG(("PDU_ID is LMP_not_accepted\n")); break; } case LMP_comb_key: { BT_LMP_DEBUG(("PDU_ID is LMP_comb_key\n")); LMP_Parse_Send_comb_key(PDU,length); break; } case LMP_version_req: { BT_LMP_DEBUG(("PDU_ID is LMP_version_req\n")); LMP_Send_LMP_version_rsp(LMP_Core_M->remote_role,LMP_VERSION_4_0,TI,LMP_SBUVERSION); break; } case LMP_version_rsp: { BT_LMP_DEBUG(("PDU_ID is LMP_version_rsp\n")); LMP_Parse_Send_version_req(PDU,length); LMP_Parse_Send_version_rsp(PDU,length); break; } case LMP_features_req: { BT_LMP_DEBUG(("PDU_ID is LMP_features_req\n")); LMP_Parse_Send_Feature_req(PDU,length); LMP_Send_Feature_rsp(LMP_Core_M->remote_role,LMP_Core_M->local_feature); break; } case LMP_features_rsp: { BT_LMP_DEBUG(("PDU_ID is LMP_features_rsp\n")); LMP_Parse_Send_Feature_rsp(PDU,length); //TODO break; } case LMP_host_connection_req: { BT_LMP_DEBUG(("PDU_ID is LMP_host_connection_req\n")); LMP_Parse_Send_host_connection_req(PDU,length); LMP_Send_accepted(LMP_Core_M->remote_role,LMP_ACCEPT,LMP_host_connection_req); break; } case LMP_setup_complete: { BT_LMP_DEBUG(("PDU_ID is LMP_setup_complete\n")); if(LMP_Core_M->has_commite_setup_complete == 1) { BT_LMP_DEBUG(("REMOTE RSP\n")); } else { BT_LMP_DEBUG(("REMOTE REQ\n")); LMP_Send_setup_complete(LMP_Core_M->remote_role); } break; } case LMP_set_AFH: { BT_LMP_DEBUG(("PDU_ID is LMP_set_AFH\n")); LMP_Parse_Send_set_AFH(PDU,length); break; } case LMP_in_rand: { BT_LMP_DEBUG(("PDU_ID is LMP_in_rand\n")); LMP_Parse_Send_in_rand(PDU,length); LMP_Send_accepted(LMP_Core_M->remote_role,LMP_ACCEPT,LMP_in_rand); break; } case LMP_au_rand: { BT_LMP_DEBUG(("PDU_ID is LMP_au_rand\n")); break; } case LMP_sres: { BT_LMP_DEBUG(("PDU_ID is LMP_sres\n")); break; } case LMP_auto_rate: { BT_LMP_DEBUG(("PDU_ID is LMP_auto_rate\n")); LMP_Parse_Send_auto_rate(PDU,length); break; } case LMP_clkoffset_req: { BT_LMP_DEBUG(("PDU_ID is LMP_clkoffset_req\n")); LMP_Parse_Send_clkoffset_req(PDU,length); break; } case LMP_clkoffset_rsp: { BT_LMP_DEBUG(("PDU_ID is LMP_clkoffset_rsp\n")); LMP_Parse_Send_clkoffset_rsp(PDU,length); break; } case LMP_incr_power_req: { BT_LMP_DEBUG(("PDU_ID is LMP_incr_power_req\n")); LMP_Parse_Send_incr_power_req(PDU,length); break; } case LMP_decr_power_req: { BT_LMP_DEBUG(("PDU_ID is LMP_decr_power_req\n")); LMP_Parse_Send_decr_power_req(PDU,length); break; } case LMP_max_power: { BT_LMP_DEBUG(("PDU_ID is LMP_max_power\n")); break; } case LMP_min_power: { BT_LMP_DEBUG(("PDU_ID is LMP_min_power\n")); break; } case LMP_detach: { BT_LMP_DEBUG(("PDU_ID is LMP_detach\n")); break; } case LMP_hold: { BT_LMP_DEBUG(("PDU_ID is LMP_hold\n")); LMP_Parse_Send_hold(PDU,length); break; } case LMP_hold_req: { BT_LMP_DEBUG(("PDU_ID is LMP_hold_req\n")); break; } case LMP_max_slot: { BT_LMP_DEBUG(("PDU_ID is LMP_max_slot\n")); break; } case LMP_max_slot_req: { BT_LMP_DEBUG(("PDU_ID is LMP_max_slot_req\n")); break; } case LMP_name_req: { BT_LMP_DEBUG(("PDU_ID is LMP_name_req\n")); LMP_Parse_Send_name_req(PDU,length); break; } case LMP_name_rsp: { BT_LMP_DEBUG(("PDU_ID is LMP_name_rsp\n")); LMP_Parse_Send_name_rsq(PDU,length); break; } case LMP_page_mode_req: { BT_LMP_DEBUG(("PDU_ID is LMP_page_mode_req\n")); LMP_Parse_Send_page_mode_req(PDU,length); break; } case LMP_page_scan_mode_req: { BT_LMP_DEBUG(("PDU_ID is LMP_page_scan_mode_req\n")); LMP_Parse_Send_page_scan_mode_req(PDU,length); break; } case LMP_preferred_rate: { BT_LMP_DEBUG(("PDU_ID is LMP_preferred_rate\n")); LMP_Parse_Send_preferred_rate(PDU,length); break; } case LMP_quality_of_service: { BT_LMP_DEBUG(("PDU_ID is LMP_quality_of_service\n")); LMP_Parse_Send_quality_of_service(PDU,length); break; } case LMP_quality_of_service_req: { BT_LMP_DEBUG(("PDU_ID is LMP_quality_of_service_req\n")); LMP_Parse_Send_quality_of_service_req(PDU,length); break; } case LMP_remove_SCO_link_req: { BT_LMP_DEBUG(("PDU_ID is LMP_remove_SCO_link_req\n")); LMP_Parse_Send_remove_SCO_link_req(PDU,length); break; } case LMP_SCO_link_req: { BT_LMP_DEBUG(("PDU_ID is LMP_SCO_link_req\n")); LMP_Parse_Send_SCO_link_req(PDU,length); break; } case LMP_Simple_Pairing_Confirm: { BT_LMP_DEBUG(("PDU_ID is LMP_Simple_Pairing_Confirm\n")); LMP_Parse_Send_Simple_Pairing_Confirm(PDU,length); break; } case LMP_Simple_Pairing_Number: { BT_LMP_DEBUG(("PDU_ID is LMP_Simple_Pairing_Number\n")); LMP_Parse_Send_Simple_Pairing_Number(PDU,length); break; } case LMP_slot_offset: { BT_LMP_DEBUG(("PDU_ID is LMP_slot_offset\n")); LMP_Parse_Send_slot_offset(PDU,length); break; } case LMP_sniff_req: { BT_LMP_DEBUG(("PDU_ID is LMP_sniff_req\n")); LMP_Parse_Send_sniff_req(PDU,length); break; } case LMP_supervision_timeout: { BT_LMP_DEBUG(("PDU_ID is LMP_supervision_timeout\n")); LMP_Parse_Send_supervision_timeout(PDU,length); break; } case LMP_switch_req: { BT_LMP_DEBUG(("PDU_ID is LMP_switch_req\n")); LMP_Parse_Send_switch_req(PDU,length); break; } default: { BT_LMP_DEBUG(("WARNING:UNKNOW PDU ID\n")); break; } }}int LMP_Parse_Send_Feature_req(uint8_t *PDU,uint32_t length){ LMP_features_req_format *tmp_PDU_ptr = (LMP_features_req_format *)PDU; LMP_Core_M->remote_role = LMP_GET_TID(PDU); LMP_Core_M->remote_feature = tmp_PDU_ptr->feature;}int LMP_Parse_Send_Feature_rsp(uint8_t *PDU,uint32_t length){ LMP_features_rsp_format *tmp_PDU_ptr = (LMP_features_rsp_format *)PDU; LMP_Core_M->remote_feature = tmp_PDU_ptr->feature; }int LMP_Parse_Send_host_connection_req(uint8_t *PDU,uint32_t length){ LMP_host_connection_req_format *tmp_PDU_ptr = (LMP_host_connection_req_format *)PDU;}int LMP_Parse_Send_accepted(uint8_t *PDU,uint32_t length){ LMP_accepted_format *tmp_PDU_ptr = (LMP_accepted_format *)PDU; uint8_t tmp_accept_opcode = tmp_PDU_ptr->opcode; }int LMP_Parse_Send_not_accepted(uint8_t *PDU,uint32_t length){ LMP_not_accepted_format *tmp_PDU_ptr = (LMP_not_accepted_format *)PDU; LMP_Core_M->local_role = LMP_GET_TID(PDU); //TODO}i