Skip to content

Commit e5ecf29

Browse files
committed
return range with advert interval set error
updates both local and flood advert preference setting errors to include the allowable range and time units
1 parent eb58266 commit e5ecf29

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/helpers/CommonCLI.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -245,10 +245,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
245245
strcpy(reply, "OK");
246246
} else if (memcmp(config, "flood.advert.interval ", 22) == 0) {
247247
int hours = _atoi(&config[22]);
248-
if (hours > 0 && hours < 3) {
249-
sprintf(reply, "Error: min is 3 hours");
250-
} else if (hours > 48) {
251-
strcpy(reply, "Error: max is 48 hours");
248+
if ((hours > 0 && hours < 3) || (hours > 48)) {
249+
strcpy(reply, "Error: interval range is 3-48 hours");
252250
} else {
253251
_prefs->flood_advert_interval = (uint8_t)(hours);
254252
_callbacks->updateFloodAdvertTimer();
@@ -257,10 +255,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
257255
}
258256
} else if (memcmp(config, "advert.interval ", 16) == 0) {
259257
int mins = _atoi(&config[16]);
260-
if (mins > 0 && mins < MIN_LOCAL_ADVERT_INTERVAL) {
261-
sprintf(reply, "Error: min is %d mins", MIN_LOCAL_ADVERT_INTERVAL);
262-
} else if (mins > 240) {
263-
strcpy(reply, "Error: max is 240 mins");
258+
if ((mins > 0 && mins < MIN_LOCAL_ADVERT_INTERVAL) || (mins > 240)) {
259+
sprintf(reply, "Error: interval range is %d-240 minutes", MIN_LOCAL_ADVERT_INTERVAL);
264260
} else {
265261
_prefs->advert_interval = (uint8_t)(mins / 2);
266262
_callbacks->updateAdvertTimer();

0 commit comments

Comments
 (0)