-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure message delivery for NASA packets
* Queue outgoing packets and send them during loop() * Only send packets during relatively quiet time * Do not send new packets until we receive an ack for the one already sent * Retry sending packet if no ack received * Make absolutely sure that there is no incoming data available or there is no more data expected to arrive before sending * Attempt to recover packets from incoming data if stars aligned in a way that all of the above failed * Modify logging to be able to easily change log levels during development * Optimize passing data buffers back and forth to prevent extra copies
- Loading branch information
1 parent
102a957
commit d6747cb
Showing
12 changed files
with
359 additions
and
245 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace esphome | ||
{ | ||
namespace samsung_ac | ||
{ | ||
bool debug_log_packets = false; | ||
bool debug_log_raw_bytes = false; | ||
|
||
} // namespace samsung_ac | ||
} // namespace esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#pragma once | ||
|
||
#include "esphome/core/log.h" | ||
#include "util.h" | ||
|
||
#define LOGV(...) ESP_LOGV(TAG, __VA_ARGS__) | ||
#define LOGD(...) ESP_LOGD(TAG, __VA_ARGS__) | ||
#define LOGI(...) ESP_LOGI(TAG, __VA_ARGS__) | ||
#define LOGW(...) ESP_LOGW(TAG, __VA_ARGS__) | ||
#define LOGE(...) ESP_LOGE(TAG, __VA_ARGS__) | ||
#define LOGC(...) ESP_LOGCONFIG(TAG, __VA_ARGS__) | ||
|
||
#define LOG_STATE(...) LOGI(__VA_ARGS__) | ||
#define LOG_RAW_SEND(inter, ...) ({ if (debug_log_raw_bytes) LOGW("<< +%d: %s", inter, bytes_to_hex(__VA_ARGS__).c_str()); }) | ||
#define LOG_RAW(inter, ...) ({ if (debug_log_raw_bytes) LOGD(">> +%d: %s", inter, bytes_to_hex(__VA_ARGS__).c_str()); }) | ||
#define LOG_RAW_DISCARDED(inter, ...) ({if (debug_log_raw_bytes) LOGV(">> +%d: %s", inter, bytes_to_hex(__VA_ARGS__).c_str()); }) | ||
#define LOG_PACKET_SEND(msg, packet) LOGI("%s: %s", msg, packet.to_string().c_str()) | ||
#define LOG_PACKET_RECV(msg, packet) ({ if (debug_log_packets) LOGD("%s: %s", msg, packet.to_string().c_str()); }) | ||
|
||
namespace esphome | ||
{ | ||
namespace samsung_ac | ||
{ | ||
extern bool debug_log_packets; | ||
extern bool debug_log_raw_bytes; | ||
|
||
} // namespace samsung_ac | ||
} // namespace esphome |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.