Skip to content

Commit

Permalink
Merge branch 'dev' into file-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HHHartmann authored Nov 6, 2020
2 parents c181849 + 0e88617 commit 3ed9566
Show file tree
Hide file tree
Showing 160 changed files with 5,157 additions and 3,395 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Fixes #\<GitHub-issue-number\>.

Make sure all boxes are checked (add x inside the brackets) when you submit your contribution, remove this sentence before doing so.

- [ ] This PR is for the `dev` branch rather than for `master`.
- [ ] This PR is for the `dev` branch rather than for the `release` branch.
- [ ] This PR is compliant with the [other contributing guidelines](https://github.com/nodemcu/nodemcu-firmware/blob/dev/CONTRIBUTING.md) as well (if not, please describe why).
- [ ] I have thoroughly tested my contribution.
- [ ] The code changes are reflected in the documentation at `docs/*`.
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.gdb_history
app/lua/.std
app/lua53/.std
sdk/
cache/
.ccache/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@
[submodule "app/ucglib/ucg"]
path = app/ucglib/ucg
url = https://github.com/olikraus/Ucglib_Arduino.git
[submodule "app/libc/c99-snprintf"]
path = app/libc/c99-snprintf
url = https://github.com/weiss/c99-snprintf.git
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ else
UNAME_P := $(shell uname -p)
ifeq ($(OS),linux)
ifndef TOOLCHAIN_ROOT
TOOLCHAIN_VERSION = 20181106.0
TOOLCHAIN_VERSION = 20190731.0
GCCTOOLCHAIN = linux-x86_64-$(TOOLCHAIN_VERSION)
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ The entire [NodeMCU documentation](https://nodemcu.readthedocs.io) is maintained

Due to the ever-growing number of modules available within NodeMCU, pre-built binaries are no longer made available. Use the automated [custom firmware build service](http://nodemcu-build.com/) to get the specific firmware configuration you need, or consult the [documentation](http://nodemcu.readthedocs.io/en/master/en/build/) for other options to build your own firmware.

This project uses two main branches, `master` and `dev`. `dev` is actively worked on and it's also where PRs should be created against. `master` thus can be considered "stable" even though there are no automated regression tests. The goal is to merge back to `master` roughly every 2 months. Depending on the current "heat" (issues, PRs) we accept changes to `dev` for 5-6 weeks and then hold back for 2-3 weeks before the next snap is completed.
This project uses two main branches, `release` and `dev`. `dev` is actively worked on and it's also where PRs should be created against. `release` thus can be considered "stable" even though there are no automated regression tests. The goal is to merge back to `release` roughly every 2 months. Depending on the current "heat" (issues, PRs) we accept changes to `dev` for 5-6 weeks and then hold back for 2-3 weeks before the next snap is completed.

A new tag is created every time `dev` is merged back to `master`. They are listed in the [releases section here on GitHub](https://github.com/nodemcu/nodemcu-firmware/releases). Tag names follow the \<SDK-version\>-master_yyyymmdd pattern.

Expand Down
1 change: 0 additions & 1 deletion app/coap/coap.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ extern "C" {

#include <stdint.h>
#include <stddef.h>
#include "lualib.h"
#include "lauxlib.h"

#define MAXOPT 16
Expand Down
1 change: 0 additions & 1 deletion app/coap/endpoints.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include "lua.h"
#include "lauxlib.h"
#include "lualib.h"

#include "os_type.h"
#include "user_interface.h"
Expand Down
81 changes: 51 additions & 30 deletions app/dht/dht.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,21 @@
#define HIGH 1
#endif /* ifndef HIGH */

#define COMBINE_HIGH_AND_LOW_BYTE(byte_high, byte_low) (((byte_high) << 8) | (byte_low))

static double dht_humidity;
static double dht_temperature;

static uint8_t dht_bytes[5]; // buffer to receive data

typedef enum {
Humidity = 0,
Temperature,
Humidity8,
Temperature8
} dht_Signal;

static int dht_readSensor(uint8_t pin, uint8_t wakeupDelay);
static double getValue(dht_Signal s);
static bool verifyChecksum();

/////////////////////////////////////////////////////
//
Expand Down Expand Up @@ -91,19 +99,17 @@ int dht_read_universal(uint8_t pin)
#endif // defined(DHT_DEBUG_BYTES)

// Assume it is DHT11
// If it is DHT11, both bit[1] and bit[3] is 0
// If it is DHT11, both temp and humidity's decimal
if ((dht_bytes[1] == 0) && (dht_bytes[3] == 0))
{
// It may DHT11
// CONVERT AND STORE
DHT_DEBUG("DHT11 method\n");
dht_humidity = dht_bytes[0]; // dht_bytes[1] == 0;
dht_temperature = dht_bytes[2]; // dht_bytes[3] == 0;
dht_humidity = getValue(Humidity8);
dht_temperature = getValue(Temperature8);

// TEST CHECKSUM
// dht_bytes[1] && dht_bytes[3] both 0
uint8_t sum = dht_bytes[0] + dht_bytes[2];
if (dht_bytes[4] != sum)
if (!verifyChecksum())
{
// It may not DHT11
dht_humidity = DHTLIB_INVALID_VALUE; // invalid value, or is NaN prefered?
Expand All @@ -119,16 +125,11 @@ int dht_read_universal(uint8_t pin)
// Assume it is not DHT11
// CONVERT AND STORE
DHT_DEBUG("DHTxx method\n");
dht_humidity = (double)COMBINE_HIGH_AND_LOW_BYTE(dht_bytes[0], dht_bytes[1]) * 0.1;
dht_temperature = (double)COMBINE_HIGH_AND_LOW_BYTE(dht_bytes[2] & 0x7F, dht_bytes[3]) * 0.1;
if (dht_bytes[2] & 0x80) // negative dht_temperature
{
dht_temperature = -dht_temperature;
}
dht_humidity = getValue(Humidity);
dht_temperature = getValue(Temperature);

// TEST CHECKSUM
uint8_t sum = dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3];
if (dht_bytes[4] != sum)
if (!verifyChecksum())
{
return DHTLIB_ERROR_CHECKSUM;
}
Expand All @@ -151,13 +152,11 @@ int dht_read11(uint8_t pin)
}

// CONVERT AND STORE
dht_humidity = dht_bytes[0]; // dht_bytes[1] == 0;
dht_temperature = dht_bytes[2]; // dht_bytes[3] == 0;
dht_humidity = getValue(Humidity8);
dht_temperature = getValue(Temperature8);

// TEST CHECKSUM
// dht_bytes[1] && dht_bytes[3] both 0
uint8_t sum = dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3];
if (dht_bytes[4] != sum) return DHTLIB_ERROR_CHECKSUM;
if (!verifyChecksum()) return DHTLIB_ERROR_CHECKSUM;

return DHTLIB_OK;
}
Expand All @@ -179,16 +178,11 @@ int dht_read(uint8_t pin)
}

// CONVERT AND STORE
dht_humidity = (double)COMBINE_HIGH_AND_LOW_BYTE(dht_bytes[0], dht_bytes[1]) * 0.1;
dht_temperature = (double)COMBINE_HIGH_AND_LOW_BYTE(dht_bytes[2] & 0x7F, dht_bytes[3]) * 0.1;
if (dht_bytes[2] & 0x80) // negative dht_temperature
{
dht_temperature = -dht_temperature;
}
dht_humidity = getValue(Humidity);
dht_temperature = getValue(Temperature);

// TEST CHECKSUM
uint8_t sum = dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3];
if (dht_bytes[4] != sum)
if (!verifyChecksum())
{
return DHTLIB_ERROR_CHECKSUM;
}
Expand Down Expand Up @@ -242,7 +236,7 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)
// volatile uint8_t *PIR = portInputRegister(port);

