mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	[api] Sync uses_password field_ifdef optimization from aioesphomeapi (#9756)
This commit is contained in:
		| @@ -203,7 +203,7 @@ message DeviceInfoResponse { | ||||
|   option (id) = 10; | ||||
|   option (source) = SOURCE_SERVER; | ||||
|  | ||||
|   bool uses_password = 1; | ||||
|   bool uses_password = 1 [(field_ifdef) = "USE_API_PASSWORD"]; | ||||
|  | ||||
|   // The name of the node, given by "App.set_name()" | ||||
|   string name = 2; | ||||
|   | ||||
| @@ -1432,8 +1432,6 @@ DeviceInfoResponse APIConnection::device_info(const DeviceInfoRequest &msg) { | ||||
|   DeviceInfoResponse resp{}; | ||||
| #ifdef USE_API_PASSWORD | ||||
|   resp.uses_password = true; | ||||
| #else | ||||
|   resp.uses_password = false; | ||||
| #endif | ||||
|   resp.name = App.get_name(); | ||||
|   resp.friendly_name = App.get_friendly_name(); | ||||
|   | ||||
| @@ -80,7 +80,9 @@ void DeviceInfo::calculate_size(uint32_t &total_size) const { | ||||
| } | ||||
| #endif | ||||
| void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { | ||||
| #ifdef USE_API_PASSWORD | ||||
|   buffer.encode_bool(1, this->uses_password); | ||||
| #endif | ||||
|   buffer.encode_string(2, this->name); | ||||
|   buffer.encode_string(3, this->mac_address); | ||||
|   buffer.encode_string(4, this->esphome_version); | ||||
| @@ -130,7 +132,9 @@ void DeviceInfoResponse::encode(ProtoWriteBuffer buffer) const { | ||||
| #endif | ||||
| } | ||||
| void DeviceInfoResponse::calculate_size(uint32_t &total_size) const { | ||||
| #ifdef USE_API_PASSWORD | ||||
|   ProtoSize::add_bool_field(total_size, 1, this->uses_password); | ||||
| #endif | ||||
|   ProtoSize::add_string_field(total_size, 1, this->name); | ||||
|   ProtoSize::add_string_field(total_size, 1, this->mac_address); | ||||
|   ProtoSize::add_string_field(total_size, 1, this->esphome_version); | ||||
|   | ||||
| @@ -474,7 +474,9 @@ class DeviceInfoResponse : public ProtoMessage { | ||||
| #ifdef HAS_PROTO_MESSAGE_DUMP | ||||
|   const char *message_name() const override { return "device_info_response"; } | ||||
| #endif | ||||
| #ifdef USE_API_PASSWORD | ||||
|   bool uses_password{false}; | ||||
| #endif | ||||
|   std::string name{}; | ||||
|   std::string mac_address{}; | ||||
|   std::string esphome_version{}; | ||||
|   | ||||
| @@ -647,10 +647,12 @@ void DeviceInfo::dump_to(std::string &out) const { | ||||
| void DeviceInfoResponse::dump_to(std::string &out) const { | ||||
|   __attribute__((unused)) char buffer[64]; | ||||
|   out.append("DeviceInfoResponse {\n"); | ||||
| #ifdef USE_API_PASSWORD | ||||
|   out.append("  uses_password: "); | ||||
|   out.append(YESNO(this->uses_password)); | ||||
|   out.append("\n"); | ||||
|  | ||||
| #endif | ||||
|   out.append("  name: "); | ||||
|   out.append("'").append(this->name).append("'"); | ||||
|   out.append("\n"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user