diff --git a/.gitignore b/.gitignore index 3c8c0fe5c..b86a8611d 100644 --- a/.gitignore +++ b/.gitignore @@ -13,7 +13,7 @@ hardware/arduino/bootloaders/caterina_LUFA/Caterina.lss hardware/arduino/bootloaders/caterina_LUFA/Caterina.elf hardware/arduino/bootloaders/caterina_LUFA/Caterina.eep hardware/arduino/bootloaders/caterina_LUFA/.dep/ -build/libastylej-*.zip +build/*.zip build/windows/work/ build/windows/*.zip build/windows/*.tgz @@ -56,6 +56,9 @@ avr-toolchain-*.zip /hardware/tools/esp8266/utils/ /hardware/tools/esp8266/xtensa-lx106-elf /hardware/tools/esp8266/esptool.exe +/hardware/esp8266com/esp8266/tools/xtensa* +/hardware/esp8266com/esp8266/tools/esptool* +/hardware/esp8266com/esp8266/tools/utils /hardware/tools/avr/ /hardware/tools/gcc-arm-none-eabi-4.8.3-2014q1/ /hardware/tools/bossac.exe diff --git a/boards.txt b/boards.txt index bfc910a2b..d1f213ca0 100644 --- a/boards.txt +++ b/boards.txt @@ -21,13 +21,7 @@ generic.build.board=ESP8266_ESP01 generic.build.core=esp8266 generic.build.variant=generic generic.build.flash_mode=qio -generic.build.flash_size=512K -generic.build.flash_freq=40 -generic.build.flash_ld=eagle.flash.512k.ld -generic.build.spiffs_start=0x6B000 -generic.build.spiffs_end=0x7B000 generic.build.spiffs_pagesize=256 -generic.build.spiffs_blocksize=4096 generic.menu.CpuFrequency.80=80 MHz generic.menu.CpuFrequency.80.build.f_cpu=80000000L @@ -123,10 +117,10 @@ generic.menu.FlashSize.4M.upload.maximum_size=1044464 # generic.menu.FlashSize.16M.build.spiffs_end=0x1000000 # generic.menu.FlashSize.16M.build.spiffs_blocksize=8192 -# generic.menu.FlashFreq.40=40MHz -# generic.menu.FlashFreq.40.build.flash_freq=40 -# generic.menu.FlashFreq.80=80MHz -# generic.menu.FlashFreq.80.build.flash_freq=80 +generic.menu.FlashFreq.40=40MHz +generic.menu.FlashFreq.40.build.flash_freq=40 +generic.menu.FlashFreq.80=80MHz +generic.menu.FlashFreq.80.build.flash_freq=80 ############################################################## modwifi.name=Olimex MOD-WIFI-ESP8266(-DEV) diff --git a/cores/esp8266/Arduino.h b/cores/esp8266/Arduino.h index 89bf32685..a715f5215 100644 --- a/cores/esp8266/Arduino.h +++ b/cores/esp8266/Arduino.h @@ -143,13 +143,13 @@ void ets_intr_unlock(); // level 15 will disable ALL interrupts, // level 0 will disable most software interrupts // -#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0," __STRINGIFY(level) "; esync; isync; dsync" : "=a" (state)) -#define xt_enable_interrupts(state) __asm__ __volatile__("wsr %0,ps; esync" :: "a" (state) : "memory") +#define xt_disable_interrupts(state, level) __asm__ __volatile__("rsil %0," __STRINGIFY(level) : "=a" (state)) +#define xt_enable_interrupts(state) __asm__ __volatile__("wsr %0,ps; isync" :: "a" (state) : "memory") extern uint32_t interruptsState; #define interrupts() xt_enable_interrupts(interruptsState) -#define noInterrupts() __asm__ __volatile__("rsil %0,15; esync; isync; dsync" : "=a" (interruptsState)) +#define noInterrupts() __asm__ __volatile__("rsil %0,15" : "=a" (interruptsState)) #define clockCyclesPerMicrosecond() ( F_CPU / 1000000L ) #define clockCyclesToMicroseconds(a) ( (a) / clockCyclesPerMicrosecond() ) @@ -195,6 +195,7 @@ 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); @@ -236,6 +237,8 @@ void loop(void); #define min(a,b) ((a)<(b)?(a):(b)) #define max(a,b) ((a)>(b)?(a):(b)) +#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); @@ -243,6 +246,7 @@ 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); @@ -250,7 +254,7 @@ void noTone(uint8_t _pin); // WMath prototypes long random(long); long random(long, long); -void randomSeed(unsigned int); +void randomSeed(unsigned long); long map(long, long, long, long, long); diff --git a/cores/esp8266/Esp.cpp b/cores/esp8266/Esp.cpp index 617dd9cba..cda089b04 100644 --- a/cores/esp8266/Esp.cpp +++ b/cores/esp8266/Esp.cpp @@ -32,7 +32,7 @@ extern struct rst_info resetInfo; // #define DEBUG_SERIAL Serial - + /** * User-defined Literals * usage: @@ -97,8 +97,8 @@ void EspClass::wdtFeed(void) void EspClass::deepSleep(uint32_t time_us, WakeMode mode) { - system_deep_sleep_set_option(static_cast(mode)); - system_deep_sleep(time_us); + system_deep_sleep_set_option(static_cast(mode)); + system_deep_sleep(time_us); } extern "C" void esp_yield(); @@ -280,8 +280,8 @@ uint32_t EspClass::getFlashChipSizeByChipId(void) { String EspClass::getResetInfo(void) { if(resetInfo.reason != 0) { - char buff[150]; - sprintf(&buff[0], "Fatal exception:%d flag:%d epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc); + char buff[200]; + sprintf(&buff[0], "Fatal exception:%d flag:%d (%s) epc1:0x%08x epc2:0x%08x epc3:0x%08x excvaddr:0x%08x depc:0x%08x", resetInfo.exccause, resetInfo.reason, (resetInfo.reason == 0 ? "DEFAULT" : resetInfo.reason == 1 ? "WDT" : resetInfo.reason == 2 ? "EXCEPTION" : resetInfo.reason == 3 ? "SOFT_WDT" : resetInfo.reason == 4 ? "SOFT_RESTART" : resetInfo.reason == 5 ? "DEEP_SLEEP_AWAKE" : "???"), resetInfo.epc1, resetInfo.epc2, resetInfo.epc3, resetInfo.excvaddr, resetInfo.depc); return String(buff); } return String("flag: 0"); @@ -400,6 +400,13 @@ bool EspClass::updateSketch(Stream& in, uint32_t size) { return false; } + if(addr == freeSpaceStart) { + // check for valid first magic byte + if(*((uint8 *) buffer.get()) != 0xE9) { + return false; + } + } + noInterrupts(); rc = SPIWrite(addr, buffer.get(), willRead); interrupts(); @@ -426,7 +433,7 @@ bool EspClass::updateSketch(Stream& in, uint32_t size) { ebcmd.args[1] = 0x00000; ebcmd.args[2] = size; eboot_command_write(&ebcmd); - + ESP.restart(); return true; // never happens } diff --git a/cores/esp8266/Esp.h b/cores/esp8266/Esp.h index df41be399..80555d591 100644 --- a/cores/esp8266/Esp.h +++ b/cores/esp8266/Esp.h @@ -129,7 +129,7 @@ class EspClass { uint32_t EspClass::getCycleCount() { uint32_t ccount; - __asm__ __volatile__("rsr %0,ccount":"=a" (ccount)); + __asm__ __volatile__("esync; rsr %0,ccount":"=a" (ccount)); return ccount; } diff --git a/cores/esp8266/HardwareSerial.cpp b/cores/esp8266/HardwareSerial.cpp index 5a91e854e..e77fe3ef4 100644 --- a/cores/esp8266/HardwareSerial.cpp +++ b/cores/esp8266/HardwareSerial.cpp @@ -620,6 +620,7 @@ size_t HardwareSerial::write(uint8_t c) { while(_tx_buffer->room() == 0) { yield(); + uart_arm_tx_interrupt(_uart); } _tx_buffer->write(c); diff --git a/cores/esp8266/Print.cpp b/cores/esp8266/Print.cpp index 1f924248a..efd6b9f17 100644 --- a/cores/esp8266/Print.cpp +++ b/cores/esp8266/Print.cpp @@ -127,8 +127,7 @@ size_t ICACHE_FLASH_ATTR Print::print(const Printable& x) { } size_t ICACHE_FLASH_ATTR Print::println(void) { - size_t n = print("\r\n"); - return n; + return print("\r\n"); } size_t ICACHE_FLASH_ATTR Print::println(const String &s) { diff --git a/cores/esp8266/Stream.h b/cores/esp8266/Stream.h index 6d08ef1dc..14eacbf6c 100644 --- a/cores/esp8266/Stream.h +++ b/cores/esp8266/Stream.h @@ -69,6 +69,8 @@ class Stream: public Print { } // returns true if target string is found, false if timed out + bool find(char target) { return find (&target, 1); } + bool findUntil(const char *target, const char *terminator); // as find but search ends if the terminator string is found bool findUntil(const uint8_t *target, const char *terminator) { return findUntil((char *) target, terminator); diff --git a/cores/esp8266/WMath.cpp b/cores/esp8266/WMath.cpp index dcd51f1f2..da46a3ddb 100644 --- a/cores/esp8266/WMath.cpp +++ b/cores/esp8266/WMath.cpp @@ -27,7 +27,7 @@ extern "C" { #include } -void randomSeed(unsigned int seed) { +void randomSeed(unsigned long seed) { if(seed != 0) { srand(seed); } diff --git a/cores/esp8266/cbuf.h b/cores/esp8266/cbuf.h index 87642510b..ceb6a7b6d 100644 --- a/cores/esp8266/cbuf.h +++ b/cores/esp8266/cbuf.h @@ -39,8 +39,12 @@ class cbuf { } size_t room() const { - if(_end >= _begin) return _size - (_end - _begin) - 1; - + if(_end >= _begin) { + return _size - (_end - _begin) - 1; + } + if(_begin == _end) { + return _size; + } return _begin - _end - 1; } diff --git a/cores/esp8266/core_esp8266_main.cpp b/cores/esp8266/core_esp8266_main.cpp index df2d65d70..dcf5631ea 100644 --- a/cores/esp8266/core_esp8266_main.cpp +++ b/cores/esp8266/core_esp8266_main.cpp @@ -121,9 +121,10 @@ void init_done() { extern "C" { void user_init(void) { - system_rtc_mem_read(0, &resetInfo, sizeof(struct rst_info)); - struct rst_info info = { 0 }; - system_rtc_mem_write(0, &info, sizeof(struct rst_info)); + struct rst_info *rtc_info_ptr = system_get_rst_info(); + + memcpy((void *) &resetInfo, (void *) rtc_info_ptr, sizeof(resetInfo)); + uart_div_modify(0, UART_CLK_FREQ / (115200)); diff --git a/cores/esp8266/core_esp8266_phy.c b/cores/esp8266/core_esp8266_phy.c index faa601184..c22272df7 100644 --- a/cores/esp8266/core_esp8266_phy.c +++ b/cores/esp8266/core_esp8266_phy.c @@ -201,6 +201,17 @@ static uint8_t phy_init_data[128] = // 18<=x<=36: use input voltage, // the value is voltage*10, 33 is 3.3V, 30 is 3.0V, // x<18 or x>36: default voltage is 3.3V + // + // the value of this byte depend from the TOUT pin usage (1 or 2): + // 1) + // analogRead function (system_adc_read()): + // is only available when wire TOUT pin17 to external circuitry, Input Voltage Range restricted to 0 ~ 1.0V. + // For this function the vdd33_const must be set as real power voltage of VDD3P3 pin 3 and 4 + // The range of operating voltage of ESP8266 is 1.8V~3.6V,the unit of vdd33_const is 0.1V,so effective value range of vdd33_const is [18,36] + // 2) + // getVcc function (system_get_vdd33): + // is only available when TOUT pin17 is suspended (floating), this function measure the power voltage of VDD3P3 pin 3 and 4 + // For this function the vdd33_const must be set to 255 (0xFF). [107] = 33, // disable RF calibration for certain number of times diff --git a/cores/esp8266/core_esp8266_wiring_pulse.c b/cores/esp8266/core_esp8266_wiring_pulse.c index 16b2ccc06..bb13e31c1 100644 --- a/cores/esp8266/core_esp8266_wiring_pulse.c +++ b/cores/esp8266/core_esp8266_wiring_pulse.c @@ -30,3 +30,7 @@ unsigned long pulseIn(uint8_t pin, uint8_t state, unsigned long timeout) { while(digitalRead(pin) == state && (micros() - start) < timeout); return micros() - start; } + +unsigned long pulseInLong(uint8_t pin, uint8_t state, unsigned long timeout) { + return pulseIn(pin, state, timeout); +} diff --git a/doc/eclipse/1_Install_New_Software.png b/doc/eclipse/1_Install_New_Software.png new file mode 100644 index 000000000..a3e9d3619 Binary files /dev/null and b/doc/eclipse/1_Install_New_Software.png differ diff --git a/doc/eclipse/2_Install_software.png b/doc/eclipse/2_Install_software.png new file mode 100644 index 000000000..b7baadaa9 Binary files /dev/null and b/doc/eclipse/2_Install_software.png differ diff --git a/doc/eclipse/eclipse.md b/doc/eclipse/eclipse.md new file mode 100644 index 000000000..348d1cf19 --- /dev/null +++ b/doc/eclipse/eclipse.md @@ -0,0 +1,38 @@ +using Eclipse with Arduino ESP8266 +=========================================== + +### What to Download ### +- [arduino IDE](https://www.arduino.cc/en/Main/Software) +- [Eclipse IDE for C/C++ Developers](http://www.eclipse.org/downloads/packages/eclipse-ide-cc-developers/marsr) +- [Java](http://www.java.com/) + +### Setup Arduino ### + see the [Readme](https://github.com/esp8266/Arduino#installing-with-boards-manager) + +### Setup Eclipse ### +- [step 1](http://www.baeyens.it/eclipse/how_to.shtml#/c) +- [step 2](http://www.baeyens.it/eclipse/how_to.shtml#/e) +- go to Window --> preferences --> Arduino +- add as private hardware path the Part to the ESP8266 + +###### example private hardware path + Windows: C:\Users\[username]\AppData\Roaming\Arduino15\packages\esp8266\hardware + Linux: /home/[username]/.arduino15/packages/esp8266/hardware + +### Eclipse wont build ### +if eclipse dont find the path to the Compiler add to the platform.txt +after: +``` +version=1.6.4 +``` +this: +``` +runtime.tools.xtensa-lx106-elf-gcc.path={runtime.platform.path}/../../../tools/xtensa-lx106-elf-gcc/1.20.0-26-gb404fb9 +runtime.tools.esptool.path={runtime.platform.path}/../../../tools/esptool/0.4.4 +``` +Note: + - the path may changed, check the current version. + - each update over the Arduino IDE will remove the fix + - may not needed in future if Eclipse Plugin get an Update + + \ No newline at end of file diff --git a/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino b/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino new file mode 100644 index 000000000..eb2278220 --- /dev/null +++ b/libraries/DNSServer/examples/CaptivePortal/CaptivePortal.ino @@ -0,0 +1,34 @@ +#include +#include +#include + +const byte DNS_PORT = 53; +IPAddress apIP(192, 168, 1, 1); +DNSServer dnsServer; +ESP8266WebServer webServer(80); + +String responseHTML = "" + "CaptivePortal" + "

Hello World!

This is a captive portal example. All requests will " + "be redirected here.

"; + +void setup() { + WiFi.mode(WIFI_AP); + WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0)); + WiFi.softAP("DNSServer CaptivePortal example"); + + // if DNSServer is started with "*" for domain name, it will reply with + // provided IP to all DNS request + dnsServer.start(DNS_PORT, "*", apIP); + + // replay to all requests with same HTML + webServer.onNotFound([]() { + webServer.send(200, "text/html", responseHTML); + }); + webServer.begin(); +} + +void loop() { + dnsServer.processNextRequest(); + webServer.handleClient(); +} diff --git a/libraries/DNSServer/examples/DNSServer/DNSServer.ino b/libraries/DNSServer/examples/DNSServer/DNSServer.ino index 15951d629..2916d5ab3 100644 --- a/libraries/DNSServer/examples/DNSServer/DNSServer.ino +++ b/libraries/DNSServer/examples/DNSServer/DNSServer.ino @@ -1,9 +1,11 @@ #include #include +#include const byte DNS_PORT = 53; IPAddress apIP(192, 168, 1, 1); DNSServer dnsServer; +ESP8266WebServer webServer(80); void setup() { WiFi.mode(WIFI_AP); @@ -19,10 +21,21 @@ void setup() { // default is DNSReplyCode::NonExistentDomain dnsServer.setErrorReplyCode(DNSReplyCode::ServerFailure); - //start DNS server for a specific domain name + // start DNS server for a specific domain name dnsServer.start(DNS_PORT, "www.example.com", apIP); + + // simple HTTP server to see that DNS server is working + webServer.onNotFound([]() { + String message = "Hello World!\n\n"; + message += "URI: "; + message += webServer.uri(); + + webServer.send(200, "text/plain", message); + }); + webServer.begin(); } void loop() { dnsServer.processNextRequest(); + webServer.handleClient(); } diff --git a/libraries/DNSServer/library.properties b/libraries/DNSServer/library.properties index b9fc670dd..71f0ae544 100644 --- a/libraries/DNSServer/library.properties +++ b/libraries/DNSServer/library.properties @@ -1,5 +1,5 @@ name=DNSServer -version=1.0.0 +version=1.1.0 author=Kristijan Novoselić maintainer=Kristijan Novoselić, sentence=A simple DNS server for ESP8266. diff --git a/libraries/DNSServer/src/DNSServer.cpp b/libraries/DNSServer/src/DNSServer.cpp index 5af48a3ce..10fc81d4a 100644 --- a/libraries/DNSServer/src/DNSServer.cpp +++ b/libraries/DNSServer/src/DNSServer.cpp @@ -54,7 +54,8 @@ void DNSServer::processNextRequest() if (_dnsHeader->QR == DNS_QR_QUERY && _dnsHeader->OPCode == DNS_OPCODE_QUERY && requestIncludesOnlyOneQuestion() && - getDomainNameWithoutWwwPrefix() == _domainName) + (_domainName == "*" || getDomainNameWithoutWwwPrefix() == _domainName) + ) { replyWithIP(); } diff --git a/libraries/DNSServer/src/DNSServer.h b/libraries/DNSServer/src/DNSServer.h index df489402a..d58efbbdd 100644 --- a/libraries/DNSServer/src/DNSServer.h +++ b/libraries/DNSServer/src/DNSServer.h @@ -27,7 +27,7 @@ struct DNSHeader unsigned char AA : 1; // authoritive answer unsigned char OPCode : 4; // message_type unsigned char QR : 1; // query/response flag - unsigned char RCode : 4; // response code + unsigned char RCode : 4; // response code unsigned char Z : 3; // its z! reserved unsigned char RA : 1; // recursion available uint16_t QDCount; // number of question entries @@ -62,7 +62,6 @@ class DNSServer uint32_t _ttl; DNSReplyCode _errorReplyCode; - void downcaseAndRemoveWwwPrefix(String &domainName); String getDomainNameWithoutWwwPrefix(); bool requestIncludesOnlyOneQuestion(); diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp index f91e6563d..c574d66f9 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFi.cpp @@ -40,7 +40,9 @@ extern "C" void esp_schedule(); extern "C" void esp_yield(); ESP8266WiFiClass::ESP8266WiFiClass() -: _useApMode(false) +: _smartConfigStarted(false) +, _smartConfigDone(false) +, _useApMode(false) , _useClientMode(false) , _useStaticIp(false) { @@ -121,7 +123,7 @@ uint8_t ESP8266WiFiClass::waitForConnectResult(){ } -// You will have to set the DNS-Server manually later since this will not enable DHCP +// You will have to set the DNS-Server manually later since this will not enable DHCP2 void ESP8266WiFiClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet) { struct ip_info info; @@ -358,12 +360,47 @@ void ESP8266WiFiClass::_scanDone(void* result, int status) } } - esp_schedule(); + + ESP8266WiFiClass::_scanStarted = false; + ESP8266WiFiClass::_scanComplete = true; + + if(!ESP8266WiFiClass::_scanAsync) { + esp_schedule(); + } } +int8_t ESP8266WiFiClass::scanComplete() { -int8_t ESP8266WiFiClass::scanNetworks() + if(_scanStarted) { + return WIFI_SCAN_RUNNING; + } + + if(_scanComplete) { + return ESP8266WiFiClass::_scanCount; + } + + return WIFI_SCAN_FAILD; +} + +void ESP8266WiFiClass::scanDelete() { + if (ESP8266WiFiClass::_scanResult) + { + delete[] reinterpret_cast(ESP8266WiFiClass::_scanResult); + ESP8266WiFiClass::_scanResult = 0; + ESP8266WiFiClass::_scanCount = 0; + } + _scanComplete = false; +} + +int8_t ESP8266WiFiClass::scanNetworks(bool async) +{ + if(ESP8266WiFiClass::_scanStarted) { + return WIFI_SCAN_RUNNING; + } + + ESP8266WiFiClass::_scanAsync = async; + if(_useApMode) { // turn on AP+STA mode mode(WIFI_AP_STA); @@ -377,22 +414,29 @@ int8_t ESP8266WiFiClass::scanNetworks() { disconnect(); } - - if (ESP8266WiFiClass::_scanResult) - { - delete[] reinterpret_cast(ESP8266WiFiClass::_scanResult); - ESP8266WiFiClass::_scanResult = 0; - ESP8266WiFiClass::_scanCount = 0; - } + scanDelete(); + struct scan_config config; config.ssid = 0; config.bssid = 0; config.channel = 0; config.show_hidden = 0; - wifi_station_scan(&config, reinterpret_cast(&ESP8266WiFiClass::_scanDone)); - esp_yield(); - return ESP8266WiFiClass::_scanCount; + if(wifi_station_scan(&config, reinterpret_cast(&ESP8266WiFiClass::_scanDone))) { + ESP8266WiFiClass::_scanComplete = false; + ESP8266WiFiClass::_scanStarted = true; + + if(ESP8266WiFiClass::_scanAsync) { + delay(0); // time for the OS to trigger the scan + return WIFI_SCAN_RUNNING; + } + + esp_yield(); + return ESP8266WiFiClass::_scanCount; + } else { + return WIFI_SCAN_FAILD; + } + } void * ESP8266WiFiClass::_getScanInfoByIndex(int i) @@ -645,6 +689,10 @@ void ESP8266WiFiClass::printDiag(Print& p) } +bool ESP8266WiFiClass::_scanAsync = false; +bool ESP8266WiFiClass::_scanStarted = false; +bool ESP8266WiFiClass::_scanComplete = false; + size_t ESP8266WiFiClass::_scanCount = 0; void* ESP8266WiFiClass::_scanResult = 0; diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFi.h b/libraries/ESP8266WiFi/src/ESP8266WiFi.h index a97ed934d..e3ba3e143 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFi.h +++ b/libraries/ESP8266WiFi/src/ESP8266WiFi.h @@ -32,6 +32,9 @@ extern "C" { #include "WiFiClient.h" #include "WiFiServer.h" +#define WIFI_SCAN_RUNNING (-1) +#define WIFI_SCAN_FAILD (-2) + enum WiFiMode { WIFI_OFF = 0, WIFI_STA = 1, WIFI_AP = 2, WIFI_AP_STA = 3 }; class ESP8266WiFiClass @@ -189,12 +192,26 @@ public: int32_t RSSI(); + + /* + * called to get the scan state in Async mode + * + * return -1 if scan not fin + * return -2 if scan not triggered + */ + int8_t scanComplete(); + + /* + * delete last scan result from RAM + */ + void scanDelete(); + /* * Start scan WiFi networks available * * return: Number of discovered networks */ - int8_t scanNetworks(); + int8_t scanNetworks(bool async = false); /* * Return the SSID discovered during the network scan. @@ -314,13 +331,17 @@ protected: void * _getScanInfoByIndex(int i); static void _smartConfigCallback(uint32_t status, void* result); static void _eventCallback(void *event); - bool _smartConfigStarted = false; - bool _smartConfigDone = false; + bool _smartConfigStarted; + bool _smartConfigDone; bool _useApMode; bool _useClientMode; bool _useStaticIp; + static bool _scanAsync; + static bool _scanStarted; + static bool _scanComplete; + static size_t _scanCount; static void* _scanResult; diff --git a/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp b/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp index 34f249637..789c1d77e 100644 --- a/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp +++ b/libraries/ESP8266WiFi/src/ESP8266WiFiMulti.cpp @@ -40,107 +40,119 @@ bool ESP8266WiFiMulti::addAP(const char* ssid, const char *passphrase) { wl_status_t ESP8266WiFiMulti::run(void) { + int8_t scanResult; wl_status_t status = WiFi.status(); if(status == WL_DISCONNECTED || status == WL_NO_SSID_AVAIL || status == WL_IDLE_STATUS || status == WL_CONNECT_FAILED) { - WifiAPlist_t bestNetwork { NULL, NULL }; - int bestNetworkDb = INT_MIN; - uint8 bestBSSID[6]; - int32_t bestChannel; + scanResult = WiFi.scanComplete(); + if(scanResult == WIFI_SCAN_RUNNING) { + // scan is running + return WL_NO_SSID_AVAIL; + } else if(scanResult > 0) { + // scan done analyze + WifiAPlist_t bestNetwork { NULL, NULL }; + int bestNetworkDb = INT_MIN; + uint8 bestBSSID[6]; + int32_t bestChannel; - DEBUG_WIFI_MULTI("[WIFI] delete old wifi config...\n"); - WiFi.disconnect(); + DEBUG_WIFI_MULTI("[WIFI] scan done\n"); + delay(0); - DEBUG_WIFI_MULTI("[WIFI] start scan\n"); - // WiFi.scanNetworks will return the number of networks found - int8_t n = WiFi.scanNetworks(); + if(scanResult <= 0) { + DEBUG_WIFI_MULTI("[WIFI] no networks found\n"); + } else { + DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", scanResult); + for(int8_t i = 0; i < scanResult; ++i) { - DEBUG_WIFI_MULTI("[WIFI] scan done\n"); - delay(0); + String ssid_scan; + int32_t rssi_scan; + uint8_t sec_scan; + uint8_t* BSSID_scan; + int32_t chan_scan; + bool hidden_scan; - if(n <= 0) { - DEBUG_WIFI_MULTI("[WIFI] no networks found\n"); - } else { - DEBUG_WIFI_MULTI("[WIFI] %d networks found\n", n); - for(int8_t i = 0; i < n; ++i) { + WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan); - String ssid_scan; - int32_t rssi_scan; - uint8_t sec_scan; - uint8_t* BSSID_scan; - int32_t chan_scan; - bool hidden_scan; + bool known = false; + for(uint32_t x = 0; x < APlist.size(); x++) { + WifiAPlist_t entry = APlist[x]; - WiFi.getNetworkInfo(i, ssid_scan, sec_scan, rssi_scan, BSSID_scan, chan_scan, hidden_scan); - - bool known = false; - for(uint32_t x = 0; x < APlist.size(); x++) { - WifiAPlist_t entry = APlist[x]; - - if(ssid_scan == entry.ssid) { // SSID match - known = true; - if(rssi_scan > bestNetworkDb) { // best network - if(sec_scan == ENC_TYPE_NONE || entry.passphrase) { // check for passphrase if not open wlan - bestNetworkDb = rssi_scan; - bestChannel = chan_scan; - memcpy((void*) &bestNetwork, (void*) &entry, sizeof(bestNetwork)); - memcpy((void*) &bestBSSID, (void*) BSSID_scan, sizeof(bestBSSID)); + if(ssid_scan == entry.ssid) { // SSID match + known = true; + if(rssi_scan > bestNetworkDb) { // best network + if(sec_scan == ENC_TYPE_NONE || entry.passphrase) { // check for passphrase if not open wlan + bestNetworkDb = rssi_scan; + bestChannel = chan_scan; + memcpy((void*) &bestNetwork, (void*) &entry, sizeof(bestNetwork)); + memcpy((void*) &bestBSSID, (void*) BSSID_scan, sizeof(bestBSSID)); + } } + break; } - break; } - } - if(known) { - DEBUG_WIFI_MULTI(" ---> "); - } else { - DEBUG_WIFI_MULTI(" "); - } + if(known) { + DEBUG_WIFI_MULTI(" ---> "); + } else { + DEBUG_WIFI_MULTI(" "); + } - DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*'); - delay(0); + DEBUG_WIFI_MULTI(" %d: [%d][%02X:%02X:%02X:%02X:%02X:%02X] %s (%d) %c\n", i, chan_scan, BSSID_scan[0], BSSID_scan[1], BSSID_scan[2], BSSID_scan[3], BSSID_scan[4], BSSID_scan[5], ssid_scan.c_str(), rssi_scan, (sec_scan == ENC_TYPE_NONE) ? ' ' : '*'); + delay(0); + } } - } - DEBUG_WIFI_MULTI("\n\n"); - delay(0); + // clean up ram + WiFi.scanDelete(); - if(bestNetwork.ssid) { - DEBUG_WIFI_MULTI("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channal: %d (%d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb); + DEBUG_WIFI_MULTI("\n\n"); + delay(0); - WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID); - status = WiFi.status(); + if(bestNetwork.ssid) { + DEBUG_WIFI_MULTI("[WIFI] Connecting BSSID: %02X:%02X:%02X:%02X:%02X:%02X SSID: %s Channal: %d (%d)\n", bestBSSID[0], bestBSSID[1], bestBSSID[2], bestBSSID[3], bestBSSID[4], bestBSSID[5], bestNetwork.ssid, bestChannel, bestNetworkDb); - // wait for connection or fail - while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) { - delay(10); + WiFi.begin(bestNetwork.ssid, bestNetwork.passphrase, bestChannel, bestBSSID); status = WiFi.status(); - } - IPAddress ip; - uint8_t * mac; - switch(status) { - case WL_CONNECTED: - ip = WiFi.localIP(); - mac = WiFi.BSSID(); - DEBUG_WIFI_MULTI("[WIFI] Connecting done.\n"); - DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID()); - DEBUG_WIFI_MULTI("[WIFI] IP: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); - DEBUG_WIFI_MULTI("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - DEBUG_WIFI_MULTI("[WIFI] Channel: %d\n", WiFi.channel()); - break; - case WL_NO_SSID_AVAIL: - DEBUG_WIFI_MULTI("[WIFI] Connecting Faild AP not found.\n"); - break; - case WL_CONNECT_FAILED: - DEBUG_WIFI_MULTI("[WIFI] Connecting Faild.\n"); - break; - default: - DEBUG_WIFI_MULTI("[WIFI] Connecting Faild (%d).\n", status); - break; + // wait for connection or fail + while(status != WL_CONNECTED && status != WL_NO_SSID_AVAIL && status != WL_CONNECT_FAILED) { + delay(10); + status = WiFi.status(); + } + + IPAddress ip; + uint8_t * mac; + switch(status) { + case WL_CONNECTED: + ip = WiFi.localIP(); + mac = WiFi.BSSID(); + DEBUG_WIFI_MULTI("[WIFI] Connecting done.\n"); + DEBUG_WIFI_MULTI("[WIFI] SSID: %s\n", WiFi.SSID()); + DEBUG_WIFI_MULTI("[WIFI] IP: %d.%d.%d.%d\n", ip[0], ip[1], ip[2], ip[3]); + DEBUG_WIFI_MULTI("[WIFI] MAC: %02X:%02X:%02X:%02X:%02X:%02X\n", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); + DEBUG_WIFI_MULTI("[WIFI] Channel: %d\n", WiFi.channel()); + break; + case WL_NO_SSID_AVAIL: + DEBUG_WIFI_MULTI("[WIFI] Connecting Faild AP not found.\n"); + break; + case WL_CONNECT_FAILED: + DEBUG_WIFI_MULTI("[WIFI] Connecting Faild.\n"); + break; + default: + DEBUG_WIFI_MULTI("[WIFI] Connecting Faild (%d).\n", status); + break; + } + } else { + DEBUG_WIFI_MULTI("[WIFI] no matching wifi found!\n"); } } else { - DEBUG_WIFI_MULTI("[WIFI] no matching wifi found!\n"); + // start scan + DEBUG_WIFI_MULTI("[WIFI] delete old wifi config...\n"); + WiFi.disconnect(); + + DEBUG_WIFI_MULTI("[WIFI] start scan\n"); + // scan wifi async mode + WiFi.scanNetworks(true); } } return status; diff --git a/libraries/ESP8266WiFi/src/include/ClientContext.h b/libraries/ESP8266WiFi/src/include/ClientContext.h index d1f728eef..619356862 100644 --- a/libraries/ESP8266WiFi/src/include/ClientContext.h +++ b/libraries/ESP8266WiFi/src/include/ClientContext.h @@ -90,12 +90,15 @@ class ClientContext { } void unref() { - DEBUGV(":ur %d\r\n", _refcnt); - if(--_refcnt == 0) { - flush(); - close(); - if(_discard_cb) _discard_cb(_discard_cb_arg, this); - delete this; + if(this != 0) { + DEBUGV(":ur %d\r\n", _refcnt); + if(--_refcnt == 0) { + flush(); + close(); + if(_discard_cb) + _discard_cb(_discard_cb_arg, this); + delete this; + } } } diff --git a/libraries/ESP8266WiFi/src/include/UdpContext.h b/libraries/ESP8266WiFi/src/include/UdpContext.h index c86e050ed..f7cebc86c 100644 --- a/libraries/ESP8266WiFi/src/include/UdpContext.h +++ b/libraries/ESP8266WiFi/src/include/UdpContext.h @@ -77,10 +77,11 @@ public: void unref() { - DEBUGV(":ur %d\r\n", _refcnt); - if (--_refcnt == 0) - { - delete this; + if(this != 0) { + DEBUGV(":ur %d\r\n", _refcnt); + if(--_refcnt == 0) { + delete this; + } } } diff --git a/libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp b/libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp index 97ec0954b..6d3e544d7 100644 --- a/libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp +++ b/libraries/ESP8266WiFiMesh/src/ESP8266WiFiMesh.cpp @@ -98,7 +98,7 @@ bool ESP8266WiFiMesh::exchangeInfo(String message, WiFiClient curr_client) * @message The string to send to the node. * */ -void WiFiMesh::connectToNode(String target_ssid, String message) +void ESP8266WiFiMesh::connectToNode(String target_ssid, String message) { WiFiClient curr_client; WiFi.begin( target_ssid.c_str() ); @@ -165,4 +165,4 @@ void ESP8266WiFiMesh::acceptRequest() if (_client.connected()) _client.println(response); } -} \ No newline at end of file +} diff --git a/libraries/ESP8266httpUpdate/library.properties b/libraries/ESP8266httpUpdate/library.properties new file mode 100644 index 000000000..9be2f7d6d --- /dev/null +++ b/libraries/ESP8266httpUpdate/library.properties @@ -0,0 +1,8 @@ +name=ESP8266httpUpdate +version=1.0 +author=Markus Sattler +maintainer=Markus Sattler +sentence=Http Update for ESP8266 +paragraph= +url=https://github.com/Links2004/Arduino/tree/esp8266/hardware/esp8266com/esp8266/libraries/ESP8266httpUpdate +architectures=ESP8266 diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp new file mode 100644 index 000000000..d6d3becec --- /dev/null +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.cpp @@ -0,0 +1,165 @@ +/** + * + * @file ESP8266HTTPUpdate.cpp + * @date 21.06.2015 + * @author Markus Sattler + * + * Copyright (c) 2015 Markus Sattler. All rights reserved. + * This file is part of the ESP8266 Http Updater. + * + * 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 + * + */ + +#include "ESP8266HTTPUpdate.h" + +ESP8266HTTPUpdate::ESP8266HTTPUpdate(void) { + +} + +ESP8266HTTPUpdate::~ESP8266HTTPUpdate(void) { + +} + +t_httpUpdate_return ESP8266HTTPUpdate::update(const char * host, uint16_t port, const char * url, const char * current_version) { + + t_httpUpdate_return ret = HTTP_UPDATE_FAILD; + WiFiClient tcp; + DEBUG_HTTP_UPDATE("[httpUpdate] connected to %s:%u %s .... ", host, port, url); + + if(!tcp.connect(host, port)) { + DEBUG_HTTP_UPDATE("faild.\n"); + return ret; + } + DEBUG_HTTP_UPDATE("ok.\n"); + + // set Timeout for readBytesUntil and readStringUntil + tcp.setTimeout(2000); + tcp.setNoDelay(true); + + String req = "GET "; + + req += url; + req += " HTTP/1.1\r\n" + "Host: "; + req += host; + req += "\r\n" + "Connection: close\r\n" + "User-Agent: ESP8266-http-Update\r\n" + "x-ESP8266-STA-MAC: "; + req += WiFi.macAddress(); + req += "\r\n" + "x-ESP8266-AP-MAC: "; + req += WiFi.softAPmacAddress(); + req += "\r\n" + "x-ESP8266-free-space: "; + req += ESP.getFreeSketchSpace(); + req += "\r\n" + "x-ESP8266-sketch-size: "; + req += ESP.getSketchSize(); + req += "\r\n" + "x-ESP8266-chip-size: "; + req += ESP.getFlashChipRealSize(); + req += "\r\n" + "x-ESP8266-sdk-version: "; + req += ESP.getSdkVersion(); + + if(current_version[0] != 0x00) { + req += "\r\n" + "x-ESP8266-version: "; + req += current_version; + } + + req += "\r\n" + "\r\n"; + + tcp.write(req.c_str(), req.length()); + + uint32_t code = 0; + size_t len = 0; + + while(true) { + String headerLine = tcp.readStringUntil('\n'); + headerLine.trim(); // remove \r + + if(headerLine.length() > 0) { + DEBUG_HTTP_UPDATE("[httpUpdate][Header] RX: %s\n", headerLine.c_str()); + if(headerLine.startsWith("HTTP/1.")) { + // 9 = lenght of "HTTP/1.x " + code = headerLine.substring(9, headerLine.indexOf(' ', 9)).toInt(); + } else if(headerLine.startsWith("Content-Length: ")) { + // 16 = lenght of "Content-Length: " + len = headerLine.substring(16).toInt(); + } + } else { + break; + } + } + + DEBUG_HTTP_UPDATE("[httpUpdate] Header read fin.\n"); + DEBUG_HTTP_UPDATE("[httpUpdate] Server header:\n"); + DEBUG_HTTP_UPDATE("[httpUpdate] - code: %d\n", code); + DEBUG_HTTP_UPDATE("[httpUpdate] - len: %d\n", len); + + DEBUG_HTTP_UPDATE("[httpUpdate] ESP8266 info:\n"); + DEBUG_HTTP_UPDATE("[httpUpdate] - free Space: %d\n", ESP.getFreeSketchSpace()); + DEBUG_HTTP_UPDATE("[httpUpdate] - current Sketch Size: %d\n", ESP.getSketchSize()); + + if(current_version[0] != 0x00) { + DEBUG_HTTP_UPDATE("[httpUpdate] - current version: %s\n", current_version); + } + + switch(code) { + case 200: ///< OK (Start Update) + if(len > 0) { + if(len > ESP.getFreeSketchSpace()) { + ret = HTTP_UPDATE_FAILD; + DEBUG_HTTP_UPDATE("[httpUpdate] FreeSketchSpace to low (%d) needed: %d\n", ESP.getFreeSketchSpace(), len); + } else { + if(ESP.updateSketch(tcp, len)) { + // may never reached! + ret = HTTP_UPDATE_OK; + DEBUG_HTTP_UPDATE("[httpUpdate] Update ok\n"); + } else { + ret = HTTP_UPDATE_FAILD; + DEBUG_HTTP_UPDATE("[httpUpdate] Update failed\n"); + } + } + } else { + ret = HTTP_UPDATE_FAILD; + DEBUG_HTTP_UPDATE("[httpUpdate]Content-Length is 0?!\n"); + } + break; + case 304: + ///< Not Modified (No updates) + ret = HTTP_UPDATE_NO_UPDATES; + break; + case 403: + ///< Forbidden + // todo handle login + default: + ret = HTTP_UPDATE_FAILD; + DEBUG_HTTP_UPDATE("[httpUpdate] Code is (%d)\n", code); + break; + } + + return ret; +} + +t_httpUpdate_return ESP8266HTTPUpdate::update(String host, uint16_t port, String url, String current_version) { + return update(host.c_str(), port, url.c_str(), current_version.c_str()); +} + +ESP8266HTTPUpdate ESPhttpUpdate; diff --git a/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h new file mode 100644 index 000000000..0456997b0 --- /dev/null +++ b/libraries/ESP8266httpUpdate/src/ESP8266httpUpdate.h @@ -0,0 +1,55 @@ +/** + * + * @file ESP8266HTTPUpdate.h + * @date 21.06.2015 + * @author Markus Sattler + * + * Copyright (c) 2015 Markus Sattler. All rights reserved. + * This file is part of the ESP8266 Http Updater. + * + * 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 ESP8266HTTPUPDATE_H_ +#define ESP8266HTTPUPDATE_H_ + +#include +#include + +#define DEBUG_HTTP_UPDATE(...) Serial1.printf( __VA_ARGS__ ) + +#ifndef DEBUG_HTTP_UPDATE +#define DEBUG_HTTP_UPDATE(...) +#endif + +typedef enum { + HTTP_UPDATE_FAILD, + HTTP_UPDATE_NO_UPDATES, + HTTP_UPDATE_OK +} t_httpUpdate_return; + +class ESP8266HTTPUpdate { + public: + ESP8266HTTPUpdate(void); + ~ESP8266HTTPUpdate(void); + + t_httpUpdate_return update(const char * host, uint16_t port, const char * url = "/", const char * current_version = ""); + t_httpUpdate_return update(String host, uint16_t port, String url = "/", String current_version = ""); +}; + +extern ESP8266HTTPUpdate ESPhttpUpdate; + +#endif /* ESP8266HTTPUPDATE_H_ */ diff --git a/libraries/OneWire/OneWire.cpp b/libraries/OneWire/OneWire.cpp index 593053794..7fbedd408 100644 --- a/libraries/OneWire/OneWire.cpp +++ b/libraries/OneWire/OneWire.cpp @@ -117,9 +117,13 @@ sample code bearing this copyright. #include "OneWire.h" -OneWire::OneWire(uint8_t pin) +OneWire::OneWire(uint8_t pin, bool pullup) { - pinMode(pin, INPUT_PULLUP); + if(pullup) { + pinMode(pin, INPUT_PULLUP); + } else { + pinMode(pin, INPUT); + } bitmask = PIN_TO_BITMASK(pin); baseReg = PIN_TO_BASEREG(pin); #if ONEWIRE_SEARCH diff --git a/libraries/OneWire/OneWire.h b/libraries/OneWire/OneWire.h index 6ff16745a..68cc25f58 100644 --- a/libraries/OneWire/OneWire.h +++ b/libraries/OneWire/OneWire.h @@ -135,7 +135,7 @@ class OneWire #endif public: - OneWire( uint8_t pin); + OneWire(uint8_t pin, bool pullup = true); // Perform a 1-Wire reset cycle. Returns 1 if a device responds // with a presence pulse. Returns 0 if there is no device or the diff --git a/libraries/SD/README.adoc b/libraries/SD/README.adoc index 4c6521ed3..fabff563c 100644 --- a/libraries/SD/README.adoc +++ b/libraries/SD/README.adoc @@ -3,7 +3,7 @@ The SD library allows for reading from and writing to SD cards. For more information about this library please visit us at -http://arduino.cc/en/Reference/SD +http://www.arduino.cc/en/Reference/SD == License == diff --git a/libraries/SD/library.properties b/libraries/SD/library.properties index 4658054f8..bc8c4e498 100644 --- a/libraries/SD/library.properties +++ b/libraries/SD/library.properties @@ -1,9 +1,9 @@ name=SD -version=1.0.4 +version=1.0.5 author=Arduino, SparkFun maintainer=Arduino sentence=Enables reading and writing on SD cards. For all Arduino boards. paragraph=Once an SD memory card is connected to the SPI interfare of the Arduino board you are enabled to create files and read/write on them. You can also move through directories on the SD card. category=Data Storage -url=http://arduino.cc/en/Reference/SD +url=http://www.arduino.cc/en/Reference/SD architectures=* diff --git a/libraries/SD/src/SD.h b/libraries/SD/src/SD.h index 62276b4ee..653adabee 100644 --- a/libraries/SD/src/SD.h +++ b/libraries/SD/src/SD.h @@ -93,18 +93,23 @@ public: // write, etc). Returns a File object for interacting with the file. // Note that currently only one file can be open at a time. File open(const char *filename, uint8_t mode = FILE_READ); + File open(const String &filename, uint8_t mode = FILE_READ) { return open( filename.c_str(), mode ); } // Methods to determine if the requested file path exists. boolean exists(char *filepath); + boolean exists(const String &filepath) { return exists(filepath.c_str()); } // Create the requested directory heirarchy--if intermediate directories // do not exist they will be created. boolean mkdir(char *filepath); + boolean mkdir(const String &filepath) { return mkdir(filepath.c_str()); } // Delete the file. boolean remove(char *filepath); + boolean remove(const String &filepath) { return remove(filepath.c_str()); } boolean rmdir(char *filepath); + boolean rmdir(const String &filepath) { return rmdir(filepath.c_str()); } uint8_t type(){ return card.type(); } uint8_t fatType(){ return volume.fatType(); } diff --git a/libraries/esp8266/examples/Blink/Blink.ino b/libraries/esp8266/examples/Blink/Blink.ino new file mode 100644 index 000000000..578f36886 --- /dev/null +++ b/libraries/esp8266/examples/Blink/Blink.ino @@ -0,0 +1,24 @@ +/* + ESP8266 Blink by Simon Peter + Blink the blue LED on the ESP-01 module + This example code is in the public domain + + The blue LED on the ESP-01 module is connected to GPIO1 + (which is also the TXD pin; so we cannot use Serial.print() at the same time) + + Note that this sketch uses BUILTIN_LED to find the pin with the internal LED +*/ + +void setup() { + pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output +} + +// the loop function runs over and over again forever +void loop() { + digitalWrite(BUILTIN_LED, LOW); // Turn the LED on (Note that LOW is the voltage level + // but actually the LED is on; this is because + // it is acive low on the ESP-01) + delay(1000); // Wait for a second + digitalWrite(BUILTIN_LED, HIGH); // Turn the LED off by making the voltage HIGH + delay(2000); // Wait for two seconds (to demonstrate the active low LED) +} diff --git a/libraries/esp8266/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino b/libraries/esp8266/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino new file mode 100644 index 000000000..740211d6d --- /dev/null +++ b/libraries/esp8266/examples/BlinkWithoutDelay/BlinkWithoutDelay.ino @@ -0,0 +1,33 @@ +/* + ESP8266 BlinkWithoutDelay by Simon Peter + Blink the blue LED on the ESP-01 module + Based on the Arduino Blink without Delay example + This example code is in the public domain + + The blue LED on the ESP-01 module is connected to GPIO1 + (which is also the TXD pin; so we cannot use Serial.print() at the same time) + + Note that this sketch uses BUILTIN_LED to find the pin with the internal LED +*/ + +int ledState = LOW; + +unsigned long previousMillis = 0; +const long interval = 1000; + +void setup() { + pinMode(BUILTIN_LED, OUTPUT); +} + +void loop() +{ + unsigned long currentMillis = millis(); + if(currentMillis - previousMillis >= interval) { + previousMillis = currentMillis; + if (ledState == LOW) + ledState = HIGH; // Note that this switches the LED *off* + else + ledState = LOW; // Note that this switches the LED *on* + digitalWrite(BUILTIN_LED, ledState); + } +} diff --git a/tools/sdk/changelog.txt b/tools/sdk/changelog.txt index 185750669..9f2ad6bf8 100644 --- a/tools/sdk/changelog.txt +++ b/tools/sdk/changelog.txt @@ -1,3 +1,35 @@ +esp_iot_sdk_v1.1.2_15_06_16_p1 Release Note +------------------------------------------- +Here is a patch based on SDK_v1.1.2 resolved issue that "wifi_station_scan" cause loss of wireless connectivity. + +Please replace them in esp_iot_sdk/lib folder. + +Sorry for the inconvenience. + + + + +esp_iot_sdk_v1.1.2_15_06_12 Release Note +------------------------------------------- + +Optimization: +1. support certificate issuer verification for SSL +2. Update SPI driver, support overlap mode + +Add APIs: +1. wifi_station_set_hostname : set ESP8266 station DHCP hostname +2. wifi_station_get_hostname : get ESP8266 station DHCP hostname +3. spi_flash_set_read_func :set user specified reading SPI function on overlap mode +4. espconn_secure_ca_disable : disable SSL CA verify +5. espconn_secure_ca_enable : enable SSL CA verify + +Add Documentation: +1. SPI overlap introduction: \esp_iot_sdk\document, sorry that it has only Chinese version now,we will add English version of this documentation ASAP. +2. SSL introduction: \esp_iot_sdk\document + + + + esp_iot_sdk_v1.1.1_15_06_05 Release Note ------------------------------------------- diff --git a/tools/sdk/include/espconn.h b/tools/sdk/include/espconn.h index a85c82392..82212103b 100644 --- a/tools/sdk/include/espconn.h +++ b/tools/sdk/include/espconn.h @@ -23,6 +23,9 @@ typedef void (* espconn_reconnect_callback)(void *arg, sint8 err); #define ESPCONN_ARG -12 /* Illegal argument. */ #define ESPCONN_ISCONN -15 /* Already connected. */ +#define ESPCONN_HANDSHAKE -28 /* ssl handshake failed */ +#define ESPCONN_PROTO_MSG -61 /* ssl application invalid */ + /** Protocol family and type of the espconn */ enum espconn_type { ESPCONN_INVALID = 0, @@ -455,6 +458,28 @@ bool espconn_secure_set_size(uint8 level, uint16 size); sint16 espconn_secure_get_size(uint8 level); +/****************************************************************************** + * FunctionName : espconn_secure_ca_enable + * Description : enable the certificate authenticate and set the flash sector + * as client or server + * Parameters : level -- set for client or server + * 1: client,2:server,3:client and server + * flash_sector -- flash sector for save certificate + * Returns : result true or false +*******************************************************************************/ + +bool espconn_secure_ca_enable(uint8 level, uint8 flash_sector ); + +/****************************************************************************** + * FunctionName : espconn_secure_ca_disable + * Description : disable the certificate authenticate as client or server + * Parameters : level -- set for client or server + * 1: client,2:server,3:client and server + * Returns : result true or false +*******************************************************************************/ + +bool espconn_secure_ca_disable(uint8 level); + /****************************************************************************** * FunctionName : espconn_secure_accept * Description : The function given as the listen diff --git a/tools/sdk/include/spi_flash.h b/tools/sdk/include/spi_flash.h index 347e1b920..bb920fef5 100644 --- a/tools/sdk/include/spi_flash.h +++ b/tools/sdk/include/spi_flash.h @@ -30,4 +30,12 @@ SpiFlashOpResult spi_flash_erase_sector(uint16 sec); SpiFlashOpResult spi_flash_write(uint32 des_addr, uint32 *src_addr, uint32 size); SpiFlashOpResult spi_flash_read(uint32 src_addr, uint32 *des_addr, uint32 size); +typedef SpiFlashOpResult (* user_spi_flash_read)( + SpiFlashChip *spi, + uint32 src_addr, + uint32 *des_addr, + uint32 size); + +void spi_flash_set_read_func(user_spi_flash_read read); + #endif diff --git a/tools/sdk/lib/libjson.a b/tools/sdk/lib/libjson.a index e8fa9d8da..5b35fba2c 100644 Binary files a/tools/sdk/lib/libjson.a and b/tools/sdk/lib/libjson.a differ diff --git a/tools/sdk/lib/liblwip.a b/tools/sdk/lib/liblwip.a index a6c42f9e9..c956810ea 100644 Binary files a/tools/sdk/lib/liblwip.a and b/tools/sdk/lib/liblwip.a differ diff --git a/tools/sdk/lib/libmain.a b/tools/sdk/lib/libmain.a index 90caec3de..14af9b0bc 100644 Binary files a/tools/sdk/lib/libmain.a and b/tools/sdk/lib/libmain.a differ diff --git a/tools/sdk/lib/libnet80211.a b/tools/sdk/lib/libnet80211.a index 648852e52..14a1d09d3 100644 Binary files a/tools/sdk/lib/libnet80211.a and b/tools/sdk/lib/libnet80211.a differ diff --git a/tools/sdk/lib/libpp.a b/tools/sdk/lib/libpp.a index e42233ab3..9238f6c53 100644 Binary files a/tools/sdk/lib/libpp.a and b/tools/sdk/lib/libpp.a differ diff --git a/tools/sdk/lib/libsmartconfig.a b/tools/sdk/lib/libsmartconfig.a index 03f296fd9..7fb8490a7 100644 Binary files a/tools/sdk/lib/libsmartconfig.a and b/tools/sdk/lib/libsmartconfig.a differ diff --git a/tools/sdk/lib/libssl.a b/tools/sdk/lib/libssl.a index 1608d8484..add670e37 100644 Binary files a/tools/sdk/lib/libssl.a and b/tools/sdk/lib/libssl.a differ diff --git a/tools/sdk/lib/libupgrade.a b/tools/sdk/lib/libupgrade.a index d0d2d5bda..e0dda74eb 100644 Binary files a/tools/sdk/lib/libupgrade.a and b/tools/sdk/lib/libupgrade.a differ diff --git a/tools/sdk/lib/libwpa.a b/tools/sdk/lib/libwpa.a index c6f1bb620..b5a513509 100644 Binary files a/tools/sdk/lib/libwpa.a and b/tools/sdk/lib/libwpa.a differ diff --git a/tools/sdk/version b/tools/sdk/version index 1aeff03a8..d3b2eb935 100644 --- a/tools/sdk/version +++ b/tools/sdk/version @@ -1 +1 @@ -1.1.1_15_06_05 \ No newline at end of file +1.1.2_15_06_16_p1 \ No newline at end of file