@@ -283,8 +283,13 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
283283 */
284284 } else if (memcmp (command, " get " , 4 ) == 0 ) {
285285 const char * config = &command[4 ];
286- if (memcmp (config, " af" , 2 ) == 0 ) {
287- sprintf (reply, " > %s" , StrHelper::ftoa (_prefs->airtime_factor ));
286+ if (memcmp (config, " dutycycle" , 8 ) == 0 ) {
287+ float dc = 100 .0f / (_prefs->airtime_factor + 1 .0f );
288+ int dc_int = (int )dc;
289+ int dc_frac = (int )((dc - dc_int) * 10 .0f + 0 .5f );
290+ sprintf (reply, " > %d.%d%%" , dc_int, dc_frac);
291+ } else if (memcmp (config, " af" , 2 ) == 0 ) {
292+ sprintf (reply, " > %s (deprecated, use 'get dutycycle')" , StrHelper::ftoa (_prefs->airtime_factor ));
288293 } else if (memcmp (config, " int.thresh" , 10 ) == 0 ) {
289294 sprintf (reply, " > %d" , (uint32_t ) _prefs->interference_threshold );
290295 } else if (memcmp (config, " agc.reset.interval" , 18 ) == 0 ) {
@@ -436,10 +441,25 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch
436441 */
437442 } else if (memcmp (command, " set " , 4 ) == 0 ) {
438443 const char * config = &command[4 ];
439- if (memcmp (config, " af " , 3 ) == 0 ) {
444+ if (memcmp (config, " dutycycle " , 9 ) == 0 ) {
445+ float dc = atof (&config[9 ]);
446+ if (dc < 10 || dc > 100 ) {
447+ strcpy (reply, " ERROR: dutycycle must be 10-100" );
448+ } else {
449+ _prefs->airtime_factor = (100 .0f / dc) - 1 .0f ;
450+ savePrefs ();
451+ float actual = 100 .0f / (_prefs->airtime_factor + 1 .0f );
452+ int a_int = (int )actual;
453+ int a_frac = (int )((actual - a_int) * 10 .0f + 0 .5f );
454+ sprintf (reply, " OK - %d.%d%%" , a_int, a_frac);
455+ }
456+ } else if (memcmp (config, " af " , 3 ) == 0 ) {
440457 _prefs->airtime_factor = atof (&config[3 ]);
441458 savePrefs ();
442- strcpy (reply, " OK" );
459+ float actual = 100 .0f / (_prefs->airtime_factor + 1 .0f );
460+ int a_int = (int )actual;
461+ int a_frac = (int )((actual - a_int) * 10 .0f + 0 .5f );
462+ sprintf (reply, " OK - %d.%d%% (deprecated, use 'set dutycycle')" , a_int, a_frac);
443463 } else if (memcmp (config, " int.thresh " , 11 ) == 0 ) {
444464 _prefs->interference_threshold = atoi (&config[11 ]);
445465 savePrefs ();
0 commit comments