فهرست منبع

Update status.json message format: add severity

Sebastien 5 سال پیش
والد
کامیت
d2f17f5b05

+ 1 - 1
.cproject

@@ -239,7 +239,7 @@
                             							
                             							
                             <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1831977109" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
                             <targetPlatform archList="all" binaryParser="org.eclipse.cdt.core.ELF" id="cdt.managedbuild.targetPlatform.gnu.cross.1831977109" isAbstract="false" osList="all" superClass="cdt.managedbuild.targetPlatform.gnu.cross"/>
                             							
                             							
-                            <builder arguments="&quot;C:/msys32/opt/esp-idf/tools/windows/eclipse_make.py&quot; -j8 EXTRA_CPPFLAGS=&quot;-DRECOVERY_APPLICATION=1 -DSQUEEZELITE_ESP32_RELEASE_URL=\&quot;https://github.com/sle118/squeezelite-esp32/releases\&quot; &quot;" command="python" id="cdt.managedbuild.builder.gnu.cross.1069921467" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
+                            <builder arguments="&quot;C:/msys32/opt/esp-idf/tools/windows/eclipse_make.py&quot; -j8 EXTRA_CPPFLAGS='-DRECOVERY_APPLICATION=1 -DSQUEEZELITE_ESP32_RELEASE_URL=\&quot;https://github.com/sle118/squeezelite-esp32/releases\&quot; '" command="python" id="cdt.managedbuild.builder.gnu.cross.1069921467" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="cdt.managedbuild.builder.gnu.cross"/>
                             							
                             							
                             <tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1302011176" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
                             <tool id="cdt.managedbuild.tool.gnu.cross.c.compiler.1302011176" name="Cross GCC Compiler" superClass="cdt.managedbuild.tool.gnu.cross.c.compiler">
                                 								
                                 								

+ 5 - 0
components/cmd_system/cmd_system.c

@@ -26,6 +26,7 @@
 #include "sdkconfig.h"
 #include "sdkconfig.h"
 #include "esp_partition.h"
 #include "esp_partition.h"
 #include "esp_ota_ops.h"
 #include "esp_ota_ops.h"
+#include "platform_esp32.h"
 
 
 #ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
 #ifdef CONFIG_FREERTOS_USE_STATS_FORMATTING_FUNCTIONS
 #define WITH_TASKS_INFO 1
 #define WITH_TASKS_INFO 1
@@ -112,6 +113,7 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
 
 
 	if(it == NULL){
 	if(it == NULL){
 		ESP_LOGE(TAG,"Unable initialize partition iterator!");
 		ESP_LOGE(TAG,"Unable initialize partition iterator!");
+		set_status_message(ERROR, "Reboot failed. Cannot iterate through partitions");
 	}
 	}
 	else
 	else
 	{
 	{
@@ -120,10 +122,12 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
 			ESP_LOGI(TAG, "Found partition type %u",partition_subtype);
 			ESP_LOGI(TAG, "Found partition type %u",partition_subtype);
 			esp_ota_set_boot_partition(partition);
 			esp_ota_set_boot_partition(partition);
 			bFound=true;
 			bFound=true;
+			set_status_message(WARNING, "Rebooting!");
 		}
 		}
 		else
 		else
 		{
 		{
 			ESP_LOGE(TAG,"partition type %u not found!  Unable to reboot to recovery.",partition_subtype);
 			ESP_LOGE(TAG,"partition type %u not found!  Unable to reboot to recovery.",partition_subtype);
+			set_status_message(ERROR, "Partition not found.");
 		}
 		}
 		esp_partition_iterator_release(it);
 		esp_partition_iterator_release(it);
 		if(bFound) {
 		if(bFound) {
@@ -131,6 +135,7 @@ esp_err_t guided_boot(esp_partition_subtype_t partition_subtype)
 			esp_restart();
 			esp_restart();
 		}
 		}
 	}
 	}
+
 	return ESP_OK;
 	return ESP_OK;
 }
 }
 
 

+ 1 - 0
components/cmd_system/component.mk

@@ -8,3 +8,4 @@
 #
 #
 
 
 COMPONENT_ADD_INCLUDEDIRS := .
 COMPONENT_ADD_INCLUDEDIRS := .
+COMPONENT_EXTRA_INCLUDES += $(PROJECT_PATH)/main/

+ 0 - 25
components/wifi-manager/http_server.c

@@ -218,31 +218,6 @@ err_t http_server_nvs_dump(struct netconn *conn, nvs_type_t nvs_type, bool * bFi
 	}
 	}
 	nvs_json = cJSON_CreateObject();
 	nvs_json = cJSON_CreateObject();
 	num_buffer = malloc(NUM_BUFFER_LEN);
 	num_buffer = malloc(NUM_BUFFER_LEN);
