Initial commit
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
idf_component_register(
|
||||
SRCS "src/gateway_core.cpp"
|
||||
INCLUDE_DIRS "include"
|
||||
REQUIRES log
|
||||
)
|
||||
|
||||
set_property(TARGET ${COMPONENT_LIB} PROPERTY CXX_STANDARD 17)
|
||||
@@ -0,0 +1,36 @@
|
||||
#pragma once
|
||||
|
||||
#include <string_view>
|
||||
|
||||
namespace gateway {
|
||||
|
||||
enum class AppRole {
|
||||
kGateway,
|
||||
kReceiver,
|
||||
kTelemetry,
|
||||
};
|
||||
|
||||
struct BootProfile {
|
||||
AppRole role;
|
||||
std::string_view instance_name;
|
||||
bool enable_wifi;
|
||||
bool enable_ble;
|
||||
bool enable_eth;
|
||||
bool enable_espnow;
|
||||
bool enable_usb;
|
||||
};
|
||||
|
||||
class GatewayCore {
|
||||
public:
|
||||
explicit GatewayCore(BootProfile profile);
|
||||
|
||||
void start() const;
|
||||
const BootProfile& profile() const;
|
||||
|
||||
static const char* RoleToString(AppRole role);
|
||||
|
||||
private:
|
||||
BootProfile profile_;
|
||||
};
|
||||
|
||||
} // namespace gateway
|
||||
@@ -0,0 +1,45 @@
|
||||
#include "gateway_core.hpp"
|
||||
|
||||
#include "esp_log.h"
|
||||
|
||||
namespace gateway {
|
||||
|
||||
namespace {
|
||||
|
||||
constexpr const char* kTag = "gateway_core";
|
||||
|
||||
} // namespace
|
||||
|
||||
GatewayCore::GatewayCore(BootProfile profile) : profile_(profile) {}
|
||||
|
||||
void GatewayCore::start() const {
|
||||
ESP_LOGI(kTag,
|
||||
"boot role=%s instance=%.*s wifi=%d ble=%d eth=%d espnow=%d usb=%d",
|
||||
RoleToString(profile_.role),
|
||||
static_cast<int>(profile_.instance_name.size()),
|
||||
profile_.instance_name.data(),
|
||||
profile_.enable_wifi,
|
||||
profile_.enable_ble,
|
||||
profile_.enable_eth,
|
||||
profile_.enable_espnow,
|
||||
profile_.enable_usb);
|
||||
}
|
||||
|
||||
const BootProfile& GatewayCore::profile() const {
|
||||
return profile_;
|
||||
}
|
||||
|
||||
const char* GatewayCore::RoleToString(AppRole role) {
|
||||
switch (role) {
|
||||
case AppRole::kGateway:
|
||||
return "gateway";
|
||||
case AppRole::kReceiver:
|
||||
return "receiver";
|
||||
case AppRole::kTelemetry:
|
||||
return "telemetry";
|
||||
}
|
||||
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
} // namespace gateway
|
||||
Reference in New Issue
Block a user