// EMPTY BUFFER
for (i = 0; i < 5; i++) dht_bytes[i] = 0;
memset(dht_bytes, sizeof(uint8_t)*5, 0);

// REQUEST SAMPLE
// pinMode(pin, OUTPUT);
Expand Down Expand Up @@ -314,6 +308,33 @@ int dht_readSensor(uint8_t pin, uint8_t wakeupDelay)

return DHTLIB_OK;
}

// Assembles the high and low byte in a signed 16bit value
static double getValue(dht_Signal s)
{
uint8_t high=0, low=0;

// the '8' variants leave the low byte set to 0
switch(s){
case Humidity:
low = dht_bytes[1];
case Humidity8:
high = dht_bytes[0];
break;
case Temperature:
low = dht_bytes[3];
case Temperature8:
high = dht_bytes[2];
break;
}
return ((high << 8) | low) * 0.1;
}

static bool verifyChecksum(){
uint8_t sum = dht_bytes[0] + dht_bytes[1] + dht_bytes[2] + dht_bytes[3];
return (dht_bytes[4] == sum);
}

//
// END OF FILE
//
4 changes: 2 additions & 2 deletions app/http/httpclient.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

#include "osapi.h"
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "user_interface.h"
#include "espconn.h"
#include "mem.h"
#include "limits.h"
#include "httpclient.h"
#include "stdlib.h"
#include "pm/swtimer.h"