-//
-//
-//	cJSON_AddItemToObject(ip_info_cjson, "version", cJSON_CreateString(desc->version));
-//	cJSON_AddNumberToObject(ip_info_cjson,"recovery",	RECOVERY_APPLICATION	);
-//	cJSON_AddNumberToObject(ip_info_cjson, "urc", update_reason_code);
-//	if(config){
-//		cJSON_AddItemToObject(ip_info_cjson, "ssid", cJSON_CreateString((char *)config->sta.ssid));
-//
-//		if(update_reason_code == UPDATE_CONNECTION_OK){
-//			/* rest of the information is copied after the ssid */
-//			tcpip_adapter_ip_info_t ip_info;
-//			ESP_ERROR_CHECK(tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip_info));
-//			cJSON_AddItemToObject(ip_info_cjson, "ip", cJSON_CreateString(ip4addr_ntoa(&ip_info.ip)));
-//			cJSON_AddItemToObject(ip_info_cjson, "netmask", cJSON_CreateString(ip4addr_ntoa(&ip_info.netmask)));
-//			cJSON_AddItemToObject(ip_info_cjson, "gw", cJSON_CreateString(ip4addr_ntoa(&ip_info.gw)));
-//		}
-//	}
-//
-//
-//	cJSON_AddItemToObject(ip_info_cjson, "ota_dsc", cJSON_CreateString(ota_get_status()));
-//	cJSON_AddNumberToObject(ip_info_cjson,"ota_pct",	ota_get_pct_complete()	);
-//
-//	cJSON_AddItemToObject(ip_info_cjson, "Jack", cJSON_CreateString(JACK_LEVEL));
-//
-//
 
 
 	nvs_iterator_t it = nvs_entry_find(NVS_PARTITION_NAME, NULL, nvs_type);
 	nvs_iterator_t it = nvs_entry_find(NVS_PARTITION_NAME, NULL, nvs_type);
 	if (it == NULL) {
 	if (it == NULL) {

+ 15 - 2
components/wifi-manager/wifi_manager.c

@@ -30,7 +30,7 @@ Contains the freeRTOS task and all necessary support
 */
 */
 
 
 #include "wifi_manager.h"
 #include "wifi_manager.h"
-
+#include "platform_esp32.h"
 #include <stdio.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <string.h>
 #include <string.h>
@@ -318,7 +318,6 @@ bool wifi_manager_fetch_wifi_sta_config(){
 
 
 }
 }
 
 
-
 cJSON * wifi_manager_get_new_json(cJSON **old){
 cJSON * wifi_manager_get_new_json(cJSON **old){
 	cJSON * root=*old;
 	cJSON * root=*old;
 	if(root!=NULL){
 	if(root!=NULL){
@@ -561,6 +560,20 @@ void wifi_manager_connect_async(){
 	wifi_manager_send_message(ORDER_CONNECT_STA, (void*)CONNECTION_REQUEST_USER);
 	wifi_manager_send_message(ORDER_CONNECT_STA, (void*)CONNECTION_REQUEST_USER);
 }
 }
 
 
+void set_status_message(message_severity_t severity, const char * message){
+	if(ip_info_cjson==NULL){
+		ip_info_cjson = wifi_manager_get_new_json(&ip_info_cjson);
+	}
+	if(ip_info_cjson==NULL){
+		ESP_LOGE(TAG,"Error setting status message. Unable to allocate cJSON.");
+		return;
+	}
+	cJSON * item=cJSON_GetObjectItem(ip_info_cjson, "message");
+	item = wifi_manager_get_new_json(&item);
+	cJSON_AddItemToObject(item, "severity", cJSON_CreateString(severity==INFO?"INFO":severity==WARNING?"WARNING":severity==ERROR?"ERROR":"" ));
+	cJSON_AddItemToObject(item, "text", cJSON_CreateString(message));
+}
+
 
 
 char* wifi_manager_get_ip_info_json(){
 char* wifi_manager_get_ip_info_json(){
 	return cJSON_Print(ip_info_cjson);
 	return cJSON_Print(ip_info_cjson);

+ 6 - 1
main/platform_esp32.h

@@ -31,4 +31,9 @@ extern  bool wait_for_wifi();
 extern void console_start();
 extern void console_start();
 extern pthread_cond_t wifi_connect_suspend_cond;
 extern pthread_cond_t wifi_connect_suspend_cond;
 extern pthread_t wifi_connect_suspend_mutex;
 extern pthread_t wifi_connect_suspend_mutex;
-
+typedef enum {
+	INFO,
+	WARNING,
+	ERROR
+} message_severity_t;
+extern void set_status_message(message_severity_t severity, const char * message);