1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-19 23:22:16 +03:00

Allow test framework to use cores/esp8266/Arduino.h directly (#7377)

* Allow test framework to use cores/esp8266/Arduino.h directly
* fix wps debugging
* some more missing debug.h
* Hunt down debug.h and roll-back
  TODO: rename it to something else... it is an internal header
* Move abs+round checks to test/device/test_sw
* Restore macros for C code
* fixup! Move abs+round checks to test/device/test_sw
* Fix bad c/p, actually try round with ints
* tweak c macros per review
* fix gcc-10 missing cerrno include
This commit is contained in:
Max Prokhorov 2020-10-06 17:18:00 +03:00 committed by GitHub
parent 7ba31010be
commit 36b444dba3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
17 changed files with 147 additions and 335 deletions

View File

@ -37,6 +37,7 @@ extern "C" {
#include "binary.h" #include "binary.h"
#include "esp8266_peri.h" #include "esp8266_peri.h"
#include "twi.h" #include "twi.h"
#include "core_esp8266_features.h" #include "core_esp8266_features.h"
#include "core_esp8266_version.h" #include "core_esp8266_version.h"
@ -125,15 +126,11 @@ void timer0_isr_init(void);
void timer0_attachInterrupt(timercallback userFunc); void timer0_attachInterrupt(timercallback userFunc);
void timer0_detachInterrupt(void); void timer0_detachInterrupt(void);
// Use stdlib abs() and round() to avoid issues with the C++ libraries
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define radians(deg) ((deg)*DEG_TO_RAD) #define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG) #define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x)) #define sq(x) ((x)*(x))
void ets_intr_lock();
void ets_intr_unlock();
#define interrupts() xt_rsil(0) #define interrupts() xt_rsil(0)
#define noInterrupts() xt_rsil(15) #define noInterrupts() xt_rsil(15)
@ -162,11 +159,12 @@ typedef uint16_t word;
typedef bool boolean; typedef bool boolean;
typedef uint8_t byte; typedef uint8_t byte;
void ets_intr_lock();
void ets_intr_unlock();
void init(void); void init(void);
void initVariant(void); void initVariant(void);
int atexit(void (*func)()) __attribute__((weak));
void pinMode(uint8_t pin, uint8_t mode); void pinMode(uint8_t pin, uint8_t mode);
void digitalWrite(uint8_t pin, uint8_t val); void digitalWrite(uint8_t pin, uint8_t val);
int digitalRead(uint8_t pin); int digitalRead(uint8_t pin);
@ -212,21 +210,20 @@ void optimistic_yield(uint32_t interval_us);
} // extern "C" } // extern "C"
#endif #endif
// undefine stdlib's definitions when encountered, provide abs that supports floating point for C code
#ifndef __cplusplus
#undef abs
#define abs(x) ({ __typeof__(x) _x = (x); _x > 0 ? _x : -_x; })
#undef round
#define round(x) ({ __typeof__(x) _x = (x); _x >= 0 ? (long)(_x + 0.5) : (long)(_x - 0.5); })
#endif // ifndef __cplusplus
// from this point onward, we need to configure the c++ environment
#ifdef __cplusplus #ifdef __cplusplus
#include <algorithm> #include <algorithm>
#include <cstdlib>
#include <cmath> #include <cmath>
#include <pgmspace.h>
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
#include "Esp.h"
#include "Updater.h"
#include "debug.h"
using std::min; using std::min;
using std::max; using std::max;
@ -234,6 +231,10 @@ using std::round;
using std::isinf; using std::isinf;
using std::isnan; using std::isnan;
// Use float-compatible stl abs() and round(), we don't use Arduino macros to avoid issues with the C++ libraries
using std::abs;
using std::round;
#define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; }) #define _min(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a < _b? _a : _b; })
#define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; }) #define _max(a,b) ({ decltype(a) _a = (a); decltype(b) _b = (b); _a > _b? _a : _b; })
@ -273,8 +274,19 @@ inline void configTzTime(const char* tz, const char* server1,
configTime(tz, server1, server2, server3); configTime(tz, server1, server2, server3);
} }
// Everything we expect to be implicitly loaded for the sketch
#include <pgmspace.h>
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
#include "Esp.h"
#include "Updater.h"
#endif // __cplusplus #endif // __cplusplus
#include "debug.h"
#include "pins_arduino.h" #include "pins_arduino.h"
#endif #endif

