mirror of
https://github.com/esphome/esphome.git
synced 2026-05-25 10:26:10 +08:00
cleanup
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -13,6 +13,7 @@ class APIServerConnectionBase : public ProtoService {
|
||||
#ifdef HAS_PROTO_MESSAGE_DUMP
|
||||
protected:
|
||||
void log_send_message_(const char *name, const char *dump);
|
||||
void log_receive_message_(const char *name, const ProtoMessage &msg);
|
||||
|
||||
public:
|
||||
#endif
|
||||
|
||||
@@ -2519,8 +2519,7 @@ def build_service_message_type(
|
||||
case += "// Empty message: no decode needed\n"
|
||||
if log:
|
||||
case += "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
|
||||
case += "DumpBuffer dump_buf;\n"
|
||||
case += f'ESP_LOGVV(TAG, "{func}: %s", msg.dump_to(dump_buf));\n'
|
||||
case += f'this->log_receive_message_("{func}", msg);\n'
|
||||
case += "#endif\n"
|
||||
case += f"this->{func}(msg);\n"
|
||||
case += "break;"
|
||||
@@ -2842,10 +2841,11 @@ static const char *const TAG = "api.service";
|
||||
hpp += f"class {class_name} : public ProtoService {{\n"
|
||||
hpp += " public:\n"
|
||||
|
||||
# Add logging helper method declaration
|
||||
# Add logging helper method declarations
|
||||
hpp += "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
|
||||
hpp += " protected:\n"
|
||||
hpp += " void log_send_message_(const char *name, const char *dump);\n"
|
||||
hpp += " void log_receive_message_(const char *name, const ProtoMessage &msg);\n"
|
||||
hpp += " public:\n"
|
||||
hpp += "#endif\n\n"
|
||||
|
||||
@@ -2858,13 +2858,17 @@ static const char *const TAG = "api.service";
|
||||
hpp += " return this->send_message_(msg, message_type);\n"
|
||||
hpp += " }\n\n"
|
||||
|
||||
# Add logging helper method implementation to cpp
|
||||
# Add logging helper method implementations to cpp
|
||||
cpp += "#ifdef HAS_PROTO_MESSAGE_DUMP\n"
|
||||
cpp += (
|
||||
f"void {class_name}::log_send_message_(const char *name, const char *dump) {{\n"
|
||||
)
|
||||
cpp += ' ESP_LOGVV(TAG, "send_message %s: %s", name, dump);\n'
|
||||
cpp += "}\n"
|
||||
cpp += f"void {class_name}::log_receive_message_(const char *name, const ProtoMessage &msg) {{\n"
|
||||
cpp += " DumpBuffer dump_buf;\n"
|
||||
cpp += ' ESP_LOGVV(TAG, "%s: %s", name, msg.dump_to(dump_buf));\n'
|
||||
cpp += "}\n"
|
||||
cpp += "#endif\n\n"
|
||||
|
||||
for mt in file.message_type:
|
||||
|
||||
Reference in New Issue
Block a user