#define REDIRECTION_FOLLOW_MAX 20
Expand Down
1 change: 1 addition & 0 deletions app/include/rtc/rtctime.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct rtc_tm{
void TEXT_SECTION_ATTR rtctime_early_startup (void);
void rtctime_late_startup (void);
void rtctime_adjust_rate (int rate);
int rtctime_get_rate (void);
void rtctime_gettimeofday (struct rtc_timeval *tv);
void rtctime_settimeofday (const struct rtc_timeval *tv);
bool rtctime_have_time (void);
Expand Down
24 changes: 18 additions & 6 deletions app/include/user_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@

// The net module optionally offers net info functionnality. Uncomment the following
// to enable the functionnality.
#define NET_PING_ENABLE
#define NET_PING_ENABLE

// The WiFi module optionally offers an enhanced level of WiFi connection
// management, using internal timer callbacks. Whilst many Lua developers
Expand All @@ -165,7 +165,9 @@
// alphanumeric characters. If you are imaging multiple modules with this
// firmware then you must also define WIFI_STA_HOSTNAME_APPEND_MAC to
// append the last 3 octets of the MAC address. Note that the total
// Hostname MUST be 32 chars or less.
// Hostname MUST be 32 chars or less. If the resulting hostname is
// invalid, then it will not be used, and a message will be printed
// during boot.

//#define WIFI_STA_HOSTNAME "NodeMCU"
//#define WIFI_STA_HOSTNAME_APPEND_MAC
Expand All @@ -174,7 +176,7 @@
// If you use the enduser_setup module, then you can also set the default
// SSID when this module is running in AP mode.

#define ENDUSER_SETUP_AP_SSID "SetupGadget"
#define ENDUSER_SETUP_AP_SSID "NodeMCU"


// I2C software driver partially supports use of GPIO16 (D0) pin for SCL line.
Expand Down Expand Up @@ -239,19 +241,29 @@
# define LUA_FLASH_STORE 0x0
#endif

#define SPIFFS_FIXED_LOCATION 0x0
#ifndef SPIFFS_FIXED_LOCATION
#define SPIFFS_FIXED_LOCATION 0x0
// You'll rarely need to customize this, because nowadays
// it's usually overruled by the partition table anyway.
#endif
#ifndef SPIFFS_MAX_FILESYSTEM_SIZE
# define SPIFFS_MAX_FILESYSTEM_SIZE 0xFFFFFFFF
#endif
//#define SPIFFS_SIZE_1M_BOUNDARY

// The following define enables recording of the number of CPU cycles at certain
// points in the startup process. It can be used to see where the time is being
// consumed. It enables a nice node.startupcounts() function to get the results.
//#define PLATFORM_STARTUP_COUNT

#define LUA_TASK_PRIO USER_TASK_PRIO_0
#define LUA_PROCESS_LINE_SIG 2
#define LUA_OPTIMIZE_DEBUG 2
// LUAI_OPTIMIZE_DEBUG 0 = Keep all debug; 1 = keep line number info; 2 = remove all debug
#define LUAI_OPTIMIZE_DEBUG 1
#define READLINE_INTERVAL 80
#define STRBUF_DEFAULT_INCREMENT 3
#define LUA_USE_BUILTIN_DEBUG_MINIMAL // for debug.getregistry() and debug.traceback()

#if defined(DEVELOPMENT_TOOLS) && defined(DEVELOPMENT_USE_GDB)
extern void LUA_DEBUG_HOOK (void);
#define lua_assert(x) ((x) ? (void) 0 : LUA_DEBUG_HOOK ())
Expand Down
6 changes: 3 additions & 3 deletions app/include/user_mbedtls.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,9 @@ extern void mbedtls_free_wrap(void *p);
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
#define MBEDTLS_PLATFORM_PRINTF_MACRO ets_printf /**< Default printf macro to use, can be undefined */
#define MBEDTLS_PLATFORM_SNPRINTF_MACRO ets_snprintf /**< Default snprintf macro to use, can be undefined */
#define MBEDTLS_PLATFORM_VSNPRINTF_MACRO ets_vsnprintf /**< Default vsnprintf macro to use, can be undefined */
//#define MBEDTLS_PLATFORM_PRINTF_MACRO ets_printf /**< Default printf macro to use, can be undefined */
//#define MBEDTLS_PLATFORM_SNPRINTF_MACRO ets_snprintf /**< Default snprintf macro to use, can be undefined */
//#define MBEDTLS_PLATFORM_VSNPRINTF_MACRO ets_vsnprintf /**< Default vsnprintf macro to use, can be undefined */
//#define MBEDTLS_PLATFORM_NV_SEED_READ_MACRO mbedtls_platform_std_nv_seed_read /**< Default nv_seed_read function to use, can be undefined */
//#define MBEDTLS_PLATFORM_NV_SEED_WRITE_MACRO mbedtls_platform_std_nv_seed_write /**< Default nv_seed_write function to use, can be undefined */
//#define MBEDTLS_SSL_CACHE_DEFAULT_TIMEOUT 86400 /**< 1 day */
Expand Down
2 changes: 2 additions & 0 deletions app/include/user_modules.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//#define LUA_USE_MODULES_BLOOM
//#define LUA_USE_MODULES_BMP085
//#define LUA_USE_MODULES_BME280
//#define LUA_USE_MODULES_BME280_MATH
//#define LUA_USE_MODULES_BME680
//#define LUA_USE_MODULES_COAP
//#define LUA_USE_MODULES_COLOR_UTILS
Expand Down Expand Up @@ -69,6 +70,7 @@
//#define LUA_USE_MODULES_U8G2
//#define LUA_USE_MODULES_UCG
//#define LUA_USE_MODULES_WEBSOCKET
//#define LUA_USE_MODULES_WIEGAND
#define LUA_USE_MODULES_WIFI
//#define LUA_USE_MODULES_WIFI_MONITOR
//#define LUA_USE_MODULES_WPS
Expand Down
1 change: 1 addition & 0 deletions app/libc/c99-snprintf
Submodule c99-snprintf added at 27b59a
58 changes: 58 additions & 0 deletions app/libc/snprintf.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Wrapper around https://github.com/weiss/c99-snprintf
*/

#define HAVE_CONFIG_H 0
#define TEST_SNPRINTF 0
#define HAVE_SNPRINTF 0
#define HAVE_VSNPRINTF 0
#define HAVE_ASPRINTF 0
#define HAVE_VASPRINTF 0

#define HAVE_STDARG_H 1
#define HAVE_STDLIB_H 1

#define HAVE_VA_COPY 0
#define HAVE___VA_COPY 0
#define HAVE_FLOAT_H 1
#define HAVE_INTTYPES_H 1
#define HAVE_LOCALE_H 0
#define HAVE_STDDEF_H 1
#define HAVE_STDINT_H 1
#define HAVE_UNSIGNED_LONG_LONG_INT 1
#define HAVE_UINTMAX_T 1
#define HAVE_LONG_DOUBLE 0
#define HAVE_LONG_LONG_INT 1
#define HAVE_INTMAX_T 1
#define HAVE_UINTPTR_T 1
#define HAVE_PTRDIFF_T 1

#define HAVE_LOCALECONV 0
#define HAVE_LCONV_DECIMAL_POINT 0
#define HAVE_LCONV_THOUSANDS_SEP 0
#define LDOUBLE_MIN_10_EXP DBL_MIN_10_EXP
#define LDOUBLE_MAX_10_EXP DBL_MAX_10_EXP

#define rpl_snprintf snprintf
#define rpl_vsnprintf vsnprintf
#define rpl_vasprintf vasprintf
#define rpl_asprintf asprintf

#include "c99-snprintf/snprintf.c"

int sprintf(char *s, const char *fmt, ...)
{
int n;
va_list arg;
va_start(arg, fmt);
n = vsnprintf(s, 1024, fmt, arg);
va_end(arg);
return n;
}

int vsprintf (char *d, const char *s, va_list ap)
{
return vsnprintf(d, 1024, s, ap);
}


Loading

0 comments on commit 3ed9566

Please sign in to comment.