mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Cleanup rpc interfaces
This commit is contained in:
@@ -52,6 +52,12 @@ std::string ConfigManager::get_wifi_password() const {
|
||||
return str;
|
||||
}
|
||||
|
||||
CommunicationMethod ConfigManager::get_communication_method() const {
|
||||
uint16_t type = DEFAULT_COMMUNICATION_METHOD;
|
||||
get_uint16(COMMUNICATION_METHOD_KEY, &type);
|
||||
return static_cast<CommunicationMethod>(type);
|
||||
}
|
||||
|
||||
esp_err_t ConfigManager::get_string(const char *key, std::string& out) const {
|
||||
std::shared_lock lock(rw_lock);
|
||||
esp_err_t ret = ESP_OK;
|
||||
@@ -133,6 +139,10 @@ void ConfigManager::set_wifi_password(const char* password) {
|
||||
set<nvs_set_cpp_str, std::string>(WIFI_PASSWORD_KEY, password);
|
||||
}
|
||||
|
||||
void ConfigManager::set_communication_method(const CommunicationMethod method) {
|
||||
set<nvs_set_u16, uint16_t>(COMMUNICATION_METHOD_KEY, method);
|
||||
}
|
||||
|
||||
// Func - the esp write function to call (ie. nvs_set_u16)
|
||||
// T - the type of the value in the key value pair
|
||||
template<auto Func, typename T>
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <unordered_map>
|
||||
#include <shared_mutex>
|
||||
|
||||
#include "enums.h"
|
||||
#include "esp_check.h"
|
||||
#include "nvs.h"
|
||||
#include "flatbuffers_generated/RobotModule_generated.h"
|
||||
@@ -30,11 +31,13 @@ public:
|
||||
ModuleType get_module_type() const;
|
||||
std::string get_wifi_ssid() const;
|
||||
std::string get_wifi_password() const;
|
||||
CommunicationMethod get_communication_method() const;
|
||||
|
||||
void set_module_id(uint16_t id);
|
||||
void set_module_type(ModuleType type);
|
||||
void set_wifi_ssid(const char* ssid);
|
||||
void set_wifi_password(const char* password);
|
||||
void set_communication_method(CommunicationMethod method);
|
||||
|
||||
private:
|
||||
ConfigManager() = default;
|
||||
|
||||
12
components/config/include/enums.h
Normal file
12
components/config/include/enums.h
Normal file
@@ -0,0 +1,12 @@
|
||||
//
|
||||
// Created by Johnathon Slightham on 2025-10-22.
|
||||
//
|
||||
|
||||
#ifndef ENUMS_H
|
||||
#define ENUMS_H
|
||||
|
||||
enum CommunicationMethod {
|
||||
Wireless,
|
||||
};
|
||||
|
||||
#endif //ENUMS_H
|
||||
Reference in New Issue
Block a user