diff options
author | Sven Gothel <[email protected]> | 2020-06-09 02:47:01 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-09 02:47:01 +0200 |
commit | af6d036f4e4b18cb95e7285b7e894844ba330626 (patch) | |
tree | 0606de6bd86b136f65daf548db3edf733d8ee1ef | |
parent | 4423cb7a5214acdcbe85a24e888322381a7a230e (diff) |
HCIHandler/Types: template process*Cmd: Pass pre-allocated template command, avoiding memcpy and explicit template type declaration @ caller
-rw-r--r-- | api/direct_bt/HCIHandler.hpp | 6 | ||||
-rw-r--r-- | api/direct_bt/HCITypes.hpp | 82 | ||||
-rw-r--r-- | src/direct_bt/HCIHandler.cpp | 118 |
3 files changed, 129 insertions, 77 deletions
diff --git a/api/direct_bt/HCIHandler.hpp b/api/direct_bt/HCIHandler.hpp index afc250a8..357d2b5c 100644 --- a/api/direct_bt/HCIHandler.hpp +++ b/api/direct_bt/HCIHandler.hpp @@ -104,15 +104,15 @@ namespace direct_bt { std::shared_ptr<HCIEvent> sendWithCmdStatusReply(HCICommand &req, HCICommandStatusEvent **res); template<typename hci_cmd_event_struct> - std::shared_ptr<HCIEvent> processCmdCompleteCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIStatusCode *status); + std::shared_ptr<HCIEvent> processSimpleCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIStatusCode *status); template<typename hci_command_struct, typename hci_cmd_event_struct> - std::shared_ptr<HCIEvent> processStructCommand(HCIOpcode opc, hci_command_struct &cp, + std::shared_ptr<HCIEvent> processStructCommand(HCIStructCommand<hci_command_struct> &req, HCIEventType evc, const hci_cmd_event_struct **res, HCIStatusCode *status); template<typename hci_command_struct, typename hci_cmd_event_struct> - std::shared_ptr<HCIEvent> processStructCommand(HCIOpcode opc, hci_command_struct &cp, + std::shared_ptr<HCIEvent> processStructMetaCmd(HCIStructCommand<hci_command_struct> &req, HCIMetaEventType mec, const hci_cmd_event_struct **res, HCIStatusCode *status); diff --git a/api/direct_bt/HCITypes.hpp b/api/direct_bt/HCITypes.hpp index 6ccc9aa6..c6b23b9e 100644 --- a/api/direct_bt/HCITypes.hpp +++ b/api/direct_bt/HCITypes.hpp @@ -435,6 +435,7 @@ namespace direct_bt { public: + /** Enabling manual construction of command without given value. */ HCICommand(const HCIOpcode opc, const uint8_t param_size) : HCIPacket(HCIPacketType::COMMAND, number(HCIConstU8::COMMAND_HDR_SIZE)+param_size) { @@ -444,13 +445,15 @@ namespace direct_bt { pdu.put_uint8(3, param_size); } - HCICommand(const HCIOpcode opc, const uint16_t param_size, const uint8_t* param) + /** Enabling manual construction of command with given value. */ + HCICommand(const HCIOpcode opc, const uint8_t* param, const uint16_t param_size) : HCICommand(opc, param_size) { if( param_size > 0 ) { memcpy(pdu.get_wptr(number(HCIConstU8::COMMAND_HDR_SIZE)), param, param_size); } } + virtual ~HCICommand() {} HCIOpcode getOpcode() const { return static_cast<HCIOpcode>( pdu.get_uint16(1) ); } @@ -490,11 +493,18 @@ namespace direct_bt { class HCIStructCommand : public HCICommand { public: - HCIStructCommand(HCIOpcode opc, const hcistruct &cp) - : HCICommand(opc, sizeof(hcistruct), (const uint8_t *)(&cp)) - { - } + /** Enabling manual construction of command without given value. */ + HCIStructCommand(const HCIOpcode opc) + : HCICommand(opc, sizeof(hcistruct)) + { } + + /** Enabling manual construction of command with given value. */ + HCIStructCommand(const HCIOpcode opc, const hcistruct &cp) + : HCICommand(opc, (const uint8_t *)(&cp), sizeof(hcistruct)) + { } + const hcistruct * getStruct() const { return (const hcistruct *)(getParam()); } + hcistruct * getWStruct() { return (hcistruct *)( pdu.get_wptr( number(HCIConstU8::COMMAND_HDR_SIZE) ) ); } }; /** @@ -554,6 +564,8 @@ namespace direct_bt { checkEventType(getEventType(), HCIEventType::INQUIRY_COMPLETE, HCIEventType::AMP_Receiver_Report); pdu.check_range(0, number(HCIConstU8::EVENT_HDR_SIZE)+getParamSize()); } + + /** Enabling manual construction of event without given value. */ HCIEvent(const HCIEventType evt, const uint16_t param_size=0) : HCIPacket(HCIPacketType::EVENT, number(HCIConstU8::EVENT_HDR_SIZE)+param_size), ts_creation(getCurrentMilliseconds()) { @@ -561,16 +573,16 @@ namespace direct_bt { pdu.put_uint8(1, number(evt)); pdu.put_uint8(2, param_size); } + + /** Enabling manual construction of event with given value. */ HCIEvent(const HCIEventType evt, const uint8_t* param, const uint16_t param_size) - : HCIPacket(HCIPacketType::EVENT, number(HCIConstU8::EVENT_HDR_SIZE)+param_size), ts_creation(getCurrentMilliseconds()) + : HCIEvent(evt, param_size) { - checkEventType(evt, HCIEventType::INQUIRY_COMPLETE, HCIEventType::AMP_Receiver_Report); - pdu.put_uint8(1, number(evt)); - pdu.put_uint8(2, param_size); if( param_size > 0 ) { memcpy(pdu.get_wptr(number(HCIConstU8::EVENT_HDR_SIZE)), param, param_size); } } + virtual ~HCIEvent() {} uint64_t getTimestamp() const { return ts_creation; } @@ -604,18 +616,31 @@ namespace direct_bt { class HCIStructCmdCompleteEvt : public HCIEvent { public: - HCIStructCmdCompleteEvt(const HCIEventType ec, const uint8_t* buffer, const int buffer_len) + /** Passing through preset buffer of this type */ + HCIStructCmdCompleteEvt(const uint8_t* buffer, const int buffer_len) : HCIEvent(buffer, buffer_len) { - checkEventType(getEventType(), ec); pdu.check_range(0, number(HCIConstU8::EVENT_HDR_SIZE)+sizeof(hcistruct)); } + + /** Enabling manual construction of event without given value. */ + HCIStructCmdCompleteEvt(const HCIEventType ec) + : HCIEvent(ec, sizeof(hcistruct)) + { } + + /** Enabling manual construction of event with given value. */ + HCIStructCmdCompleteEvt(const HCIEventType ec, const hcistruct &data) + : HCIEvent(ec, (const uint8_t *)(&data), sizeof(hcistruct)) + { } + bool isTypeAndSizeValid(const HCIEventType ec) const { return isEvent(ec) && pdu.is_range_valid(0, number(HCIConstU8::EVENT_HDR_SIZE)+sizeof(hcistruct)); } const hcistruct * getStruct() const { return (const hcistruct *)(getParam()); } HCIStatusCode getStatus() const { return static_cast<HCIStatusCode>( getStruct()->status ); } + + hcistruct * getWStruct() { return (hcistruct *)( pdu.get_wptr(number(HCIConstU8::EVENT_HDR_SIZE)) ); } }; @@ -779,10 +804,28 @@ namespace direct_bt { } public: + /** Passing through preset buffer of this type */ HCIMetaEvent(const uint8_t* buffer, const int buffer_len) : HCIEvent(buffer, buffer_len) { checkEventType(getEventType(), HCIEventType::LE_META); + pdu.check_range(0, number(HCIConstU8::EVENT_HDR_SIZE)+1); + } + + /** Enabling manual construction of event without given value. */ + HCIMetaEvent(const HCIMetaEventType mc, const int meta_param_size) + : HCIEvent(HCIEventType::LE_META, 1+meta_param_size) + { + pdu.put_uint8(number(HCIConstU8::EVENT_HDR_SIZE), number(mc)); + } + + /** Enabling manual construction of event with given value. */ + HCIMetaEvent(const HCIMetaEventType mc, const uint8_t * meta_param, const int meta_param_size) + : HCIMetaEvent(mc, meta_param_size) + { + if( meta_param_size > 0 ) { + memcpy(pdu.get_wptr(number(HCIConstU8::EVENT_HDR_SIZE)+1), meta_param, meta_param_size); + } } HCIMetaEventType getMetaEventType() const override { return static_cast<HCIMetaEventType>( pdu.get_uint8(number(HCIConstU8::EVENT_HDR_SIZE)) ); } @@ -796,18 +839,31 @@ namespace direct_bt { class HCIStructCmdCompleteMetaEvt : public HCIMetaEvent { public: - HCIStructCmdCompleteMetaEvt(const HCIMetaEventType mc, const uint8_t* buffer, const int buffer_len) + /** Passing through preset buffer of this type */ + HCIStructCmdCompleteMetaEvt(const uint8_t* buffer, const int buffer_len) : HCIMetaEvent(buffer, buffer_len) { - checkMetaType(getMetaEventType(), mc); pdu.check_range(0, number(HCIConstU8::EVENT_HDR_SIZE)+1+sizeof(hcistruct)); } + + /** Enabling manual construction of event without given value. */ + HCIStructCmdCompleteMetaEvt(const HCIMetaEventType mc) + : HCIMetaEvent(mc, sizeof(hcistruct)) + { } + + /** Enabling manual construction of event with given value. */ + HCIStructCmdCompleteMetaEvt(const HCIMetaEventType mc, const hcistruct &data) + : HCIMetaEvent(mc, (const uint8_t *)(&data), sizeof(hcistruct)) + { } + bool isTypeAndSizeValid(const HCIMetaEventType mc) const { return isMetaEvent(mc) && pdu.is_range_valid(0, number(HCIConstU8::EVENT_HDR_SIZE)+1+sizeof(hcistruct)); } const hcistruct * getStruct() const { return (const hcistruct *)( pdu.get_ptr(number(HCIConstU8::EVENT_HDR_SIZE)+1) ); } HCIStatusCode getStatus() const { return static_cast<HCIStatusCode>( getStruct()->status ); } + + hcistruct * getWStruct() { return (hcistruct *)( pdu.get_wptr(number(HCIConstU8::EVENT_HDR_SIZE)+1) ); } }; } // namespace direct_bt diff --git a/src/direct_bt/HCIHandler.cpp b/src/direct_bt/HCIHandler.cpp index a4477b32..78dda77e 100644 --- a/src/direct_bt/HCIHandler.cpp +++ b/src/direct_bt/HCIHandler.cpp @@ -35,7 +35,7 @@ // #define SHOW_LE_ADVERTISING 1 // #define PERF_PRINT_ON 1 -// #define VERBOSE_ON 1 +#define VERBOSE_ON 1 #include <dbt_debug.hpp> #include "BTIoctl.hpp" @@ -269,7 +269,7 @@ HCIHandler::HCIHandler(const BTMode btMode, const uint16_t dev_id, const int rep HCICommand req0(HCIOpcode::READ_LOCAL_VERSION, 0); const hci_rp_read_local_version * ev_lv; HCIStatusCode status; - std::shared_ptr<HCIEvent> ev = processCmdCompleteCommand<hci_rp_read_local_version>( + std::shared_ptr<HCIEvent> ev = processSimpleCommand<hci_rp_read_local_version>( HCIOpcode::READ_LOCAL_VERSION, &ev_lv, &status); if( nullptr == ev || nullptr == ev_lv ) { ERR_PRINT("HCIHandler::ctor: failed READ_LOCAL_VERSION: 0x%x (%s)", number(status), getHCIStatusCodeString(status).c_str()); @@ -341,30 +341,29 @@ HCIStatusCode HCIHandler::le_create_conn(uint16_t * handle_return, const EUI48 & ERR_PRINT("HCIHandler::le_create_conn: device not open"); return HCIStatusCode::INTERNAL_FAILURE; } - hci_cp_le_create_conn cp; - const uint16_t min_ce_length = 0x0000; const uint16_t max_ce_length = 0x0000; const uint8_t initiator_filter = 0x00; // whitelist not used but peer_bdaddr* - bzero((void*)&cp, sizeof(cp)); - cp.scan_interval = cpu_to_le(le_scan_interval); - cp.scan_window = cpu_to_le(le_scan_window); - cp.filter_policy = initiator_filter; - cp.peer_addr_type = peer_mac_type; - cp.peer_addr = peer_bdaddr; - cp.own_address_type = own_mac_type; - cp.conn_interval_min = cpu_to_le(conn_interval_min); - cp.conn_interval_max = cpu_to_le(conn_interval_max); - cp.conn_latency = cpu_to_le(conn_latency); - cp.supervision_timeout = cpu_to_le(supervision_timeout); - cp.min_ce_len = cpu_to_le(min_ce_length); - cp.max_ce_len = cpu_to_le(max_ce_length); + HCIStructCommand<hci_cp_le_create_conn> req0(HCIOpcode::LE_CREATE_CONN); + hci_cp_le_create_conn * cp = req0.getWStruct(); + bzero((void*)cp, sizeof(*cp)); + cp->scan_interval = cpu_to_le(le_scan_interval); + cp->scan_window = cpu_to_le(le_scan_window); + cp->filter_policy = initiator_filter; + cp->peer_addr_type = peer_mac_type; + cp->peer_addr = peer_bdaddr; + cp->own_address_type = own_mac_type; + cp->conn_interval_min = cpu_to_le(conn_interval_min); + cp->conn_interval_max = cpu_to_le(conn_interval_max); + cp->conn_latency = cpu_to_le(conn_latency); + cp->supervision_timeout = cpu_to_le(supervision_timeout); + cp->min_ce_len = cpu_to_le(min_ce_length); + cp->max_ce_len = cpu_to_le(max_ce_length); const hci_ev_le_conn_complete * ev_cc; HCIStatusCode status; - std::shared_ptr<HCIEvent> ev = processStructCommand<hci_cp_le_create_conn, hci_ev_le_conn_complete>( - HCIOpcode::LE_CREATE_CONN, cp, HCIMetaEventType::LE_CONN_COMPLETE, &ev_cc, &status); + std::shared_ptr<HCIEvent> ev = processStructMetaCmd(req0, HCIMetaEventType::LE_CONN_COMPLETE, &ev_cc, &status); if( HCIStatusCode::SUCCESS != status ) { return status; @@ -386,20 +385,20 @@ HCIStatusCode HCIHandler::create_conn(uint16_t * handle_return, const EUI48 &bda ERR_PRINT("HCIHandler::create_conn: device not open"); return HCIStatusCode::INTERNAL_FAILURE; } - hci_cp_create_conn cp; - bzero((void*)&cp, sizeof(cp)); - cp.bdaddr = bdaddr; - cp.pkt_type = cpu_to_le((uint16_t)(pkt_type & (uint16_t)ACL_PTYPE_MASK)); /* TODO OK excluding SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3) ? */ - cp.pscan_rep_mode = 0x02; /* TODO magic? */ - cp.pscan_mode = 0x00; /* TODO magic? */ - cp.clock_offset = cpu_to_le(clock_offset); - cp.role_switch = role_switch; + HCIStructCommand<hci_cp_create_conn> req0(HCIOpcode::CREATE_CONN); + hci_cp_create_conn * cp = req0.getWStruct(); + bzero((void*)cp, sizeof(*cp)); + cp->bdaddr = bdaddr; + cp->pkt_type = cpu_to_le((uint16_t)(pkt_type & (uint16_t)ACL_PTYPE_MASK)); /* TODO OK excluding SCO_PTYPE_MASK (HCI_HV1 | HCI_HV2 | HCI_HV3) ? */ + cp->pscan_rep_mode = 0x02; /* TODO magic? */ + cp->pscan_mode = 0x00; /* TODO magic? */ + cp->clock_offset = cpu_to_le(clock_offset); + cp->role_switch = role_switch; const hci_ev_conn_complete * ev_cc; HCIStatusCode status; - std::shared_ptr<HCIEvent> ev = processStructCommand<hci_cp_create_conn, hci_ev_conn_complete>( - HCIOpcode::CREATE_CONN, cp, HCIEventType::CONN_COMPLETE, &ev_cc, &status); + std::shared_ptr<HCIEvent> ev = processStructCommand(req0, HCIEventType::CONN_COMPLETE, &ev_cc, &status); if( HCIStatusCode::SUCCESS != status ) { return status; @@ -419,22 +418,21 @@ HCIStatusCode HCIHandler::disconnect(const uint16_t conn_handle, const HCIStatus if( 0 == conn_handle ) { return HCIStatusCode::SUCCESS; } - hci_cp_disconnect cp; - - bzero(&cp, sizeof(cp)); - cp.handle = conn_handle; - cp.reason = number(reason); + HCIStructCommand<hci_cp_disconnect> req0(HCIOpcode::DISCONNECT); + hci_cp_disconnect * cp = req0.getWStruct(); + bzero(cp, sizeof(*cp)); + cp->handle = conn_handle; + cp->reason = number(reason); const hci_ev_disconn_complete * ev_cc; HCIStatusCode status; - std::shared_ptr<HCIEvent> ev = processStructCommand<hci_cp_disconnect, hci_ev_disconn_complete>( - HCIOpcode::DISCONNECT, cp, HCIEventType::DISCONN_COMPLETE, &ev_cc, &status); + std::shared_ptr<HCIEvent> ev = processStructCommand(req0, HCIEventType::DISCONN_COMPLETE, &ev_cc, &status); return status; } template<typename hci_cmd_event_struct> -std::shared_ptr<HCIEvent> HCIHandler::processCmdCompleteCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIStatusCode *status) +std::shared_ptr<HCIEvent> HCIHandler::processSimpleCommand(HCIOpcode opc, const hci_cmd_event_struct **res, HCIStatusCode *status) { *res = nullptr; *status = HCIStatusCode::INTERNAL_FAILURE; @@ -474,21 +472,20 @@ std::shared_ptr<HCIEvent> HCIHandler::processCmdCompleteCommand(HCIOpcode opc, c } template<typename hci_command_struct, typename hci_cmd_event_struct> -std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_command_struct &cp, +std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIStructCommand<hci_command_struct> &req, HCIEventType evc, const hci_cmd_event_struct **res, HCIStatusCode *status) { *res = nullptr; *status = HCIStatusCode::INTERNAL_FAILURE; - HCIStructCommand<hci_command_struct> req0(opc, cp); - if( !sendCommand(req0) ) { + if( !sendCommand(req) ) { return nullptr; } int retryCount = 0; std::shared_ptr<HCIEvent> ev = nullptr; while( retryCount < HCI_READ_PACKET_MAX_RETRY ) { - ev = getNextReply(req0, retryCount); + ev = getNextReply(req, retryCount); if( nullptr == ev ) { break; // timeout, leave loop } else if( ev->isEvent(evc) ) { @@ -499,9 +496,9 @@ std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_co if( HCIStatusCode::SUCCESS != ev_cs->getStatus() ) { *status = ev_cs->getStatus(); WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s), errno %d %s: res %s, req %s", - getHCIOpcodeString(opc).c_str(), getHCIEventTypeString(evc).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIEventTypeString(evc).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), errno, strerror(errno), - ev_cs->toString().c_str(), req0.toString().c_str()); + ev_cs->toString().c_str(), req.toString().c_str()); return ev; } continue; // next packet @@ -512,9 +509,9 @@ std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_co if( nullptr == ev ) { // timeout exit WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s), errno %d %s: res nullptr, req %s", - getHCIOpcodeString(opc).c_str(), getHCIEventTypeString(evc).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIEventTypeString(evc).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), errno, strerror(errno), - req0.toString().c_str()); + req.toString().c_str()); return nullptr; } typedef HCIStructCmdCompleteEvt<hci_cmd_event_struct> HCIConnCompleteEvt; @@ -523,34 +520,33 @@ std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_co *status = ev_cc->getStatus(); *res = ev_cc->getStruct(); DBG_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s): res %s, req %s", - getHCIOpcodeString(opc).c_str(), getHCIEventTypeString(evc).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIEventTypeString(evc).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), - ev_cc->toString().c_str(), req0.toString().c_str()); + ev_cc->toString().c_str(), req.toString().c_str()); } else { WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s), errno %d %s: res %s, req %s", - getHCIOpcodeString(opc).c_str(), getHCIEventTypeString(evc).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIEventTypeString(evc).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), errno, strerror(errno), - ev_cc->toString().c_str(), req0.toString().c_str()); + ev_cc->toString().c_str(), req.toString().c_str()); } return ev; } template<typename hci_command_struct, typename hci_cmd_event_struct> -std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_command_struct &cp, +std::shared_ptr<HCIEvent> HCIHandler::processStructMetaCmd(HCIStructCommand<hci_command_struct> &req, HCIMetaEventType mec, const hci_cmd_event_struct **res, HCIStatusCode *status) { *res = nullptr; *status = HCIStatusCode::INTERNAL_FAILURE; - HCIStructCommand<hci_command_struct> req0(opc, cp); - if( !sendCommand(req0) ) { + if( !sendCommand(req) ) { return nullptr; } int retryCount = 0; std::shared_ptr<HCIEvent> ev = nullptr; while( retryCount < HCI_READ_PACKET_MAX_RETRY ) { - ev = getNextReply(req0, retryCount); + ev = getNextReply(req, retryCount); if( nullptr == ev ) { break; // timeout, leave loop } else if( ev->isMetaEvent(mec) ) { @@ -561,9 +557,9 @@ std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_co if( HCIStatusCode::SUCCESS != ev_cs->getStatus() ) { *status = ev_cs->getStatus(); WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s), errno %d %s: res %s, req %s", - getHCIOpcodeString(opc).c_str(), getHCIMetaEventTypeString(mec).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIMetaEventTypeString(mec).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), errno, strerror(errno), - ev_cs->toString().c_str(), req0.toString().c_str()); + ev_cs->toString().c_str(), req.toString().c_str()); return ev; } continue; // next packet @@ -574,9 +570,9 @@ std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_co if( nullptr == ev ) { // timeout exit WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s), errno %d %s: res nullptr, req %s", - getHCIOpcodeString(opc).c_str(), getHCIMetaEventTypeString(mec).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIMetaEventTypeString(mec).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), errno, strerror(errno), - req0.toString().c_str()); + req.toString().c_str()); return nullptr; } typedef HCIStructCmdCompleteMetaEvt<hci_cmd_event_struct> HCIConnCompleteMetaEvt; @@ -585,14 +581,14 @@ std::shared_ptr<HCIEvent> HCIHandler::processStructCommand(HCIOpcode opc, hci_co *status = ev_cc->getStatus(); *res = ev_cc->getStruct(); WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Status 0x%2.2X (%s): res %s, req %s", - getHCIOpcodeString(opc).c_str(), getHCIMetaEventTypeString(mec).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIMetaEventTypeString(mec).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), - ev_cc->toString().c_str(), req0.toString().c_str()); + ev_cc->toString().c_str(), req.toString().c_str()); } else { WARN_PRINT("HCIHandler::processStructCommand %s -> %s: Type or size mismatch: Status 0x%2.2X (%s), errno %d %s: res %s, req %s", - getHCIOpcodeString(opc).c_str(), getHCIMetaEventTypeString(mec).c_str(), + getHCIOpcodeString(req.getOpcode()).c_str(), getHCIMetaEventTypeString(mec).c_str(), number(*status), getHCIStatusCodeString(*status).c_str(), errno, strerror(errno), - ev_cc->toString().c_str(), req0.toString().c_str()); + ev_cc->toString().c_str(), req.toString().c_str()); } return ev; } |