There are multiple custom features that can be enabled by default. For example: SSL support, custom LWIP, open PWM, custom heap allocation, more verbose debugging, etc. Click here to see the details
-- Custom LWIP: (default: ON) By default we are using custom compiled LWIP stack instead of the binary one provided from Espressif. This is increasing the free memory and decreasing the space on the flash. All espconn_* functions are turned off by default. If your application requires the use of some of the espconn_* functions then add the ENABLE_ESPCONN=1 directive. See `Makefile-user.mk` from the [Basic_SmartConfig](https://github.com/SmingHub/Sming/blob/develop/samples/Basic_SmartConfig/Makefile-user.mk#L41) application for examples. If you would like to use the binary LWIP then you should turn off the custom LWIP compilation by providing `ENABLE_CUSTOM_LWIP=0`.
-- SSL: (default: OFF) The SSL support is not built-in by default to conserve resources. If you want to enable it then take a look at the [Readme](https://github.com/SmingHub/Sming/blob/develop/samples/Basic_Ssl/README.md) in the Basic_Ssl samples.
-- Custom PWM: (default: ON) If you don't want to use the [open PWM implementation](https://github.com/StefanBruens/ESP8266_new_pwm) then compile your application with `ENABLE_CUSTOM_PWM=0`. There is no need to recompile the Sming library.
-- Custom serial baud rate: (default: OFF) The default serial baud rate is 115200. If you want to change it to a higher baud rate you can recompile Sming and your application changing the `COM_SPEED_SERIAL` directive. For example `COM_SPEED_SERIAL=921600`.
-- Custom heap allocation: (default: OFF) If your application is experiencing heap fragmentation then you can try the [umm_malloc](https://github.com/rhempel/umm_malloc) heap allocation. To enable it compile Sming with `ENABLE_CUSTOM_HEAP=1`. In order to use it in your sample/application make sure to compile the sample with `ENABLE_CUSTOM_HEAP=1`. **Do not enable custom heap allocation and -mforce-l32 compiler flag together**.
-- Debug information log level and format: There are four debug levels: debug=3, info=2, warn=1, error=0. Using `DEBUG_VERBOSE_LEVEL` you can set the desired level (0-3). For example `DEBUG_VERBOSE_LEVEL=2` will show only info messages and above. Another make directive is `DEBUG_PRINT_FILENAME_AND_LINE=1` which enables printing the filename and line number of every debug line. This will require extra space on flash. Note: you can compile the Sming library with a set of debug directives and your project with another settings, this way you can control debugging separately for Sming and your application code.
-- Debug information for custom LWIP: If you use custom LWIP (see above) some debug information will be printed for critical errors and situations. You can enable debug information printing altogether using `ENABLE_LWIPDEBUG=1`. To increase debugging for certain areas you can modify debug options in `third-party/esp-open-lwip/include/lwipopts.h`.
-- Interactive debugging on the device: (default: OFF) In order to be able to debug live directly on the ESP8266 microcontroller you should re-compile your application and the Sming library with `ENABLE_GDB=1` directive. See [Basic_Debug](https://github.com/SmingHub/Sming/tree/develop/samples/Basic_Debug) sample for more details.
+- **Custom LWIP**: (default: ON) By default we are using custom compiled LWIP stack instead of the binary one provided from Espressif. This is increasing the free memory and decreasing the space on the flash. All espconn_* functions are turned off by default. If your application requires the use of some of the espconn_* functions then add the ENABLE_ESPCONN=1 directive. See `Makefile-user.mk` from the [Basic_SmartConfig](https://github.com/SmingHub/Sming/blob/develop/samples/Basic_SmartConfig/Makefile-user.mk#L41) application for examples. If you would like to use the binary LWIP then you should turn off the custom LWIP compilation by providing `ENABLE_CUSTOM_LWIP=0`.
+- **LWIP 2**: (default: OFF) LWIP 2 stands for LightWeight IP stack, version 2. In order to enable that feature you should (re)compile the Sming library AND your application using the following directive ENABLE_CUSTOM_LWIP=2. LWIP v2 does not have support for espconn_* functions.
+This feature is still **experimental** which means that we still do not recommend it in production.
+- **SSL support**: (default: OFF) The SSL support is not built-in by default to conserve resources. If you want to enable it then take a look at the [Readme](https://github.com/SmingHub/Sming/blob/develop/samples/Basic_Ssl/README.md) in the Basic_Ssl samples.
+- **Custom PWM**: (default: ON) If you don't want to use the [open PWM implementation](https://github.com/StefanBruens/ESP8266_new_pwm) then compile your application with `ENABLE_CUSTOM_PWM=0`. There is no need to recompile the Sming library.
+- WPS: (default: OFF) The WPS support (Wi-Fi Protected Setup) is not activated by default to preserve resources. To enable WPS, use the switch ENABLE_WPS=1 for compiling Sming.
+- **Custom serial baud rate**: (default: OFF) The default serial baud rate is 115200. If you want to change it to a higher baud rate you can recompile Sming and your application changing the `COM_SPEED_SERIAL` directive. For example `COM_SPEED_SERIAL=921600`.
+- **Custom heap allocation**: (default: OFF) If your application is experiencing heap fragmentation then you can try the [umm_malloc](https://github.com/rhempel/umm_malloc) heap allocation. To enable it compile Sming with `ENABLE_CUSTOM_HEAP=1`. In order to use it in your sample/application make sure to compile the sample with `ENABLE_CUSTOM_HEAP=1`. **Do not enable custom heap allocation and -mforce-l32 compiler flag at the same time**.
+- **Debug information log level and format**: There are four debug levels: debug=3, info=2, warn=1, error=0. Using `DEBUG_VERBOSE_LEVEL` you can set the desired level (0-3). For example `DEBUG_VERBOSE_LEVEL=2` will show only info messages and above. Another make directive is `DEBUG_PRINT_FILENAME_AND_LINE=1` which enables printing the filename and line number of every debug line. This will require extra space on flash. Note: you can compile the Sming library with a set of debug directives and your project with another settings, this way you can control debugging separately for Sming and your application code.
+- **Debug information for custom LWIP**: If you use custom LWIP (see above) some debug information will be printed for critical errors and situations. You can enable debug information printing altogether using `ENABLE_LWIPDEBUG=1`. To increase debugging for certain areas you can modify debug options in `third-party/esp-open-lwip/include/lwipopts.h`.
+- **Interactive debugging on the device**: (default: OFF) In order to be able to debug live directly on the ESP8266 microcontroller you should re-compile your application and the Sming library with `ENABLE_GDB=1` directive. See [Basic_Debug](https://github.com/SmingHub/Sming/tree/develop/samples/Basic_Debug) sample for more details.
- CommandExecutor feature: (default: ON) This feature enables execution of certain commands by registering token handlers for text received via serial, websocket or telnet connection. If this feature is not used additional RAM/Flash can be obtained by setting `ENABLE_CMD_EXECUTOR=0`. This will save ~1KB RAM and ~3KB of flash memory.
+- **SDK 2.1.0+**: (default: OFF) In order to use SDK 2.1 you should set one environment variable before (re)compiling Sming AND applications based on it. The variable is SDK_BASE and it should point to `$SMING_HOME/third-party/ESP8266_NONOS_SDK`.
+For Windows you need to do:
+```
+set SDK_BASE %SMING_HOME%//third-party/ESP8266_NONOS_SDK
+```
+
+For Linux(bash) you need to do:
+```
+export SDK_BASE="$SMING_HOME/third-party/ESP8266_NONOS_SDK"
+```
+
+Read the comments from [this URL](https://github.com/SmingHub/Sming/pull/1264) for known issues.
+This feature is still **experimental** which means that we still do not recommend it in production.
## Compilation and flashing
diff --git a/Sming/Libraries/.patches/Adafruit_SSD1306.patch b/Sming/Libraries/.patches/Adafruit_SSD1306.patch
new file mode 100644
index 0000000000..c0baf653c3
--- /dev/null
+++ b/Sming/Libraries/.patches/Adafruit_SSD1306.patch
@@ -0,0 +1,96 @@
+diff --git a/Adafruit_SSD1306.cpp b/Adafruit_SSD1306.cpp
+index 570a335..40f4784 100644
+--- a/Adafruit_SSD1306.cpp
++++ b/Adafruit_SSD1306.cpp
+@@ -252,7 +252,7 @@ void Adafruit_SSD1306::begin(uint8_t vccstate, uint8_t i2caddr, bool reset) {
+ ssd1306_command(SSD1306_SETCONTRAST); // 0x81
+ ssd1306_command(0x8F);
+
+-#elif defined SSD1306_128_64
++#elif defined SSD1306_128_64 || defined SH1106_128_64
+ ssd1306_command(SSD1306_SETCOMPINS); // 0xDA
+ ssd1306_command(0x12);
+ ssd1306_command(SSD1306_SETCONTRAST); // 0x81
+@@ -417,6 +417,28 @@ void Adafruit_SSD1306::dim(boolean dim) {
+ }
+
+ void Adafruit_SSD1306::display(void) {
++#if defined SH1106_128_64
++ for (int index = 0; index < 8; index++) {
++ ssd1306_command(SH1106_SETSTARTPAGE + index);
++ /* for some reason display is shifted by 2 columns
++ * on 1.3" displays from ebay
++ */
++ ssd1306_command(SSD1306_SETLOWCOLUMN + 2); // low column start address
++ ssd1306_command(SSD1306_SETHIGHCOLUMN); // high column start address
++
++ for (int pixel = 0; pixel < SSD1306_LCDWIDTH; pixel++) {
++ Wire.beginTransmission(_i2caddr);
++ WIRE_WRITE(0x40);
++ // input buffer doesn't accept all bytes at once
++ for (uint8_t x=0; x<16; x++) {
++ WIRE_WRITE(buffer[index * SSD1306_LCDWIDTH + pixel]);
++ ++pixel;
++ }
++ --pixel;
++ Wire.endTransmission();
++ }
++ }
++#else
+ ssd1306_command(SSD1306_COLUMNADDR);
+ ssd1306_command(0); // Column start address (0 = reset)
+ ssd1306_command(SSD1306_LCDWIDTH-1); // Column end address (127 = reset)
+@@ -482,6 +504,7 @@ void Adafruit_SSD1306::display(void) {
+ TWBR = twbrbackup;
+ #endif
+ }
++#endif /* defined SH1106_128_64 */
+ }
+
+ // clear everything
+diff --git a/Adafruit_SSD1306.h b/Adafruit_SSD1306.h
+index 1162f87..4226f3e 100644
+--- a/Adafruit_SSD1306.h
++++ b/Adafruit_SSD1306.h
+@@ -69,20 +69,28 @@ All text above, and the splash screen must be included in any redistribution
+
+ SSD1306_96_16
+
++ SH1106_128_64 - 1.3" OLED display version
++
+ -----------------------------------------------------------------------*/
+-// #define SSD1306_128_64
+- #define SSD1306_128_32
++// #define SH1106_128_64
++ #define SSD1306_128_64
++// #define SSD1306_128_32
+ // #define SSD1306_96_16
+ /*=========================================================================*/
+
++#if defined SSD1306_128_64 && defined SH1106_128_64
++ #error "Select either SH1106 or SSD1306 display type in SSD1306.h"
++#endif
++
++
+ #if defined SSD1306_128_64 && defined SSD1306_128_32
+ #error "Only one SSD1306 display can be specified at once in SSD1306.h"
+ #endif
+-#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16
++#if !defined SSD1306_128_64 && !defined SSD1306_128_32 && !defined SSD1306_96_16 && !defined SH1106_128_64
+ #error "At least one SSD1306 display must be specified in SSD1306.h"
+ #endif
+
+-#if defined SSD1306_128_64
++#if defined SSD1306_128_64 || defined SH1106_128_64
+ #define SSD1306_LCDWIDTH 128
+ #define SSD1306_LCDHEIGHT 64
+ #endif
+@@ -132,6 +140,8 @@ All text above, and the splash screen must be included in any redistribution
+ #define SSD1306_EXTERNALVCC 0x1
+ #define SSD1306_SWITCHCAPVCC 0x2
+
++#define SH1106_SETSTARTPAGE 0xB0
++
+ // Scrolling #defines
+ #define SSD1306_ACTIVATE_SCROLL 0x2F
+ #define SSD1306_DEACTIVATE_SCROLL 0x2E
diff --git a/Sming/Libraries/.patches/Readme.md b/Sming/Libraries/.patches/Readme.md
new file mode 100644
index 0000000000..555d2f6422
--- /dev/null
+++ b/Sming/Libraries/.patches/Readme.md
@@ -0,0 +1 @@
+This directory contains patches to upstream Arudino libraries.
diff --git a/Sming/Libraries/Adafruit_BME280_Library/.github/ISSUE_TEMPLATE.md b/Sming/Libraries/Adafruit_BME280_Library/.github/ISSUE_TEMPLATE.md
new file mode 100644
index 0000000000..f0e26146fa
--- /dev/null
+++ b/Sming/Libraries/Adafruit_BME280_Library/.github/ISSUE_TEMPLATE.md
@@ -0,0 +1,46 @@
+Thank you for opening an issue on an Adafruit Arduino library repository. To
+improve the speed of resolution please review the following guidelines and
+common troubleshooting steps below before creating the issue:
+
+- **Do not use GitHub issues for troubleshooting projects and issues.** Instead use
+ the forums at http://forums.adafruit.com to ask questions and troubleshoot why
+ something isn't working as expected. In many cases the problem is a common issue
+ that you will more quickly receive help from the forum community. GitHub issues
+ are meant for known defects in the code. If you don't know if there is a defect
+ in the code then start with troubleshooting on the forum first.
+
+- **If following a tutorial or guide be sure you didn't miss a step.** Carefully
+ check all of the steps and commands to run have been followed. Consult the
+ forum if you're unsure or have questions about steps in a guide/tutorial.
+
+- **For Arduino projects check these very common issues to ensure they don't apply**:
+
+ - For uploading sketches or communicating with the board make sure you're using
+ a **USB data cable** and **not** a **USB charge-only cable**. It is sometimes
+ very hard to tell the difference between a data and charge cable! Try using the
+ cable with other devices or swapping to another cable to confirm it is not
+ the problem.
+
+ - **Be sure you are supplying adequate power to the board.** Check the specs of
+ your board and plug in an external power supply. In many cases just
+ plugging a board into your computer is not enough to power it and other
+ peripherals.
+
+ - **Double check all soldering joints and connections.** Flakey connections
+ cause many mysterious problems. See the [guide to excellent soldering](https://learn.adafruit.com/adafruit-guide-excellent-soldering/tools) for examples of good solder joints.
+
+ - **Ensure you are using an official Arduino or Adafruit board.** We can't
+ guarantee a clone board will have the same functionality and work as expected
+ with this code and don't support them.
+
+If you're sure this issue is a defect in the code and checked the steps above
+please fill in the following fields to provide enough troubleshooting information.
+You may delete the guideline and text above to just leave the following details:
+
+- Arduino board: **INSERT ARDUINO BOARD NAME/TYPE HERE**
+
+- Arduino IDE version (found in Arduino -> About Arduino menu): **INSERT ARDUINO
+ VERSION HERE**
+
+- List the steps to reproduce the problem below (if possible attach a sketch or
+ copy the sketch code in too): **LIST REPRO STEPS BELOW**
diff --git a/Sming/Libraries/Adafruit_BME280_Library/.github/PULL_REQUEST_TEMPLATE.md b/Sming/Libraries/Adafruit_BME280_Library/.github/PULL_REQUEST_TEMPLATE.md
new file mode 100644
index 0000000000..7b641eb862
--- /dev/null
+++ b/Sming/Libraries/Adafruit_BME280_Library/.github/PULL_REQUEST_TEMPLATE.md
@@ -0,0 +1,26 @@
+Thank you for creating a pull request to contribute to Adafruit's GitHub code!
+Before you open the request please review the following guidelines and tips to
+help it be more easily integrated:
+
+- **Describe the scope of your change--i.e. what the change does and what parts
+ of the code were modified.** This will help us understand any risks of integrating
+ the code.
+
+- **Describe any known limitations with your change.** For example if the change
+ doesn't apply to a supported platform of the library please mention it.
+
+- **Please run any tests or examples that can exercise your modified code.** We
+ strive to not break users of the code and running tests/examples helps with this
+ process.
+
+Thank you again for contributing! We will try to test and integrate the change
+as soon as we can, but be aware we have many GitHub repositories to manage and
+can't immediately respond to every request. There is no need to bump or check in
+on a pull request (it will clutter the discussion of the request).
+
+Also don't be worried if the request is closed or not integrated--sometimes the
+priorities of Adafruit's GitHub code (education, ease of use) might not match the
+priorities of the pull request. Don't fret, the open source community thrives on
+forks and GitHub makes it easy to keep your changes in a forked repo.
+
+After reviewing the guidelines above you can delete this text from the pull request.
diff --git a/Sming/Libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp b/Sming/Libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp
new file mode 100644
index 0000000000..6ed7dcf572
--- /dev/null
+++ b/Sming/Libraries/Adafruit_BME280_Library/Adafruit_BME280.cpp
@@ -0,0 +1,528 @@
+/***************************************************************************
+ This is a library for the BME280 humidity, temperature & pressure sensor
+
+ Designed specifically to work with the Adafruit BME280 Breakout
+ ----> http://www.adafruit.com/products/2650
+
+ These sensors use I2C or SPI to communicate, 2 or 4 pins are required
+ to interface.
+
+ Adafruit invests time and resources providing this open source code,
+ please support Adafruit andopen-source hardware by purchasing products
+ from Adafruit!
+
+ Written by Limor Fried & Kevin Townsend for Adafruit Industries.
+ BSD license, all text above must be included in any redistribution
+ ***************************************************************************/
+#include "Arduino.h"
+#include