1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-07 16:23:38 +03:00

Merge remote-tracking branch 'esp8266/master'

This commit is contained in:
Me No Dev 2016-01-09 13:31:28 +02:00
commit 377864f76b
24 changed files with 200 additions and 21 deletions

View File

@ -59,7 +59,9 @@ public:
int read() override;
int peek() override;
void flush() override;
size_t readBytes(char *buffer, size_t length) override {
return read((uint8_t*)buffer, length);
}
size_t read(uint8_t* buf, size_t size);
bool seek(uint32_t pos, SeekMode mode);
size_t position() const;

View File

@ -23,6 +23,46 @@ void MD5Builder::addHexString(const char * data){
free(tmp);
}
bool MD5Builder::addStream(Stream & stream, const size_t total_len) {
const int buf_size = 512;
int bytesleft = total_len;
uint8_t * buf = (uint8_t*) malloc(buf_size);
if(buf) {
while((stream.available() > -1) && (bytesleft > 0)) {
// get available data size
int sizeAvailable = stream.available();
if(sizeAvailable) {
int readBytes = sizeAvailable;
// read only the asked bytes
if(readBytes > bytesleft) {
readBytes = bytesleft ;
}
// not read more the buffer can handle
if(readBytes > buf_size) {
readBytes = buf_size;
}
// read data
int bytesread = stream.readBytes(buf, readBytes);
bytesleft -= bytesread;
if(bytesread > 0) {
MD5Update(&_ctx, buf, bytesread);
}
}
// time for network streams
delay(0);
}
// not free null ptr
free(buf);
return (bytesleft == 0);
} else {
return false;
}
}
void MD5Builder::calculate(void){
MD5Final(_buf, &_ctx);
}

View File