View File

@ -26,7 +26,9 @@
#include "MD5Builder.h" #include "MD5Builder.h"
#include "umm_malloc/umm_malloc.h" #include "umm_malloc/umm_malloc.h"
#include "cont.h" #include "cont.h"
#include "coredecls.h" #include "coredecls.h"
#include <pgmspace.h>
extern "C" { extern "C" {
#include "user_interface.h" #include "user_interface.h"

View File

@ -22,6 +22,7 @@
#define ESP_H #define ESP_H
#include <Arduino.h> #include <Arduino.h>
#include "core_esp8266_features.h"
#include "spi_vendors.h" #include "spi_vendors.h"
/** /**

View File

@ -18,7 +18,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <assert.h> #include <assert.h>
#include <debug.h>
#include <Arduino.h> #include <Arduino.h>
#include <cxxabi.h> #include <cxxabi.h>

View File

@ -54,6 +54,7 @@
// level 0 will enable ALL interrupts, // level 0 will enable ALL interrupts,
// //
#ifndef CORE_MOCK #ifndef CORE_MOCK
#define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;})) #define xt_rsil(level) (__extension__({uint32_t state; __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state) :: "memory"); state;}))
#define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") #define xt_wsr_ps(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory")
@ -73,6 +74,9 @@ inline uint32_t esp_get_program_counter() {
#else // CORE_MOCK #else // CORE_MOCK
#define xt_rsil(level) (level)
#define xt_wsr_ps(state) do { (void)(state); } while (0)
inline uint32_t esp_get_program_counter() { return 0; } inline uint32_t esp_get_program_counter() { return 0; }
#endif // CORE_MOCK #endif // CORE_MOCK

View File

@ -21,6 +21,9 @@
#ifndef ESP8266_PERI_H_INCLUDED #ifndef ESP8266_PERI_H_INCLUDED
#define ESP8266_PERI_H_INCLUDED #define ESP8266_PERI_H_INCLUDED
// we expect mocking framework to provide these
#ifndef CORE_MOCK
#include "c_types.h" #include "c_types.h"
#include "esp8266_undocumented.h" #include "esp8266_undocumented.h"
@ -847,4 +850,6 @@ extern volatile uint32_t* const esp8266_gpioToFn[16];
**/ **/
#define RANDOM_REG32 ESP8266_DREG(0x20E44) #define RANDOM_REG32 ESP8266_DREG(0x20E44)
#endif // ifndef CORE_MOCK
#endif #endif

View File

@ -127,6 +127,7 @@ void _exit(int status) {
abort(); abort();
} }
int atexit(void (*func)()) __attribute__((weak));
int atexit(void (*func)()) { int atexit(void (*func)()) {
(void) func; (void) func;
return 0; return 0;

View File

@ -17,9 +17,10 @@
#include <stdint.h> #include <stdint.h>
#include <stddef.h> #include <stddef.h>
#include <stdbool.h> #include <stdbool.h>
#include <debug.h>
#include <pgmspace.h> #include <pgmspace.h>
#include <esp8266_undocumented.h> #include "../debug.h"
#include "../esp8266_undocumented.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@ -0,0 +1,86 @@
/*
Small math example, checking whether we properly integrate with c++ math
ref:
- https://github.com/esp8266/Arduino/issues/5530
- https://github.com/espressif/arduino-esp32/pull/2738
Released to public domain
*/
#include <BSTest.h>
#include <type_traits>
BS_ENV_DECLARE();
void setup()
{
Serial.begin(115200);
BS_RUN(Serial);
}
bool pretest()
{
return true;
}
#define TEST_MATH_IS_SAME(OP1, OP2) \
std::is_same<decltype(OP1), decltype(OP2)>::value
TEST_CASE("std::abs and abs result is the same", "[arduino-math]")
{
CHECK(TEST_MATH_IS_SAME(abs(-5), std::abs(-5)));
CHECK(TEST_MATH_IS_SAME(abs(-25.0), std::abs(-25.0)));
CHECK(TEST_MATH_IS_SAME(abs(10.0), std::abs(10.0)));
CHECK(! TEST_MATH_IS_SAME(abs(10.0), std::abs(10)));
CHECK(! TEST_MATH_IS_SAME(abs(-5), std::abs(10.0)));
}
TEST_CASE("abs works with ints", "[arduino-math]")
{
int a = -3;
int b = 3;
CHECK(TEST_MATH_IS_SAME(abs(a), a));
CHECK(TEST_MATH_IS_SAME(abs(b), b));
CHECK(abs(a) == b);
CHECK(abs(b) == b);
}
template <typename T>
bool compare_floats(T a, T b) {
static_assert(std::is_floating_point<T>::value, "");
return std::fabs(a - b) < std::numeric_limits<float>::epsilon();
}
TEST_CASE("abs works with floats", "[arduino-math]")
{
float a = -3.5;
float b = 3.5;
CHECK(TEST_MATH_IS_SAME(abs(a), a));
CHECK(TEST_MATH_IS_SAME(abs(b), b));
CHECK(compare_floats(abs(a), b));
CHECK(compare_floats(abs(b), b));
}
TEST_CASE("round works with ints", "[arduino-math]")
{
int a = 5;
int b = 10;
CHECK(TEST_MATH_IS_SAME(round(a), std::round(a)));
CHECK(TEST_MATH_IS_SAME(round(b), std::round(b)));
CHECK(compare_floats(round(a), std::round(a)));
CHECK(compare_floats(round(b), std::round(b)));
}
TEST_CASE("round works with floats", "[arduino-math]")
{
float a = 2.9;
float b = 3.0;
CHECK(TEST_MATH_IS_SAME(round(a), a));
CHECK(TEST_MATH_IS_SAME(round(b), b));
CHECK(compare_floats(round(a), b));
CHECK(compare_floats(round(b), b));
}
void loop(){}

View File

@ -174,6 +174,7 @@ FLAGS += -DHTTPCLIENT_1_1_COMPATIBLE=0
FLAGS += -DLWIP_IPV6=0 FLAGS += -DLWIP_IPV6=0
FLAGS += -DHOST_MOCK=1 FLAGS += -DHOST_MOCK=1
FLAGS += -DNONOSDK221=1 FLAGS += -DNONOSDK221=1
FLAGS += -DF_CPU=80000000
FLAGS += $(MKFLAGS) FLAGS += $(MKFLAGS)
FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings FLAGS += -Wimplicit-fallthrough=2 # allow "// fall through" comments to stop spurious warnings
FLAGS += $(USERCFLAGS) FLAGS += $(USERCFLAGS)

View File

@ -1,279 +0,0 @@
/*
Arduino.h - Main include file for the Arduino SDK
Copyright (c) 2005-2013 Arduino Team. All right reserved.
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
*/
#ifndef Arduino_h
#define Arduino_h
#define MOCK "(mock) "
#ifdef __cplusplus
extern "C" {
#endif
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <errno.h>
#include "binary.h"
#include "twi.h"
#include "core_esp8266_features.h"
#define HIGH 0x1
#define LOW 0x0
#define PWMRANGE 1023
//GPIO FUNCTIONS
#define INPUT 0x00
#define INPUT_PULLUP 0x02
#define INPUT_PULLDOWN_16 0x04 // PULLDOWN only possible for pin16
#define OUTPUT 0x01
#define OUTPUT_OPEN_DRAIN 0x03
#define WAKEUP_PULLUP 0x05
#define WAKEUP_PULLDOWN 0x07
#define SPECIAL 0xF8 //defaults to the usable BUSes uart0rx/tx uart1tx and hspi
#define FUNCTION_0 0x08
#define FUNCTION_1 0x18
#define FUNCTION_2 0x28
#define FUNCTION_3 0x38
#define FUNCTION_4 0x48
#define PI 3.1415926535897932384626433832795
#define HALF_PI 1.5707963267948966192313216916398
#define TWO_PI 6.283185307179586476925286766559
#define DEG_TO_RAD 0.017453292519943295769236907684886
#define RAD_TO_DEG 57.295779513082320876798154814105
#define EULER 2.718281828459045235360287471352
#define SERIAL 0x0
#define DISPLAY 0x1
#define LSBFIRST 0
#define MSBFIRST 1
//Interrupt Modes
#define DISABLED 0x00
#define RISING 0x01
#define FALLING 0x02
#define CHANGE 0x03
#define ONLOW 0x04
#define ONHIGH 0x05
#define ONLOW_WE 0x0C
#define ONHIGH_WE 0x0D
#define DEFAULT 1
#define EXTERNAL 0
//timer dividers
#define TIM_DIV1 0 //80MHz (80 ticks/us - 104857.588 us max)
#define TIM_DIV16 1 //5MHz (5 ticks/us - 1677721.4 us max)
#define TIM_DIV265 3 //312.5Khz (1 tick = 3.2us - 26843542.4 us max)
//timer int_types
#define TIM_EDGE 0
#define TIM_LEVEL 1
//timer reload values
#define TIM_SINGLE 0 //on interrupt routine you need to write a new value to start the timer again
#define TIM_LOOP 1 //on interrupt the counter will start with the same value again
#define timer1_read() (T1V)
#define timer1_enabled() ((T1C & (1 << TCTE)) != 0)
#define timer1_interrupted() ((T1C & (1 << TCIS)) != 0)
typedef void(*timercallback)(void);
void timer1_isr_init(void);
void timer1_enable(uint8_t divider, uint8_t int_type, uint8_t reload);
void timer1_disable(void);
void timer1_attachInterrupt(timercallback userFunc);
void timer1_detachInterrupt(void);
void timer1_write(uint32_t ticks); //maximum ticks 8388607
// timer0 is a special CPU timer that has very high resolution but with
// limited control.
// it uses CCOUNT (ESP.GetCycleCount()) as the non-resetable timer counter
// it does not support divide, type, or reload flags
// it is auto-disabled when the compare value matches CCOUNT
// it is auto-enabled when the compare value changes
#define timer0_interrupted() (ETS_INTR_PENDING() & (_BV(ETS_COMPARE0_INUM)))
#define timer0_read() ((__extension__({uint32_t count;__asm__ __volatile__("esync; rsr %0,ccompare0":"=a" (count));count;})))
#define timer0_write(count) __asm__ __volatile__("wsr %0,ccompare0; esync"::"a" (count) : "memory")
void timer0_isr_init(void);
void timer0_attachInterrupt(timercallback userFunc);
void timer0_detachInterrupt(void);
// undefine stdlib's abs if encountered
#ifdef abs
#undef abs
#endif
#define abs(x) ((x)>0?(x):-(x))
#define constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt)))
#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
#define radians(deg) ((deg)*DEG_TO_RAD)
#define degrees(rad) ((rad)*RAD_TO_DEG)
#define sq(x) ((x)*(x))
void ets_intr_lock();
void ets_intr_unlock();
#ifndef __STRINGIFY
#define __STRINGIFY(a) #a
#endif
#define xt_rsil(level) (level)
#define xt_wsr_ps(state) do { (void)(state); } while (0)
#define interrupts() xt_rsil(0)
#define noInterrupts() xt_rsil(15)
#define clockCyclesPerMicrosecond() ( F_CPU / 1000000L )
#define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() )
#define microsecondsToClockCycles(a) ( (a) * clockCyclesPerMicrosecond() )
#define lowByte(w) ((uint8_t) ((w) & 0xff))
#define highByte(w) ((uint8_t) ((w) >> 8))
#define bitRead(value, bit) (((value) >> (bit)) & 0x01)
#define bitSet(value, bit) ((value) |= (1UL << (bit)))
#define bitClear(value, bit) ((value) &= ~(1UL << (bit)))
#define bitWrite(value, bit, bitvalue) (bitvalue ? bitSet(value, bit) : bitClear(value, bit))
// avr-libc defines _NOP() since 1.6.2
#ifndef _NOP
#define _NOP() do { __asm__ volatile ("nop"); } while (0)
#endif
typedef unsigned int word;
#define bit(b) (1UL << (b))
#define _BV(b) (1UL << (b))
typedef uint8_t boolean;
typedef uint8_t byte;
void init(void);
void initVariant(void);
void pinMode(uint8_t pin, uint8_t mode);
void digitalWrite(uint8_t pin, uint8_t val);
int digitalRead(uint8_t pin);
int analogRead(uint8_t pin);
void analogReference(uint8_t mode);
void analogWrite(uint8_t pin, int val);
void analogWriteFreq(uint32_t freq);
void analogWriteRange(uint32_t range);
unsigned long millis(void);
unsigned long micros(void);
void delay(unsigned long);
void delayMicroseconds(unsigned int us);
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout);
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout);
void shiftOut(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder, uint8_t val);
uint8_t shiftIn(uint8_t dataPin, uint8_t clockPin, uint8_t bitOrder);
void attachInterrupt(uint8_t pin, void (*)(void), int mode);
void detachInterrupt(uint8_t pin);
void setup(void);
void loop(void);
void yield(void);
void esp_yield(void);
void optimistic_yield(uint32_t interval_us);
#define digitalPinToPort(pin) (0)
#define digitalPinToBitMask(pin) (1UL << (pin))
#define digitalPinToTimer(pin) (0)
#define portOutputRegister(port) ((volatile uint32_t*) &GPO)
#define portInputRegister(port) ((volatile uint32_t*) &GPI)
#define portModeRegister(port) ((volatile uint32_t*) &GPE)
#define NOT_A_PIN -1
#define NOT_A_PORT -1
#define NOT_AN_INTERRUPT -1
#define NOT_ON_TIMER 0
#ifdef __cplusplus
} // extern "C"
#endif
#ifdef __cplusplus
#include <pgmspace.h>
#include "WCharacter.h"
#include "WString.h"
#include "HardwareSerial.h"
#include "Esp.h"
#include "Updater.h"
#include "debug.h"
#if 0
#ifndef _GLIBCXX_VECTOR
// arduino is not compatible with std::vector
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#endif
#endif
#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
uint16_t makeWord(uint16_t w);
uint16_t makeWord(byte h, byte l);
#define word(...) makeWord(__VA_ARGS__)
unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout = 1000000L);
void tone(uint8_t _pin, unsigned int frequency, unsigned long duration = 0);
void noTone(uint8_t _pin);
// WMath prototypes
long random(long);
long random(long, long);
void randomSeed(unsigned long);
long map(long, long, long, long, long);
extern "C" void configTime(long timezone, int daylightOffset_sec,
const char* server1, const char* server2 = nullptr, const char* server3 = nullptr);
#endif
#include "pins_arduino.h"
#endif /* Arduino_h */
#if __cplusplus
#include <WString.h>
#include <map>
#define MOCKARGS 1
extern std::map<String,String> mockArgs;
#endif

