added expected and fmt for cleaner code/interfaces
This commit is contained in:
@ -30,9 +30,12 @@ set(dependencies
|
||||
esp_system
|
||||
# esp_http_client
|
||||
esp_websocket_client
|
||||
tcp_transport
|
||||
|
||||
cpputils
|
||||
espchrono
|
||||
tcp_transport
|
||||
expected
|
||||
fmt
|
||||
)
|
||||
|
||||
idf_component_register(
|
||||
|
@ -1,19 +1,29 @@
|
||||
#include "espstrutils.h"
|
||||
|
||||
// system includes
|
||||
#include <cctype>
|
||||
// esp-idf includes
|
||||
#include <esp_log.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
|
||||
// local includes
|
||||
#include "futurecpp.h"
|
||||
|
||||
namespace espcpputils {
|
||||
namespace {
|
||||
constexpr const char * const TAG = "ESPCPPUTILS";
|
||||
}
|
||||
|
||||
std::string toString(sntp_sync_mode_t val)
|
||||
{
|
||||
switch (val)
|
||||
{
|
||||
case SNTP_SYNC_MODE_IMMED: return "SNTP_SYNC_MODE_IMMED";
|
||||
case SNTP_SYNC_MODE_SMOOTH: return "SNTP_SYNC_MODE_SMOOTH";
|
||||
case SNTP_SYNC_MODE_IMMED: return "IMMED";
|
||||
case SNTP_SYNC_MODE_SMOOTH: return "SMOOTH";
|
||||
default:
|
||||
ESP_LOGW(TAG, "unknown sntp_sync_mode_t(%i)", std::to_underlying(val));
|
||||
return fmt::format("Unknown sntp_sync_mode_t({})", std::to_underlying(val));
|
||||
}
|
||||
|
||||
return std::string{"Unknown sntp_sync_mode_t("} + std::to_string(int(val)) + ')';
|
||||
}
|
||||
|
||||
void urldecode(char *dst, const char *src)
|
||||
|
@ -8,6 +8,12 @@
|
||||
#include <esp_websocket_client.h>
|
||||
#include <esp_transport_ws.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
|
||||
// local includes
|
||||
#include "futurecpp.h"
|
||||
|
||||
namespace espcpputils {
|
||||
class websocket_client
|
||||
{
|
||||
@ -56,7 +62,7 @@ public:
|
||||
case WS_TRANSPORT_OPCODES_PING: return "PING";
|
||||
case WS_TRANSPORT_OPCODES_PONG: return "PONG";
|
||||
case WS_TRANSPORT_OPCODES_FIN: return "FIN";
|
||||
default: return "unknown opcode(" + std::to_string(op_code) + ')';
|
||||
default: return fmt::format("unknown opcode({})", std::to_underlying(op_code));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user