diff --git a/components/networking/api_rest.c b/components/networking/api_rest.c index 0c78e10..9c2d04c 100644 --- a/components/networking/api_rest.c +++ b/components/networking/api_rest.c @@ -349,7 +349,7 @@ static esp_err_t trklog_put_handler(httpd_req_t *req) static esp_err_t trackers_handler(httpd_req_t *req) { rest_cors_enable(req); cJSON *root = cJSON_CreateArray(); - mdns_result_t * res = mdns_find_service("_http", "_tcp"); + mdns_result_t * res = mdns_find_service("_https", "_tcp"); while(res) { cJSON *obj = cJSON_CreateObject(); cJSON_AddStringToObject(obj, "name", res->instance_name); diff --git a/components/networking/cmd_networking.c b/components/networking/cmd_networking.c index c8b8e88..5afd203 100644 --- a/components/networking/cmd_networking.c +++ b/components/networking/cmd_networking.c @@ -26,40 +26,6 @@ void register_wifi(void); -/******************************************************************************** - * Join an access point - ********************************************************************************/ - -/** Arguments used by 'connect' function */ -static struct { - struct arg_int *timeout; - struct arg_str *ssid; - struct arg_str *password; - struct arg_end *end; -} join_args; - - -int do_join(int argc, char** argv) -{ - int nerrors = arg_parse(argc, argv, (void**) &join_args); - if (nerrors != 0) { - arg_print_errors(stderr, join_args.end, argv[0]); - return 1; - } - - bool connected = wifi_join( - join_args.ssid->sval[0], - join_args.password->sval[0], - join_args.timeout->ival[0]); - - if (!connected) - printf("Connection failed\n"); - else - printf("Ok\n"); - return 0; -} - - /******************************************************************************** * Connect to an internet server using tcp (like telnet command) ********************************************************************************/ @@ -119,6 +85,7 @@ int do_connect(int argc, char** argv) int do_scan(int argc, char** argv) { + wifi_suspend(false); if (!wifi_startScan()) { printf("Couldn't start scan of Wifi\n"); return 0; @@ -211,10 +178,10 @@ int do_info(int argc, char** argv) printf(" Stn status: %s\n", wifi_getStatus()); if (wifi_isConnected()) { - // tcpip_adapter_ip_info_t ipinfo = wifi_getIpInfo(); + esp_netif_ip_info_t ipinfo = wifi_getIpInfo(); char buf[40]; printf(" Connected to: %s\n", (char*) wifi_getConnectedAp(buf)); - // printf(" IP address: %s\n", ip4addr_ntoa(&ipinfo.ip) ); + printf(" IP address: %s\n", ip4addr_ntoa(&ipinfo.ip) ); printf(" mDNS hostname: %s\n", mdns_hostname(buf)); } uint8_t mac[6]; @@ -303,22 +270,6 @@ CMD_STR_SETTING (_param_fwcert, "FW.CERT", BBUF_SIZE, "", NULL); void register_wifi() { - join_args.timeout = arg_int0(NULL, "timeout", "", "Connection timeout, ms"); - join_args.timeout->ival[0] = 8000; // set default value - join_args.ssid = arg_str1(NULL, NULL, "", "SSID of AP"); - join_args.password = arg_str0(NULL, NULL, "", "PSK of AP"); - join_args.end = arg_end(2); - - const esp_console_cmd_t join_cmd = { - .command = "wifi-join", - .help = "Join WiFi AP as a station", - .hint = NULL, - .func = &do_join, - .argtable = &join_args - }; - - ADD_CMD_X(&join_cmd); - ADD_CMD("mdns", &do_mdns, "Scan for MDNS services", NULL); ADD_CMD("wifi-scan", &do_scan, "Scan for wifi access points", NULL); ADD_CMD("wifi-info", &do_info, "Info about WIFI connection", NULL); diff --git a/components/networking/mdns.c b/components/networking/mdns.c index 00d1023..46143bf 100644 --- a/components/networking/mdns.c +++ b/components/networking/mdns.c @@ -30,14 +30,14 @@ void mdns_start(char* ident) { mdns_instance_name_set(buffer); /* Announce services */ - mdns_service_add(NULL, "_http", "_tcp", 80, NULL, 0); - mdns_service_instance_name_set("_http", "_tcp", "Arctic Tracker HTTP Server"); + mdns_service_add(NULL, "_https", "_tcp", 443, NULL, 0); + mdns_service_instance_name_set("_https", "_tcp", "Arctic Tracker HTTP Server"); mdns_txt_item_t txtData[1] = { {"ident", ident} }; /* Set txt data for service (will free and replace current data) */ - mdns_service_txt_set("_http", "_tcp", txtData, 1); + mdns_service_txt_set("_https", "_tcp", txtData, 1); } diff --git a/components/networking/networking.h b/components/networking/networking.h index 69f4454..5fc3204 100644 --- a/components/networking/networking.h +++ b/components/networking/networking.h @@ -34,7 +34,9 @@ bool wifi_softAp_isEnabled(); int wifi_softAp_clients(void); bool wifi_isConnected(void); void wifi_waitConnected(void); -bool wifi_join(const char* ssid, const char* pass, int timeout_ms); +void wifi_suspend(bool susp); +bool wifi_isSuspended(); +void wifi_endPause(); void wifi_init(void); void wifi_enable(bool); void wifi_enable_softAp(bool); diff --git a/components/networking/wifi.c b/components/networking/wifi.c index 950beec..84a0d2d 100644 --- a/components/networking/wifi.c +++ b/components/networking/wifi.c @@ -37,10 +37,12 @@ static wifi_ap_record_t *apList = NULL; static bool initialized = false; static bool enabled = false; static bool suspended = false; +static bool pause = false; static bool softApEnabled = false; static bool connected = false; static char *status = "Off"; static cond_t scanDone; + char default_ssid[32]; @@ -278,6 +280,10 @@ void wifi_enable(bool en) suspended = false; } + +/******************************************************************************** + * Temprarily suspend the WIFI + ********************************************************************************/ void wifi_suspend(bool susp) { @@ -302,6 +308,11 @@ bool wifi_isSuspended() { } +void wifi_endPause() { + pause = false; +} + + /******************************************************************************** * Set ap alternative @@ -315,6 +326,7 @@ void wifi_setApAlt(int n, wifiAp_t* ap) { char key[12]; sprintf(key, "AP.ALT.%d", n); set_bin_param(key, (void*) ap, sizeof(wifiAp_t)); + wifi_endPause(); } @@ -559,7 +571,9 @@ static void task_autoConnect( void * pvParms ) ESP_LOGI(TAG, "Waiting - to save power"); if (!wifi_softAp_isEnabled()) wifi_suspend(true); - sleepMs(AUTOCONNECT_PERIOD*1000); + pause = true; + for (int i=0; i | * [|delete]") ; + ADD_CMD("log", &do_log, "Set loglevel (for debugging/development)", " | * [|delete]") ; ADD_CMD("time", &do_time, "Get date and time", NULL); ADD_CMD("nmea", &do_nmea, "Monitor GPS NMEA datastream", "[raw]"); ADD_CMD("tone", &do_tone, "tone generator test", ""); diff --git a/main/system.c b/main/system.c index e8cea87..d5aaeda 100644 --- a/main/system.c +++ b/main/system.c @@ -485,10 +485,10 @@ static char* logtags[] = { "system", "main", "wifi", "wifix", "config", "httpd", "shell", "tracker", "esp-tls", "radio", "ui", "hdlc_enc", "hdlc-dec", "gps", "uart", "digi", "igate", "tcp-cli", "trackstore", "tracklog", "mbedtls", "rest", "adc", "httpd_txrx", - "httpd_uri", "httpd_parse" + "httpd_uri", "httpd_parse", "mdns" }; -#define NLOGTAGS 26 +#define NLOGTAGS 27 uint8_t lglv_dfl = ESP_LOG_NONE;