feat: implement device name handling and update gateway name features

Signed-off-by: Tony <tonylu@tony-cloud.com>
This commit is contained in:
Tony
2026-06-12 01:26:31 +08:00
parent dceede8602
commit 40a0e8e303
11 changed files with 192 additions and 23 deletions
@@ -74,6 +74,8 @@ class GatewaySettingsStore {
bool setWifiCredentials(std::string_view ssid, std::string_view password);
bool clearWifiCredentials();
std::string getDeviceName(std::string_view fallback) const;
bool setDeviceName(std::string_view name);
std::string getGatewayName(uint8_t gateway_id, std::string_view fallback) const;
bool setGatewayName(uint8_t gateway_id, std::string_view name);
uint8_t getChannelGatewayId(uint8_t channel_index, uint8_t fallback) const;
@@ -140,6 +142,8 @@ class GatewayRuntime {
bool setCacheEnabled(bool enabled);
uint8_t gatewayIdForChannel(uint8_t channel_index, uint8_t fallback) const;
bool setGatewayIdForChannel(uint8_t channel_index, uint8_t gateway_id);
std::string deviceName() const;
bool setDeviceName(std::string_view name);
std::string gatewayName(uint8_t gateway_id) const;
bool setGatewayName(uint8_t gateway_id, std::string_view name);
std::vector<uint8_t> serialNumberBytes() const;
@@ -154,6 +158,7 @@ class GatewayRuntime {
std::deque<std::vector<uint8_t>>& queueForPriorityLocked(CommandPriority priority);
const std::deque<std::vector<uint8_t>>& queueForPriorityLocked(CommandPriority priority) const;
std::optional<std::string> queryCommandKey(const std::vector<uint8_t>& command) const;
std::string defaultDeviceName() const;
std::string defaultGatewayName(uint8_t gateway_id) const;
std::vector<uint8_t> serialBytes() const;
static std::string toHex(const std::vector<uint8_t>& bytes);
@@ -167,6 +172,7 @@ class GatewayRuntime {
std::deque<std::vector<uint8_t>> control_commands_;
std::deque<std::vector<uint8_t>> normal_commands_;
std::deque<std::vector<uint8_t>> maintenance_commands_;
mutable std::optional<std::string> device_name_;
mutable std::map<uint8_t, std::string> gateway_names_;
mutable std::map<uint8_t, uint8_t> channel_gateway_ids_;
size_t gateway_count_{0};