diff --git a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h index 664454dc81..49bb87f28c 100644 --- a/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h +++ b/libraries/ESP8266HTTPUpdateServer/src/ESP8266HTTPUpdateServer-impl.h @@ -111,7 +111,7 @@ void ESP8266HTTPUpdateServerTemplate::setup(ESP8266WebServerTemplate } } else if(_authenticated && upload.status == UPLOAD_FILE_END && !_updaterError.length()){ if(Update.end(true)){ //true to set the size to the current progress - if (_serial_output) Serial.printf("Update Success: %u\nRebooting...\n", upload.totalSize); + if (_serial_output) Serial.printf("Update Success: %zu\nRebooting...\n", upload.totalSize); } else { _setUpdaterError(); } diff --git a/tests/host/Makefile b/tests/host/Makefile index b7c8d1ce20..13c9feed52 100644 --- a/tests/host/Makefile +++ b/tests/host/Makefile @@ -136,7 +136,7 @@ MOCK_CPP_FILES_COMMON := \ MockUART.cpp \ MockTools.cpp \ MocklwIP.cpp \ - MockDigital.cpp \ + HostWiring.cpp \ ) MOCK_CPP_FILES := $(MOCK_CPP_FILES_COMMON) \ @@ -356,7 +356,6 @@ MOCK_ARDUINO_LIBS := \ MockWiFiServerSocket.cpp \ MockWiFiServer.cpp \ UdpContextSocket.cpp \ - HostWiring.cpp \ MockEsp.cpp \ MockEEPROM.cpp \ MockSPI.cpp \ diff --git a/tests/host/common/Arduino.cpp b/tests/host/common/Arduino.cpp index 1c651e7e1f..ffeeae05cd 100644 --- a/tests/host/common/Arduino.cpp +++ b/tests/host/common/Arduino.cpp @@ -111,3 +111,11 @@ cont_t* g_pcont = NULL; extern "C" void cont_suspend(cont_t*) { } + +extern "C" int __mockverbose (const char* fmt, ...) +{ + (void)fmt; + return 0; +} + +int mockverbose (const char* fmt, ...) __attribute__ ((weak, alias("__mockverbose"), format (printf, 1, 2))); diff --git a/tests/host/common/HostWiring.cpp b/tests/host/common/HostWiring.cpp index 765d4297b6..1b93d72ece 100644 --- a/tests/host/common/HostWiring.cpp +++ b/tests/host/common/HostWiring.cpp @@ -37,6 +37,11 @@ #define VERBOSE(x...) mockverbose(x) #endif +#define GPIONUM 17 + +static uint8_t _mode[GPIONUM]; +static uint8_t _gpio[GPIONUM]; + void pinMode (uint8_t pin, uint8_t mode) { #define xxx(mode) case mode: m=STRHELPER(mode); break @@ -53,11 +58,19 @@ void pinMode (uint8_t pin, uint8_t mode) default: m="(special)"; } VERBOSE("gpio%d: mode='%s'\n", pin, m); + + if (pin < GPIONUM) + { + _mode[pin] = mode; + } } void digitalWrite(uint8_t pin, uint8_t val) { VERBOSE("digitalWrite(pin=%d val=%d)\n", pin, val); + if (pin < GPIONUM) { + _gpio[pin] = val; + } } void analogWrite(uint8_t pin, int val) @@ -80,6 +93,9 @@ int digitalRead(uint8_t pin) { VERBOSE("digitalRead(%d)\n", pin); - // pin 0 is most likely a low active input - return pin ? 0 : 1; + if (pin < GPIONUM) { + return _gpio[pin] != 0; + } else { + return 0; + } } diff --git a/tests/host/common/MockDigital.cpp b/tests/host/common/MockDigital.cpp deleted file mode 100644 index aa04527ab5..0000000000 --- a/tests/host/common/MockDigital.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/* - digital.c - wiring digital implementation for esp8266 - - Copyright (c) 2015 Hristo Gochkov. All rights reserved. - This file is part of the esp8266 core for Arduino environment. - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -*/ -#define ARDUINO_MAIN -#include "wiring_private.h" -#include "pins_arduino.h" -#include "c_types.h" -#include "eagle_soc.h" -#include "ets_sys.h" -#include "user_interface.h" -#include "core_esp8266_waveform.h" -#include "interrupts.h" - -extern "C" { - -static uint8_t _mode[17]; -static uint8_t _gpio[17]; - -extern void pinMode(uint8_t pin, uint8_t mode) { - if (pin < 17) { - _mode[pin] = mode; - } -} - -extern void digitalWrite(uint8_t pin, uint8_t val) { - if (pin < 17) { - _gpio[pin] = val; - } -} - -extern int digitalRead(uint8_t pin) { - if (pin < 17) { - return _gpio[pin] != 0; - } else { - return 0; - } -} - -}; diff --git a/tests/host/common/MockEsp.cpp b/tests/host/common/MockEsp.cpp index d11a39e940..293f6c5047 100644 --- a/tests/host/common/MockEsp.cpp +++ b/tests/host/common/MockEsp.cpp @@ -142,6 +142,15 @@ void EspClass::getHeapStats(uint32_t* hfree, uint16_t* hmax, uint8_t* hfrag) { if (hfrag) *hfrag = 100 - (sqrt(hm) * 100) / hf; } +void EspClass::getHeapStats(uint32_t* hfree, uint32_t* hmax, uint8_t* hfrag) { + uint32_t hf = 10 * 1024; + float hm = 1 * 1024; + + if (hfree) *hfree = hf; + if (hmax) *hmax = hm; + if (hfrag) *hfrag = 100 - (sqrt(hm) * 100) / hf; +} + bool EspClass::flashEraseSector(uint32_t sector) { (void) sector; @@ -263,3 +272,8 @@ void EspClass::setExternalHeap() void EspClass::resetHeap() { } + +void EspClass::reset () +{ + abort(); +} diff --git a/tests/host/common/MockTools.cpp b/tests/host/common/MockTools.cpp index 5eb7969de7..eb2c41ed12 100644 --- a/tests/host/common/MockTools.cpp +++ b/tests/host/common/MockTools.cpp @@ -78,3 +78,12 @@ void configTime(int timezone, int daylightOffset_sec, mockverbose("configTime: TODO (tz=%dH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec); } + +void configTime(const char* tz, const char* server1, const char* server2, const char* server3) +{ + (void)server1; + (void)server2; + (void)server3; + + mockverbose("configTime: TODO (tz='%s') (time will be host's)\n", tz); +}