View File

@ -56,8 +56,6 @@ const char* fspath = nullptr;
static struct termios initial_settings; static struct termios initial_settings;
std::map<String,String> mockArgs;
int mockverbose (const char* fmt, ...) int mockverbose (const char* fmt, ...)
{ {
va_list ap; va_list ap;
@ -137,8 +135,6 @@ void help (const char* argv0, int exitcode)
"\t-S - spiffs size in KBytes (default: %zd)\n" "\t-S - spiffs size in KBytes (default: %zd)\n"
"\t-L - littlefs size in KBytes (default: %zd)\n" "\t-L - littlefs size in KBytes (default: %zd)\n"
"\t (spiffs, littlefs: negative value will force mismatched size)\n" "\t (spiffs, littlefs: negative value will force mismatched size)\n"
"\t-K - key\n"
"\t-V - value\n"
"\tgeneral:\n" "\tgeneral:\n"
"\t-c - ignore CTRL-C (send it via Serial)\n" "\t-c - ignore CTRL-C (send it via Serial)\n"
"\t-f - no throttle (possibly 100%%CPU)\n" "\t-f - no throttle (possibly 100%%CPU)\n"
@ -162,8 +158,6 @@ static struct option options[] =
{ "spiffskb", required_argument, NULL, 'S' }, { "spiffskb", required_argument, NULL, 'S' },
{ "littlefskb", required_argument, NULL, 'L' }, { "littlefskb", required_argument, NULL, 'L' },
{ "portshifter", required_argument, NULL, 's' }, { "portshifter", required_argument, NULL, 's' },
{ "key", required_argument, NULL, 'K' },
{ "value", required_argument, NULL, 'V' },
{ "once", no_argument, NULL, '1' }, { "once", no_argument, NULL, '1' },
}; };
@ -215,11 +209,10 @@ int main (int argc, char* const argv [])
mock_port_shifter = 0; mock_port_shifter = 0;
else else
mock_port_shifter = MOCK_PORT_SHIFTER; mock_port_shifter = MOCK_PORT_SHIFTER;
String key;
for (;;) for (;;)
{ {
int n = getopt_long(argc, argv, "hlcfbvTi:S:s:L:P:1K:V:", options, NULL); int n = getopt_long(argc, argv, "hlcfbvTi:S:s:L:P:1", options, NULL);
if (n < 0) if (n < 0)
break; break;
switch (n) switch (n)
@ -260,12 +253,6 @@ int main (int argc, char* const argv [])
case 'T': case 'T':
serial_timestamp = true; serial_timestamp = true;
break; break;
case 'K':
key = optarg;
break;
case 'V':
mockArgs[key] = optarg;
break;
case '1': case '1':
run_once = true; run_once = true;
break; break;

View File

@ -53,16 +53,6 @@ int ets_printf (const char* fmt, ...)
return len; return len;
} }
extern "C" void configTime(long timezone, int daylightOffset_sec,
const char* server1, const char* server2, const char* server3)
{
(void)server1;
(void)server2;
(void)server3;
mockverbose("configTime: TODO (tz=%ldH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec);
}
void stack_thunk_add_ref() { } void stack_thunk_add_ref() { }
void stack_thunk_del_ref() { } void stack_thunk_del_ref() { }
void stack_thunk_repaint() { } void stack_thunk_repaint() { }
@ -78,3 +68,13 @@ void stack_thunk_dump_stack() { }
#define make_stack_thunk(fcnToThunk) #define make_stack_thunk(fcnToThunk)
}; };
void configTime(int timezone, int daylightOffset_sec,
const char* server1, const char* server2, const char* server3)
{
(void)server1;
(void)server2;
(void)server3;
mockverbose("configTime: TODO (tz=%dH offset=%dS) (time will be host's)\n", timezone, daylightOffset_sec);
}

