Commit ecf9c644 authored by Marcel Stör's avatar Marcel Stör
Browse files

Revert "Next 1.5.4.1 master drop (#1627)"

This reverts commit 04ce0adf.
parent ec265a6c
......@@ -4,22 +4,16 @@
The following is a set of guidelines for contributing to NodeMCU on GitHub. These are just guidelines, not rules, use your best judgment and feel free to propose changes to this document in a pull request.
It is appreciated if you raise an issue _before_ you start changing NodeMCU, discussing the proposed change; emphasing that the you are proposing to develop the patch yourself, and outlining the strategy for implementation. This type of discussion is what we should be doing on the issues list and it is better to do this before or in parallel to developing the patch rather than having "you should have done it this way" type of feedback on the PR itself.
It is appreciated but optional if you raise an issue _before_ you start changing NodeMCU, discussing the proposed change; emphasing that the you are proposing to develop the patch yourself, and outlining the strategy for implementation. This type of discussion is what we should be doing on the issues list and it is better to do this before or in parallel to developing the patch rather than having "you should have done it this way" type of feedback on the PR itself.
### Table Of Contents
* [General remarks](#general-remarks)
* [Development environment setup](#development-environment-setup)
* [Writing Documentation](#writing-documentation)
* [Working with Git and GitHub](#working-with-git-and-github)
* [General flow](#general-flow)
* [Keeping your fork in sync](#keeping-your-fork-in-sync)
* [Commit messages](#commit-messages)
* [For collaborators](#for-collaborators)
* [Handling releases](#handling-release)
## General remarks
We are a friendly and welcoming community and look forward to your contributions. Once your contribution is integrated into this repository we feel responsible for it. Therefore, be prepared for constructive feedback. Before we merge anything we need to ensure that it fits in and is consistent with the rest of NodeMCU.
If you made something really cool but won't spend time to integrate it into this upstream project please still share it in your fork on GitHub. If you mention it in an issues we'll take a look at it anyway.
## Development environment setup
Use the platform and tools you feel most comfortable with. There are no constraints imposed by this project. You have (at least) two options to set up the toolchain to build the NodeMCU firmware:
......@@ -58,7 +52,7 @@ Avoid intermediate merge commits. [Rebase](https://www.atlassian.com/git/tutoria
1. `git checkout <branch-name>`
1. Make changes to the code base and commit them using e.g. `git commit -a -m 'Look ma, I did it'`
1. When you're done:
1. Think about [squashing (some of) your commits](http://www.andrewconnell.com/blog/squash-multiple-git-commits-into-one). There are [several ways](http://stackoverflow.com/a/5201642/131929) to do this. There's no need to squash everything into a single commit as GitHub offers to do this when we merge your changes. However, you might want to trim your commit history to relevant chunks.
1. [Squash your commits](http://www.andrewconnell.com/blog/squash-multiple-git-commits-into-one). There are [several ways](http://stackoverflow.com/a/5201642/131929) of doing this.
1. Bring your fork up-to-date with the NodeMCU upstream repo ([see below](#keeping-your-fork-in-sync)). Then rebase your branch on `dev` running `git rebase dev`.
1. `git push`
1. [Create a pull request](https://help.github.com/articles/creating-a-pull-request/) (PR) on GitHub.
......@@ -96,15 +90,3 @@ Further paragraphs come after blank lines.
Don't forget to [reference affected issues](https://help.github.com/articles/closing-issues-via-commit-messages/) in the commit message to have them closed automatically on GitHub.
[Amend](https://help.github.com/articles/changing-a-commit-message/) your commit messages if necessary to make sure what the world sees on GitHub is as expressive and meaningful as possible.
## For collaborators
### Handling releases
- Create a [milestone](https://github.com/nodemcu/nodemcu-firmware/milestones) right after you cut a new release. Give it a meaningful name if you already have an idea what the scope of the upcoming release is going to be. Also set the due date to ~2 months in the future.
- Add this milestone to every PR before you merge it. Also add the milestone to PRs you want to see land in this milestone.
- Add notes to the description of the milestone in the course of the ~2 months it lives.
- Be careful and reluctant to merge PRs once we're past the 6-weeks mark of a milestone. Ideally we don't merge anything in the last 2 weeks.
- Cutting a release
- Create an annotated tag like so: `git tag -a <SDK-version>-master_<yyyyMMdd> -m ""`, `git push --tags`
- Create a new [release](https://github.com/nodemcu/nodemcu-firmware/releases) based on the tag you just pushed. The version name is the same as the tag name.
- Write release notes. Mention breaking changes explicitly. Since every PR that went into this release is linked to from the milestone it should be fairly easy to include important changes in the release notes.
......@@ -207,14 +207,14 @@ sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER)
$(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER): $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_FILE_VER).zip
mkdir -p "$(dir $@)"
(cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK/lib/* ESP8266_NONOS_SDK/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK/include/* ESP8266_NONOS_SDK/bin/esp_init_data_default.bin)
(cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK/lib/* ESP8266_NONOS_SDK/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK/include/* )
mv $(dir $@)/ESP8266_NONOS_SDK $(dir $@)/esp_iot_sdk_v$(SDK_VER)
rm -f $(SDK_DIR)/lib/liblwip.a
touch $@
$(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER).zip
mkdir -p "$(dir $@)/patch"
(cd "$(dir $@)/patch" && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER)*.zip *.a esp_init_data_default.bin && mv *.a $(SDK_DIR)/lib/ && mv esp_init_data_default.bin $(SDK_DIR)/bin/)
(cd "$(dir $@)/patch" && unzip $(TOP_DIR)/cache/esp_iot_sdk_v$(SDK_PATCH_VER)*.zip *.a && mv *.a $(SDK_DIR)/lib/)
rmdir $(dir $@)/patch
rm -f $(SDK_DIR)/lib/liblwip.a
touch $@
......
......@@ -33,8 +33,6 @@ LOCAL uint8 pinSCL = 15;
LOCAL void ICACHE_FLASH_ATTR
i2c_master_setDC(uint8 SDA, uint8 SCL)
{
uint8 sclLevel;
SDA &= 0x01;
SCL &= 0x01;
m_nLastSDA = SDA;
......@@ -49,11 +47,6 @@ i2c_master_setDC(uint8 SDA, uint8 SCL)
} else {
I2C_MASTER_SDA_HIGH_SCL_HIGH();
}
if(1 == SCL) {
do {
sclLevel = GPIO_INPUT_GET(GPIO_ID_PIN(I2C_MASTER_SCL_GPIO));
} while(sclLevel == 0);
}
}
/******************************************************************************
......
......@@ -30,8 +30,6 @@
// For event signalling
static task_handle_t sig = 0;
static uint8 *sig_flag;
static uint8 isr_flag = 0;
// UartDev is defined and initialized in rom code.
extern UartDevice UartDev;
......@@ -279,12 +277,8 @@ uart0_rx_intr_handler(void *para)
got_input = true;
}
if (got_input && sig) {
if (isr_flag == *sig_flag) {
isr_flag ^= 0x01;
task_post_low (sig, 0x8000 | isr_flag << 14 | false);
}
}
if (got_input && sig)
task_post_low (sig, false);
}
static void
......@@ -322,21 +316,21 @@ uart_stop_autobaud()
* Description : user interface for init uart
* Parameters : UartBautRate uart0_br - uart0 bautrate
* UartBautRate uart1_br - uart1 bautrate
* uint8 task_prio - task priority to signal on input
* os_signal_t sig_input - signal to post
* uint8 *flag_input - flag of consumer task
* Returns : NONE
*******************************************************************************/
void ICACHE_FLASH_ATTR
uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input, uint8 *flag_input)
uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input)
{
sig = sig_input;
sig_flag = flag_input;
// rom use 74880 baut_rate, here reinitialize
UartDev.baut_rate = uart0_br;
uart_config(UART0);
UartDev.baut_rate = uart1_br;
uart_config(UART1);
ETS_UART_INTR_ENABLE();
#ifdef BIT_RATE_AUTOBAUD
uart_init_autobaud(0);
#endif
......
......@@ -13,7 +13,6 @@
*/
#include "osapi.h"
#include "../libc/c_stdio.h"
#include "user_interface.h"
#include "espconn.h"
#include "mem.h"
......@@ -95,7 +94,7 @@ static int ICACHE_FLASH_ATTR http_chunked_decode( const char * chunked, char * d
char * endstr;
/* [chunk-size] */
i = strtoul( str + j, NULL, 16 );
HTTPCLIENT_DEBUG( "Chunk Size:%d", i );
HTTPCLIENT_DEBUG( "Chunk Size:%d\r\n", i );
if ( i <= 0 )
break;
/* [chunk-size-end-ptr] */
......@@ -138,7 +137,7 @@ static void ICACHE_FLASH_ATTR http_receive_callback( void * arg, char * buf, uns
char * new_buffer;
if ( new_size > BUFFER_SIZE_MAX || NULL == (new_buffer = (char *) os_malloc( new_size ) ) )
{
HTTPCLIENT_ERR( "Response too long (%d)", new_size );
HTTPCLIENT_DEBUG( "Response too long (%d)\n", new_size );
req->buffer[0] = '\0'; /* Discard the buffer to avoid using an incomplete response. */
if ( req->secure )
espconn_secure_disconnect( conn );
......@@ -164,12 +163,12 @@ static void ICACHE_FLASH_ATTR http_send_callback( void * arg )
if ( req->post_data == NULL )
{
HTTPCLIENT_DEBUG( "All sent" );
HTTPCLIENT_DEBUG( "All sent\n" );
}
else
{
/* The headers were sent, now send the contents. */
HTTPCLIENT_DEBUG( "Sending request body" );
HTTPCLIENT_DEBUG( "Sending request body\n" );
if ( req->secure )
espconn_secure_send( conn, (uint8_t *) req->post_data, strlen( req->post_data ) );
else
......@@ -182,7 +181,7 @@ static void ICACHE_FLASH_ATTR http_send_callback( void * arg )
static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
{
HTTPCLIENT_DEBUG( "Connected" );
HTTPCLIENT_DEBUG( "Connected\n" );
struct espconn * conn = (struct espconn *) arg;
request_args_t * req = (request_args_t *) conn->reverse;
espconn_regist_recvcb( conn, http_receive_callback );
......@@ -251,7 +250,7 @@ static void ICACHE_FLASH_ATTR http_connect_callback( void * arg )
}
req->headers = NULL;
HTTPCLIENT_DEBUG( "Sending request header" );
HTTPCLIENT_DEBUG( "Sending request header\n" );
}
static void http_free_req( request_args_t * req)
......@@ -273,7 +272,7 @@ static void http_free_req( request_args_t * req)
static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
{
HTTPCLIENT_DEBUG( "Disconnected" );
HTTPCLIENT_DEBUG( "Disconnected\n" );
struct espconn *conn = (struct espconn *) arg;
if ( conn == NULL )
......@@ -296,7 +295,7 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
if ( req->buffer == NULL )
{
HTTPCLIENT_DEBUG( "Buffer probably shouldn't be NULL" );
HTTPCLIENT_DEBUG( "Buffer probably shouldn't be NULL\n" );
}
else if ( req->buffer[0] != '\0' )
{
......@@ -306,7 +305,7 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
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 ))
{
HTTPCLIENT_ERR( "Invalid version in %s", req->buffer );
HTTPCLIENT_DEBUG( "Invalid version in %s\n", req->buffer );
}
else
{
......@@ -327,7 +326,7 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
char *locationOffsetEnd = (char *) os_strstr(locationOffset, "\r\n");
if ( locationOffsetEnd == NULL ) {
HTTPCLIENT_ERR( "Found Location header but was incomplete" );
HTTPCLIENT_DEBUG( "Found Location header but was incomplete\n" );
http_status = -1;
} else {
*locationOffsetEnd = '\0';
......@@ -372,7 +371,7 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
return;
}
} else {
HTTPCLIENT_ERR("Too many redirections");
HTTPCLIENT_DEBUG("Too many redirections\n");
http_status = -1;
}
} else {
......@@ -380,7 +379,7 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
if (NULL == body) {
/* Find missing body */
HTTPCLIENT_ERR("Body shouldn't be NULL");
HTTPCLIENT_DEBUG("Body shouldn't be NULL\n");
/* To avoid NULL body */
body = "";
} else {
......@@ -412,9 +411,16 @@ static void ICACHE_FLASH_ATTR http_disconnect_callback( void * arg )
}
static void ICACHE_FLASH_ATTR http_error_callback( void *arg, sint8 errType )
{
HTTPCLIENT_DEBUG( "Disconnected with error\n" );
http_disconnect_callback( arg );
}
static void ICACHE_FLASH_ATTR http_timeout_callback( void *arg )
{
HTTPCLIENT_ERR( "Connection timeout" );
HTTPCLIENT_DEBUG( "Connection timeout\n" );
struct espconn * conn = (struct espconn *) arg;
if ( conn == NULL )
{
......@@ -433,20 +439,13 @@ static void ICACHE_FLASH_ATTR http_timeout_callback( void *arg )
}
static void ICACHE_FLASH_ATTR http_error_callback( void *arg, sint8 errType )
{
HTTPCLIENT_ERR( "Disconnected with error: %d", errType );
http_timeout_callback( arg );
}
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 )
{
HTTPCLIENT_ERR( "DNS failed for %s", hostname );
HTTPCLIENT_DEBUG( "DNS failed for %s\n", hostname );
if ( req->callback_handle != NULL )
{
req->callback_handle( "", -1, "" );
......@@ -455,7 +454,7 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
}
else
{
HTTPCLIENT_DEBUG( "DNS found %s " IPSTR, hostname, IP2STR( addr ) );
HTTPCLIENT_DEBUG( "DNS found %s " IPSTR "\n", hostname, IP2STR( addr ) );
struct espconn * conn = (struct espconn *) os_zalloc( sizeof(struct espconn) );
conn->type = ESPCONN_TCP;
......@@ -490,7 +489,7 @@ static void ICACHE_FLASH_ATTR http_dns_callback( const char * hostname, ip_addr_
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 )
{
HTTPCLIENT_DEBUG( "DNS request" );
HTTPCLIENT_DEBUG( "DNS request\n" );
request_args_t * req = (request_args_t *) os_zalloc( sizeof(request_args_t) );
req->hostname = esp_strdup( hostname );
......@@ -513,7 +512,7 @@ void ICACHE_FLASH_ATTR http_raw_request( const char * hostname, int port, bool s
if ( error == ESPCONN_INPROGRESS )
{
HTTPCLIENT_DEBUG( "DNS pending" );
HTTPCLIENT_DEBUG( "DNS pending\n" );
}
else if ( error == ESPCONN_OK )
{
......@@ -524,9 +523,9 @@ void ICACHE_FLASH_ATTR http_raw_request( const char * hostname, int port, bool s
{
if ( error == ESPCONN_ARG )
{
HTTPCLIENT_ERR( "DNS arg error %s", hostname );
HTTPCLIENT_DEBUG( "DNS arg error %s\n", hostname );
}else {
HTTPCLIENT_ERR( "DNS error code %d", error );
HTTPCLIENT_DEBUG( "DNS error code %d\n", error );
}
http_dns_callback( hostname, NULL, req ); /* Handle all DNS errors the same way. */
}
......@@ -562,7 +561,7 @@ void ICACHE_FLASH_ATTR http_request( const char * url, const char * method, cons
}
else
{
HTTPCLIENT_ERR( "URL is not HTTP or HTTPS %s", url );
HTTPCLIENT_DEBUG( "URL is not HTTP or HTTPS %s\n", url );
return;
}
......@@ -579,7 +578,7 @@ void ICACHE_FLASH_ATTR http_request( const char * url, const char * method, cons
}
if (path - url >= sizeof(hostname)) {
HTTPCLIENT_ERR( "hostname is too long %s", url );
HTTPCLIENT_DEBUG( "hostname is too long %s\n", url );
return;
}
......@@ -593,7 +592,7 @@ void ICACHE_FLASH_ATTR http_request( const char * url, const char * method, cons
port = atoi( colon + 1 );
if ( port == 0 )
{
HTTPCLIENT_ERR( "Port error %s", url );
HTTPCLIENT_DEBUG( "Port error %s\n", url );
return;
}
......@@ -607,10 +606,10 @@ void ICACHE_FLASH_ATTR http_request( const char * url, const char * method, cons
path = "/";
}
HTTPCLIENT_DEBUG( "hostname=%s", hostname );
HTTPCLIENT_DEBUG( "port=%d", port );
HTTPCLIENT_DEBUG( "method=%s", method );
HTTPCLIENT_DEBUG( "path=%s", path );
HTTPCLIENT_DEBUG( "hostname=%s\n", hostname );
HTTPCLIENT_DEBUG( "port=%d\n", port );
HTTPCLIENT_DEBUG( "method=%s\n", method );
HTTPCLIENT_DEBUG( "path=%s\n", path );
http_raw_request( hostname, port, secure, method, path, headers, post_data, callback_handle, redirect_follow_count);
}
......@@ -646,11 +645,10 @@ void ICACHE_FLASH_ATTR http_put( const char * url, const char * headers, const c
void ICACHE_FLASH_ATTR http_callback_example( char * response, int http_status, char * full_response )
{
dbg_printf( "http_status=%d\n", http_status );
os_printf( "http_status=%d\n", http_status );
if ( http_status != HTTP_STATUS_GENERIC_ERROR )
{
dbg_printf( "strlen(full_response)=%d\n", strlen( full_response ) );
dbg_printf( "response=%s<EOF>\n", response );
os_printf( "strlen(full_response)=%d\n", strlen( full_response ) );
os_printf( "response=%s<EOF>\n", response );
}
}
......@@ -10,25 +10,18 @@
#ifndef __HTTPCLIENT_H__
#define __HTTPCLIENT_H__
static const char log_prefix[] = "HTTP client: ";
#if defined(DEVELOP_VERSION)
#define HTTPCLIENT_DEBUG_ON
#if defined(GLOBAL_DEBUG_ON)
#define HTTPCLIENT_DEBUG_ON
#endif
#if defined(HTTPCLIENT_DEBUG_ON)
#define HTTPCLIENT_DEBUG(format, ...) dbg_printf("%s"format"\n", log_prefix, ##__VA_ARGS__)
#else
#define HTTPCLIENT_DEBUG(...)
#endif
#if defined(NODE_ERROR)
#define HTTPCLIENT_ERR(format, ...) NODE_ERR("%s"format"\n", log_prefix, ##__VA_ARGS__)
#define HTTPCLIENT_DEBUG(format, ...) os_printf(format, ##__VA_ARGS__)
#else
#define HTTPCLIENT_ERR(...)
#define HTTPCLIENT_DEBUG(format, ...)
#endif
#if defined(USES_SDK_BEFORE_V140)
#define espconn_send espconn_sent
#define espconn_secure_send espconn_secure_sent
#define espconn_send espconn_sent
#define espconn_secure_send espconn_secure_sent
#endif
/*
......
......@@ -101,7 +101,7 @@ typedef struct {
int buff_uart_no; //indicate which uart use tx/rx buffer
} UartDevice;
void uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input, uint8 *flag_input);
void uart_init(UartBautRate uart0_br, UartBautRate uart1_br, os_signal_t sig_input);
void uart0_alt(uint8 on);
void uart0_sendStr(const char *str);
void uart0_putc(const char c);
......
......@@ -149,7 +149,5 @@ void uart_div_modify(int no, unsigned int freq);
/* Returns 0 on success, 1 on failure */
uint8_t SPIRead(uint32_t src_addr, uint32_t *des_addr, uint32_t size);
uint8_t SPIWrite(uint32_t dst_addr, const uint32_t *src, uint32_t size);
uint8_t SPIEraseSector(uint32_t sector);
#endif
......@@ -2,6 +2,5 @@
#define _SECTIONS_H_
#define TEXT_SECTION_ATTR __attribute__((section(".text")))
#define RAM_CONST_SECTION_ATTR __attribute((section(".data")))
#endif
......@@ -24,7 +24,6 @@
//
// I2C based displays go into here:
// U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_i2c) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x32_i2c) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_i2c) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_64x48_i2c) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1309_128x64_i2c) \
......@@ -41,7 +40,6 @@
// U8G_DISPLAY_TABLE_ENTRY(pcd8544_84x48_hw_spi) \
// U8G_DISPLAY_TABLE_ENTRY(pcf8812_96x65_hw_spi) \
// U8G_DISPLAY_TABLE_ENTRY(sh1106_128x64_hw_spi) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x32_hw_spi) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1306_64x48_hw_spi) \
// U8G_DISPLAY_TABLE_ENTRY(ssd1309_128x64_hw_spi) \
......@@ -77,10 +75,6 @@
U8G_DISPLAY_TABLE_ENTRY(ssd1306_128x64_hw_spi) \
#undef U8G_DISPLAY_TABLE_ENTRY
// Special display device to provide run-length encoded framebuffer contents
// to a Lua callback:
//#define U8G_DISPLAY_FB_RLE
//
// ***************************************************************************
......
......@@ -36,13 +36,13 @@ extern void luaL_assertfail(const char *file, int line, const char *message);
#define NODE_ERROR
#ifdef NODE_DEBUG
#define NODE_DBG dbg_printf
#define NODE_DBG c_printf
#else
#define NODE_DBG
#endif /* NODE_DEBUG */
#ifdef NODE_ERROR
#define NODE_ERR dbg_printf
#define NODE_ERR c_printf
#else
#define NODE_ERR
#endif /* NODE_ERROR */
......@@ -76,9 +76,6 @@ extern void luaL_assertfail(const char *file, int line, const char *message);
// maximum length of a filename
#define FS_OBJ_NAME_LEN 31
// maximum number of open files for SPIFFS
#define SPIFFS_MAX_OPEN_FILES 4
// Uncomment this next line for fastest startup
// It reduces the format time dramatically
// #define SPIFFS_MAX_FILESYSTEM_SIZE 32768
......
......@@ -53,7 +53,6 @@
//#define LUA_USE_MODULES_RTCTIME
//#define LUA_USE_MODULES_SIGMA_DELTA
//#define LUA_USE_MODULES_SNTP
//#define LUA_USE_MODULES_SOMFY
#define LUA_USE_MODULES_SPI
//#define LUA_USE_MODULES_STRUCT
//#define LUA_USE_MODULES_SWITEC
......
......@@ -63,8 +63,6 @@ extern void output_redirect(const char *str);
int c_sprintf(char* s,const char *fmt, ...);
#endif
extern void dbg_printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
#define c_vsprintf ets_vsprintf
#define c_printf(...) do { \
unsigned char __print_buf[BUFSIZ]; \
......
/* $NetBSD: printf.c,v 1.12 1997/06/26 19:11:48 drochner Exp $ */
/*-
* Copyright (c) 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)printf.c 8.1 (Berkeley) 6/11/93
*/
// This version uses almost no stack, and does not suffer from buffer
// overflows. The downside is that it does not implement a wide range
// of formatting characters.
#include <c_stdlib.h>
#include <c_types.h>
#include <c_stdarg.h>
#include "driver/uart.h"
static void kprintn (void (*)(const char), uint32_t, int, int, char);
static void kdoprnt (void (*)(const char), const char *, va_list);
void
dbg_printf(const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
kdoprnt(uart0_putc, fmt, ap);
va_end(ap);
}
void
dbg_vprintf(const char *fmt, va_list ap)
{
kdoprnt(uart0_putc, fmt, ap);
}
void
kdoprnt(void (*put)(const char), const char *fmt, va_list ap)
{
register char *p;
register int ch, n;
unsigned long ul;
int lflag, set;
char zwidth;
char width;
for (;;) {
while ((ch = *fmt++) != '%') {
if (ch == '\0')
return;
put(ch);
}
lflag = 0;
width = 0;
zwidth = ' ';
reswitch: switch (ch = *fmt++) {
case '\0':
/* XXX print the last format character? */
return;
case 'l':
lflag = 1;
goto reswitch;
case 'c':
ch = va_arg(ap, int);
put(ch & 0x7f);
break;
case 's':
p = va_arg(ap, char *);
if (p == 0) {
p = "<null>";
}
while ((ch = *p++))
put(ch);
break;
case 'd':
ul = lflag ?
va_arg(ap, long) : va_arg(ap, int);
if ((long)ul < 0) {
put('-');
ul = -(long)ul;
}
kprintn(put, ul, 10, width, zwidth);
break;
case 'o':
ul = lflag ?
va_arg(ap, uint32_t) : va_arg(ap, uint32_t);
kprintn(put, ul, 8, width, zwidth);
break;
case 'u':
ul = lflag ?
va_arg(ap, uint32_t) : va_arg(ap, uint32_t);
kprintn(put, ul, 10, width, zwidth);
break;
case 'x':
ul = lflag ?
va_arg(ap, uint32_t) : va_arg(ap, uint32_t);
kprintn(put, ul, 16, width, zwidth);
break;
default:
if (ch >= '0' && ch <= '9') {
if (ch == '0' && width == 0 && zwidth == ' ') {
zwidth = '0';
} else {
width = width * 10 + ch - '0';
}
goto reswitch;
}
put('%');
if (lflag)
put('l');
put(ch);
}
}
va_end(ap);
}
static void
kprintn(void (*put)(const char), unsigned long ul, int base, int width, char padchar)
{
/* hold a long in base 8 */
char *p, buf[(sizeof(long) * 8 / 3) + 2];
p = buf;
do {
*p++ = "0123456789abcdef"[ul % base];
} while (ul /= base);
while (p - buf < width--) {
put(padchar);
}
do {
put(*--p);
} while (p > buf);
}
......@@ -807,7 +807,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
}
LUALIB_API void luaL_assertfail(const char *file, int line, const char *message) {
dbg_printf("ASSERT@%s(%d): %s\n", file, line, message);
c_printf("ASSERT@%s(%d): %s\n", file, line, message);
}
static int panic (lua_State *L) {
......
......@@ -343,19 +343,28 @@ static int read_line (lua_State *L, int f) {
static int read_line (lua_State *L, int f) {
luaL_Buffer b;
luaL_buffinit(L, &b);
signed char c;
do {
char *p = luaL_prepbuffer(&b);
signed char c = EOF;
int i = 0;
do{
c = (signed char)vfs_getc(f);
if (c==EOF) {
if(c==EOF){
break;
}
if (c != '\n') {
luaL_addchar(&b, c);
}
} while (c != '\n');
p[i++] = c;
}while((c!=EOF) && (c!='\n') && (i<LUAL_BUFFERSIZE) );
if(i>0 && p[i-1] == '\n')
i--; /* do not include `eol' */
if(i==0){
luaL_pushresult(&b); /* close buffer */
return (lua_objlen(L, -1) > 0); /* check whether read something */
}
luaL_addsize(&b, i);
luaL_pushresult(&b); /* close buffer */
return (lua_objlen(L, -1) > 0); /* check whether read something */
return 1; /* read at least an `eol' */
}
#endif
......
......@@ -346,7 +346,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
** (A format string with one argument is enough for Lua...)
*/
#if !defined(LUA_USE_STDIO)
#define luai_writestringerror(s,p) dbg_printf((s), (p))
#define luai_writestringerror(s,p) c_printf((s), (p))
#endif // defined(LUA_USE_STDIO)
......@@ -556,7 +556,7 @@ extern int readline4lua(const char *prompt, char *buffer, int length);
** For example: If set to 4K a call to string.gsub will need more than
** 5k C stack space.
*/
#define LUAL_BUFFERSIZE 256
#define LUAL_BUFFERSIZE BUFSIZ
/* }================================================================== */
......
This diff is collapsed.
<!DOCTYPE html>
<html>
<head>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>WiFi Login</title>
<style type=text/css>
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
font-family: sans-serif;
text-align: center;
background: #444d44;
}
#content {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
width: 320px;
height: 480px;
margin: auto;
}
input,
button,
select {
-webkit-appearance: none;
border-radius: 0;
}
fieldset {
border: 0;
box-shadow: 0 0 15px 1px rgba(0, 0, 0, .4);
box-sizing: border-box;
padding: 20px 30px;
background: #fff;
min-height: 320px;
margin: -1px;
}
input {
border: 1px solid #ccc;
margin-bottom: 10px;
width: 100%;
box-sizing: border-box;
color: #222;
font: 16px monospace;
padding: 15px;
}
select {
font: 16px monospace;
background-color: transparent;
padding: 15px;
}
button {
color: #fff;
border: 0;
border-radius: 3px;
cursor: pointer;
display: block;
font: 16px sans-serif;
text-decoration: none;
padding: 10px 5px;
background: #31b457;
width: 100%;
}
button:focus,
button:hover {
box-shadow: 0 0 0 2px #fff, 0 0 0 3px #31b457;
}
h3 {
font-size: 16px;
color: #666;
margin-bottom: 20px;
}
h4 {
color: #ccc;
padding: 10px;
}
.utility {
float: right;
clear: both;
max-width: 75%;
font-size: 13px;
color: #222;
margin: 10px 0;
padding: 5px 10px;
background: #ccc;
}
.utility:focus,
.utility:hover {
box-shadow: 0 0 0 2px #fff, 0 0 0 3px #ccc;
}
#dropdown,
#f2,
#f3,
#bk2 {
display: none;
}
#dropdown {
position: relative;
width: 100%;
overflow: auto;
height: 51px;
margin-bottom: 10px;
}
#aplist {
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
bottom: 0;
border: 1px solid #ccc;
font-family: monospace;
padding: 10px 5px;
}
#arrow {
color: #888;
position: absolute;
right: 8px;
top: 15px;
}
#i {
text-align: justify;
}
</style>
</head>
<body>
<div id=content>
<fieldset>
<div id=deviceId></div>
<div id=f1>
<h3>Connect device to your Wi-Fi</h3>
<button id=networks type=button class=utility></button>
<div id=dropdown>
<span id=arrow>&#x25bc;</span>
<select id=aplist name=aplist></select>
</div>
<input id=ssid type=text autocorrect=off autocapitalize=none placeholder='Wi-Fi Name' />
<input id=wifi_password type=text autocorrect=off autocapitalize=none autocomplete=off placeholder=Password />
<button id=submit type=button>Save</button>
</div>
<div id=f2>
<h1>Success!</h1>
<div id=i>
<h3>Your device has successfully connected to the Wi-Fi network.</h3>
</div>
</div>
<div id=f3>
<h2>Trying...</h2>
<button id=bk2 type=button class='utility'>Go Back to Wi-Fi Setup</button>
</div>
</fieldset>
<h4 id='st'>Updating Status...</h4>
</div>
<script>
var $ = function (selector) { return document.querySelector(selector); };
var ab = $('#networks'), ap = $('#aplist');
var stopAll = false, ra, rs;
function show(f, y) {
if (y == null) y = f;
$(f).style.display = y == f ? 'block' : 'none';
}
function hide(f) {
$(f).style.display = 'none';
}
function to(cb, x) {
return setTimeout(cb, 1000 * x);
}
function refr() {
if (!stopAll)
fetch('/status.json?n=' + Math.random(), 'GET', newSt, 2);
}
function cur(f) {
show('#f1', f);
show('#f2', f);
show('#f3', f);
}
function newSt(s, d) {
clearTimeout(rs);
rs = to(refr, 3);
if (s != 200) {
$('#st').innerText = 'Awaiting Status (' + s + ')';
} else {
if (typeof d === 'string') {
d = JSON.parse(d);
}
$('#deviceId').innerText = d.deviceid;
var c = d.pairing;
var s = [
'Idle',
'Connecting...',
'Failed - wrong password',
'Failed - network not found',
'Failed',
'Wi-Fi successfully connected!'
][d.status];
$('#st').innerText = s;
if (d.status === 5) {
cur('#f2');
stopAll = true;
clearTimeout(ra);
} else if (d.status > 1) {
cur('#f1');
}
}
}
function submit() {
var url = '/setwifi?wifi_ssid=' + encodeURIComponent($('#ssid').value) + '&wifi_password=' + encodeURIComponent($('#wifi_password').value);
clearTimeout(rs);
fetch(url, 'GET', newSt, 2);
cur('#f3');
}
function fetch(url, method, callback, time_out) {
var xhr = new XMLHttpRequest();
xhr.onloadend = function () {
callback(xhr.status, xhr.responseText);
}
xhr.ontimeout = function () {
callback(-1, null);
}
xhr.open(method, url, true);
xhr.setRequestHeader('Accept', 'application/json');
xhr.timeout = (time_out || 10) * 1000;
xhr.send();
}
function gotAp(s, json) {
var list;
if (s === 200 && json != null) {
if (typeof json === 'string' && json.length > 0) {
list = JSON.parse(json);
} else if (typeof json === 'object') {
list = json;
}
list.sort(function (a, b) {
return b.rssi - a.rssi;
});
var ops = '<option>Select a Network...</option>';
for (var i = 0; i < list.length; ++i) {
ops += '<option>' + list[i].ssid + '</option>';
}
ap.innerHTML = ops;
ab.disabled = false;
togAp(null, true);
ab.onclick = togAp;
} else {
ab.innerText = 'No networks found (' + s + ')';
ra = to(refrAp, 5);
}
}
function togAp(ev, force) {
if (!force || ap.style.display == 'block') {
hide('#dropdown');
show('#ssid');
ab.innerText = 'Scan for Networks';
ab.onclick = refrAp;
} else {
show('#dropdown');
hide('#ssid');
ab.innerText = 'Manual Entry';
}
}
function refrAp() {
ab.innerText = 'Searching for networks...';
ab.disabled = true;
ap.innerHTML = '<option disabled>Scanning...</option>';
if (!stopAll)
fetch('/aplist?n=' + Math.random(), 'GET', gotAp, 10);
}
window.onload = function() {
ab.innerText = 'Scan for Networks';
ab.onclick = refrAp;
$('#aplist').onchange = function () {
$('#ssid').value = $('#aplist').value;
};
$('#submit').onclick = submit;
$('#bk2').onclick = function () {
cur('#f1')
}
rs = to(refr, 0.5);
}
</script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment