Files
bolar_2/main/protocol/realtime_config.h
2026-11-27 16:38:11 +08:00

42 lines
1.2 KiB
C++

#pragma once
#include "protocol/websocket_transport.h"
namespace borla {
// Build default used when NVS holds nothing, and the replacement applied when
// a stored/pushed endpoint turns out to be a retired staging host.
inline constexpr const char* kDefaultRealtimeUrl =
"wss://borlaws.lkall.com/v1/ws";
struct RealtimeConfig {
WebsocketTransportConfig transport;
uint32_t hello_timeout_ms = 15000;
uint32_t heartbeat_interval_ms = 30000;
uint32_t heartbeat_timeout_ms = 90000;
};
class IRealtimeConfigStore {
public:
virtual ~IRealtimeConfigStore() = default;
virtual bool Load(RealtimeConfig* output) const = 0;
// Persist an endpoint handed down by the OTA check response. `token` may
// be null to leave the stored token untouched. Returns false only on a
// real NVS failure; the caller treats that as non-fatal because the
// in-memory endpoint is still usable for this boot.
virtual bool SaveEndpoint(
const char* url,
const char* token) = 0;
};
class NvsRealtimeConfigStore final : public IRealtimeConfigStore {
public:
bool Load(RealtimeConfig* output) const override;
bool SaveEndpoint(
const char* url,
const char* token) override;
};
} // namespace borla