@ -37,6 +37,7 @@ class MD5Builder {
void addHexString(const char * data);
void addHexString(char * data){ addHexString((const char*)data); }
void addHexString(String data){ addHexString(data.c_str()); }
bool addStream(Stream & stream, const size_t total_len);
void calculate(void);
void getBytes(uint8_t * output);
void getChars(char * output);

View File

@ -87,8 +87,8 @@ class Stream: public Print {
float parseFloat(); // float version of parseInt
size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
size_t readBytes(uint8_t *buffer, size_t length) {
virtual size_t readBytes(char *buffer, size_t length); // read chars from stream into buffer
virtual size_t readBytes(uint8_t *buffer, size_t length) {
return readBytes((char *) buffer, length);
}
// terminates if length characters have been read or timeout (see setTimeout)

View File

@ -40,6 +40,17 @@ extern "C" {
#include "WiFiServer.h"
#include "WiFiClientSecure.h"
#ifdef DEBUG_ESP_WIFI
#ifdef DEBUG_ESP_PORT
#define DEBUG_WIFI(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
#endif
#endif
#ifndef DEBUG_WIFI
#define DEBUG_WIFI(...)
#endif
class ESP8266WiFiClass : public ESP8266WiFiGenericClass, public ESP8266WiFiSTAClass, public ESP8266WiFiScanClass, public ESP8266WiFiAPClass {
public:

View File

@ -85,19 +85,24 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
if(!WiFi.enableAP(true)) {
// enable AP failed
DEBUG_WIFI("[AP] enableAP failed!\n");
return false;
}
if(!ssid || *ssid == 0 || strlen(ssid) > 31) {
// fail SSID too long or missing!
DEBUG_WIFI("[AP] SSID too long or missing!\n");
return false;
}
if(passphrase && (strlen(passphrase) > 63 || strlen(passphrase) < 8)) {
// fail passphrase to long or short!
DEBUG_WIFI("[AP] fail passphrase to long or short!\n");
return false;
}
bool ret = false;
struct softap_config conf;
strcpy(reinterpret_cast<char*>(conf.ssid), ssid);
conf.channel = channel;
@ -116,20 +121,50 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
struct softap_config conf_current;
wifi_softap_get_config(&conf_current);
if(softap_config_equal(conf, conf_current)) {
DEBUGV("softap config unchanged");
return true;
}
if(!softap_config_equal(conf, conf_current)) {
bool ret;
ETS_UART_INTR_DISABLE();
if(WiFi._persistent) {
ret = wifi_softap_set_config(&conf);
} else {
ret = wifi_softap_set_config_current(&conf);
}
ETS_UART_INTR_ENABLE();
if(!ret) {
DEBUG_WIFI("[AP] set_config failed!\n");
return false;
}
ETS_UART_INTR_DISABLE();
if(WiFi._persistent) {
ret = wifi_softap_set_config(&conf);
} else {
ret = wifi_softap_set_config_current(&conf);
DEBUG_WIFI("[AP] softap config unchanged\n");
}
if(wifi_softap_dhcps_status() != DHCP_STARTED) {
DEBUG_WIFI("[AP] DHCP not started, starting...\n");
if(!wifi_softap_dhcps_start()) {
DEBUG_WIFI("[AP] wifi_softap_dhcps_start failed!\n");
ret = false;
}
}
// check IP config
struct ip_info ip;
if(wifi_get_ip_info(SOFTAP_IF, &ip)) {
if(ip.ip.addr == 0x00000000) {
// Invalid config
DEBUG_WIFI("[AP] IP config Invalid resetting...\n");
//192.168.244.1 , 192.168.244.1 , 255.255.255.0
ret = softAPConfig(0x01F4A8C0, 0x01F4A8C0, 0x00FFFFFF);
if(!ret) {
DEBUG_WIFI("[AP] softAPConfig failed!\n");
ret = false;
}
}
} else {
DEBUG_WIFI("[AP] wifi_get_ip_info failed!\n");
ret = false;
}
ETS_UART_INTR_ENABLE();
return ret;
}
@ -142,21 +177,76 @@ bool ESP8266WiFiAPClass::softAP(const char* ssid, const char* passphrase, int ch
* @param subnet subnet mask
*/
bool ESP8266WiFiAPClass::softAPConfig(IPAddress local_ip, IPAddress gateway, IPAddress subnet) {
DEBUG_WIFI("[APConfig] local_ip: %s gateway: %s subnet: %s\n", local_ip.toString().c_str(), gateway.toString().c_str(), subnet.toString().c_str());
if(!WiFi.enableAP(true)) {
// enable AP failed
DEBUG_WIFI("[APConfig] enableAP failed!\n");
return false;
}
bool ret = true;
struct ip_info info;
info.ip.addr = static_cast<uint32_t>(local_ip);
info.gw.addr = static_cast<uint32_t>(gateway);
info.netmask.addr = static_cast<uint32_t>(subnet);
wifi_softap_dhcps_stop();
if(wifi_set_ip_info(SOFTAP_IF, &info)) {
return wifi_softap_dhcps_start();
if(!wifi_softap_dhcps_stop()) {
DEBUG_WIFI("[APConfig] wifi_softap_dhcps_stop failed!\n");
}
return false;
if(!wifi_set_ip_info(SOFTAP_IF, &info)) {
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
ret = false;
}
struct dhcps_lease dhcp_lease;
IPAddress ip = local_ip;
ip[3] += 99;
dhcp_lease.start_ip.addr = static_cast<uint32_t>(ip);
DEBUG_WIFI("[APConfig] DHCP IP start: %s\n", ip.toString().c_str());
ip[3] += 100;
dhcp_lease.end_ip.addr = static_cast<uint32_t>(ip);
DEBUG_WIFI("[APConfig] DHCP IP end: %s\n", ip.toString().c_str());
if(!wifi_softap_set_dhcps_lease(&dhcp_lease)) {
DEBUG_WIFI("[APConfig] wifi_set_ip_info failed!\n");
ret = false;
}
// set lease time to 720min --> 12h
if(!wifi_softap_set_dhcps_lease_time(720)) {
DEBUG_WIFI("[APConfig] wifi_softap_set_dhcps_lease_time failed!\n");
ret = false;
}
uint8 mode = 1;
if(!wifi_softap_set_dhcps_offer_option(OFFER_ROUTER, &mode)) {
DEBUG_WIFI("[APConfig] wifi_softap_set_dhcps_offer_option failed!\n");
ret = false;
}
if(!wifi_softap_dhcps_start()) {
DEBUG_WIFI("[APConfig] wifi_softap_dhcps_start failed!\n");
ret = false;
}
// check config
if(wifi_get_ip_info(SOFTAP_IF, &info)) {
if(info.ip.addr == 0x00000000) {
DEBUG_WIFI("[APConfig] IP config Invalid?!\n");
ret = false;
} else if(local_ip != info.ip.addr) {
ip = info.ip.addr;
DEBUG_WIFI("[APConfig] IP config not set correct?! new IP: %s\n", ip.toString().c_str());
ret = false;
}
} else {
DEBUG_WIFI("[APConfig] wifi_get_ip_info failed!\n");
ret = false;
}
return ret;
}
@ -179,6 +269,10 @@ bool ESP8266WiFiAPClass::softAPdisconnect(bool wifioff) {
}
ETS_UART_INTR_ENABLE();
if(!ret) {
DEBUG_WIFI("[APdisconnect] set_config failed!\n");
}
if(wifioff) {
ret = WiFi.enableAP(false);
}

View File

@ -103,10 +103,10 @@ void ESP8266WiFiGenericClass::removeEvent(WiFiEventCb cbEvent, WiFiEvent_t event
*/
void ESP8266WiFiGenericClass::_eventCallback(void* arg) {
System_Event_t* event = reinterpret_cast<System_Event_t*>(arg);
DEBUGV("wifi evt: %d\n", event->event);
DEBUG_WIFI("wifi evt: %d\n", event->event);
if(event->event == EVENT_STAMODE_DISCONNECTED) {
DEBUGV("STA disconnect: %d\n", event->event_info.disconnected.reason);
DEBUG_WIFI("STA disconnect: %d\n", event->event_info.disconnected.reason);
WiFiClient::stopAll();
}

View File

@ -1,3 +1,34 @@
esp_iot_sdk_v1.5.1_16_01_08 Release Note
----------------------------------------
Resolved Issues (Bugs listed below apply to Bug Bounty Program):
1.espconn_abort may cause system crash.
Optimization:
1.Optimize the data receiving process under TCP connection.
2.Optimize low MAC and increase stability of the software.
3.Optimize watchdog feeding process.
4.Optimize softAP working mode so that some stations can be easily connected.
5.Optimize station working mode, enabling connection even when the SSID of the AP has changed.
6.Optimize station working mode, and increase routers compatibility during the connection process.
7.Optimize SSL shakehand.
8.Optimize espconn internal timer.
9.Optimize UDP transmission.
10.Improve the flash writing process.
11.Strenthen WPA2 security protocols.
12.Improve data sending ability.
13.Straighten the control capability of GPIO16 under light sleep mode.
14.boot.bin is upgrade to version 1.5, resolving boot failure when firmware is upgraded over the air (OTA).
AT release note
1.Optimize the process of establishing TCP server via AT command.
2.Optimize UART-WiFi transparent transmission mode via AT command.
Please be noted that with the release of NONOS SDK Version 1.5.0 (ESP8266_NONOS_SDK_V1.5.0), the space that AT commands occupies has increased to more than 4Mbit. Therefore, flash with 512Kbit capacity is no longer supported. Please choose flash with at least 8Mbit capacity.
Please be noted that firmware upgrade over-the-air process is changed a bit. We will upgrade the latest firmware to Espressif Cloud server only after it has been tested and the overall performance is guaranteed. Users may not be able to download firmware encapsulated in ESP8266_NONOS_SDK_V1.5.0 and other more advanced versions.
esp_iot_sdk_v1.5.0_15_12_15_p1 Release Note
----------------------------------------
Here is a patch based on ESP8266_NONOS_SDK_V1.5.0 solved a problem that calling espconn_abort may cause unexpected reset.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1 +1 @@
1.5.0_15_12_15_p1
1.5.1_16_01_08