View File

@ -6,4 +6,4 @@ const int GPI = 0;
const int GPO = 0; const int GPO = 0;
const int GP16I = 0; const int GP16I = 0;
#endif #endif

View File

@ -31,6 +31,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <cerrno>
#include "flash_hal_mock.h" #include "flash_hal_mock.h"
#define LITTLEFS_FILE_NAME "littlefs.bin" #define LITTLEFS_FILE_NAME "littlefs.bin"

View File

@ -30,6 +30,7 @@
*/ */
#define CORE_MOCK 1 #define CORE_MOCK 1
#define MOCK "(mock) " // TODO: provide common logging API instead of adding this string everywhere?
// //
@ -37,7 +38,6 @@
#define ESP8266 1 #define ESP8266 1
#define A0 0 #define A0 0
#define LED_BUILTIN 0 #define LED_BUILTIN 0
#define F_CPU 80000000
#define LWIP_OPEN_SRC #define LWIP_OPEN_SRC
#define TCP_MSS 536 #define TCP_MSS 536
#define LWIP_FEATURES 1 #define LWIP_FEATURES 1
@ -54,19 +54,12 @@
#define D7 7 #define D7 7
#define D8 8 #define D8 8
// include host's STL before any other include file
// because core definition like max() is in the way
#ifdef __cplusplus
#include <vector>
#endif
#include <stddef.h> #include <stddef.h>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
//#include <stdlib_noniso.h> // TODO: #include <stdlib_noniso.h> ?
char* itoa (int val, char *s, int radix); char* itoa (int val, char *s, int radix);
char* ltoa (long val, char *s, int radix); char* ltoa (long val, char *s, int radix);
#ifdef __cplusplus #ifdef __cplusplus
@ -91,9 +84,6 @@ uint32_t esp_get_cycle_count();
#include <Arduino.h> #include <Arduino.h>
//
#include <stdlib.h>
#define RANDOM_REG32 ((uint32_t)random()) #define RANDOM_REG32 ((uint32_t)random())
// net tweak // net tweak

View File

@ -26,6 +26,7 @@
#include <sys/stat.h> #include <sys/stat.h>
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <cerrno>
#include "flash_hal_mock.h" #include "flash_hal_mock.h"