mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Fix crashing due to config with the wrong number of ports
This commit is contained in:
@@ -124,10 +124,12 @@ std::optional<T> ConfigManager::get_config_from_cache(const std::string& key) co
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::set_module_id(const uint16_t id) {
|
void ConfigManager::set_module_id(const uint16_t id) {
|
||||||
|
if (id < 2) return;
|
||||||
set<nvs_set_u16, uint16_t>(MODULE_ID_KEY, id);
|
set<nvs_set_u16, uint16_t>(MODULE_ID_KEY, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::set_module_type(const ModuleType type) {
|
void ConfigManager::set_module_type(const ModuleType type) {
|
||||||
|
if (type > ModuleType_MAX || type < ModuleType_MIN) return;
|
||||||
set<nvs_set_u16, uint16_t>(MODULE_TYPE_KEY, type);
|
set<nvs_set_u16, uint16_t>(MODULE_TYPE_KEY, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,6 +142,7 @@ void ConfigManager::set_wifi_password(const char* password) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ConfigManager::set_communication_method(const CommunicationMethod method) {
|
void ConfigManager::set_communication_method(const CommunicationMethod method) {
|
||||||
|
if (method != 0) return;
|
||||||
set<nvs_set_u16, uint16_t>(COMMUNICATION_METHOD_KEY, method);
|
set<nvs_set_u16, uint16_t>(COMMUNICATION_METHOD_KEY, method);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,16 @@ inline std::unordered_map<int, int> MODULE_TO_NUM_CHANNELS_MAP {
|
|||||||
{ModuleType_SERVO_2, 2},
|
{ModuleType_SERVO_2, 2},
|
||||||
{ModuleType_DISPLAY, 1},
|
{ModuleType_DISPLAY, 1},
|
||||||
{ModuleType_GRIPPER, 1},
|
{ModuleType_GRIPPER, 1},
|
||||||
|
{ModuleType_SPEAKER, 1},
|
||||||
|
{ModuleType_IMU, 1},
|
||||||
|
{ModuleType_DISTANCE_SENSOR, 1},
|
||||||
|
{ModuleType_SPLITTER_2, 4},
|
||||||
|
{ModuleType_SPLITTER_3, 3},
|
||||||
|
{ModuleType_SPLITTER_4, 3},
|
||||||
|
{ModuleType_SPLITTER_5, 3},
|
||||||
|
{ModuleType_SPLITTER_6, 3},
|
||||||
|
{ModuleType_SPLITTER_7, 3},
|
||||||
|
{ModuleType_SPLITTER_8, 3},
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PC_ADDR 0
|
#define PC_ADDR 0
|
||||||
|
|||||||
Reference in New Issue
Block a user