OTA Work in progress

This commit is contained in:
Sebastien
2019-09-19 11:41:20 -04:00
committed by Sebastien Leclerc
parent 3bd886b8df
commit 8aedca48a7
18 changed files with 439 additions and 252 deletions

View File

@@ -45,10 +45,6 @@ static const char array_separator[]=",";
/* @brief task handle for the http server */
static TaskHandle_t task_http_server = NULL;
#ifndef CONFIG_IS_RECOVERY_MODE
#define CONFIG_IS_RECOVERY_MODE 0
#endif
/**
* @brief embedded binary data.
* @see file "component.mk"
@@ -225,7 +221,7 @@ void http_server_netconn_serve(struct netconn *conn) {
netconn_write(conn, http_ok_json_no_cache_hdr, sizeof(http_ok_json_no_cache_hdr) - 1, NETCONN_NOCOPY);
autoexec_flag = wifi_manager_get_flag();
snprintf(buff,buflen-1, json_start, CONFIG_IS_RECOVERY_MODE, autoexec_flag);
snprintf(buff,buflen-1, json_start, RECOVERY_APPLICATION, autoexec_flag);
netconn_write(conn, buff, strlen(buff), NETCONN_NOCOPY);
do {
snprintf(autoexec_name,sizeof(autoexec_name)-1,"autoexec%u",i);

View File

@@ -55,14 +55,14 @@ Contains the freeRTOS task and all necessary support
#include "lwip/netdb.h"
#include "lwip/ip4_addr.h"
#ifndef SQUEEZELITE_ESP32_BASE_RELEASE
#define SQUEEZELITE_ESP32_BASE_RELEASE "unknown"
#endif
#ifndef SQUEEZELITE_ESP32_RELEASE_URL
#define SQUEEZELITE_ESP32_RELEASE_URL "https://github.com/sle118/squeezelite-esp32/releases"
#endif
#if RECOVERY_APPLICATION
extern const char * ota_get_status();
extern uint8_t ota_get_pct_complete();
#endif
/* objects used to manipulate the main queue of events */
QueueHandle_t wifi_manager_queue;
@@ -406,9 +406,11 @@ void wifi_manager_clear_ip_info_json(){
void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code){
wifi_config_t *config = wifi_manager_get_wifi_sta_config();
if(config){
#if !RECOVERY_APPLICATION
const char ip_info_json_format[] = ",\"ip\":\"%s\",\"netmask\":\"%s\",\"gw\":\"%s\",\"urc\":%d}\n";
#else
const char ip_info_json_format[] = ",\"ip\":\"%s\",\"netmask\":\"%s\",\"gw\":\"%s\",\"urc\":%d, \"ota_dsc\":\"%s\", \"ota_pct\":%d}\n";
#endif
memset(ip_info_json, 0x00, JSON_IP_INFO_SIZE);
@@ -431,7 +433,12 @@ void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code)
ip,
netmask,
gw,
(int)update_reason_code);
(int)update_reason_code
#if RECOVERY_APPLICATION
,ota_get_status(),
ota_get_pct_complete()
#endif
);
}
else{
/* notify in the json output the reason code why this was updated without a connection */
@@ -439,7 +446,12 @@ void wifi_manager_generate_ip_info_json(update_reason_code_t update_reason_code)
"0",
"0",
"0",
(int)update_reason_code);
(int)update_reason_code
#if RECOVERY_APPLICATION
,"",
0
#endif
);
}
}
else{

View File

@@ -40,6 +40,13 @@ extern "C" {
#include "esp_wifi.h"
#include "esp_wifi_types.h"
#ifndef RECOVERY_APPLICATION
#define RECOVERY_APPLICATION 0
#else
#undef RECOVERY_APPLICATION
#define RECOVERY_APPLICATION 1
#endif
#define DEFAULT_COMMAND_LINE CONFIG_DEFAULT_COMMAND_LINE
@@ -163,10 +170,14 @@ extern "C" {
/**
* @brief Defines the maximum length in bytes of a JSON representation of the IP information
* assuming all ips are 4*3 digits, and all characters in the ssid require to be escaped.
* example: {"ssid":"abcdefghijklmnopqrstuvwxyz012345","ip":"192.168.1.119","netmask":"255.255.255.0","gw":"192.168.1.1","urc":0}
* example: {"ssid":"abcdefghijklmnopqrstuvwxyz012345","ip":"192.168.1.119","netmask":"255.255.255.0","gw":"192.168.1.1","urc":0, "ota_dsc":"Installing...", "ota_pct":100}
*/
#if RECOVERY_APPLICATION
// recovery has more resources available. Let's use them to include more details about the OTA process
#define JSON_IP_INFO_SIZE 150+255
#else
#define JSON_IP_INFO_SIZE 150
#endif
/**