Loading system/bta/gatt/bta_gattc_act.cc +27 −19 Original line number Diff line number Diff line Loading @@ -546,13 +546,16 @@ void bta_gattc_close_fail(tBTA_GATTC_CLCB* p_clcb, void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { tBTA_GATTC_CBACK* p_cback = p_clcb->p_rcb->p_cback; tBTA_GATTC_RCB* p_clreg = p_clcb->p_rcb; tBTA_GATTC cb_data; cb_data.close.client_if = p_clcb->p_rcb->client_if; cb_data.close.conn_id = p_clcb->bta_conn_id; cb_data.close.reason = GATT_CONN_OK; cb_data.close.remote_bda = p_clcb->bda; cb_data.close.status = GATT_SUCCESS; tBTA_GATTC cb_data = { .close = { .client_if = p_clcb->p_rcb->client_if, .conn_id = p_clcb->bta_conn_id, .reason = GATT_CONN_OK, .remote_bda = p_clcb->bda, .status = GATT_SUCCESS, }, }; if (p_clcb->transport == BT_TRANSPORT_BR_EDR) bta_sys_conn_close(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda); Loading Loading @@ -959,26 +962,31 @@ static void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB* p_clcb, /** operation completed */ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { uint8_t op = (uint8_t)p_data->op_cmpl.op_code; uint8_t mapped_op = 0; VLOG(1) << __func__ << ": op:" << +op; if (op == GATTC_OPTYPE_INDICATION || op == GATTC_OPTYPE_NOTIFICATION) { LOG(ERROR) << "unexpected operation, ignored"; if (p_clcb->p_q_cmd == NULL) { LOG_ERROR("No pending command gatt client command"); return; } if (op < GATTC_OPTYPE_READ) return; const tGATTC_OPTYPE op = p_data->op_cmpl.op_code; switch (op) { case GATTC_OPTYPE_READ: case GATTC_OPTYPE_WRITE: case GATTC_OPTYPE_EXE_WRITE: case GATTC_OPTYPE_CONFIG: break; if (p_clcb->p_q_cmd == NULL) { LOG(ERROR) << "No pending command"; case GATTC_OPTYPE_NONE: case GATTC_OPTYPE_DISCOVERY: case GATTC_OPTYPE_NOTIFICATION: case GATTC_OPTYPE_INDICATION: default: LOG(ERROR) << "unexpected operation, ignored"; return; } if (p_clcb->p_q_cmd->hdr.event != bta_gattc_opcode_to_int_evt[op - GATTC_OPTYPE_READ]) { mapped_op = uint8_t mapped_op = p_clcb->p_q_cmd->hdr.event - BTA_GATTC_API_READ_EVT + GATTC_OPTYPE_READ; if (mapped_op > GATTC_OPTYPE_INDICATION) mapped_op = 0; Loading system/bta/gatt/bta_gattc_int.h +1 −1 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ typedef struct { typedef struct { BT_HDR_RIGID hdr; uint8_t op_code; tGATTC_OPTYPE op_code; tGATT_STATUS status; tGATT_CL_COMPLETE* p_cmpl; } tBTA_GATTC_OP_CMPL; Loading system/common/stop_watch_legacy.cc +28 −23 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ namespace bluetooth { namespace common { static const int LOG_BUFFER_LENGTH = 10; static std::array<std::string, LOG_BUFFER_LENGTH> stopwatch_logs; static std::array<StopWatchLog, LOG_BUFFER_LENGTH> stopwatch_logs; static int current_buffer_index; void StopWatchLegacy::RecordLog(std::string log) { void StopWatchLegacy::RecordLog(StopWatchLog log) { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } Loading @@ -47,38 +47,43 @@ void StopWatchLegacy::DumpStopWatchLog() { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } if (stopwatch_logs[current_buffer_index].empty()) { if (stopwatch_logs[current_buffer_index].message.empty()) { break; } LOG_INFO("%s", stopwatch_logs[current_buffer_index].c_str()); current_buffer_index++; } LOG_INFO("====================================="); } StopWatchLegacy::StopWatchLegacy(std::string text) : text_(std::move(text)), start_time_(std::chrono::high_resolution_clock::now()) { std::stringstream ss; auto now = std::chrono::system_clock::now(); auto now = stopwatch_logs[current_buffer_index].timestamp; auto millis = std::chrono::duration_cast<std::chrono::milliseconds>( now.time_since_epoch()) % 1000; auto now_time_t = std::chrono::system_clock::to_time_t(now); ss << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S"); ss << '.' << std::setfill('0') << std::setw(3) << millis.count(); start_timestamp_ = ss.str(); RecordLog(start_timestamp_ + ": " + text_); std::string start_timestamp = ss.str(); LOG_INFO("%s: %s: took %zu us", start_timestamp.c_str(), stopwatch_logs[current_buffer_index].message.c_str(), static_cast<size_t>( std::chrono::duration_cast<std::chrono::microseconds>( stopwatch_logs[current_buffer_index].end_timestamp - stopwatch_logs[current_buffer_index].start_timestamp) .count())); current_buffer_index++; } LOG_INFO("====================================="); } StopWatchLegacy::StopWatchLegacy(std::string text) : text_(std::move(text)), timestamp_(std::chrono::system_clock::now()), start_timestamp_(std::chrono::high_resolution_clock::now()) {} StopWatchLegacy::~StopWatchLegacy() { RecordLog(start_timestamp_ + ": " + text_ + ": took " + std::to_string(static_cast<size_t>( std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now() - start_time_) .count())) + " us"); StopWatchLog sw_log; sw_log.timestamp = timestamp_; sw_log.start_timestamp = start_timestamp_; sw_log.end_timestamp = std::chrono::high_resolution_clock::now(); sw_log.message = std::move(text_); RecordLog(std::move(sw_log)); } } // namespace common Loading system/common/stop_watch_legacy.h +10 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,13 @@ namespace bluetooth { namespace common { typedef struct { std::chrono::system_clock::time_point timestamp; std::chrono::high_resolution_clock::time_point start_timestamp; std::chrono::high_resolution_clock::time_point end_timestamp; std::string message; } StopWatchLog; class StopWatchLegacy { public: static void DumpStopWatchLog(void); Loading @@ -30,9 +37,9 @@ class StopWatchLegacy { private: std::string text_; std::chrono::time_point<std::chrono::high_resolution_clock> start_time_; std::string start_timestamp_; void RecordLog(std::string log); std::chrono::system_clock::time_point timestamp_; std::chrono::high_resolution_clock::time_point start_timestamp_; void RecordLog(StopWatchLog log); }; } // namespace common Loading system/gd/common/stop_watch.cc +30 −21 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ namespace bluetooth { namespace common { static const int LOG_BUFFER_LENGTH = 10; static std::array<std::string, LOG_BUFFER_LENGTH> stopwatch_logs; static std::array<StopWatchLog, LOG_BUFFER_LENGTH> stopwatch_logs; static int current_buffer_index; void StopWatch::RecordLog(std::string log) { void StopWatch::RecordLog(StopWatchLog log) { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } Loading @@ -47,35 +47,44 @@ void StopWatch::DumpStopWatchLog() { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } if (stopwatch_logs[current_buffer_index].empty()) { if (stopwatch_logs[current_buffer_index].message.empty()) { break; } LOG_DEBUG("%s", stopwatch_logs[current_buffer_index].c_str()); std::stringstream ss; auto now = stopwatch_logs[current_buffer_index].timestamp; auto millis = std::chrono::duration_cast<std::chrono::milliseconds>( now.time_since_epoch()) % 1000; auto now_time_t = std::chrono::system_clock::to_time_t(now); ss << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S"); ss << '.' << std::setfill('0') << std::setw(3) << millis.count(); std::string start_timestamp = ss.str(); LOG_INFO( "%s: %s: took %zu us", start_timestamp.c_str(), stopwatch_logs[current_buffer_index].message.c_str(), static_cast<size_t>(std::chrono::duration_cast<std::chrono::microseconds>( stopwatch_logs[current_buffer_index].end_timestamp - stopwatch_logs[current_buffer_index].start_timestamp) .count())); current_buffer_index++; } LOG_INFO("====================================="); } StopWatch::StopWatch(std::string text) : text_(std::move(text)), start_time_(std::chrono::high_resolution_clock::now()) { std::stringstream ss; auto now = std::chrono::system_clock::now(); auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000; auto now_time_t = std::chrono::system_clock::to_time_t(now); ss << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S"); ss << '.' << std::setfill('0') << std::setw(3) << millis.count(); start_timestamp_ = ss.str(); RecordLog(start_timestamp_ + ": " + text_); } : text_(std::move(text)), timestamp_(std::chrono::system_clock::now()), start_timestamp_(std::chrono::high_resolution_clock::now()) {} StopWatch::~StopWatch() { RecordLog( start_timestamp_ + ": " + text_ + ": took " + std::to_string(static_cast<size_t>( std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_time_) .count())) + " us"); StopWatchLog sw_log; sw_log.timestamp = timestamp_; sw_log.start_timestamp = start_timestamp_; sw_log.end_timestamp = std::chrono::high_resolution_clock::now(); sw_log.message = std::move(text_); RecordLog(std::move(sw_log)); } } // namespace common Loading Loading
system/bta/gatt/bta_gattc_act.cc +27 −19 Original line number Diff line number Diff line Loading @@ -546,13 +546,16 @@ void bta_gattc_close_fail(tBTA_GATTC_CLCB* p_clcb, void bta_gattc_close(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { tBTA_GATTC_CBACK* p_cback = p_clcb->p_rcb->p_cback; tBTA_GATTC_RCB* p_clreg = p_clcb->p_rcb; tBTA_GATTC cb_data; cb_data.close.client_if = p_clcb->p_rcb->client_if; cb_data.close.conn_id = p_clcb->bta_conn_id; cb_data.close.reason = GATT_CONN_OK; cb_data.close.remote_bda = p_clcb->bda; cb_data.close.status = GATT_SUCCESS; tBTA_GATTC cb_data = { .close = { .client_if = p_clcb->p_rcb->client_if, .conn_id = p_clcb->bta_conn_id, .reason = GATT_CONN_OK, .remote_bda = p_clcb->bda, .status = GATT_SUCCESS, }, }; if (p_clcb->transport == BT_TRANSPORT_BR_EDR) bta_sys_conn_close(BTA_ID_GATTC, BTA_ALL_APP_ID, p_clcb->bda); Loading Loading @@ -959,26 +962,31 @@ static void bta_gattc_cfg_mtu_cmpl(tBTA_GATTC_CLCB* p_clcb, /** operation completed */ void bta_gattc_op_cmpl(tBTA_GATTC_CLCB* p_clcb, const tBTA_GATTC_DATA* p_data) { uint8_t op = (uint8_t)p_data->op_cmpl.op_code; uint8_t mapped_op = 0; VLOG(1) << __func__ << ": op:" << +op; if (op == GATTC_OPTYPE_INDICATION || op == GATTC_OPTYPE_NOTIFICATION) { LOG(ERROR) << "unexpected operation, ignored"; if (p_clcb->p_q_cmd == NULL) { LOG_ERROR("No pending command gatt client command"); return; } if (op < GATTC_OPTYPE_READ) return; const tGATTC_OPTYPE op = p_data->op_cmpl.op_code; switch (op) { case GATTC_OPTYPE_READ: case GATTC_OPTYPE_WRITE: case GATTC_OPTYPE_EXE_WRITE: case GATTC_OPTYPE_CONFIG: break; if (p_clcb->p_q_cmd == NULL) { LOG(ERROR) << "No pending command"; case GATTC_OPTYPE_NONE: case GATTC_OPTYPE_DISCOVERY: case GATTC_OPTYPE_NOTIFICATION: case GATTC_OPTYPE_INDICATION: default: LOG(ERROR) << "unexpected operation, ignored"; return; } if (p_clcb->p_q_cmd->hdr.event != bta_gattc_opcode_to_int_evt[op - GATTC_OPTYPE_READ]) { mapped_op = uint8_t mapped_op = p_clcb->p_q_cmd->hdr.event - BTA_GATTC_API_READ_EVT + GATTC_OPTYPE_READ; if (mapped_op > GATTC_OPTYPE_INDICATION) mapped_op = 0; Loading
system/bta/gatt/bta_gattc_int.h +1 −1 Original line number Diff line number Diff line Loading @@ -135,7 +135,7 @@ typedef struct { typedef struct { BT_HDR_RIGID hdr; uint8_t op_code; tGATTC_OPTYPE op_code; tGATT_STATUS status; tGATT_CL_COMPLETE* p_cmpl; } tBTA_GATTC_OP_CMPL; Loading
system/common/stop_watch_legacy.cc +28 −23 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ namespace bluetooth { namespace common { static const int LOG_BUFFER_LENGTH = 10; static std::array<std::string, LOG_BUFFER_LENGTH> stopwatch_logs; static std::array<StopWatchLog, LOG_BUFFER_LENGTH> stopwatch_logs; static int current_buffer_index; void StopWatchLegacy::RecordLog(std::string log) { void StopWatchLegacy::RecordLog(StopWatchLog log) { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } Loading @@ -47,38 +47,43 @@ void StopWatchLegacy::DumpStopWatchLog() { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } if (stopwatch_logs[current_buffer_index].empty()) { if (stopwatch_logs[current_buffer_index].message.empty()) { break; } LOG_INFO("%s", stopwatch_logs[current_buffer_index].c_str()); current_buffer_index++; } LOG_INFO("====================================="); } StopWatchLegacy::StopWatchLegacy(std::string text) : text_(std::move(text)), start_time_(std::chrono::high_resolution_clock::now()) { std::stringstream ss; auto now = std::chrono::system_clock::now(); auto now = stopwatch_logs[current_buffer_index].timestamp; auto millis = std::chrono::duration_cast<std::chrono::milliseconds>( now.time_since_epoch()) % 1000; auto now_time_t = std::chrono::system_clock::to_time_t(now); ss << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S"); ss << '.' << std::setfill('0') << std::setw(3) << millis.count(); start_timestamp_ = ss.str(); RecordLog(start_timestamp_ + ": " + text_); std::string start_timestamp = ss.str(); LOG_INFO("%s: %s: took %zu us", start_timestamp.c_str(), stopwatch_logs[current_buffer_index].message.c_str(), static_cast<size_t>( std::chrono::duration_cast<std::chrono::microseconds>( stopwatch_logs[current_buffer_index].end_timestamp - stopwatch_logs[current_buffer_index].start_timestamp) .count())); current_buffer_index++; } LOG_INFO("====================================="); } StopWatchLegacy::StopWatchLegacy(std::string text) : text_(std::move(text)), timestamp_(std::chrono::system_clock::now()), start_timestamp_(std::chrono::high_resolution_clock::now()) {} StopWatchLegacy::~StopWatchLegacy() { RecordLog(start_timestamp_ + ": " + text_ + ": took " + std::to_string(static_cast<size_t>( std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now() - start_time_) .count())) + " us"); StopWatchLog sw_log; sw_log.timestamp = timestamp_; sw_log.start_timestamp = start_timestamp_; sw_log.end_timestamp = std::chrono::high_resolution_clock::now(); sw_log.message = std::move(text_); RecordLog(std::move(sw_log)); } } // namespace common Loading
system/common/stop_watch_legacy.h +10 −3 Original line number Diff line number Diff line Loading @@ -22,6 +22,13 @@ namespace bluetooth { namespace common { typedef struct { std::chrono::system_clock::time_point timestamp; std::chrono::high_resolution_clock::time_point start_timestamp; std::chrono::high_resolution_clock::time_point end_timestamp; std::string message; } StopWatchLog; class StopWatchLegacy { public: static void DumpStopWatchLog(void); Loading @@ -30,9 +37,9 @@ class StopWatchLegacy { private: std::string text_; std::chrono::time_point<std::chrono::high_resolution_clock> start_time_; std::string start_timestamp_; void RecordLog(std::string log); std::chrono::system_clock::time_point timestamp_; std::chrono::high_resolution_clock::time_point start_timestamp_; void RecordLog(StopWatchLog log); }; } // namespace common Loading
system/gd/common/stop_watch.cc +30 −21 Original line number Diff line number Diff line Loading @@ -29,10 +29,10 @@ namespace bluetooth { namespace common { static const int LOG_BUFFER_LENGTH = 10; static std::array<std::string, LOG_BUFFER_LENGTH> stopwatch_logs; static std::array<StopWatchLog, LOG_BUFFER_LENGTH> stopwatch_logs; static int current_buffer_index; void StopWatch::RecordLog(std::string log) { void StopWatch::RecordLog(StopWatchLog log) { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } Loading @@ -47,35 +47,44 @@ void StopWatch::DumpStopWatchLog() { if (current_buffer_index >= LOG_BUFFER_LENGTH) { current_buffer_index = 0; } if (stopwatch_logs[current_buffer_index].empty()) { if (stopwatch_logs[current_buffer_index].message.empty()) { break; } LOG_DEBUG("%s", stopwatch_logs[current_buffer_index].c_str()); std::stringstream ss; auto now = stopwatch_logs[current_buffer_index].timestamp; auto millis = std::chrono::duration_cast<std::chrono::milliseconds>( now.time_since_epoch()) % 1000; auto now_time_t = std::chrono::system_clock::to_time_t(now); ss << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S"); ss << '.' << std::setfill('0') << std::setw(3) << millis.count(); std::string start_timestamp = ss.str(); LOG_INFO( "%s: %s: took %zu us", start_timestamp.c_str(), stopwatch_logs[current_buffer_index].message.c_str(), static_cast<size_t>(std::chrono::duration_cast<std::chrono::microseconds>( stopwatch_logs[current_buffer_index].end_timestamp - stopwatch_logs[current_buffer_index].start_timestamp) .count())); current_buffer_index++; } LOG_INFO("====================================="); } StopWatch::StopWatch(std::string text) : text_(std::move(text)), start_time_(std::chrono::high_resolution_clock::now()) { std::stringstream ss; auto now = std::chrono::system_clock::now(); auto millis = std::chrono::duration_cast<std::chrono::milliseconds>(now.time_since_epoch()) % 1000; auto now_time_t = std::chrono::system_clock::to_time_t(now); ss << std::put_time(std::localtime(&now_time_t), "%Y-%m-%d %H:%M:%S"); ss << '.' << std::setfill('0') << std::setw(3) << millis.count(); start_timestamp_ = ss.str(); RecordLog(start_timestamp_ + ": " + text_); } : text_(std::move(text)), timestamp_(std::chrono::system_clock::now()), start_timestamp_(std::chrono::high_resolution_clock::now()) {} StopWatch::~StopWatch() { RecordLog( start_timestamp_ + ": " + text_ + ": took " + std::to_string(static_cast<size_t>( std::chrono::duration_cast<std::chrono::microseconds>(std::chrono::high_resolution_clock::now() - start_time_) .count())) + " us"); StopWatchLog sw_log; sw_log.timestamp = timestamp_; sw_log.start_timestamp = start_timestamp_; sw_log.end_timestamp = std::chrono::high_resolution_clock::now(); sw_log.message = std::move(text_); RecordLog(std::move(sw_log)); } } // namespace common Loading