1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-04 18:03:20 +03:00

Merge pull request #729 from Links2004/esp8266

fix mac 599 for ESP8266HTTPUpdate
This commit is contained in:
Ivan Grokhotkov 2015-08-31 09:38:28 +03:00
commit a9fbe27cba
10 changed files with 44 additions and 4 deletions

View File

@ -1,6 +1,8 @@
#include "Updater.h"
#include "Arduino.h"
#include "eboot_command.h"
#include "interrupts.h"
//#define DEBUG_UPDATER Serial
extern "C" {

View File

@ -11,6 +11,8 @@
#define UPDATE_ERROR_SIZE 4
#define UPDATE_ERROR_STREAM 5
//#define DEBUG_UPDATER Serial1
class UpdaterClass {
public:
UpdaterClass();

View File

@ -2,8 +2,11 @@
#define ARD_DEBUG_H
#include <stddef.h>
// #define DEBUGV(...) ets_printf(__VA_ARGS__)
//#define DEBUGV(...) ets_printf(__VA_ARGS__)
#ifndef DEBUGV
#define DEBUGV(...)
#endif
#ifdef __cplusplus
void hexdump(uint8_t *mem, uint32_t len, uint8_t cols = 16);

View File

@ -332,3 +332,16 @@ void WiFiClient::stopAll()
}
}
}
void WiFiClient::stopAllExcept(WiFiClient * exC) {
for (WiFiClient* it = _s_first; it; it = it->_next) {
ClientContext* c = it->_client;
if (c && c != exC->_client) {
c->abort();
c->unref();
it->_client = 0;
}
}
}

View File

@ -96,6 +96,7 @@ public:
using Print::write;
static void stopAll();
static void stopAllExcept(WiFiClient * c);
private:

View File

@ -290,3 +290,12 @@ void WiFiUDP::stopAll()
it->stop();
}
}
void WiFiUDP::stopAllExcept(WiFiUDP * exC) {
for (WiFiUDP* it = _s_first; it; it = it->_next) {
if (it->_ctx != exC->_ctx) {
DEBUGV("%s %08x %08x\n", __func__, (uint32_t) it, (uint32_t) _s_first);
it->stop();
}
}
}

View File

@ -105,6 +105,7 @@ public:
uint16_t localPort();
static void stopAll();
static void stopAllExcept(WiFiUDP * exC);
};

View File

@ -128,10 +128,17 @@ t_httpUpdate_return ESP8266HTTPUpdate::update(const char * host, uint16_t port,
ret = HTTP_UPDATE_FAILD;
DEBUG_HTTP_UPDATE("[httpUpdate] FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len);
} else {
if(ESP.updateSketch(tcp, len)) {
// may never reached!
WiFiUDP::stopAll();
WiFiClient::stopAllExcept(&tcp);
delay(100);
if(ESP.updateSketch(tcp, len, false, false)) {
ret = HTTP_UPDATE_OK;
DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n");
tcp.stop();
ESP.restart();
} else {
ret = HTTP_UPDATE_FAILD;
DEBUG_HTTP_UPDATE("[httpUpdate] Update failed\n");

View File

@ -28,6 +28,8 @@
#include <Arduino.h>
#include <ESP8266WiFi.h>
#include <WiFiUdp.h>
#include <WiFiClient.h>
//#define DEBUG_HTTP_UPDATE(...) Serial1.printf( __VA_ARGS__ )

View File

@ -46,7 +46,7 @@
#ifdef USE_OPTIMIZE_PRINTF
#define os_printf(fmt, ...) do { \
static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \
static const char flash_str[] ICACHE_RODATA_ATTR __attribute__((aligned(4))) = fmt; \
os_printf_plus(flash_str, ##__VA_ARGS__); \
} while(0)
#else