22
22
#include "nw_helper_func.h"
23
23
#include "esp_hosted_custom_rpc.h"
24
24
#include "app_custom_rpc.h"
25
+ #include <stdint.h>
25
26
26
27
27
28
#define MAC_ADDR_LENGTH 18
28
- #define NETWORK_CHECK_INTERVAL_MS 1000
29
+ #define NETWORK_CHECK_INTERVAL_MS 100
29
30
#define RPC_RETRY_INTERVAL_MS 1000
30
31
31
32
#define POLL_FOR_IP_RESTORE (0)
@@ -334,6 +335,10 @@ static const cmd_arg_t custom_rpc_request_args[] = {
334
335
{"--demo" , "Demo number (1, 2, or 3)" , ARG_TYPE_INT , true, NULL }
335
336
};
336
337
338
+ static const cmd_arg_t set_country_code_args [] = {
339
+ {"--code" , "Country code (e.g. US, IN, CN)" , ARG_TYPE_STRING , true, NULL }
340
+ };
341
+
337
342
/* Forward declarations for command handlers */
338
343
static int handle_exit (int argc , char * * argv );
339
344
static int handle_help (int argc , char * * argv );
@@ -365,6 +370,10 @@ static int handle_subscribe_event(int argc, char **argv);
365
370
static int handle_unsubscribe_event (int argc , char * * argv );
366
371
static int handle_set_host_port_range (int argc , char * * argv );
367
372
static int handle_custom_demo_rpc_request (int argc , char * * argv );
373
+ static int handle_set_country_code (int argc , char * * argv );
374
+ static int handle_set_country_code_with_ieee80211d_on (int argc , char * * argv );
375
+ static int handle_get_country_code (int argc , char * * argv );
376
+
368
377
369
378
370
379
/* Command table */
@@ -401,6 +410,9 @@ static const shell_command_t commands[] = {
401
410
{"exit" , "Exit the shell" , handle_exit , NULL , 0 },
402
411
{"quit" , "Exit the shell" , handle_exit , NULL , 0 },
403
412
{"q" , "Exit the shell" , handle_exit , NULL , 0 },
413
+ {"set_country_code" , "Set Wi-Fi country code" , handle_set_country_code , set_country_code_args , sizeof (set_country_code_args )/sizeof (cmd_arg_t )},
414
+ {"set_country_code_with_ieee80211d_on" , "Set Wi-Fi country code with ieee80211d enabled" , handle_set_country_code_with_ieee80211d_on , NULL , 0 },
415
+ {"get_country_code" , "Get Wi-Fi country code" , handle_get_country_code , NULL , 0 },
404
416
{NULL , NULL , NULL , NULL , 0 }
405
417
};
406
418
@@ -1203,11 +1215,10 @@ static void stop_rpc_auto_ip_restore(void) {
1203
1215
exit_thread_auto_ip_restore = 1 ;
1204
1216
rpc_state = RPC_STATE_INACTIVE ;
1205
1217
1206
- printf ("Cleaning up RPC resources...\n" );
1218
+ // printf("Cleaning up RPC resources...\n");
1207
1219
1208
1220
// Give app thread a chance to notice exit flag
1209
- printf ("Waiting for background threads to terminate...\n" );
1210
- sleep (1 ); // Brief pause
1221
+ //sleep(1); // Brief pause (removed for faster exit)
1211
1222
1212
1223
// Join the app thread if it exists
1213
1224
if (auto_ip_restore_thread ) {
@@ -1228,7 +1239,7 @@ static void stop_rpc_auto_ip_restore(void) {
1228
1239
}
1229
1240
1230
1241
cleanup_in_progress = 0 ;
1231
- printf ("RPC cleanup complete\n" );
1242
+ // printf("Cleanup complete\n");
1232
1243
}
1233
1244
1234
1245
/* Shell main loop */
@@ -1380,7 +1391,7 @@ int main(int argc, char *argv[]) {
1380
1391
ret = shell_run (& ctx );
1381
1392
1382
1393
/* The shell has exited - initiate cleanup */
1383
- printf ("Shell exited, initiating cleanup\n" );
1394
+ // printf("Shell exited, initiating cleanup\n");
1384
1395
exit_thread_auto_ip_restore = 1 ;
1385
1396
1386
1397
/* Clean up resources */
@@ -1690,3 +1701,28 @@ static int handle_custom_demo_rpc_request(int argc, char **argv) {
1690
1701
return FAILURE ;
1691
1702
}
1692
1703
}
1704
+
1705
+ static int handle_set_country_code (int argc , char * * argv ) {
1706
+ CHECK_RPC_ACTIVE ();
1707
+ if (!parse_arguments (argc , argv , set_country_code_args , sizeof (set_country_code_args )/sizeof (cmd_arg_t ))) {
1708
+ return FAILURE ;
1709
+ }
1710
+ const char * code = get_arg_value (argc , argv , set_country_code_args ,
1711
+ sizeof (set_country_code_args )/sizeof (cmd_arg_t ),
1712
+ "--code" );
1713
+ if (!code || strlen (code ) < 2 ) {
1714
+ printf ("Invalid or missing country code\n" );
1715
+ return FAILURE ;
1716
+ }
1717
+ return test_set_country_code_with_params (code );
1718
+ }
1719
+
1720
+ static int handle_set_country_code_with_ieee80211d_on (int argc , char * * argv ) {
1721
+ CHECK_RPC_ACTIVE ();
1722
+ return test_set_country_code_with_ieee80211d_on ();
1723
+ }
1724
+
1725
+ static int handle_get_country_code (int argc , char * * argv ) {
1726
+ CHECK_RPC_ACTIVE ();
1727
+ return test_get_country_code ();
1728
+ }
0 commit comments