Selaa lähdekoodia

fixing some merging issues

Sebastien 5 vuotta sitten
vanhempi
commit
7adc14a5aa
2 muutettua tiedostoa jossa 20 lisäystä ja 8 poistoa
  1. 17 5
      main/esp_app_main.c
  2. 3 3
      sdkconfig

+ 17 - 5
main/esp_app_main.c

@@ -35,7 +35,7 @@
 #include "nvs_flash.h"
 #include "esp_log.h"
 #include "freertos/event_groups.h"
-
+#include "mdns.h"
 #include "lwip/api.h"
 #include "lwip/err.h"
 #include "lwip/netdb.h"
@@ -44,8 +44,9 @@
 #include "wifi_manager.h"
 #include "squeezelite-ota.h"
 #include <math.h>
-#include "platform_config.h"
+#include "config.h"
 #include "audio_controls.h"
+#include "platform_config.h"
 #include "telnet.h"
 #include "messaging.h"
 
@@ -70,12 +71,22 @@ extern const uint8_t server_cert_pem_end[] asm("_binary_github_pem_end");
 // as an exception _init function don't need include
 extern void services_init(void);
 extern void	display_init(char *welcome);
-
-bool is_recovery_running;
 const char * str_or_unknown(const char * str) { return (str?str:unknown_string_placeholder); }
-
+bool is_recovery_running;
 /* brief this is an exemple of a callback that you can setup in your own app to get notified of wifi manager event */
 void cb_connection_got_ip(void *pvParameter){
+	static ip4_addr_t ip;
+	tcpip_adapter_ip_info_t ipInfo; 
+
+	tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ipInfo);
+	if (ip.addr && ipInfo.ip.addr != ip.addr) {
+		ESP_LOGW(TAG, "IP change, need to reboot");
+		if(!wait_for_commit()){
+			ESP_LOGW(TAG,"Unable to commit configuration. ");
+		}
+		esp_restart();
+	}
+	ip.addr = ipInfo.ip.addr;
 	ESP_LOGI(TAG, "I have a connection!");
 	messaging_post_message(MESSAGING_INFO,MESSAGING_CLASS_SYSTEM,"Wifi connected");
 	xEventGroupSetBits(wifi_event_group, CONNECTED_BIT);
@@ -375,6 +386,7 @@ void app_main()
 
 	ESP_LOGI(TAG,"Initializing display");
 	display_init("SqueezeESP32");
+
 	if(!is_recovery_running){
 		ESP_LOGI(TAG,"Checking if certificates need to be updated");
 		update_certificates();

+ 3 - 3
sdkconfig

@@ -437,10 +437,10 @@ CONFIG_LIBSODIUM_USE_MBEDTLS_SHA=y
 # CONFIG_LOG_DEFAULT_LEVEL_NONE is not set
 # CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set
 # CONFIG_LOG_DEFAULT_LEVEL_WARN is not set
-CONFIG_LOG_DEFAULT_LEVEL_INFO=y
-# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set
+# CONFIG_LOG_DEFAULT_LEVEL_INFO is not set
+CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
 # CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set
-CONFIG_LOG_DEFAULT_LEVEL=3
+CONFIG_LOG_DEFAULT_LEVEL=4
 CONFIG_LOG_COLORS=y
 CONFIG_LWIP_LOCAL_HOSTNAME="espressif"
 # CONFIG_LWIP_L2_TO_L3_COPY is not set