mirror of
https://github.com/esp8266/Arduino.git
synced 2025-04-22 21:23:07 +03:00
Merge branch 'master' into MD5
This commit is contained in:
commit
489b9e77e6
@ -11,7 +11,7 @@ ESP8266 Arduino core comes with libraries to communicate over WiFi using TCP and
|
||||
- [Using git version](#using-git-version-)
|
||||
- [Using stable version with PlatformIO](#using-stable-version-with-platformio)
|
||||
- [Documentation](#documentation)
|
||||
- [Issues and support](#issues-and-support)
|
||||
- [Issues and support](#issues-and-support)
|
||||
- [Contributing](#contributing)
|
||||
- [License and credits](#license-and-credits)
|
||||
|
||||
@ -25,7 +25,7 @@ Starting with 1.6.4, Arduino allows installation of third-party platform package
|
||||
- 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.
|
||||
If you find this forum or the ESP8266 Boards Manager package useful, please consider supporting it with a donation.
|
||||
[](https://www.paypal.com/webscr?cmd=_s-xclick&hosted_button_id=4M56YCWV6PX66)
|
||||
|
||||
#### Available versions
|
||||
@ -38,11 +38,11 @@ Documentation: [http://esp8266.github.io/Arduino/versions/2.0.0/](http://esp8266
|
||||
##### Staging version 
|
||||
Boards manager link: `http://arduino.esp8266.com/staging/package_esp8266com_index.json`
|
||||
|
||||
Documentation: [http://esp8266.github.io/Arduino/versions/2.0.0-rc2/](http://esp8266.github.io/Arduino/versions/2.0.0-rc2/)
|
||||
Documentation: [http://esp8266.github.io/Arduino/versions/2.1.0-rc1/](http://esp8266.github.io/Arduino/versions/2.1.0-rc1/)
|
||||
|
||||
### Using git version [](https://travis-ci.org/esp8266/Arduino)
|
||||
|
||||
- Install Arduino 1.6.5
|
||||
- Install Arduino 1.6.7
|
||||
- Go to Arduino directory
|
||||
- Clone this repository into hardware/esp8266com/esp8266 directory (or clone it elsewhere and create a symlink)
|
||||
```bash
|
||||
|
18
boards.txt
18
boards.txt
@ -189,6 +189,8 @@ generic.menu.DebugLevel.WiFi=WiFi
|
||||
generic.menu.DebugLevel.WiFi.build.debug_level=-DDEBUG_ESP_WIFI
|
||||
generic.menu.DebugLevel.HTTPClient=HTTPClient
|
||||
generic.menu.DebugLevel.HTTPClient.build.debug_level=-DDEBUG_ESP_HTTP_CLIENT
|
||||
generic.menu.DebugLevel.HTTPClient2=HTTPClient + SSL
|
||||
generic.menu.DebugLevel.HTTPClient2.build.debug_level=-DDEBUG_ESP_HTTP_CLIENT -DDEBUG_ESP_SSL
|
||||
generic.menu.DebugLevel.HTTPUpdate=HTTPUpdate
|
||||
generic.menu.DebugLevel.HTTPUpdate.build.debug_level=-DDEBUG_ESP_HTTP_UPDATE
|
||||
generic.menu.DebugLevel.HTTPUpdate2=HTTPClient + HTTPUpdate
|
||||
@ -944,8 +946,20 @@ wifinfo.build.variant=wifinfo
|
||||
wifinfo.build.flash_mode=qio
|
||||
wifinfo.build.board=ESP8266_ESP12
|
||||
wifinfo.build.spiffs_pagesize=256
|
||||
wifinfo.build.debug_port=
|
||||
wifinfo.build.debug_level=
|
||||
wifinfo.build.debug_port=Serial1
|
||||
wifinfo.build.debug_level=Wifinfo
|
||||
|
||||
wifinfo.menu.Debug.Disabled=Disabled
|
||||
wifinfo.menu.Debug.Disabled.build.debug_port=
|
||||
wifinfo.menu.Debug.Serial=Serial
|
||||
wifinfo.menu.Debug.Serial.build.debug_port=-DDEBUG_ESP_PORT=Serial
|
||||
wifinfo.menu.Debug.Serial1=Serial1
|
||||
wifinfo.menu.Debug.Serial1.build.debug_port=-DDEBUG_ESP_PORT=Serial1
|
||||
|
||||
wifinfo.menu.DebugLevel.None=None
|
||||
wifinfo.menu.DebugLevel.None.build.debug_level=
|
||||
wifinfo.menu.DebugLevel.Wifinfo=Wifinfo
|
||||
wifinfo.menu.DebugLevel.Wifinfo.build.debug_level=-DDEBUG_ESP_WIFINFO
|
||||
|
||||
#wifinfo.menu.ESPModule.ESP07512=ESP07 (1M/512K SPIFFS)
|
||||
#wifinfo.menu.ESPModule.ESP07512.build.board=ESP8266_ESP07
|
||||
|
@ -101,7 +101,8 @@ void uart_disarm_tx_interrupt(uart_t* uart);
|
||||
void uart_set_baudrate(uart_t* uart, int baud_rate);
|
||||
int uart_get_baudrate(uart_t* uart);
|
||||
|
||||
uart_t* uart_init(int uart_nr, int baudrate, byte config);
|
||||
uart_t* uart_start_init(int uart_nr, int baudrate, byte config);
|
||||
void uart_finish_init(uart_t* uart);
|
||||
void uart_uninit(uart_t* uart);
|
||||
void uart_swap(uart_t* uart);
|
||||
|
||||
@ -116,6 +117,13 @@ int uart_get_debug();
|
||||
// ####################################################################################################
|
||||
// ####################################################################################################
|
||||
|
||||
// These function internals can be used from interrupt handlers to ensure they
|
||||
// are in instruction RAM, or anywhere that the uart_nr has been validated.
|
||||
#define UART_GET_TX_FIFO_ROOM(uart_nr) (UART_TX_FIFO_SIZE - ((USS(uart_nr) >> USTXC) & 0xff))
|
||||
#define UART_TRANSMIT_CHAR(uart_nr, c) do { USF(uart_nr) = (c); } while(0)
|
||||
#define UART_ARM_TX_INTERRUPT(uart_nr) do { USIE(uart_nr) |= (1 << UIFE); } while(0)
|
||||
#define UART_DISARM_TX_INTERRUPT(uart_nr) do { USIE(uart_nr) &= ~(1 << UIFE); } while(0)
|
||||
|
||||
void ICACHE_RAM_ATTR uart_interrupt_handler(uart_t* uart) {
|
||||
|
||||
// -------------- UART 0 --------------
|
||||
@ -133,13 +141,7 @@ void ICACHE_RAM_ATTR uart_interrupt_handler(uart_t* uart) {
|
||||
}
|
||||
|
||||
// -------------- UART 1 --------------
|
||||
|
||||
if(Serial1.isRxEnabled()) {
|
||||
while(U1IS & (1 << UIFF)) {
|
||||
Serial1._rx_complete_irq((char) (U1F & 0xff));
|
||||
U1IC = (1 << UIFF);
|
||||
}
|
||||
}
|
||||
// Note: only TX is supported on UART 1.
|
||||
if(Serial1.isTxEnabled()) {
|
||||
if(U1IS & (1 << UIFE)) {
|
||||
U1IC = (1 << UIFE);
|
||||
@ -166,7 +168,7 @@ size_t uart_get_tx_fifo_room(uart_t* uart) {
|
||||
if(uart == 0)
|
||||
return 0;
|
||||
if(uart->txEnabled) {
|
||||
return UART_TX_FIFO_SIZE - ((USS(uart->uart_nr) >> USTXC) & 0xff);
|
||||
return UART_GET_TX_FIFO_ROOM(uart->uart_nr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -183,7 +185,7 @@ void uart_transmit_char(uart_t* uart, char c) {
|
||||
if(uart == 0)
|
||||
return;
|
||||
if(uart->txEnabled) {
|
||||
USF(uart->uart_nr) = c;
|
||||
UART_TRANSMIT_CHAR(uart->uart_nr, c);
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +249,7 @@ void uart_arm_tx_interrupt(uart_t* uart) {
|
||||
if(uart == 0)
|
||||
return;
|
||||
if(uart->txEnabled) {
|
||||
USIE(uart->uart_nr) |= (1 << UIFE);
|
||||
UART_ARM_TX_INTERRUPT(uart->uart_nr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -255,7 +257,7 @@ void uart_disarm_tx_interrupt(uart_t* uart) {
|
||||
if(uart == 0)
|
||||
return;
|
||||
if(uart->txEnabled) {
|
||||
USIE(uart->uart_nr) &= ~(1 << UIFE);
|
||||
UART_DISARM_TX_INTERRUPT(uart->uart_nr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -272,9 +274,8 @@ int uart_get_baudrate(uart_t* uart) {
|
||||
return uart->baud_rate;
|
||||
}
|
||||
|
||||
uart_t* uart_init(int uart_nr, int baudrate, byte config, byte mode) {
|
||||
uart_t* uart_start_init(int uart_nr, int baudrate, byte config, byte mode) {
|
||||
|
||||
uint32_t conf1 = 0x00000000;
|
||||
uart_t* uart = (uart_t*) os_malloc(sizeof(uart_t));
|
||||
|
||||
if(uart == 0) {
|
||||
@ -294,6 +295,7 @@ uart_t* uart_init(int uart_nr, int baudrate, byte config, byte mode) {
|
||||
IOSWAP &= ~(1 << IOSWAPU0);
|
||||
break;
|
||||
case UART1:
|
||||
// Note: uart_interrupt_handler does not support RX on UART 1.
|
||||
uart->rxEnabled = false;
|
||||
uart->txEnabled = (mode != SERIAL_RX_ONLY);
|
||||
uart->rxPin = 255;
|
||||
@ -309,6 +311,12 @@ uart_t* uart_init(int uart_nr, int baudrate, byte config, byte mode) {
|
||||
uart_set_baudrate(uart, baudrate);
|
||||
USC0(uart->uart_nr) = config;
|
||||
|
||||
return uart;
|
||||
}
|
||||
|
||||
void uart_finish_init(uart_t* uart) {
|
||||
uint32_t conf1 = 0x00000000;
|
||||
|
||||
uart_flush(uart);
|
||||
uart_interrupt_enable(uart);
|
||||
|
||||
@ -321,8 +329,6 @@ uart_t* uart_init(int uart_nr, int baudrate, byte config, byte mode) {
|
||||
}
|
||||
|
||||
USC1(uart->uart_nr) = conf1;
|
||||
|
||||
return uart;
|
||||
}
|
||||
|
||||
void uart_uninit(uart_t* uart) {
|
||||
@ -479,35 +485,48 @@ int uart_get_debug() {
|
||||
// ####################################################################################################
|
||||
|
||||
HardwareSerial::HardwareSerial(int uart_nr) :
|
||||
_uart_nr(uart_nr), _uart(0), _tx_buffer(0), _rx_buffer(0), _written(false) {
|
||||
_uart_nr(uart_nr), _uart(0), _tx_buffer(0), _rx_buffer(0) {
|
||||
}
|
||||
|
||||
void HardwareSerial::begin(unsigned long baud, byte config, byte mode) {
|
||||
InterruptLock il;
|
||||
|
||||
// disable debug for this interface
|
||||
if(uart_get_debug() == _uart_nr) {
|
||||
uart_set_debug(UART_NO);
|
||||
}
|
||||
|
||||
_uart = uart_init(_uart_nr, baud, config, mode);
|
||||
if (_uart) {
|
||||
os_free(_uart);
|
||||
}
|
||||
_uart = uart_start_init(_uart_nr, baud, config, mode);
|
||||
|
||||
if(_uart == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(_uart->rxEnabled) {
|
||||
if(!_rx_buffer)
|
||||
_rx_buffer = new cbuf(SERIAL_RX_BUFFER_SIZE);
|
||||
// Disable the RX and/or TX functions if we fail to allocate circular buffers.
|
||||
// The user can confirm they are enabled with isRxEnabled() and isTxEnabled().
|
||||
if(_uart->rxEnabled && !_rx_buffer) {
|
||||
_rx_buffer = new cbuf(SERIAL_RX_BUFFER_SIZE);
|
||||
if(!_rx_buffer) {
|
||||
_uart->rxEnabled = false;
|
||||
}
|
||||
}
|
||||
if(_uart->txEnabled) {
|
||||
if(!_tx_buffer)
|
||||
_tx_buffer = new cbuf(SERIAL_TX_BUFFER_SIZE);
|
||||
if(_uart->txEnabled && !_tx_buffer) {
|
||||
_tx_buffer = new cbuf(SERIAL_TX_BUFFER_SIZE);
|
||||
if(!_tx_buffer) {
|
||||
_uart->txEnabled = false;
|
||||
}
|
||||
}
|
||||
_written = false;
|
||||
delay(1);
|
||||
|
||||
uart_finish_init(_uart);
|
||||
}
|
||||
|
||||
void HardwareSerial::end() {
|
||||
InterruptLock il;
|
||||
|
||||
if(uart_get_debug() == _uart_nr) {
|
||||
uart_set_debug(UART_NO);
|
||||
}
|
||||
@ -541,13 +560,13 @@ void HardwareSerial::setDebugOutput(bool en) {
|
||||
}
|
||||
}
|
||||
|
||||
bool HardwareSerial::isTxEnabled(void) {
|
||||
bool ICACHE_RAM_ATTR HardwareSerial::isTxEnabled(void) {
|
||||
if(_uart == 0)
|
||||
return false;
|
||||
return _uart->txEnabled;
|
||||
}
|
||||
|
||||
bool HardwareSerial::isRxEnabled(void) {
|
||||
bool ICACHE_RAM_ATTR HardwareSerial::isRxEnabled(void) {
|
||||
if(_uart == 0)
|
||||
return false;
|
||||
return _uart->rxEnabled;
|
||||
@ -606,44 +625,52 @@ void HardwareSerial::flush() {
|
||||
return;
|
||||
if(!_uart->txEnabled)
|
||||
return;
|
||||
if(!_written)
|
||||
return;
|
||||
|
||||
const int uart_nr = _uart->uart_nr;
|
||||
while(true) {
|
||||
{
|
||||
InterruptLock il;
|
||||
if(_tx_buffer->getSize() == 0 &&
|
||||
uart_get_tx_fifo_room(_uart) >= UART_TX_FIFO_SIZE) {
|
||||
UART_GET_TX_FIFO_ROOM(uart_nr) >= UART_TX_FIFO_SIZE) {
|
||||
break;
|
||||
} else if(il.savedInterruptLevel() > 0) {
|
||||
_tx_empty_irq();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
yield();
|
||||
}
|
||||
_written = false;
|
||||
}
|
||||
|
||||
size_t HardwareSerial::write(uint8_t c) {
|
||||
if(_uart == 0 || !_uart->txEnabled)
|
||||
return 0;
|
||||
_written = true;
|
||||
|
||||
bool tx_now = false;
|
||||
const int uart_nr = _uart->uart_nr;
|
||||
while(true) {
|
||||
{
|
||||
InterruptLock il;
|
||||
if(_tx_buffer->empty()) {
|
||||
if(uart_get_tx_fifo_room(_uart) > 0) {
|
||||
uart_transmit_char(_uart, c);
|
||||
if(UART_GET_TX_FIFO_ROOM(uart_nr) > 0) {
|
||||
tx_now = true;
|
||||
} else {
|
||||
_tx_buffer->write(c);
|
||||
uart_arm_tx_interrupt(_uart);
|
||||
UART_ARM_TX_INTERRUPT(uart_nr);
|
||||
}
|
||||
break;
|
||||
} else if(_tx_buffer->write(c)) {
|
||||
break;
|
||||
} else if(il.savedInterruptLevel() > 0) {
|
||||
_tx_empty_irq();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
yield();
|
||||
}
|
||||
if (tx_now) {
|
||||
UART_TRANSMIT_CHAR(uart_nr, c);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -651,26 +678,21 @@ HardwareSerial::operator bool() const {
|
||||
return _uart != 0;
|
||||
}
|
||||
|
||||
void HardwareSerial::_rx_complete_irq(char c) {
|
||||
if(_rx_buffer) {
|
||||
_rx_buffer->write(c);
|
||||
}
|
||||
void ICACHE_RAM_ATTR HardwareSerial::_rx_complete_irq(char c) {
|
||||
_rx_buffer->write(c);
|
||||
}
|
||||
|
||||
void HardwareSerial::_tx_empty_irq(void) {
|
||||
if(_uart == 0)
|
||||
return;
|
||||
if(_tx_buffer == 0)
|
||||
return;
|
||||
void ICACHE_RAM_ATTR HardwareSerial::_tx_empty_irq(void) {
|
||||
const int uart_nr = _uart->uart_nr;
|
||||
size_t queued = _tx_buffer->getSize();
|
||||
if(!queued) {
|
||||
uart_disarm_tx_interrupt(_uart);
|
||||
UART_DISARM_TX_INTERRUPT(uart_nr);
|
||||
return;
|
||||
}
|
||||
|
||||
size_t room = uart_get_tx_fifo_room(_uart);
|
||||
size_t room = UART_GET_TX_FIFO_ROOM(uart_nr);
|
||||
int n = static_cast<int>((queued < room) ? queued : room);
|
||||
while(n--) {
|
||||
uart_transmit_char(_uart, _tx_buffer->read());
|
||||
UART_TRANSMIT_CHAR(uart_nr, _tx_buffer->read());
|
||||
}
|
||||
}
|
||||
|
@ -117,7 +117,6 @@ class HardwareSerial: public Stream {
|
||||
uart_t* _uart;
|
||||
cbuf* _tx_buffer;
|
||||
cbuf* _rx_buffer;
|
||||
bool _written;
|
||||
};
|
||||
|
||||
extern HardwareSerial Serial;
|
||||
|
45
cores/esp8266/cbuf.cpp
Normal file
45
cores/esp8266/cbuf.cpp
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
cbuf.cpp - Circular buffer implementation
|
||||
Copyright (c) 2014 Ivan Grokhotkov. All rights reserved.
|
||||
This file is part of the esp8266 core for Arduino environment.
|
||||
|
||||
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 "cbuf.h"
|
||||
#include "c_types.h"
|
||||
|
||||
size_t ICACHE_RAM_ATTR cbuf::getSize() const {
|
||||
if(_end >= _begin) {
|
||||
return _end - _begin;
|
||||
}
|
||||
return _size - (_begin - _end);
|
||||
}
|
||||
|
||||
int ICACHE_RAM_ATTR cbuf::read() {
|
||||
if(empty()) return -1;
|
||||
|
||||
char result = *_begin;
|
||||
_begin = wrap_if_bufend(_begin + 1);
|
||||
return static_cast<int>(result);
|
||||
}
|
||||
|
||||
size_t ICACHE_RAM_ATTR cbuf::write(char c) {
|
||||
if(full()) return 0;
|
||||
|
||||
*_end = c;
|
||||
_end = wrap_if_bufend(_end + 1);
|
||||
return 1;
|
||||
}
|
@ -21,7 +21,10 @@
|
||||
#ifndef __cbuf_h
|
||||
#define __cbuf_h
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
class cbuf {
|
||||
public:
|
||||
cbuf(size_t size) :
|
||||
@ -32,11 +35,7 @@ class cbuf {
|
||||
delete[] _buf;
|
||||
}
|
||||
|
||||
size_t getSize() const {
|
||||
if(_end >= _begin) return _end - _begin;
|
||||
|
||||
return _size - (_begin - _end);
|
||||
}
|
||||
size_t getSize() const;
|
||||
|
||||
size_t room() const {
|
||||
if(_end >= _begin) {
|
||||
@ -45,23 +44,21 @@ class cbuf {
|
||||
return _begin - _end - 1;
|
||||
}
|
||||
|
||||
bool empty() const {
|
||||
inline bool empty() const {
|
||||
return _begin == _end;
|
||||
}
|
||||
|
||||
inline bool full() const {
|
||||
return wrap_if_bufend(_end + 1) == _begin;
|
||||
}
|
||||
|
||||
int peek() {
|
||||
if(_end == _begin) return -1;
|
||||
if(empty()) return -1;
|
||||
|
||||
return static_cast<int>(*_begin);
|
||||
}
|
||||
|
||||
int read() {
|
||||
if(getSize() == 0) return -1;
|
||||
|
||||
char result = *_begin;
|
||||
_begin = wrap_if_bufend(_begin + 1);
|
||||
return static_cast<int>(result);
|
||||
}
|
||||
int read();
|
||||
|
||||
size_t read(char* dst, size_t size) {
|
||||
size_t bytes_available = getSize();
|
||||
@ -79,13 +76,7 @@ class cbuf {
|
||||
return size_read;
|
||||
}
|
||||
|
||||
size_t write(char c) {
|
||||
if(room() == 0) return 0;
|
||||
|
||||
*_end = c;
|
||||
_end = wrap_if_bufend(_end + 1);
|
||||
return 1;
|
||||
}
|
||||
size_t write(char c);
|
||||
|
||||
size_t write(const char* src, size_t size) {
|
||||
size_t bytes_available = room();
|
||||
@ -109,7 +100,7 @@ class cbuf {
|
||||
}
|
||||
|
||||
private:
|
||||
inline char* wrap_if_bufend(char* ptr) {
|
||||
inline char* wrap_if_bufend(char* ptr) const {
|
||||
return (ptr == _bufend) ? _buf : ptr;
|
||||
}
|
||||
|
||||
|
@ -31,6 +31,10 @@ public:
|
||||
xt_wsr_ps(_state);
|
||||
}
|
||||
|
||||
uint32_t savedInterruptLevel() const {
|
||||
return _state & 0x0f;
|
||||
}
|
||||
|
||||
protected:
|
||||
uint32_t _state;
|
||||
};
|
||||
|
BIN
doc/Troubleshooting/debug_level.png
Normal file
BIN
doc/Troubleshooting/debug_level.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
doc/Troubleshooting/debug_port.png
Normal file
BIN
doc/Troubleshooting/debug_port.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 34 KiB |
102
doc/Troubleshooting/debugging.md
Normal file
102
doc/Troubleshooting/debugging.md
Normal file
@ -0,0 +1,102 @@
|
||||
---
|
||||
title: Debugging
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
* [Introduction](#introduction)
|
||||
* [Requirements](#requirements)
|
||||
* [Usage](#Usage)
|
||||
* [Informations](#Informations)
|
||||
* [For Developers](#for-developers)
|
||||
|
||||
## Introduction
|
||||
|
||||
Since 2.1.0-rc1 the core includes a Debugging feature that is controllable over the IDE menu.
|
||||
|
||||
The new menu points manage the real-time Debug messages.
|
||||
|
||||
### Requirements
|
||||
|
||||
For usage of the debugging a Serial connection is required (Serial or Serial1).
|
||||
|
||||
The Serial Interface need to be initialized in the ```setup()```.
|
||||
|
||||
Set the Serial baud rate as high as possible for your Hardware setup.
|
||||
|
||||
Minimum sketch to use debugging:
|
||||
```cpp
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
}
|
||||
|
||||
void loop() {
|
||||
}
|
||||
```
|
||||
|
||||
### Usage
|
||||
|
||||
1. Select the Serial interface for the Debugging messages:
|
||||

|
||||
|
||||
2. Select which type / level you want debug messages for:
|
||||

|
||||
|
||||
3. Check if the Serial interface is initialized in ```setup()``` (see [Requirements](#requirements))
|
||||
|
||||
4. Flash sketch
|
||||
|
||||
5. Check the Serial Output
|
||||
|
||||
|
||||
|
||||
## Informations
|
||||
|
||||
It work with every sketch that enables the Serial interface that is selected as debug port.
|
||||
|
||||
The Serial interface can still be used normal in the Sketch.
|
||||
|
||||
The debug output is additional and will not disable any interface from usage in the sketch.
|
||||
|
||||
### For Developers
|
||||
|
||||
For the debug handling uses defines.
|
||||
|
||||
The defined are set by command line.
|
||||
|
||||
#### Debug Port
|
||||
|
||||
The port has the define ```DEBUG_ESP_PORT``` possible value:
|
||||
- Disabled: define not existing
|
||||
- Serial: Serial
|
||||
- Serial1: Serial1
|
||||
|
||||
#### Debug Level
|
||||
|
||||
All defines for the different levels starts with ```DEBUG_ESP_```
|
||||
|
||||
a full list can be found here in the [boards.txt](https://github.com/esp8266/Arduino/blob/master/boards.txt#L180)
|
||||
|
||||
#### Example for own debug messages
|
||||
|
||||
The debug messages will be only shown when the Debug Port in the IDE menu is set.
|
||||
|
||||
```cpp
|
||||
#ifdef DEBUG_ESP_PORT
|
||||
#define DEBUG_MSG(...) DEBUG_ESP_PORT.printf( __VA_ARGS__ )
|
||||
#else
|
||||
#define DEBUG_MSG(...)
|
||||
#endif
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
delay(3000);
|
||||
DEBUG_MSG("bootup...\n");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
DEBUG_MSG("loop %d\n", millis());
|
||||
delay(1000);
|
||||
}
|
||||
```
|
||||
|
@ -6,10 +6,44 @@ title: Change Log
|
||||
|
||||
### Core
|
||||
|
||||
- Allow control of enabling debug and debug level from IDE
|
||||
- Make HardwareSerial::begin() and end() interrupt safe
|
||||
- Put HardwareSerial and cbuf methods called from interrupt context in RAM
|
||||
- Re-enable interrupts before directly enqueuing characters in the UART FIFO
|
||||
- Add espduino board
|
||||
- Rework StreamString::write to use String internal buffer directly (#1289)
|
||||
- Add function to measure stack high water mark
|
||||
- Update SDK to esp_iot_sdk_v1.5.0_15_12_15_p1
|
||||
- Fix RAM corruption caused by our hook of register_chipv6_phy(init_data*).
|
||||
- Optimize PWM interrupt handler for better precision
|
||||
- Add warning levels configurable through Preferences
|
||||
- Protect HardwareSerial's cbuf usage with InterruptLock
|
||||
- SPIFFS: check if path length is valid (#1089)
|
||||
- Set CPU frequency before running setup
|
||||
- Add core_esp8266_features.h to be able to detect the features and libraries included in the ESP core
|
||||
- Added ESPino to supported boards
|
||||
|
||||
### Libraries
|
||||
|
||||
- ESP8266HTTPClient: add CHUNKED encoding support (#1324)
|
||||
- Fixed crash bug with mDNS where a string buffer could be used uninitialized
|
||||
- Add WiFi TX power control
|
||||
- Add WiFi sleep management
|
||||
- Allow to hook into WiFi events from sketch
|
||||
- Allow setting TCP timeout
|
||||
- Add setSleepMode + getSleepMode and setPhyMode + getPhyMode to WiFi
|
||||
- Update GDBStub library with the source of esp-gdbstub
|
||||
- Servo: fix detach and attach
|
||||
- ESP8266mDNS: refactoring, add TXT support
|
||||
- Add HTTP Basic Auth to WebServer and libb64 (base64) to core
|
||||
- Fix link-time dependency of ESP8266WebServer on SPIFFS (#862)
|
||||
- Allow setting client side TLS key and certificate
|
||||
- Replace chain of UDP pbufs with a single pbuf before sending (#1009)
|
||||
|
||||
### Tools
|
||||
|
||||
- espota.py: add support for manually selecting ip and port for host side
|
||||
|
||||
---
|
||||
## 2.0.0
|
||||
November 30, 2015
|
||||
|
@ -141,6 +141,7 @@ While many RC servo motors will accept the 3.3V IO data pin from a ESP8266, most
|
||||
Libraries that don't rely on low-level access to AVR registers should work well. Here are a few libraries that were verified to work:
|
||||
|
||||
- [Adafruit_ILI9341](https://github.com/Links2004/Adafruit_ILI9341) - Port of the Adafruit ILI9341 for the ESP8266
|
||||
- [arduinoVNC](https://github.com/Links2004/arduinoVNC) - VNC Client for Arduino
|
||||
- [arduinoWebSockets](https://github.com/Links2004/arduinoWebSockets) - WebSocket Server and Client compatible with ESP8266 (RFC6455)
|
||||
- [aREST](https://github.com/marcoschwartz/aREST) - REST API handler library.
|
||||
- [Blynk](https://github.com/blynkkk/blynk-library) - easy IoT framework for Makers (check out the [Kickstarter page](http://tiny.cc/blynk-kick)).
|
||||
|
@ -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:
|
||||
|
||||
|
@ -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("[AP] IP config Invalid?!\n");
|
||||
ret = false;
|
||||
} else if(local_ip != info.ip.addr) {
|
||||
ip = info.ip.addr;
|
||||
DEBUG_WIFI("[AP] IP config not set correct?! new IP: %s\n", ip.toString().c_str());
|
||||
ret = false;
|
||||
}
|
||||
} else {
|
||||
DEBUG_WIFI("[AP] 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);
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
|
@ -127,7 +127,7 @@ wl_status_t ESP8266WiFiMulti::run(void) {
|
||||
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] SSID: %s\n", WiFi.SSID().c_str());
|
||||
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());
|
||||
|
@ -38,7 +38,6 @@ extern "C"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "cbuf.h"
|
||||
#include "include/ClientContext.h"
|
||||
#include "c_types.h"
|
||||
|
||||
|
@ -37,7 +37,6 @@ extern "C"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "cbuf.h"
|
||||
#include "include/ClientContext.h"
|
||||
#include "c_types.h"
|
||||
|
||||
|
@ -35,7 +35,6 @@ extern "C" {
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/tcp.h"
|
||||
#include "lwip/inet.h"
|
||||
#include "cbuf.h"
|
||||
#include "include/ClientContext.h"
|
||||
|
||||
WiFiServer::WiFiServer(IPAddress addr, uint16_t port)
|
||||
|
@ -39,7 +39,7 @@ cat << EOF > exclude.txt
|
||||
package
|
||||
EOF
|
||||
# Also include all files which are ignored by git
|
||||
git ls-files --other --ignored --exclude-standard --directory >> exclude.txt
|
||||
git ls-files --other --directory >> exclude.txt
|
||||
# Now copy files to $outdir
|
||||
rsync -a --exclude-from 'exclude.txt' $srcdir/ $outdir/
|
||||
rm exclude.txt
|
||||
|
@ -24,8 +24,9 @@ set -e
|
||||
|
||||
# some variable definitions
|
||||
tmp_path=$1
|
||||
arduinoESP_src="$tmp_path/arduino"
|
||||
version="$(git --work-tree=$arduinoESP_src describe --tags --always)"
|
||||
doc_src_path=$2
|
||||
arduinoESP_src=$(cd $PWD/..; pwd)
|
||||
version="$(git --work-tree=$arduinoESP_src --git-dir=$arduinoESP_src/.git describe --tags --always)"
|
||||
release_date=$(date "+%b_%d,_%Y") # format for badge link
|
||||
build_date=$(date "+%b %d, %Y")
|
||||
destination_path="$tmp_path/doc"
|
||||
@ -62,7 +63,8 @@ mkdir -p $destination_path/$version
|
||||
cp -R $arduinoESP_src/doc/* $destination_path/src
|
||||
|
||||
# download doc template
|
||||
git clone $doc_template_url $destination_path/build
|
||||
rsync -av $doc_src_path/ $destination_path/build/
|
||||
# git clone $doc_template_url $destination_path/build
|
||||
|
||||
# create versions.html file
|
||||
|
||||
@ -113,4 +115,3 @@ popd
|
||||
|
||||
# grab badge
|
||||
wget -q -O $destination_path/$version/badge.svg "https://img.shields.io/badge/updated-$release_date-blue.svg"
|
||||
|
||||
|
@ -5,11 +5,12 @@
|
||||
#
|
||||
# Modified since 2015-09-18 from Pascal Gollor (https://github.com/pgollor)
|
||||
# Modified since 2015-11-09 from Hristo Gochkov (https://github.com/me-no-dev)
|
||||
# Modified since 2016-01-03 from Matthew O'Gorman (https://githumb.com/mogorman)
|
||||
#
|
||||
# This script will push an OTA update to the ESP
|
||||
# use it like: python espota.py -i <ESP_IP_address> -p <ESP_port> [-a password] -f <sketch.bin>
|
||||
# use it like: python espota.py -i <ESP_IP_address> -I <Host_IP_address> -p <ESP_port> -P <Host_port> [-a password] -f <sketch.bin>
|
||||
# Or to upload SPIFFS image:
|
||||
# python espota.py -i <ESP_IP_address> -p <ESP_port> [-a password] -s -f <spiffs.bin>
|
||||
# python espota.py -i <ESP_IP_address> -I <Host_IP_address> -p <ESP_port> -P <HOST_port> [-a password] -s -f <spiffs.bin>
|
||||
#
|
||||
# Changes
|
||||
# 2015-09-18:
|
||||
@ -22,6 +23,10 @@
|
||||
# - Added digest authentication
|
||||
# - Enchanced error tracking and reporting
|
||||
#
|
||||
# Changes
|
||||
# 2016-01-03:
|
||||
# - Added more options to parser.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import socket
|
||||
@ -64,11 +69,10 @@ def update_progress(progress):
|
||||
sys.stderr.write('.')
|
||||
sys.stderr.flush()
|
||||
|
||||
def serve(remoteAddr, remotePort, password, filename, command = FLASH):
|
||||
def serve(remoteAddr, localAddr, remotePort, localPort, password, filename, command = FLASH):
|
||||
# Create a TCP/IP socket
|
||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
serverPort = random.randint(10000,60000)
|
||||
server_address = ('0.0.0.0', serverPort)
|
||||
server_address = (localAddr, localPort)
|
||||
logging.info('Starting on %s:%s', str(server_address[0]), str(server_address[1]))
|
||||
try:
|
||||
sock.bind(server_address)
|
||||
@ -82,7 +86,7 @@ def serve(remoteAddr, remotePort, password, filename, command = FLASH):
|
||||
file_md5 = hashlib.md5(f.read()).hexdigest()
|
||||
f.close()
|
||||
logging.info('Upload size: %d', content_size)
|
||||
message = '%d %d %d %s\n' % (command, serverPort, content_size, file_md5)
|
||||
message = '%d %d %d %s\n' % (command, localPort, content_size, file_md5)
|
||||
|
||||
# Wait for a connection
|
||||
logging.info('Sending invitation to: %s', remoteAddr)
|
||||
@ -209,12 +213,24 @@ def parser():
|
||||
help = "ESP8266 IP Address.",
|
||||
default = False
|
||||
)
|
||||
group.add_option("-I", "--host_ip",
|
||||
dest = "host_ip",
|
||||
action = "store",
|
||||
help = "Host IP Address.",
|
||||
default = "0.0.0.0"
|
||||
)
|
||||
group.add_option("-p", "--port",
|
||||
dest = "esp_port",
|
||||
type = "int",
|
||||
help = "ESP8266 ota Port. Default 8266",
|
||||
default = 8266
|
||||
)
|
||||
group.add_option("-P", "--host_port",
|
||||
dest = "host_port",
|
||||
type = "int",
|
||||
help = "Host server ota Port. Default random 10000-60000",
|
||||
default = random.randint(10000,60000)
|
||||
)
|
||||
parser.add_option_group(group)
|
||||
|
||||
# auth
|
||||
@ -294,7 +310,7 @@ def main(args):
|
||||
command = SPIFFS
|
||||
# end if
|
||||
|
||||
return serve(options.esp_ip, options.esp_port, options.auth, options.image, command)
|
||||
return serve(options.esp_ip, options.host_ip, options.esp_port, options.host_port, options.auth, options.image, command)
|
||||
# end main
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user