From 0a8e1c08e10d53f58d9e67d5bca09b8ae6a16c39 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 21 Jul 2015 08:33:53 +0100 Subject: fish --- polycom_xmit/upgrade.c | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 polycom_xmit/upgrade.c (limited to 'polycom_xmit/upgrade.c') diff --git a/polycom_xmit/upgrade.c b/polycom_xmit/upgrade.c new file mode 100644 index 0000000..2bf0c99 --- /dev/null +++ b/polycom_xmit/upgrade.c @@ -0,0 +1,83 @@ +#include "project.h" + + +#define pheadbuffer "Connection: keep-alive\r\n\ +Cache-Control: no-cache\r\n\ +User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/30.0.1599.101 Safari/537.36 \r\n\ +Accept: */*\r\n\ +\r\n\r\n" + + +static void ICACHE_FLASH_ATTR +upgrade_check_cb (void *arg) +{ + struct upgrade_server_info *server = arg; + + if (server->upgrade_flag == true) + { + os_printf ("upgrade finished sucesfully\n"); + } + else + { + os_printf ("upgrade finished un-sucessfully\n"); + } + + os_free (server->url); + server->url = NULL; + os_free (server); + server = NULL; +} + + +void ICACHE_FLASH_ATTR +upgrade (void) +{ + struct upgrade_server_info *server = NULL; + char user_bin[10]; + + server = (struct upgrade_server_info *) os_zalloc (sizeof (*server)); + + if (!server) + return; + + + server->ip[0] = 82; + server->ip[1] = 68; + server->ip[2] = 70; + server->ip[3] = 173; + + server->port = 80; + + server->check_cb = upgrade_check_cb; + server->check_times = 120000; + + server->url = (uint8 *) os_zalloc (512); + + if (system_upgrade_userbin_check () == UPGRADE_FW_BIN1) + { + os_strcpy (user_bin, "user2.bin"); + } + else if (system_upgrade_userbin_check () == UPGRADE_FW_BIN2) + { + os_strcpy (user_bin, "user1.bin"); + } + + + os_sprintf (server->url, + "GET /esp8266/%s HTTP/1.1\r\nHost: " IPSTR ":%d\r\n" pheadbuffer + "", user_bin, IP2STR (server->ip), server->port); + + +#if 0 + if (system_upgrade_start_ssl (server) == false) +#else + if (system_upgrade_start (server) == false) +#endif + { + os_printf ("Upgrade start failed\n"); + } + else + { + os_printf ("Upgrade start ok\n"); + } +} -- cgit v1.2.3