Add case structure for better handling of future config params

A case structure to send the correct config value has been added.
This commit is contained in:
Sebastian H. Gabrielli 2024-04-27 14:55:44 +02:00
parent dd624d4d48
commit f654ae96f6

View File

@ -163,6 +163,9 @@ uint8_t route_command(int pos) {
case WRITE_CONFIG:
return WRITE_CONFIG;
case READ_CONFIG:
{
switch (context.conf) {
case SAMPLE_TIME:
{
// Validate that pos is within the valid range
if (pos >= 2) { return 0x00; }
@ -175,10 +178,11 @@ uint8_t route_command(int pos) {
} config_value;
config_value.value = config.ms_fanspeed_sample_rate;
uint8_t data = config_value.bytes[1-pos];
// Return the corresponding data byte
return data;
return config_value.bytes[1-pos];
}
break;
}
}
break;