2015-12-29 12:25:37 +01:00
|
|
|
/*
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
|
|
* Martin d'Allens <martin.dallens@gmail.com> wrote this file. As long as you retain
|
|
|
|
* this notice you can do whatever you want with this stuff. If we meet some day,
|
|
|
|
* and you think this stuff is worth it, you can buy me a beer in return.
|
|
|
|
* ----------------------------------------------------------------------------
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FIXME: sprintf->snprintf everywhere.
|
|
|
|
* FIXME: support null characters in responses.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "osapi.h"
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
#include "../libc/c_stdio.h"
|
2015-12-29 12:25:37 +01:00
|
|
|
#include "user_interface.h"
|
|
|
|
#include "espconn.h"
|
|
|
|
#include "mem.h"
|
|
|
|
#include "limits.h"
|
|
|
|
#include "httpclient.h"
|
2016-04-09 13:54:10 +02:00
|
|
|
#include "stdlib.h"
|
2015-12-29 12:25:37 +01:00
|
|
|
|
2016-08-14 00:48:13 +02:00
|
|
|
#define REDIRECTION_FOLLOW_MAX 20
|
|
|
|
|
2015-12-29 12:25:37 +01:00
|
|
|
/* Internal state. */
|
|
|
|
typedef struct request_args_t {
|
|
|
|
char * hostname;
|
|
|
|
int port;
|
|
|
|
bool secure;
|
|
|
|
char * method;
|
|
|
|
char * path;
|
|
|
|
char * headers;
|
|
|
|
char * post_data;
|
|
|
|
char * buffer;
|
|
|
|
int buffer_size;
|
2016-08-14 00:48:13 +02:00
|
|
|
int redirect_follow_count;
|
2015-12-29 12:25:37 +01:00
|
|
|
int timeout;
|
|
|
|
os_timer_t timeout_timer;
|
|
|
|
http_callback_t callback_handle;
|
|
|
|
} request_args_t;
|
|
|
|
|
|
|
|
static char * ICACHE_FLASH_ATTR esp_strdup( const char * str )
|
|
|
|
{
|
|
|
|
if ( str == NULL )
|
|
|
|
{
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
char * new_str = (char *) os_malloc( os_strlen( str ) + 1 ); /* 1 for null character */
|
|
|
|
if ( new_str == NULL )
|
|
|
|
{
|
|
|
|
HTTPCLIENT_DEBUG( "esp_strdup: malloc error" );
|
|
|
|
return(NULL);
|
|
|
|
}
|
|
|
|
os_strcpy( new_str, str );
|
|
|
|
return(new_str);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ICACHE_FLASH_ATTR
|
|
|
|
esp_isupper( char c )
|
|
|
|
{
|
|
|
|
return(c >= 'A' && c <= 'Z');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ICACHE_FLASH_ATTR
|
|
|
|
esp_isalpha( char c )
|
|
|
|
{
|
|
|
|
return( (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ICACHE_FLASH_ATTR
|
|
|
|
esp_isspace( char c )
|
|
|
|
{
|
|
|
|
return(c == ' ' || c == '\t' || c == '\n' || c == '\12');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ICACHE_FLASH_ATTR
|
|
|
|
esp_isdigit( char c )
|
|
|
|
{
|
|
|
|
return(c >= '0' && c <= '9');
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int ICACHE_FLASH_ATTR http_chunked_decode( const char * chunked, char * decode )
|
|
|
|
{
|
|
|
|
int i = 0, j = 0;
|
|
|
|
int decode_size = 0;
|
|
|
|
char *str = (char *) chunked;
|
|
|
|
do
|
|
|
|
{
|
2016-04-09 13:54:10 +02:00
|
|
|
char * endstr;
|
2015-12-29 12:25:37 +01:00
|
|
|
/* [chunk-size] */
|
2016-04-09 13:54:10 +02:00
|
|
|
i = strtoul( str + j, NULL, 16 );
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "Chunk Size:%d", i );
|
2015-12-29 12:25:37 +01:00
|
|
|
if ( i <= 0 )
|
|
|
|
break;
|
|
|
|
/* [chunk-size-end-ptr] */
|
|
|
|
endstr = (char *) os_strstr( str + j, "\r\n" );
|
|
|
|
/* [chunk-ext] */
|
|
|
|
j += endstr - (str + j);
|
|
|
|
/* [CRLF] */
|
|
|
|
j += 2;
|
|
|
|
/* [chunk-data] */
|
|
|
|
decode_size += i;
|
|
|
|
os_memcpy( (char *) &decode[decode_size - i], (char *) str + j, i );
|
|
|
|
j += i;
|
|
|
|
/* [CRLF] */
|
|
|
|
j += 2;
|
|
|
|
}
|
|
|
|
while ( true );
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* footer CRLF
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
return(j);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR http_receive_callback( void * arg, char * buf, unsigned short len )
|
|
|
|
{
|
|
|
|
struct espconn * conn = (struct espconn *) arg;
|
|
|
|
request_args_t * req = (request_args_t *) conn->reverse;
|
|
|
|
|
|
|
|
if ( req->buffer == NULL )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Let's do the equivalent of a realloc(). */
|
|
|
|
const int new_size = req->buffer_size + len;
|
|
|
|
char * new_buffer;
|
|
|
|
if ( new_size > BUFFER_SIZE_MAX || NULL == (new_buffer = (char *) os_malloc( new_size ) ) )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "Response too long (%d)", new_size );
|
2015-12-29 12:25:37 +01:00
|
|
|
req->buffer[0] = '\0'; /* Discard the buffer to avoid using an incomplete response. */
|
|
|
|
if ( req->secure )
|
|
|
|
espconn_secure_disconnect( conn );
|
|
|
|
else
|
|
|
|
espconn_disconnect( conn );
|
|
|
|
return; /* The disconnect callback will be called. */
|
|
|
|
}
|
|
|
|
|
|
|
|
os_memcpy( new_buffer, req->buffer, req->buffer_size );
|
|
|
|
os_memcpy( new_buffer + req->buffer_size - 1 /*overwrite the null character*/, buf, len ); /* Append new data. */
|
|
|
|
new_buffer[new_size - 1] = '\0'; /* Make sure there is an end of string. */
|
|
|
|
|
|
|
|
os_free( req->buffer );
|
|
|
|
req->buffer = new_buffer;
|
|
|
|
req->buffer_size = new_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR http_send_callback( void * arg )
|
|
|
|
{
|
|
|
|
struct espconn * conn = (struct espconn *) arg;
|
|
|
|
request_args_t * req = (request_args_t *) conn->reverse;
|
|
|
|
|
|
|
|
if ( req->post_data == NULL )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "All sent" );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* The headers were sent, now send the contents. */
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "Sending request body" );
|
2015-12-29 12:25:37 +01:00
|
|
|
if ( req->secure )
|
|
|
|
espconn_secure_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) );
|
|
|
|
else
|
|
|
|
espconn_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) );
|
|
|
|
os_free( req->post_data );
|
|
|
|
req->post_data = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "Connected" );
|
2015-12-29 12:25:37 +01:00
|
|
|
struct espconn * conn = (struct espconn *) arg;
|
|
|
|
request_args_t * req = (request_args_t *) conn->reverse;
|
|
|
|
espconn_regist_recvcb( conn, http_receive_callback );
|
|
|
|
espconn_regist_sentcb( conn, http_send_callback );
|
|
|
|
|
|
|
|
char post_headers[32] = "";
|
|
|
|
|
|
|
|
if ( req->post_data != NULL ) /* If there is data then add Content-Length header. */
|
|
|
|
{
|
|
|
|
os_sprintf( post_headers, "Content-Length: %d\r\n", strlen( req->post_data ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
if(req->headers == NULL) /* Avoid NULL pointer, it may cause exception */
|
|
|
|
{
|
|
|
|
req->headers = (char *)os_malloc(sizeof(char));
|
|
|
|
req->headers[0] = '\0';
|
|
|
|
}
|
|
|
|
|
2016-08-11 05:22:31 +02:00
|
|
|
char ua_header[32] = "";
|
|
|
|
int ua_len = 0;
|
|
|
|
if (os_strstr( req->headers, "User-Agent:" ) == NULL && os_strstr( req->headers, "user-agent:" ) == NULL)
|
|
|
|
{
|
|
|
|
os_sprintf( ua_header, "User-Agent: %s\r\n", "ESP8266" );
|
|
|
|
ua_len = strlen(ua_header);
|
|
|
|
}
|
|
|
|
|
|
|
|
char host_header[32] = "";
|
|
|
|
int host_len = 0;
|
|
|
|
if ( os_strstr( req->headers, "Host:" ) == NULL && os_strstr( req->headers, "host:" ) == NULL)
|
|
|
|
{
|
|
|
|
if ((req->port == 80) || ((req->port == 443) && ( req->secure )))
|
|
|
|
{
|
|
|
|
os_sprintf( host_header, "Host: %s\r\n", req->hostname );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
os_sprintf( host_header, "Host: %s:%d\r\n", req->hostname, req->port );
|
|
|
|
}
|
|
|
|
host_len = strlen(host_header);
|
|
|
|
}
|
|
|
|
|
|
|
|
char buf[69 + strlen( req->method ) + strlen( req->path ) + host_len +
|
|
|
|
strlen( req->headers ) + ua_len + strlen( post_headers )];
|
|
|
|
int len = os_sprintf( buf,
|
|
|
|
"%s %s HTTP/1.1\r\n"
|
|
|
|
"%s" // Host (if not provided in the headers from Lua)
|
|
|
|
"Connection: close\r\n"
|
|
|
|
"%s" // Headers from Lua (optional)
|
|
|
|
"%s" // User-Agent (if not provided in the headers from Lua)
|
|
|
|
"%s" // Content-Length
|
|
|
|
"\r\n",
|
|
|
|
req->method, req->path, host_header, req->headers, ua_header, post_headers );
|
|
|
|
|
|
|
|
if (req->secure)
|
|
|
|
{
|
|
|
|
espconn_secure_send( conn, (uint8_t *) buf, len );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
espconn_send( conn, (uint8_t *) buf, len );
|
|
|
|
}
|
|
|
|
|
|
|
|
if (req->headers != NULL)
|
|
|
|
{
|
|
|
|
os_free( req->headers );
|
|
|
|
}
|
|
|
|
|
|
|
|
req->headers = NULL;
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "Sending request header" );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
|
2016-07-17 22:27:26 +02:00
|
|
|
static void http_free_req( request_args_t * req)
|
|
|
|
{
|
|
|
|
if (req->buffer) {
|
|
|
|
os_free( req->buffer );
|
|
|
|
}
|
|
|
|
if (req->post_data) {
|
|
|
|
os_free( req->post_data );
|
|
|
|
}
|
|
|
|
if (req->headers) {
|
|
|
|
os_free( req->headers );
|
|
|
|
}
|
|
|
|
os_free( req->hostname );
|
|
|
|
os_free( req->method );
|
|
|
|
os_free( req->path );
|
|
|
|
os_free( req );
|
|
|
|
}
|
2015-12-29 12:25:37 +01:00
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "Disconnected" );
|
2015-12-29 12:25:37 +01:00
|
|
|
struct espconn *conn = (struct espconn *) arg;
|
|
|
|
|
|
|
|
if ( conn == NULL )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( conn->proto.tcp != NULL )
|
|
|
|
{
|
|
|
|
os_free( conn->proto.tcp );
|
|
|
|
}
|
|
|
|
if ( conn->reverse != NULL )
|
|
|
|
{
|
|
|
|
request_args_t * req = (request_args_t *) conn->reverse;
|
|
|
|
int http_status = -1;
|
|
|
|
char * body = "";
|
|
|
|
|
|
|
|
// Turn off timeout timer
|
|
|
|
os_timer_disarm( &(req->timeout_timer) );
|
|
|
|
|
|
|
|
if ( req->buffer == NULL )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "Buffer probably shouldn't be NULL" );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
else if ( req->buffer[0] != '\0' )
|
|
|
|
{
|
|
|
|
/* FIXME: make sure this is not a partial response, using the Content-Length header. */
|
2016-01-26 09:06:11 +01:00
|
|
|
const char * version_1_0 = "HTTP/1.0 ";
|
|
|
|
const char * version_1_1 = "HTTP/1.1 ";
|
|
|
|
if (( os_strncmp( req->buffer, version_1_0, strlen( version_1_0 ) ) != 0 ) &&
|
|
|
|
( os_strncmp( req->buffer, version_1_1, strlen( version_1_1 ) ) != 0 ))
|
2015-12-29 12:25:37 +01:00
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "Invalid version in %s", req->buffer );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-01-26 09:06:11 +01:00
|
|
|
http_status = atoi( req->buffer + strlen( version_1_0 ) );
|
2016-08-14 00:48:13 +02:00
|
|
|
|
|
|
|
char *locationOffset = (char *) os_strstr( req->buffer, "Location:" );
|
|
|
|
if ( locationOffset == NULL ) {
|
|
|
|
locationOffset = (char *) os_strstr( req->buffer, "location:" );
|
2016-04-09 13:54:10 +02:00
|
|
|
}
|
2016-08-14 00:48:13 +02:00
|
|
|
|
|
|
|
if ( locationOffset != NULL && http_status >= 300 && http_status <= 308 ) {
|
|
|
|
if (req->redirect_follow_count < REDIRECTION_FOLLOW_MAX) {
|
|
|
|
locationOffset += strlen("location:");
|
|
|
|
|
|
|
|
while (*locationOffset == ' ') { // skip url leading white-space
|
|
|
|
locationOffset++;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *locationOffsetEnd = (char *) os_strstr(locationOffset, "\r\n");
|
|
|
|
if ( locationOffsetEnd == NULL ) {
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "Found Location header but was incomplete" );
|
2016-08-14 00:48:13 +02:00
|
|
|
http_status = -1;
|
|
|
|
} else {
|
|
|
|
*locationOffsetEnd = '\0';
|
|
|
|
req->redirect_follow_count++;
|
|
|
|
|
|
|
|
// Check if url is absolute
|
|
|
|
bool url_has_protocol =
|
|
|
|
os_strncmp( locationOffset, "http://", strlen( "http://" ) ) == 0 ||
|
|
|
|
os_strncmp( locationOffset, "https://", strlen( "https://" ) ) == 0;
|
|
|
|
|
|
|
|
if ( url_has_protocol ) {
|
|
|
|
http_request( locationOffset, req->method, req->headers,
|
|
|
|
req->post_data, req->callback_handle, req->redirect_follow_count );
|
|
|
|
} else {
|
|
|
|
if ( os_strncmp( locationOffset, "/", 1 ) == 0) { // relative and full path
|
|
|
|
http_raw_request( req->hostname, req->port, req->secure, req->method,
|
|
|
|
locationOffset, req->headers, req->post_data, req->callback_handle, req->redirect_follow_count );
|
|
|
|
} else { // relative and relative path
|
|
|
|
|
|
|
|
// find last /
|
|
|
|
const char *pathFolderEnd = strrchr(req->path, '/');
|
|
|
|
|
|
|
|
int pathFolderLength = pathFolderEnd - req->path;
|
|
|
|
pathFolderLength++; // use the '/'
|
|
|
|
int locationLength = strlen(locationOffset);
|
|
|
|
locationLength++; // use the '\0'
|
|
|
|
|
|
|
|
// append pathFolder with given relative path
|
|
|
|
char *completeRelativePath = (char *) os_malloc(pathFolderLength + locationLength);
|
|
|
|
os_memcpy( completeRelativePath, req->path, pathFolderLength );
|
|
|
|
os_memcpy( completeRelativePath + pathFolderLength, locationOffset, locationLength);
|
|
|
|
|
|
|
|
http_raw_request( req->hostname, req->port, req->secure, req->method,
|
|
|
|
completeRelativePath, req->headers, req->post_data, req->callback_handle, req->redirect_follow_count );
|
|
|
|
|
|
|
|
os_free( completeRelativePath );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
http_free_req( req );
|
|
|
|
espconn_delete( conn );
|
|
|
|
os_free( conn );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} else {
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR("Too many redirections");
|
2016-08-14 00:48:13 +02:00
|
|
|
http_status = -1;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
body = (char *) os_strstr(req->buffer, "\r\n\r\n");
|
|
|
|
|
|
|
|
if (NULL == body) {
|
|
|
|
/* Find missing body */
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR("Body shouldn't be NULL");
|
2016-08-14 00:48:13 +02:00
|
|
|
/* To avoid NULL body */
|
|
|
|
body = "";
|
|
|
|
} else {
|
|
|
|
/* Skip CR & LF */
|
|
|
|
body = body + 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( os_strstr( req->buffer, "Transfer-Encoding: chunked" ) )
|
|
|
|
{
|
|
|
|
int body_size = req->buffer_size - (body - req->buffer);
|
|
|
|
char chunked_decode_buffer[body_size];
|
|
|
|
os_memset( chunked_decode_buffer, 0, body_size );
|
|
|
|
/* Chuncked data */
|
|
|
|
http_chunked_decode( body, chunked_decode_buffer );
|
|
|
|
os_memcpy( body, chunked_decode_buffer, body_size );
|
|
|
|
}
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ( req->callback_handle != NULL ) /* Callback is optional. */
|
|
|
|
{
|
|
|
|
req->callback_handle( body, http_status, req->buffer );
|
|
|
|
}
|
2016-07-17 22:27:26 +02:00
|
|
|
http_free_req( req );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
/* Fix memory leak. */
|
|
|
|
espconn_delete( conn );
|
|
|
|
os_free( conn );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void ICACHE_FLASH_ATTR http_timeout_callback( void *arg )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "Connection timeout" );
|
2015-12-29 12:25:37 +01:00
|
|
|
struct espconn * conn = (struct espconn *) arg;
|
|
|
|
if ( conn == NULL )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( conn->reverse == NULL )
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
request_args_t * req = (request_args_t *) conn->reverse;
|
|
|
|
/* Call disconnect */
|
|
|
|
if ( req->secure )
|
|
|
|
espconn_secure_disconnect( conn );
|
|
|
|
else
|
|
|
|
espconn_disconnect( conn );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
static void ICACHE_FLASH_ATTR http_error_callback( void *arg, sint8 errType )
|
|
|
|
{
|
|
|
|
HTTPCLIENT_ERR( "Disconnected with error: %d", errType );
|
|
|
|
http_timeout_callback( arg );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-29 12:25:37 +01:00
|
|
|
static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_t * addr, void * arg )
|
|
|
|
{
|
|
|
|
request_args_t * req = (request_args_t *) arg;
|
|
|
|
|
|
|
|
if ( addr == NULL )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "DNS failed for %s", hostname );
|
2015-12-29 12:25:37 +01:00
|
|
|
if ( req->callback_handle != NULL )
|
|
|
|
{
|
|
|
|
req->callback_handle( "", -1, "" );
|
|
|
|
}
|
2016-07-17 22:27:26 +02:00
|
|
|
http_free_req( req );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "DNS found %s " IPSTR, hostname, IP2STR( addr ) );
|
2015-12-29 12:25:37 +01:00
|
|
|
|
2016-03-07 02:25:05 +01:00
|
|
|
struct espconn * conn = (struct espconn *) os_zalloc( sizeof(struct espconn) );
|
2015-12-29 12:25:37 +01:00
|
|
|
conn->type = ESPCONN_TCP;
|
|
|
|
conn->state = ESPCONN_NONE;
|
2016-03-07 02:25:05 +01:00
|
|
|
conn->proto.tcp = (esp_tcp *) os_zalloc( sizeof(esp_tcp) );
|
2015-12-29 12:25:37 +01:00
|
|
|
conn->proto.tcp->local_port = espconn_port();
|
|
|
|
conn->proto.tcp->remote_port = req->port;
|
|
|
|
conn->reverse = req;
|
|
|
|
|
|
|
|
os_memcpy( conn->proto.tcp->remote_ip, addr, 4 );
|
|
|
|
|
|
|
|
espconn_regist_connectcb( conn, http_connect_callback );
|
|
|
|
espconn_regist_disconcb( conn, http_disconnect_callback );
|
|
|
|
espconn_regist_reconcb( conn, http_error_callback );
|
|
|
|
|
|
|
|
/* Set connection timeout timer */
|
|
|
|
os_timer_disarm( &(req->timeout_timer) );
|
|
|
|
os_timer_setfn( &(req->timeout_timer), (os_timer_func_t *) http_timeout_callback, conn );
|
|
|
|
os_timer_arm( &(req->timeout_timer), req->timeout, false );
|
|
|
|
|
|
|
|
if ( req->secure )
|
|
|
|
{
|
|
|
|
espconn_secure_connect( conn );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
espconn_connect( conn );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-08-14 00:48:13 +02:00
|
|
|
void ICACHE_FLASH_ATTR http_raw_request( const char * hostname, int port, bool secure, const char * method, const char * path, const char * headers, const char * post_data, http_callback_t callback_handle, int redirect_follow_count )
|
2015-12-29 12:25:37 +01:00
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "DNS request" );
|
2015-12-29 12:25:37 +01:00
|
|
|
|
2016-03-07 02:25:05 +01:00
|
|
|
request_args_t * req = (request_args_t *) os_zalloc( sizeof(request_args_t) );
|
2015-12-29 12:25:37 +01:00
|
|
|
req->hostname = esp_strdup( hostname );
|
|
|
|
req->port = port;
|
|
|
|
req->secure = secure;
|
|
|
|
req->method = esp_strdup( method );
|
|
|
|
req->path = esp_strdup( path );
|
|
|
|
req->headers = esp_strdup( headers );
|
|
|
|
req->post_data = esp_strdup( post_data );
|
|
|
|
req->buffer_size = 1;
|
|
|
|
req->buffer = (char *) os_malloc( 1 );
|
|
|
|
req->buffer[0] = '\0'; /* Empty string. */
|
|
|
|
req->callback_handle = callback_handle;
|
|
|
|
req->timeout = HTTP_REQUEST_TIMEOUT_MS;
|
2016-08-14 00:48:13 +02:00
|
|
|
req->redirect_follow_count = redirect_follow_count;
|
2015-12-29 12:25:37 +01:00
|
|
|
|
|
|
|
ip_addr_t addr;
|
|
|
|
err_t error = espconn_gethostbyname( (struct espconn *) req, /* It seems we don't need a real espconn pointer here. */
|
|
|
|
hostname, &addr, http_dns_callback );
|
|
|
|
|
|
|
|
if ( error == ESPCONN_INPROGRESS )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "DNS pending" );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
else if ( error == ESPCONN_OK )
|
|
|
|
{
|
|
|
|
/* Already in the local names table (or hostname was an IP address), execute the callback ourselves. */
|
|
|
|
http_dns_callback( hostname, &addr, req );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if ( error == ESPCONN_ARG )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "DNS arg error %s", hostname );
|
2015-12-29 12:25:37 +01:00
|
|
|
}else {
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "DNS error code %d", error );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
http_dns_callback( hostname, NULL, req ); /* Handle all DNS errors the same way. */
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse an URL of the form http://host:port/path
|
|
|
|
* <host> can be a hostname or an IP address
|
|
|
|
* <port> is optional
|
|
|
|
*/
|
2016-08-14 00:48:13 +02:00
|
|
|
void ICACHE_FLASH_ATTR http_request( const char * url, const char * method, const char * headers, const char * post_data, http_callback_t callback_handle, int redirect_follow_count )
|
2015-12-29 12:25:37 +01:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
* FIXME: handle HTTP auth with http://user:pass@host/
|
|
|
|
* FIXME: get rid of the #anchor part if present.
|
|
|
|
*/
|
|
|
|
|
|
|
|
char hostname[128] = "";
|
|
|
|
int port = 80;
|
|
|
|
bool secure = false;
|
|
|
|
|
|
|
|
bool is_http = os_strncmp( url, "http://", strlen( "http://" ) ) == 0;
|
|
|
|
bool is_https = os_strncmp( url, "https://", strlen( "https://" ) ) == 0;
|
|
|
|
|
|
|
|
if ( is_http )
|
|
|
|
url += strlen( "http://" ); /* Get rid of the protocol. */
|
|
|
|
else if ( is_https )
|
|
|
|
{
|
|
|
|
port = 443;
|
|
|
|
secure = true;
|
|
|
|
url += strlen( "https://" ); /* Get rid of the protocol. */
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "URL is not HTTP or HTTPS %s", url );
|
2015-12-29 12:25:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char * path = os_strchr( url, '/' );
|
|
|
|
if ( path == NULL )
|
|
|
|
{
|
|
|
|
path = os_strchr( url, '\0' ); /* Pointer to end of string. */
|
|
|
|
}
|
|
|
|
|
|
|
|
char * colon = os_strchr( url, ':' );
|
|
|
|
if ( colon > path )
|
|
|
|
{
|
|
|
|
colon = NULL; /* Limit the search to characters before the path. */
|
|
|
|
}
|
|
|
|
|
2016-03-07 02:25:05 +01:00
|
|
|
if (path - url >= sizeof(hostname)) {
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "hostname is too long %s", url );
|
2016-03-07 02:25:05 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-12-29 12:25:37 +01:00
|
|
|
if ( colon == NULL ) /* The port is not present. */
|
|
|
|
{
|
|
|
|
os_memcpy( hostname, url, path - url );
|
|
|
|
hostname[path - url] = '\0';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
port = atoi( colon + 1 );
|
|
|
|
if ( port == 0 )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_ERR( "Port error %s", url );
|
2015-12-29 12:25:37 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
os_memcpy( hostname, url, colon - url );
|
|
|
|
hostname[colon - url] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( path[0] == '\0' ) /* Empty path is not allowed. */
|
|
|
|
{
|
|
|
|
path = "/";
|
|
|
|
}
|
|
|
|
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
HTTPCLIENT_DEBUG( "hostname=%s", hostname );
|
|
|
|
HTTPCLIENT_DEBUG( "port=%d", port );
|
|
|
|
HTTPCLIENT_DEBUG( "method=%s", method );
|
|
|
|
HTTPCLIENT_DEBUG( "path=%s", path );
|
2016-08-14 00:48:13 +02:00
|
|
|
http_raw_request( hostname, port, secure, method, path, headers, post_data, callback_handle, redirect_follow_count);
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Parse an URL of the form http://host:port/path
|
|
|
|
* <host> can be a hostname or an IP address
|
|
|
|
* <port> is optional
|
|
|
|
*/
|
|
|
|
void ICACHE_FLASH_ATTR http_post( const char * url, const char * headers, const char * post_data, http_callback_t callback_handle )
|
|
|
|
{
|
2016-08-14 00:48:13 +02:00
|
|
|
http_request( url, "POST", headers, post_data, callback_handle, 0 );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ICACHE_FLASH_ATTR http_get( const char * url, const char * headers, http_callback_t callback_handle )
|
|
|
|
{
|
2016-08-14 00:48:13 +02:00
|
|
|
http_request( url, "GET", headers, NULL, callback_handle, 0 );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ICACHE_FLASH_ATTR http_delete( const char * url, const char * headers, const char * post_data, http_callback_t callback_handle )
|
|
|
|
{
|
2016-08-14 00:48:13 +02:00
|
|
|
http_request( url, "DELETE", headers, post_data, callback_handle, 0 );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ICACHE_FLASH_ATTR http_put( const char * url, const char * headers, const char * post_data, http_callback_t callback_handle )
|
|
|
|
{
|
2016-08-14 00:48:13 +02:00
|
|
|
http_request( url, "PUT", headers, post_data, callback_handle, 0 );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void ICACHE_FLASH_ATTR http_callback_example( char * response, int http_status, char * full_response )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
dbg_printf( "http_status=%d\n", http_status );
|
2015-12-29 12:25:37 +01:00
|
|
|
if ( http_status != HTTP_STATUS_GENERIC_ERROR )
|
|
|
|
{
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
dbg_printf( "strlen(full_response)=%d\n", strlen( full_response ) );
|
|
|
|
dbg_printf( "response=%s<EOF>\n", response );
|
2015-12-29 12:25:37 +01:00
|
|
|
}
|
|
|
|
}
|
Next 1.5.4.1 master drop (#1627)
* add u8g.fb_rle display
* move comm drivers to u8g_glue.c
* disable fb_rle per default
* implement file.size for spiffs (#1516)
Another bug squashed!
* Fix start-up race between UART & start_lua. (#1522)
Input during startup (especially while doing initial filesystem format)
ran the risk of filling up the task queue, preventing the start_lua task
from being queued, and hence NodeMCU would not start up that time.
* Reimplemented esp_init_data_default.
To work around the pesky "rf_cal[0] !=0x05" hang when booting on a chip
which doesn't have esp_init_data written to it.
It is no longer possible to do the writing of the esp_init_data_default
from within nodemcu_init(), as the SDK now hangs long before it gets
there. As such, I've had to reimplement this in our user_start_trampoline
and get it all done before the SDK has a chance to look for the init data.
It's unfortunate that we have to spend IRAM on this, but I see no better
alternative at this point.
* Replace hardcoded init data with generated data from SDK
The esp_init_data_default.bin is now extracted from the SDK (and its
patch file, if present), and the contents are automatically embedded
into user_main.o.
* Rework flashing instructions
Clarifies issues around SDK init data and hopefully clears up some
confusion, when paired with the esp_init_data_default changes in
NodeMCU.
* Fix typo
* Fixes the gpio.serout problem from #1534 (#1535)
* Fix some issues in gpio.serout
* Minor cleanup
* fix dereferencing NULL pointer in vfs_errno() (#1539)
* add map ids for flash sizes 32m-c2, 64m, 128m in user_rf_cal_sector_set() (#1529)
* Somfy/TELIS driver (#1521)
* Reduced LUAL_BUFFERSIZE to 256. Should free up some stack (#1530)
* avoid task queue overrun for serial input (#1540)
Thank you.
* Increase irom0_0_seg size for PR build
* Improve reliability of FS detection. (#1528)
* Version to make filesystem detection more reliable
* Improve bad fs detection
* Version of printf that doesn't suffer from buffer overflows (#1564)
* Small improvement to http client (#1558)
* Remove luaL_buffer from file_g_read() (#1541)
* remove luaL_buffer from file_g_read()
- avoid memory leak when function gets terminated by lua_error
- skip scanning for end_char when reading until EOF
* attempt to free memory in any case
* Change HTTP failures from debug to error messages (#1568)
* Change HTTP failures from debug to error messages
* Add tag to HTTP error messages
* Create macro for error msg and improve dbg msg
* Add ssd1306_128x32 for U8G (#1571)
* Update CONTRIBUTING.md
* Add support to mix ws2812.buffer objects. (#1575)
* Add load/dump/mix/power operations on the buffer object
* Calculate the pixel value in mix and then clip to the range.
* Fixed the two wrong userdata types
* Added a couple more useful methods
* Add support for shifting a piece of the buffer.
* Fix a minor bug with offset shifts
* Update to the wifi module (#1497)
* Removed inline documentation for several functions and update comments
Since documentation is now part of the repository, the inline
documentation just adds to the already huge wifi.c
* Wifi module: add new functionality, update documentation
Functions Added:
wifi.getdefaultmode(): returns default wifi opmode
wifi.sta.apchange(): select alternate cached AP
wifi.sta.apinfo(): get cached AP list
wifi.sta.aplimit(): set cached AP limit
wifi.sta.getapindex(): get index of currently configured AP
wifi.sta.getdefaultconfig(): get default station configuration
wifi.ap.getdefaultconfig(): get default AP configuration
functions modified:
wifi.setmode: saving mode to flash is now optional
wifi.sta.config: now accepts table as an argument and save config to
flash is now optional
wifi.sta.getconfig: added option to return table
wifi.ap.config: save config to flash is now optional
wifi.ap.getconfig: added option to return table
Documentation changes:
- Modified documentation to reflect above changes
- Removed unnecessary inline documentation from `wifi.c`
- Updated documentation for `wifi.sta.disconnect`to address issue #1480
- Fixed inaccurate documentation for function `wifi.sleeptype`
- Added more details to `wifi.nullmodesleep()`
* Move function `wifi.sleeptype()` to `wifi.sta.sleeptype()`
* Fixed problem where wifi.x.getconfig() returned invalid strings when
ssid or password were set to maximum length.
* fix error in documentation for `wifi.sta.getapindex`
* Renamed some wifi functions
wifi.sta.apinfo -> getapinfo
wifi.sta.aplimit -> setaplimit
wifi.sta.apchange -> changeap
also organized the wifi_station_map array
* Make the MQTT PING functionality work better. (#1557)
Deal with flow control stopped case
* Implement object model for files (#1532)
* Eus channelfix (#1583)
Squashed commits included:
Bug fixes and final implementation
- Added Content-Length: 0 to all headers
- Endpoint name checks not using trailing space so cache-busting techniques can be used (i.e., append a nonce to the URL)
- Track when connecting so APList scan doesn't take place during (which changes the channel)
- More debugging output added to assist in tracking down some issues
Added /status.json endpoint for phone apps/XHR to get JSON response
Station Status caching for wifi channel workaround + AJAX/CORS
- During checkstation poll, cache the last station status
- Shut down the station if status = 2,3,4 and channel is different than SoftAP
- Add Access-Control-Allow-Origin: * to endpoint responses used by a service
- Add a /setwifi GET endpoint for phone apps/XHR to use (same parameters as /update endpoint). Returns a JSON response containing chip id and status code.
- Add handler for OPTIONS verb (needed for CORS support)
Wi-Fi Channel Issue Workaround
- Do a site survey upon startup, set SoftAP channel to the strongest rssi's channel
- Compare successful station connect channel to SoftAP's. If different, then defer the Lua success callback to the end. Shut down Station and start the SoftAP back up with original channel.
- After the 10 second shutdown timer fires, check to see if success callback was already called. If not, then call it while starting the Station back up.
HTTP Response and DNS enhancements
- If DNS's UDP buffer fills up, keep going as non-fatal. It's UDP and not guaranteed anyways. I've seen this occur when connecting a PC to the SoftAP and every open program tries to phone home at the same time, overwhelming the EUS DNS server.
- Support for detecting/handling pre-gzipped `enduser_setup.html` (and `http_html_backup`) payload. Nice for keeping the size of the `state->http_payload_data` as small as possible (also makes minimization not as critical)
- Corrected misuse of HTTP 401 response status (changed one occurrence to 400/Bad Request, and changed another to 405/Method Not Allowed)
* Normalized formatting (tabs-to-spaces)
* Added documentation
* Corrected misuse of strlen for binary (gzip) data.
* Added NULL check after malloc
* fix vfs_lseek() result checking in enduser_setup and clarify SPIFFS_lseek() return value (#1570)
* Fix link
* Overhaul flashing docs once again (#1587)
* Add chapter about determine flash size plus small fixes
* Rewrite esptool.py chapter, move flash size chapter to end
* i2c - allow slave stretching SCL (just loop and check) (#1589)
* Add note on dev board usage of SPI bus 0 (#1591)
* Turn SPI busses note to admonition note
* support for custom websocket headers (#1573)
Looks good to me. Thank you.
Also:
- allow for '\0's in received messages
* add client:config for setting websocket headers
Also:
- headers are case-insensitive now
* fix docs
* fix typo
* remove unnecessary luaL_argcheck calls
* replace os_sprintf with simple string copy
* Handle error condition in file.read() (#1599)
* handle error condition in file.read()
* simplify loop initialization
* Fix macro as suggested in #1548
* Extract and hoist net receive callbacks
This is done to avoid the accidental upval binding
* Fix typo at rtctime.md
rtctime.dsleep -> rtctime.dsleep_aligned
2016-12-01 21:37:24 +01:00
|
|
|
|