1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-06 05:21:22 +03:00

Merge pull request #532 from me-no-dev/esp8266

add synchronous ota
This commit is contained in:
Ivan Grokhotkov 2015-07-13 02:10:14 +03:00
commit 9342874432
5 changed files with 13 additions and 10 deletions

Binary file not shown.

View File

@ -114,8 +114,12 @@ bool UpdaterClass::end(bool evenIfRemaining){
bool UpdaterClass::_writeBuffer(){
noInterrupts();
int rc = SPIEraseSector(_currentAddress/FLASH_SECTOR_SIZE);
interrupts();
yield();
if(!rc){
noInterrupts();
rc = SPIWrite(_currentAddress, _buffer, _bufferLen);
interrupts();
}
interrupts();
if (rc) {

View File

@ -54,8 +54,11 @@ void loop() {
WiFiClient client;
if (client.connect(remote, port)) {
Serial.setDebugOutput(true);
while(!Update.isFinished()) Update.write(client);
uint32_t written;
while(!Update.isFinished()){
written = Update.write(client);
if(written > 0) client.print(written, DEC);
}
Serial.setDebugOutput(false);
if(Update.end()){

View File

@ -48,12 +48,14 @@ def serve(remoteAddr, remotePort, filename):
sys.stderr.write('Uploading')
sys.stderr.flush()
while True:
chunk = f.read(4096)
chunk = f.read(1460)
if not chunk: break
sys.stderr.write('.')
sys.stderr.flush()
connection.settimeout(10)
try:
connection.sendall(chunk)
res = connection.recv(4)
except:
print('\nError Uploading', file=sys.stderr)
connection.close()

View File

@ -15,12 +15,6 @@ struct ip_info {
struct ip_addr gw;
};
#define IP4_ADDR(ipaddr, a,b,c,d) \
(ipaddr)->addr = ((uint32)((d) & 0xff) << 24) | \
((uint32)((c) & 0xff) << 16) | \
((uint32)((b) & 0xff) << 8) | \
(uint32)((a) & 0xff)
/**
* Determine if two address are on the same network.
*