Skip to content

Commit 7c421c1

Browse files
authored
Merge pull request #420 from 446564/feat-GH142
return range with advert interval setting error
2 parents 553e3c1 + e5ecf29 commit 7c421c1

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
@@ -249,10 +249,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
249249
strcpy(reply, "OK");
250250
} else if (memcmp(config, "flood.advert.interval ", 22) == 0) {
251251
int hours = _atoi(&config[22]);
252-
if (hours > 0 && hours < 3) {
253-
sprintf(reply, "Error: min is 3 hours");
254-
} else if (hours > 48) {
255-
strcpy(reply, "Error: max is 48 hours");
252+
if ((hours > 0 && hours < 3) || (hours > 48)) {
253+
strcpy(reply, "Error: interval range is 3-48 hours");
256254
} else {
257255
_prefs->flood_advert_interval = (uint8_t)(hours);
258256
_callbacks->updateFloodAdvertTimer();
@@ -261,10 +259,8 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
261259
}
262260
} else if (memcmp(config, "advert.interval ", 16) == 0) {
263261
int mins = _atoi(&config[16]);
264-
if (mins > 0 && mins < MIN_LOCAL_ADVERT_INTERVAL) {
265-
sprintf(reply, "Error: min is %d mins", MIN_LOCAL_ADVERT_INTERVAL);
266-
} else if (mins > 240) {
267-
strcpy(reply, "Error: max is 240 mins");
262+
if ((mins > 0 && mins < MIN_LOCAL_ADVERT_INTERVAL) || (mins > 240)) {
263+
sprintf(reply, "Error: interval range is %d-240 minutes", MIN_LOCAL_ADVERT_INTERVAL);
268264
} else {
269265
_prefs->advert_interval = (uint8_t)(mins / 2);
270266
_callbacks->updateAdvertTimer();

0 commit comments

Comments
 (0)