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

Merge remote-tracking branch 'remotes/esp8266/master' into httpClient

This commit is contained in:
Markus Sattler 2015-11-17 18:17:58 +01:00
commit a359992fa4
18 changed files with 217 additions and 106 deletions

View File

@ -14,6 +14,10 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
- Enter ```http://arduino.esp8266.com/stable/package_esp8266com_index.json``` into *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas. - Enter ```http://arduino.esp8266.com/stable/package_esp8266com_index.json``` into *Additional Board Manager URLs* field. You can add multiple URLs, separating them with commas.
- Open Boards Manager from Tools > Board menu and install *esp8266* platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation). - Open Boards Manager from Tools > Board menu and install *esp8266* platform (and don't forget to select your ESP8266 board from Tools > Board menu after installation).
The best place to ask questions related to this core is ESP8266 community forum: http://www.esp8266.com/arduino.
If you find this ESP8266 board manager useful, please consider supporting it with a donation. The ESP8266 Community Forum and IGRR have made this wonderful port available.
[![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=4M56YCWV6PX66)
#### Available versions #### Available versions
##### Stable version ![](http://arduino.esp8266.com/stable/badge.svg) ##### Stable version ![](http://arduino.esp8266.com/stable/badge.svg)
@ -26,7 +30,6 @@ Boards manager link: `http://arduino.esp8266.com/staging/package_esp8266com_inde
Documentation: [Reference](http://arduino.esp8266.com/staging/doc/reference.html) Documentation: [Reference](http://arduino.esp8266.com/staging/doc/reference.html)
### Using git version [![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino) ### Using git version [![Linux build status](https://travis-ci.org/esp8266/Arduino.svg)](https://travis-ci.org/esp8266/Arduino)
- Install Arduino 1.6.5 - Install Arduino 1.6.5
@ -54,10 +57,6 @@ Documentation for latest development version:
### Issues and support ### ### Issues and support ###
The best place to ask questions related to this core is ESP8266 community forum: http://www.esp8266.com/arduino.
If you find the forum useful, please consider supporting it with a donation.
[![Donate](https://img.shields.io/badge/paypal-donate-yellow.svg)](https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=4M56YCWV6PX66)
If you encounter an issue, you are welcome to submit it here on Github: https://github.com/esp8266/Arduino/issues. If you encounter an issue, you are welcome to submit it here on Github: https://github.com/esp8266/Arduino/issues.
Please provide as much context as possible: version which you are using (you can check it in Boards Manager), your sketch code, serial output, board model, IDE settings (board selection, flash size, etc). Please provide as much context as possible: version which you are using (you can check it in Boards Manager), your sketch code, serial output, board model, IDE settings (board selection, flash size, etc).

View File

@ -584,6 +584,8 @@ d1.menu.UploadTool.esptool.upload.verbose=-vv
d1.menu.UploadTool.espota=OTA d1.menu.UploadTool.espota=OTA
d1.menu.UploadTool.espota.upload.tool=espota d1.menu.UploadTool.espota.upload.tool=espota
d1.menu.UploadSpeed.921600=921600
d1.menu.UploadSpeed.921600.upload.speed=921600
d1.menu.UploadSpeed.115200=115200 d1.menu.UploadSpeed.115200=115200
d1.menu.UploadSpeed.115200.upload.speed=115200 d1.menu.UploadSpeed.115200.upload.speed=115200
d1.menu.UploadSpeed.9600=9600 d1.menu.UploadSpeed.9600=9600
@ -601,8 +603,7 @@ d1.menu.UploadSpeed.460800.macosx=460800
d1.menu.UploadSpeed.460800.upload.speed=460800 d1.menu.UploadSpeed.460800.upload.speed=460800
d1.menu.UploadSpeed.512000.windows=512000 d1.menu.UploadSpeed.512000.windows=512000
d1.menu.UploadSpeed.512000.upload.speed=512000 d1.menu.UploadSpeed.512000.upload.speed=512000
d1.menu.UploadSpeed.921600=921600
d1.menu.UploadSpeed.921600.upload.speed=921600
d1.menu.FlashSize.4M3M=4M (3M SPIFFS) d1.menu.FlashSize.4M3M=4M (3M SPIFFS)
d1.menu.FlashSize.4M3M.build.flash_size=4M d1.menu.FlashSize.4M3M.build.flash_size=4M
@ -654,6 +655,8 @@ d1_mini.menu.UploadTool.esptool.upload.verbose=-vv
d1_mini.menu.UploadTool.espota=OTA d1_mini.menu.UploadTool.espota=OTA
d1_mini.menu.UploadTool.espota.upload.tool=espota d1_mini.menu.UploadTool.espota.upload.tool=espota
d1_mini.menu.UploadSpeed.921600=921600
d1_mini.menu.UploadSpeed.921600.upload.speed=921600
d1_mini.menu.UploadSpeed.115200=115200 d1_mini.menu.UploadSpeed.115200=115200
d1_mini.menu.UploadSpeed.115200.upload.speed=115200 d1_mini.menu.UploadSpeed.115200.upload.speed=115200
d1_mini.menu.UploadSpeed.9600=9600 d1_mini.menu.UploadSpeed.9600=9600
@ -671,8 +674,7 @@ d1_mini.menu.UploadSpeed.460800.macosx=460800
d1_mini.menu.UploadSpeed.460800.upload.speed=460800 d1_mini.menu.UploadSpeed.460800.upload.speed=460800
d1_mini.menu.UploadSpeed.512000.windows=512000 d1_mini.menu.UploadSpeed.512000.windows=512000
d1_mini.menu.UploadSpeed.512000.upload.speed=512000 d1_mini.menu.UploadSpeed.512000.upload.speed=512000
d1_mini.menu.UploadSpeed.921600=921600
d1_mini.menu.UploadSpeed.921600.upload.speed=921600
d1_mini.menu.FlashSize.4M3M=4M (3M SPIFFS) d1_mini.menu.FlashSize.4M3M=4M (3M SPIFFS)
d1_mini.menu.FlashSize.4M3M.build.flash_size=4M d1_mini.menu.FlashSize.4M3M.build.flash_size=4M

View File

@ -37,6 +37,11 @@ static void uart1_write_char_d(char c);
static void print_stack(uint32_t start, uint32_t end); static void print_stack(uint32_t start, uint32_t end);
//static void print_pcs(uint32_t start, uint32_t end); //static void print_pcs(uint32_t start, uint32_t end);
extern void __custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) {
}
extern void custom_crash_callback( struct rst_info * rst_info, uint32_t stack, uint32_t stack_end ) __attribute__ ((weak, alias("__custom_crash_callback")));
void __wrap_system_restart_local() { void __wrap_system_restart_local() {
register uint32_t sp asm("a1"); register uint32_t sp asm("a1");
@ -92,6 +97,9 @@ void __wrap_system_restart_local() {
// print_pcs(sp + offset, stack_end); // print_pcs(sp + offset, stack_end);
print_stack(sp + offset, stack_end); print_stack(sp + offset, stack_end);
custom_crash_callback( &rst_info, sp + offset, stack_end );
delayMicroseconds(10000); delayMicroseconds(10000);
__real_system_restart_local(); __real_system_restart_local();
} }

View File

@ -10,6 +10,8 @@ title: Supported Hardware
- [SparkFun ESP8266 Thing](#sparkfun-esp8266-thing) - [SparkFun ESP8266 Thing](#sparkfun-esp8266-thing)
- [SweetPea ESP-210](#sweetpea-esp-210) - [SweetPea ESP-210](#sweetpea-esp-210)
- [Generic ESP8266 modules](#generic-esp8266-modules) - [Generic ESP8266 modules](#generic-esp8266-modules)
- [WeMos D1](#wemos-d1)
- [WeMos D1 mini](#wemos-d1-mini)
### Adafruit HUZZAH ESP8266 (ESP-12) ### Adafruit HUZZAH ESP8266 (ESP-12)
@ -212,4 +214,7 @@ the first value respects the pin setup of the Pins 0, 2 and 15.
note: note:
- number = ((GPIO15 << 2) | (GPIO0 << 1) | GPIO2); - number = ((GPIO15 << 2) | (GPIO0 << 1) | GPIO2);
### WeMos D1
Product page: http://wemos.cc
### WeMos D1 mini
Product page: http://wemos.cc

View File

@ -167,6 +167,7 @@ NodeMCU 1.0 | 4M | 1M, 3M
Olimex MOD-WIFI-ESP8266(-DEV)| 2M | 1M Olimex MOD-WIFI-ESP8266(-DEV)| 2M | 1M
SparkFun Thing | 512k | 64k SparkFun Thing | 512k | 64k
SweetPea ESP-210 | 4M | 1M, 3M SweetPea ESP-210 | 4M | 1M, 3M
WeMos D1 & D1 mini | 4M | 1M, 3M
**Note:** to use any of file system functions in the sketch, add the following include to the sketch: **Note:** to use any of file system functions in the sketch, add the following include to the sketch:

View File

@ -31,23 +31,32 @@
#define DEBUG_OUTPUT Serial #define DEBUG_OUTPUT Serial
ESP8266WebServer::ESP8266WebServer(IPAddress addr, int port)
: _server(addr, port)
, _firstHandler(0)
, _lastHandler(0)
, _currentArgCount(0)
, _currentArgs(0)
, _headerKeysCount(0)
, _currentHeaders(0)
{
}
ESP8266WebServer::ESP8266WebServer(int port) ESP8266WebServer::ESP8266WebServer(int port)
: _server(port) : _server(port)
, _firstHandler(0) , _firstHandler(0)
, _lastHandler(0) , _lastHandler(0)
, _currentArgCount(0) , _currentArgCount(0)
, _currentArgs(0) , _currentArgs(0)
,_headerKeysCount(0) , _headerKeysCount(0)
,_currentHeaders(0) , _currentHeaders(0)
{ {
} }
ESP8266WebServer::~ESP8266WebServer() { ESP8266WebServer::~ESP8266WebServer() {
if (_currentHeaders) if (_currentHeaders)
delete[]_currentHeaders; delete[]_currentHeaders;
_headerKeysCount = 0; _headerKeysCount = 0;
if (!_firstHandler)
return;
RequestHandler* handler = _firstHandler; RequestHandler* handler = _firstHandler;
while (handler) { while (handler) {
RequestHandler* next = handler->next(); RequestHandler* next = handler->next();

View File

@ -59,6 +59,7 @@ typedef struct {
class ESP8266WebServer class ESP8266WebServer
{ {
public: public:
ESP8266WebServer(IPAddress addr, int port = 80);
ESP8266WebServer(int port = 80); ESP8266WebServer(int port = 80);
~ESP8266WebServer(); ~ESP8266WebServer();

View File

@ -50,7 +50,6 @@ extern "C"
#define SSL_DEBUG_OPTS 0 #define SSL_DEBUG_OPTS 0
#endif #endif
#define SSL_RX_BUF_SIZE 4096
class SSLContext { class SSLContext {
public: public:
@ -59,8 +58,6 @@ public:
_ssl_ctx = ssl_ctx_new(SSL_SERVER_VERIFY_LATER | SSL_DEBUG_OPTS, 0); _ssl_ctx = ssl_ctx_new(SSL_SERVER_VERIFY_LATER | SSL_DEBUG_OPTS, 0);
} }
++_ssl_ctx_refcnt; ++_ssl_ctx_refcnt;
_rxbuf = new cbuf(SSL_RX_BUF_SIZE);
} }
~SSLContext() { ~SSLContext() {
@ -73,8 +70,6 @@ public:
if (_ssl_ctx_refcnt == 0) { if (_ssl_ctx_refcnt == 0) {
ssl_ctx_free(_ssl_ctx); ssl_ctx_free(_ssl_ctx);
} }
delete _rxbuf;
} }
void ref() { void ref() {
@ -92,38 +87,50 @@ public:
} }
int read(uint8_t* dst, size_t size) { int read(uint8_t* dst, size_t size) {
if (!_rxbuf->getSize()) { if (!_available) {
_readAll(); if (!_readAll())
return 0;
} }
size_t available = _rxbuf->getSize(); size_t will_copy = (_available < size) ? _available : size;
size_t will_read = (available < size) ? available : size; memcpy(dst, _read_ptr, will_copy);
return _rxbuf->read(reinterpret_cast<char*>(dst), will_read); _read_ptr += will_copy;
_available -= will_copy;
if (_available == 0) {
_read_ptr = nullptr;
}
return will_copy;
} }
int read() { int read() {
optimistic_yield(100); if (!_available) {
if (!_rxbuf->getSize()) { if (!_readAll())
_readAll(); return -1;
} }
return _rxbuf->read(); int result = _read_ptr[0];
++_read_ptr;
--_available;
if (_available == 0) {
_read_ptr = nullptr;
}
return result;
} }
int peek() { int peek() {
if (!_rxbuf->getSize()) { if (!_available) {
_readAll(); if (!_readAll())
return -1;
} }
return _rxbuf->peek(); return _read_ptr[0];
} }
int available() { int available() {
auto rc = _rxbuf->getSize(); auto cb = _available;
if (rc == 0) { if (cb == 0) {
_readAll(); cb = _readAll();
rc = _rxbuf->getSize();
} else { } else {
optimistic_yield(100); optimistic_yield(100);
} }
return rc; return cb;
} }
operator SSL*() { operator SSL*() {
@ -135,6 +142,8 @@ protected:
if (!_ssl) if (!_ssl)
return 0; return 0;
optimistic_yield(100);
uint8_t* data; uint8_t* data;
int rc = ssl_read(_ssl, &data); int rc = ssl_read(_ssl, &data);
if (rc <= 0) { if (rc <= 0) {
@ -144,25 +153,18 @@ protected:
} }
return 0; return 0;
} }
DEBUGV(":wcs ra %d", rc);
_read_ptr = data;
if (rc > _rxbuf->room()) { _available = rc;
DEBUGV("WiFiClientSecure rx overflow"); return _available;
rc = _rxbuf->room();
}
int result = 0;
size_t sizeBefore = _rxbuf->getSize();
if (rc)
result = _rxbuf->write(reinterpret_cast<const char*>(data), rc);
DEBUGV("*** rb: %d + %d = %d\r\n", sizeBefore, rc, _rxbuf->getSize());
return result;
} }
static SSL_CTX* _ssl_ctx; static SSL_CTX* _ssl_ctx;
static int _ssl_ctx_refcnt; static int _ssl_ctx_refcnt;
SSL* _ssl = nullptr; SSL* _ssl = nullptr;
int _refcnt = 0; int _refcnt = 0;
cbuf* _rxbuf; const uint8_t* _read_ptr = nullptr;
size_t _available = 0;
}; };
SSL_CTX* SSLContext::_ssl_ctx = nullptr; SSL_CTX* SSLContext::_ssl_ctx = nullptr;
@ -313,14 +315,13 @@ bool WiFiClientSecure::verify(const char* fp, const char* url) {
while (pos < len && fp[pos] == ' ') { while (pos < len && fp[pos] == ' ') {
++pos; ++pos;
} }
DEBUGV("pos:%d ", pos);
if (pos > len - 2) { if (pos > len - 2) {
DEBUGV("fingerprint too short\r\n"); DEBUGV("pos:%d len:%d fingerprint too short\r\n", pos, len);
return false; return false;
} }
uint8_t high, low; uint8_t high, low;
if (!parseHexNibble(fp[pos], &high) || !parseHexNibble(fp[pos+1], &low)) { if (!parseHexNibble(fp[pos], &high) || !parseHexNibble(fp[pos+1], &low)) {
DEBUGV("invalid hex sequence: %c%c\r\n", fp[pos], fp[pos+1]); DEBUGV("pos:%d len:%d invalid hex sequence: %c%c\r\n", pos, len, fp[pos], fp[pos+1]);
return false; return false;
} }
pos += 2; pos += 2;

View File

@ -38,33 +38,41 @@ extern "C" {
#include "cbuf.h" #include "cbuf.h"
#include "include/ClientContext.h" #include "include/ClientContext.h"
WiFiServer::WiFiServer(uint16_t port) WiFiServer::WiFiServer(IPAddress addr, uint16_t port)
: _port(port)
, _addr(addr)
, _pcb(nullptr)
, _unclaimed(nullptr)
, _discarded(nullptr)
{ {
_port = port;
_pcb = 0;
_unclaimed = 0;
_discarded = 0;
} }
void WiFiServer::begin() WiFiServer::WiFiServer(uint16_t port)
: _port(port)
, _addr((uint32_t) IPADDR_ANY)
, _pcb(nullptr)
, _unclaimed(nullptr)
, _discarded(nullptr)
{ {
err_t err; }
void WiFiServer::begin() {
err_t err;
tcp_pcb* pcb = tcp_new(); tcp_pcb* pcb = tcp_new();
if (!pcb) if (!pcb)
return; return;
err = tcp_bind(pcb, INADDR_ANY, _port); ip_addr_t local_addr;
local_addr.addr = (uint32_t) _addr;
err = tcp_bind(pcb, &local_addr, _port);
if (err != ERR_OK) if (err != ERR_OK) {
{
tcp_close(pcb); tcp_close(pcb);
return; return;
} }
tcp_pcb* listen_pcb = tcp_listen(pcb); tcp_pcb* listen_pcb = tcp_listen(pcb);
if (!listen_pcb) if (!listen_pcb) {
{
tcp_close(pcb); tcp_close(pcb);
return; return;
} }
@ -73,26 +81,30 @@ void WiFiServer::begin()
tcp_arg(listen_pcb, (void*) this); tcp_arg(listen_pcb, (void*) this);
} }
void WiFiServer::setNoDelay(bool nodelay){ void WiFiServer::setNoDelay(bool nodelay) {
if(!_pcb) return; if (!_pcb)
if(nodelay) tcp_nagle_disable(_pcb); return;
else tcp_nagle_enable(_pcb);
if (nodelay)
tcp_nagle_disable(_pcb);
else
tcp_nagle_enable(_pcb);
} }
bool WiFiServer::getNoDelay(){ bool WiFiServer::getNoDelay() {
if(!_pcb) return false; if (!_pcb)
return tcp_nagle_disabled(_pcb); return false;
return tcp_nagle_disabled(_pcb);
} }
bool WiFiServer::hasClient(){ bool WiFiServer::hasClient() {
if (_unclaimed) return true;
return false;
}
WiFiClient WiFiServer::available(byte* status)
{
if (_unclaimed) if (_unclaimed)
{ return true;
return false;
}
WiFiClient WiFiServer::available(byte* status) {
if (_unclaimed) {
WiFiClient result(_unclaimed); WiFiClient result(_unclaimed);
_unclaimed = _unclaimed->next(); _unclaimed = _unclaimed->next();
DEBUGV("WS:av\r\n"); DEBUGV("WS:av\r\n");
@ -100,32 +112,28 @@ WiFiClient WiFiServer::available(byte* status)
} }
optimistic_yield(1000); optimistic_yield(1000);
return WiFiClient(); return WiFiClient();
} }
uint8_t WiFiServer::status() { uint8_t WiFiServer::status() {
if (!_pcb) if (!_pcb)
return CLOSED; return CLOSED;
return _pcb->state; return _pcb->state;
} }
size_t WiFiServer::write(uint8_t b) size_t WiFiServer::write(uint8_t b) {
{
return write(&b, 1); return write(&b, 1);
} }
size_t WiFiServer::write(const uint8_t *buffer, size_t size) size_t WiFiServer::write(const uint8_t *buffer, size_t size) {
{
// write to all clients // write to all clients
// not implemented // not implemented
return 0; return 0;
} }
template<typename T> template<typename T>
T* slist_append_tail(T* head, T* item) T* slist_append_tail(T* head, T* item) {
{
if (!head) if (!head)
return item; return item;
T* last = head; T* last = head;
@ -135,29 +143,23 @@ T* slist_append_tail(T* head, T* item)
return head; return head;
} }
int8_t WiFiServer::_accept(tcp_pcb* apcb, int8_t err) int8_t WiFiServer::_accept(tcp_pcb* apcb, int8_t err) {
{
DEBUGV("WS:ac\r\n"); DEBUGV("WS:ac\r\n");
ClientContext* client = new ClientContext(apcb, &WiFiServer::_s_discard, this); ClientContext* client = new ClientContext(apcb, &WiFiServer::_s_discard, this);
_unclaimed = slist_append_tail(_unclaimed, client); _unclaimed = slist_append_tail(_unclaimed, client);
tcp_accepted(_pcb); tcp_accepted(_pcb);
// printf("WiFiServer::_accept\r\n");
return ERR_OK; return ERR_OK;
} }
void WiFiServer::_discard(ClientContext* client) void WiFiServer::_discard(ClientContext* client) {
{
// _discarded = slist_append_tail(_discarded, client); // _discarded = slist_append_tail(_discarded, client);
DEBUGV("WS:dis\r\n"); DEBUGV("WS:dis\r\n");
// printf("WiFiServer::_discard\r\n");
} }
int8_t WiFiServer::_s_accept(void *arg, tcp_pcb* newpcb, int8_t err) int8_t WiFiServer::_s_accept(void *arg, tcp_pcb* newpcb, int8_t err) {
{
return reinterpret_cast<WiFiServer*>(arg)->_accept(newpcb, err); return reinterpret_cast<WiFiServer*>(arg)->_accept(newpcb, err);
} }
void WiFiServer::_s_discard(void* server, ClientContext* ctx) void WiFiServer::_s_discard(void* server, ClientContext* ctx) {
{
reinterpret_cast<WiFiServer*>(server)->_discard(ctx); reinterpret_cast<WiFiServer*>(server)->_discard(ctx);
} }

View File

@ -29,6 +29,7 @@ extern "C" {
} }
#include "Server.h" #include "Server.h"
#include "IPAddress.h"
class ClientContext; class ClientContext;
class WiFiClient; class WiFiClient;
@ -36,12 +37,14 @@ class WiFiClient;
class WiFiServer : public Server { class WiFiServer : public Server {
private: private:
uint16_t _port; uint16_t _port;
IPAddress _addr;
tcp_pcb* _pcb; tcp_pcb* _pcb;
ClientContext* _unclaimed; ClientContext* _unclaimed;
ClientContext* _discarded; ClientContext* _discarded;
public: public:
WiFiServer(IPAddress addr, uint16_t port);
WiFiServer(uint16_t port); WiFiServer(uint16_t port);
WiFiClient available(uint8_t* status = NULL); WiFiClient available(uint8_t* status = NULL);
bool hasClient(); bool hasClient();

View File

@ -34,17 +34,19 @@ ESP8266HTTPUpdate::~ESP8266HTTPUpdate(void) {
} }
t_httpUpdate_return ESP8266HTTPUpdate::update(const char * host, uint16_t port, const char * url, const char * current_version) { t_httpUpdate_return ESP8266HTTPUpdate::update(const char * host, uint16_t port, const char * url, const char * current_version) {
t_httpUpdate_return ret = HTTP_UPDATE_FAILED;
WiFiClient tcp; WiFiClient tcp;
DEBUG_HTTP_UPDATE("[httpUpdate] connected to %s:%u %s .... ", host, port, url); DEBUG_HTTP_UPDATE("[httpUpdate] connected to %s:%u %s .... ", host, port, url);
if(!tcp.connect(host, port)) { if(!tcp.connect(host, port)) {
DEBUG_HTTP_UPDATE("failed.\n"); DEBUG_HTTP_UPDATE("failed.\n");
return ret; return HTTP_UPDATE_FAILED;
} }
DEBUG_HTTP_UPDATE("ok.\n"); DEBUG_HTTP_UPDATE("ok.\n");
return update(tcp, host, url, current_version);
}
t_httpUpdate_return ESP8266HTTPUpdate::update(WiFiClient& tcp, const char* host, const char* url, const char * current_version) {
t_httpUpdate_return ret = HTTP_UPDATE_FAILED;
// set Timeout for readBytesUntil and readStringUntil // set Timeout for readBytesUntil and readStringUntil
tcp.setTimeout(2000); tcp.setTimeout(2000);
tcp.setNoDelay(true); tcp.setNoDelay(true);

View File

@ -50,6 +50,7 @@ class ESP8266HTTPUpdate {
t_httpUpdate_return update(const char * host, uint16_t port, const char * url = "/", const char * current_version = ""); 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 = ""); t_httpUpdate_return update(String host, uint16_t port, String url = "/", String current_version = "");
t_httpUpdate_return update(WiFiClient& client, const char* host, const char* url = "/", const char * current_version = "");
}; };
extern ESP8266HTTPUpdate ESPhttpUpdate; extern ESP8266HTTPUpdate ESPhttpUpdate;

View File

@ -0,0 +1,9 @@
name=ESP8266
version=1.0
author=Simon Peter,Markus Sattler,Ivan Grokhotkov
maintainer=Ivan Grokhtkov <ivan@esp8266.com>
sentence=ESP8266 sketches examples
paragraph=
category=Other
url=
architectures=esp8266

View File

@ -0,0 +1,2 @@
// This file is here only to silence warnings from Arduino IDE
// Currently IDE doesn't support no-code libraries, like this collection of example sketches.

60
package/merge_packages.py Normal file
View File

@ -0,0 +1,60 @@
#!/usr/bin/env python
# This script merges two Arduino Board Manager package json files.
# Usage:
# python merge_packages.py package_esp8266com_index.json version/new/package_esp8266com_index.json
# Written by Ivan Grokhotkov, 2015
#
from __future__ import print_function
import json
import sys
def load_package(filename):
pkg = json.load(open(filename))['packages'][0]
print("Loaded package {0} from {1}".format(pkg['name'], filename))
print("{0} platform(s), {1} tools".format(len(pkg['platforms']), len(pkg['tools'])))
return pkg
def merge_objects(versions, obj):
for o in obj:
name = o['name'].encode('ascii')
ver = o['version'].encode('ascii')
if not name in versions:
print("found new object, {0}".format(name))
versions[name] = {}
if not ver in versions[name]:
print("found new version {0} for object {1}".format(ver, name))
versions[name][ver] = o
return versions
def main(args):
if len(args) < 3:
print("Usage: {0} <package1> <package2>".format(args[0]))
return 1
tools = {}
platforms = {}
pkg1 = load_package(args[1])
tools = merge_objects(tools, pkg1['tools']);
platforms = merge_objects(platforms, pkg1['platforms']);
pkg2 = load_package(args[2])
tools = merge_objects(tools, pkg2['tools']);
platforms = merge_objects(platforms, pkg2['platforms']);
pkg1['tools'] = []
pkg1['platforms'] = []
for name in tools:
for version in tools[name]:
print("Adding tool {0}-{1}".format(name, version))
pkg1['tools'].append(tools[name][version])
for name in platforms:
for version in platforms[name]:
print("Adding platform {0}-{1}".format(name, version))
pkg1['platforms'].append(platforms[name][version])
json.dump({'packages':[pkg1]}, sys.stdout, indent=2)
if __name__ == '__main__':
sys.exit(main(sys.argv))

View File

@ -42,6 +42,12 @@
}, },
{ {
"name": "SweetPea ESP-210" "name": "SweetPea ESP-210"
},
{
"name": "WeMos D1"
},
{
"name": "WeMos D1 mini"
} }
], ],
"toolsDependencies": [ "toolsDependencies": [

View File

@ -1,7 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
# This script will download and extract required tools into the current directory # This script will download and extract required tools into the current directory.
# Tools list is obtained from tools.json file # Tools list is obtained from package/package_esp8266com_index.template.json file.
# Written by Ivan Grokhotkov, 2015 # Written by Ivan Grokhotkov, 2015.
# #
from __future__ import print_function from __future__ import print_function
import urllib import urllib

Binary file not shown.