Tasmota/lib/lib_basic/IRremoteESP8266/IRremoteESP8266/test/ut_utils.h
Mateusz Bronk faff39ca11
IRremoteESP8266 upgraded to v2.8.5 (#18610)
* IRremoteESP8266 upgraded to v2.8.5 (from v2.8.4)

* Fix ir panasonic esp8266 (#18013)

* revert part of #16179 for ESP8266

* Revert "revert part of #16179 for ESP8266"

This reverts commit b8e61264074f0dd92e5fca29a991d31c97f8f9ee.

* try to revert #16179 for esp8266

* Build: removed redundand USE_IR_REMOTE_FULL flag

Tasmota32-ir PIO had both FIRMWARE_IR and USE_IR_REMOTE_FULL defined.
The latter is redundand and yielded unnecessary build warns.
See: tasmota_configurations.h

---------

Co-authored-by: Mateusz Bronk <2566147+mbronk@users.noreply.github.com>
Co-authored-by: Barbudor <barbudor@barbudor.net>
2023-05-08 19:04:25 +02:00

36 lines
886 B
C++

// Copyright 2022 Mateusz Bronk
#ifndef TEST_UT_UTILS_H_
#define TEST_UT_UTILS_H_
#include <sstream>
#include <string>
#include <iomanip>
#include <vector>
#include <algorithm>
std::string bytesToHexString(const std::vector<uint8_t>& value) {
std::ostringstream oss;
oss << std::hex << std::setfill('0');
std::for_each(std::begin(value), std::end(value), [&oss] (uint8_t i) {
oss << std::setw(2) << std::uppercase << static_cast<uint16_t>(i);
});
return oss.str();
}
std::vector<uint8_t> hexStringToBytes(const std::string& hex) {
std::vector<uint8_t> bytes;
bytes.reserve(hex.length() / 2);
for (size_t i = 0; i < hex.length(); i += 2) {
std::string nextByte = hex.substr(i, 2);
uint8_t byte = static_cast<uint8_t>(strtol(nextByte.c_str(), nullptr, 16));
bytes.emplace_back(byte);
}
return bytes;
}
#endif // TEST_UT_UTILS_H_