ESPHome 2026.3.0-dev
Loading...
Searching...
No Matches
raw_protocol.cpp
Go to the documentation of this file.
1#include "raw_protocol.h"
3#include "esphome/core/log.h"
4
5namespace esphome {
6namespace remote_base {
7
8static const char *const TAG = "remote.raw";
9
11 char buffer[256];
12 size_t pos = buf_append_printf(buffer, sizeof(buffer), 0, "Received Raw: ");
13
14 for (int32_t i = 0; i < src.size() - 1; i++) {
15 const int32_t value = src[i];
16 size_t prev_pos = pos;
17
18 if (i + 1 < src.size() - 1) {
19 pos = buf_append_printf(buffer, sizeof(buffer), pos, "%" PRId32 ", ", value);
20 } else {
21 pos = buf_append_printf(buffer, sizeof(buffer), pos, "%" PRId32, value);
22 }
23
24 if (pos >= sizeof(buffer) - 1) {
25 // buffer full, flush and continue
26 buffer[prev_pos] = '\0';
27 ESP_LOGI(TAG, "%s", buffer);
28 if (i + 1 < src.size() - 1) {
29 pos = buf_append_printf(buffer, sizeof(buffer), 0, " %" PRId32 ", ", value);
30 } else {
31 pos = buf_append_printf(buffer, sizeof(buffer), 0, " %" PRId32, value);
32 }
33 }
34 }
35 if (pos != 0) {
36 ESP_LOGI(TAG, "%s", buffer);
37 }
38 return true;
39}
40
41} // namespace remote_base
42} // namespace esphome
bool dump(RemoteReceiveData src) override
Providing packet encoding functions for exchanging data with a remote host.
Definition a01nyub.cpp:7
size_t size_t pos
Definition helpers.h:854