mirror of
				https://github.com/esphome/esphome.git
				synced 2025-10-30 22:53:59 +00:00 
			
		
		
		
	have to dupe macros
This commit is contained in:
		| @@ -13,6 +13,16 @@ namespace api { | ||||
|  | ||||
| static const char *const TAG = "api.frame_helper"; | ||||
|  | ||||
| #define HELPER_LOG(msg, ...) ESP_LOGVV(TAG, "%s: " msg, this->client_info_->get_combined_info().c_str(), ##__VA_ARGS__) | ||||
|  | ||||
| #ifdef HELPER_LOG_PACKETS | ||||
| #define LOG_PACKET_RECEIVED(buffer) ESP_LOGVV(TAG, "Received frame: %s", format_hex_pretty(buffer).c_str()) | ||||
| #define LOG_PACKET_SENDING(data, len) ESP_LOGVV(TAG, "Sending raw: %s", format_hex_pretty(data, len).c_str()) | ||||
| #else | ||||
| #define LOG_PACKET_RECEIVED(buffer) ((void) 0) | ||||
| #define LOG_PACKET_SENDING(data, len) ((void) 0) | ||||
| #endif | ||||
|  | ||||
| const char *api_error_to_str(APIError err) { | ||||
|   // not using switch to ensure compiler doesn't try to build a big table out of it | ||||
|   if (err == APIError::OK) { | ||||
|   | ||||
| @@ -15,21 +15,9 @@ | ||||
| namespace esphome { | ||||
| namespace api { | ||||
|  | ||||
| // HELPER_LOG macro - TAG must be defined in the implementation file using this macro | ||||
| #define HELPER_LOG(msg, ...) ESP_LOGVV(TAG, "%s: " msg, this->client_info_->get_combined_info().c_str(), ##__VA_ARGS__) | ||||
|  | ||||
| // uncomment to log raw packets | ||||
| //#define HELPER_LOG_PACKETS | ||||
|  | ||||
| // Packet logging macros | ||||
| #ifdef HELPER_LOG_PACKETS | ||||
| #define LOG_PACKET_RECEIVED(buffer) ESP_LOGVV(TAG, "Received frame: %s", format_hex_pretty(buffer).c_str()) | ||||
| #define LOG_PACKET_SENDING(data, len) ESP_LOGVV(TAG, "Sending raw: %s", format_hex_pretty(data, len).c_str()) | ||||
| #else | ||||
| #define LOG_PACKET_RECEIVED(buffer) ((void) 0) | ||||
| #define LOG_PACKET_SENDING(data, len) ((void) 0) | ||||
| #endif | ||||
|  | ||||
| // Forward declaration | ||||
| struct ClientInfo; | ||||
|  | ||||
|   | ||||
| @@ -15,6 +15,16 @@ namespace api { | ||||
| static const char *const TAG = "api.noise"; | ||||
| static const char *const PROLOGUE_INIT = "NoiseAPIInit"; | ||||
|  | ||||
| #define HELPER_LOG(msg, ...) ESP_LOGVV(TAG, "%s: " msg, this->client_info_->get_combined_info().c_str(), ##__VA_ARGS__) | ||||
|  | ||||
| #ifdef HELPER_LOG_PACKETS | ||||
| #define LOG_PACKET_RECEIVED(buffer) ESP_LOGVV(TAG, "Received frame: %s", format_hex_pretty(buffer).c_str()) | ||||
| #define LOG_PACKET_SENDING(data, len) ESP_LOGVV(TAG, "Sending raw: %s", format_hex_pretty(data, len).c_str()) | ||||
| #else | ||||
| #define LOG_PACKET_RECEIVED(buffer) ((void) 0) | ||||
| #define LOG_PACKET_SENDING(data, len) ((void) 0) | ||||
| #endif | ||||
|  | ||||
| /// Convert a noise error code to a readable error | ||||
| std::string noise_err_to_str(int err) { | ||||
|   if (err == NOISE_ERROR_NO_MEMORY) | ||||
|   | ||||
| @@ -14,6 +14,16 @@ namespace api { | ||||
|  | ||||
| static const char *const TAG = "api.plaintext"; | ||||
|  | ||||
| #define HELPER_LOG(msg, ...) ESP_LOGVV(TAG, "%s: " msg, this->client_info_->get_combined_info().c_str(), ##__VA_ARGS__) | ||||
|  | ||||
| #ifdef HELPER_LOG_PACKETS | ||||
| #define LOG_PACKET_RECEIVED(buffer) ESP_LOGVV(TAG, "Received frame: %s", format_hex_pretty(buffer).c_str()) | ||||
| #define LOG_PACKET_SENDING(data, len) ESP_LOGVV(TAG, "Sending raw: %s", format_hex_pretty(data, len).c_str()) | ||||
| #else | ||||
| #define LOG_PACKET_RECEIVED(buffer) ((void) 0) | ||||
| #define LOG_PACKET_SENDING(data, len) ((void) 0) | ||||
| #endif | ||||
|  | ||||
| /// Initialize the frame helper, returns OK if successful. | ||||
| APIError APIPlaintextFrameHelper::init() { | ||||
|   APIError err = init_common_(); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user