Changed all tab characters to two spaces as per #600.

This commit is contained in:
Neil Kolban 2015-10-06 17:46:11 -05:00
parent c2cc382700
commit 15248475cd
6 changed files with 1711 additions and 1711 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,69 +1,69 @@
#include <ets_sys.h>
#include <osapi.h>
#include <os_type.h>
#include <user_interface.h>
#include <espconn.h>
#include <gpio.h>
#include <mem.h>
#include <espmissingincludes.h>
#define _GCC_WRAP_STDINT_H
typedef long long int64_t;
#include "jsutils.h"
/**
* Convert an ESP8266 error code to a string.
* Given an ESP8266 network error code, return a string representation
* of the meaning of that code.
* \return A string representation of an error code.
*/
const char *esp8266_errorToString(
sint8 err //!< The error code to be transformed to a string.
) {
switch(err) {
case ESPCONN_MEM:
return "ESPCONN_MEM";
case ESPCONN_TIMEOUT:
return "ESPCONN_TIMEOUT";
case ESPCONN_RTE:
return "ESPCONN_RTE";
case ESPCONN_INPROGRESS:
return "ESPCONN_INPROGRESS";
case ESPCONN_ABRT:
return "ESPCONN_ABRT";
case ESPCONN_RST:
return "ESPCONN_RST";
case ESPCONN_CLSD:
return "ESPCONN_CLSD";
case ESPCONN_CONN:
return "ESPCONN_CONN";
case ESPCONN_ARG:
return "ESPCONN_ARG";
case ESPCONN_ISCONN:
return "ESPCONN_ISCONN";
case ESPCONN_HANDSHAKE:
return "ESPCONN_HANDSHAKE";
default:
return "Unknown error";
}
}
/**
* Write a buffer of data to the console.
* The buffer is pointed to by the buffer
* parameter and will be written for the length parameter. This is useful because
* unlike a string, the data does not have to be NULL terminated.
*/
void esp8266_board_writeString(
uint8 *buffer, //!< The start of the buffer to write.
size_t length //!< The length of the buffer to write.
) {
assert(length==0 || buffer != NULL);
size_t i;
for (i=0; i<length; i++) {
os_printf("%c", buffer[i]);
}
}
#include <ets_sys.h>
#include <osapi.h>
#include <os_type.h>
#include <user_interface.h>
#include <espconn.h>
#include <gpio.h>
#include <mem.h>
#include <espmissingincludes.h>
#define _GCC_WRAP_STDINT_H
typedef long long int64_t;
#include "jsutils.h"
/**
* Convert an ESP8266 error code to a string.
* Given an ESP8266 network error code, return a string representation
* of the meaning of that code.
* \return A string representation of an error code.
*/
const char *esp8266_errorToString(
sint8 err //!< The error code to be transformed to a string.
) {
switch(err) {
case ESPCONN_MEM:
return "ESPCONN_MEM";
case ESPCONN_TIMEOUT:
return "ESPCONN_TIMEOUT";
case ESPCONN_RTE:
return "ESPCONN_RTE";
case ESPCONN_INPROGRESS:
return "ESPCONN_INPROGRESS";
case ESPCONN_ABRT:
return "ESPCONN_ABRT";
case ESPCONN_RST:
return "ESPCONN_RST";
case ESPCONN_CLSD:
return "ESPCONN_CLSD";
case ESPCONN_CONN:
return "ESPCONN_CONN";
case ESPCONN_ARG:
return "ESPCONN_ARG";
case ESPCONN_ISCONN:
return "ESPCONN_ISCONN";
case ESPCONN_HANDSHAKE:
return "ESPCONN_HANDSHAKE";
default:
return "Unknown error";
}
}
/**
* Write a buffer of data to the console.
* The buffer is pointed to by the buffer
* parameter and will be written for the length parameter. This is useful because
* unlike a string, the data does not have to be NULL terminated.
*/
void esp8266_board_writeString(
uint8 *buffer, //!< The start of the buffer to write.
size_t length //!< The length of the buffer to write.
) {
assert(length==0 || buffer != NULL);
size_t i;
for (i=0; i<length; i++) {
os_printf("%c", buffer[i]);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +1,93 @@
/*
* This file is part of Espruino/ESP8266, a JavaScript interpreter for ESP8266
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
//#include "espmissingincludes.h"
#include <ets_sys.h>
#include <osapi.h>
#include <os_type.h>
#include <user_interface.h>
#include <espconn.h>
#include <mem.h>
#include <telnet.h>
#define MAXLINE 200
static char line[MAXLINE];
static struct espconn conn1;
static esp_tcp tcp1;
static bool discard;
static void (*lineCB)(char *);
static struct espconn *pTelnetClientConn;
/**
* Callback invoked when a new TCP/IP connection has been formed.
* o arg - This is a pointer to the struct espconn that reflects this entry.
*/
static void connectCB(void *arg) {
struct espconn *pConn = (struct espconn *)arg;
// By default, an ESP TCP connection times out after 10 seconds
// Change to the max value.
espconn_regist_time(pConn, 7200, 1);
os_printf("Connect cb!!\n");
strcpy(line, "");
discard = false;
pTelnetClientConn = pConn;
}
static void disconnectCB(void *arg) {
os_printf("Disconnect cb!!\n");
}
static void receiveCB(void *arg, char *pData, unsigned short len) {
//os_printf("Receive cb!! len=%d\n", len);
if (strlen(line) + len >= MAXLINE) {
discard = true;
strcpy(line, "");
}
strncat(line, pData, len);
if (strstr(line, "\r\n") != NULL) {
if (discard) {
os_printf("Discarded ... line too long");
discard = false;
} else {
//os_printf("Found: %s", line);
(*lineCB)(line);
}
strcpy(line, "");
} else {
//os_printf("Not found, current='%s'\n", line);
}
}
/**
* Register a telnet serever listener on port 23 to handle incoming telnet client
* connections. The parameter called pLineCB is a pointer to a callback function
* that should be called when we have received a link of input.
*/
void telnet_startListening(void (*plineCB)(char *)) {
lineCB= plineCB;
tcp1.local_port = 23;
conn1.type = ESPCONN_TCP;
conn1.state = ESPCONN_NONE;
conn1.proto.tcp = &tcp1;
espconn_regist_connectcb(&conn1, connectCB);
espconn_regist_disconcb(&conn1, disconnectCB);
espconn_regist_recvcb(&conn1, receiveCB);
espconn_accept(&conn1);
os_printf("Now listening for telnet client connection ...\n");
}
/**
* Send the string passed as a parameter to the telnet client.
*/
void telnet_send(char *text) {
espconn_sent(pTelnetClientConn, (uint8_t *)text, strlen(text));
}
/*
* This file is part of Espruino/ESP8266, a JavaScript interpreter for ESP8266
*
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
//#include "espmissingincludes.h"
#include <ets_sys.h>
#include <osapi.h>
#include <os_type.h>
#include <user_interface.h>
#include <espconn.h>
#include <mem.h>
#include <telnet.h>
#define MAXLINE 200
static char line[MAXLINE];
static struct espconn conn1;
static esp_tcp tcp1;
static bool discard;
static void (*lineCB)(char *);
static struct espconn *pTelnetClientConn;
/**
* Callback invoked when a new TCP/IP connection has been formed.
* o arg - This is a pointer to the struct espconn that reflects this entry.
*/
static void connectCB(void *arg) {
struct espconn *pConn = (struct espconn *)arg;
// By default, an ESP TCP connection times out after 10 seconds
// Change to the max value.
espconn_regist_time(pConn, 7200, 1);
os_printf("Connect cb!!\n");
strcpy(line, "");
discard = false;
pTelnetClientConn = pConn;
}
static void disconnectCB(void *arg) {
os_printf("Disconnect cb!!\n");
}
static void receiveCB(void *arg, char *pData, unsigned short len) {
//os_printf("Receive cb!! len=%d\n", len);
if (strlen(line) + len >= MAXLINE) {
discard = true;
strcpy(line, "");
}
strncat(line, pData, len);
if (strstr(line, "\r\n") != NULL) {
if (discard) {
os_printf("Discarded ... line too long");
discard = false;
} else {
//os_printf("Found: %s", line);
(*lineCB)(line);
}
strcpy(line, "");
} else {
//os_printf("Not found, current='%s'\n", line);
}
}
/**
* Register a telnet serever listener on port 23 to handle incoming telnet client
* connections. The parameter called pLineCB is a pointer to a callback function
* that should be called when we have received a link of input.
*/
void telnet_startListening(void (*plineCB)(char *)) {
lineCB= plineCB;
tcp1.local_port = 23;
conn1.type = ESPCONN_TCP;
conn1.state = ESPCONN_NONE;
conn1.proto.tcp = &tcp1;
espconn_regist_connectcb(&conn1, connectCB);
espconn_regist_disconcb(&conn1, disconnectCB);
espconn_regist_recvcb(&conn1, receiveCB);
espconn_accept(&conn1);
os_printf("Now listening for telnet client connection ...\n");
}
/**
* Send the string passed as a parameter to the telnet client.
*/
void telnet_send(char *text) {
espconn_sent(pTelnetClientConn, (uint8_t *)text, strlen(text));
}

View File

@ -1,5 +1,5 @@
/*
* File : uart.c
* File : uart.c
* Copyright (C) 2013 - 2016, Espressif Systems
*
* This program is free software: you can redistribute it and/or modify
@ -34,16 +34,16 @@ static char rxBuffer[MAX_RX_BUFFER];
static int rxBufferLen = 0;
int getRXBuffer(char *pBuffer, int bufferLen) {
if (rxBufferLen > bufferLen) {
memcpy(pBuffer,rxBuffer, bufferLen);
memcpy(rxBuffer, rxBuffer+bufferLen, rxBufferLen-bufferLen);
rxBufferLen = rxBufferLen - bufferLen;
return bufferLen;
}
int sizeReturned = rxBufferLen;
memcpy(pBuffer, rxBuffer, rxBufferLen);
rxBufferLen = 0;
return sizeReturned;
if (rxBufferLen > bufferLen) {
memcpy(pBuffer,rxBuffer, bufferLen);
memcpy(rxBuffer, rxBuffer+bufferLen, rxBufferLen-bufferLen);
rxBufferLen = rxBufferLen - bufferLen;
return bufferLen;
}
int sizeReturned = rxBufferLen;
memcpy(pBuffer, rxBuffer, rxBufferLen);
rxBufferLen = 0;
return sizeReturned;
}
/*uart demo with a system task, to output what uart receives*/
@ -78,10 +78,10 @@ uart_config(uint8 uart_no)
ETS_UART_INTR_ATTACH(uart0_rx_intr_handler, &(UartDev.rcv_buff));
PIN_PULLUP_DIS(PERIPHS_IO_MUX_U0TXD_U);
PIN_FUNC_SELECT(PERIPHS_IO_MUX_U0TXD_U, FUNC_U0TXD);
#if UART_HW_RTS
#if UART_HW_RTS
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTDO_U, FUNC_U0RTS); //HW FLOW CONTROL RTS PIN
#endif
#if UART_HW_CTS
#if UART_HW_CTS
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U, FUNC_U0CTS); //HW FLOW CONTROL CTS PIN
#endif
}
@ -240,10 +240,10 @@ uart0_rx_intr_handler(void *para)
uint8 temp,cnt;
//RcvMsgBuff *pRxBuff = (RcvMsgBuff *)para;
/*ATTENTION:*/
/*IN NON-OS VERSION SDK, DO NOT USE "ICACHE_FLASH_ATTR" FUNCTIONS IN THE WHOLE HANDLER PROCESS*/
/*ALL THE FUNCTIONS CALLED IN INTERRUPT HANDLER MUST BE DECLARED IN RAM */
/*IF NOT , POST AN EVENT AND PROCESS IN SYSTEM TASK */
/*ATTENTION:*/
/*IN NON-OS VERSION SDK, DO NOT USE "ICACHE_FLASH_ATTR" FUNCTIONS IN THE WHOLE HANDLER PROCESS*/
/*ALL THE FUNCTIONS CALLED IN INTERRUPT HANDLER MUST BE DECLARED IN RAM */
/*IF NOT , POST AN EVENT AND PROCESS IN SYSTEM TASK */
if(UART_FRM_ERR_INT_ST == (READ_PERI_REG(UART_INT_ST(uart_no)) & UART_FRM_ERR_INT_ST)){
DBG1("FRM_ERR\r\n");
WRITE_PERI_REG(UART_INT_CLR(uart_no), UART_FRM_ERR_INT_CLR);
@ -259,15 +259,15 @@ uart0_rx_intr_handler(void *para)
system_os_post(uart_recvTaskPrio, 0, 0);
}else if(UART_TXFIFO_EMPTY_INT_ST == (READ_PERI_REG(UART_INT_ST(uart_no)) & UART_TXFIFO_EMPTY_INT_ST)){
DBG("e");
/* to output uart data from uart buffer directly in empty interrupt handler*/
/*instead of processing in system event, in order not to wait for current task/function to quit */
/*ATTENTION:*/
/*IN NON-OS VERSION SDK, DO NOT USE "ICACHE_FLASH_ATTR" FUNCTIONS IN THE WHOLE HANDLER PROCESS*/
/*ALL THE FUNCTIONS CALLED IN INTERRUPT HANDLER MUST BE DECLARED IN RAM */
CLEAR_PERI_REG_MASK(UART_INT_ENA(UART0), UART_TXFIFO_EMPTY_INT_ENA);
#if UART_BUFF_EN
tx_start_uart_buffer(UART0);
#endif
/* to output uart data from uart buffer directly in empty interrupt handler*/
/*instead of processing in system event, in order not to wait for current task/function to quit */
/*ATTENTION:*/
/*IN NON-OS VERSION SDK, DO NOT USE "ICACHE_FLASH_ATTR" FUNCTIONS IN THE WHOLE HANDLER PROCESS*/
/*ALL THE FUNCTIONS CALLED IN INTERRUPT HANDLER MUST BE DECLARED IN RAM */
CLEAR_PERI_REG_MASK(UART_INT_ENA(UART0), UART_TXFIFO_EMPTY_INT_ENA);
#if UART_BUFF_EN
tx_start_uart_buffer(UART0);
#endif
//system_os_post(uart_recvTaskPrio, 1, 0);
WRITE_PERI_REG(UART_INT_CLR(uart_no), UART_TXFIFO_EMPTY_INT_CLR);
@ -312,19 +312,19 @@ uart_recvTask(os_event_t *events)
// Uncomment the following line to local echo
//uart_tx_one_char(UART0, d_tmp);
if (rxBufferLen < MAX_RX_BUFFER) {
rxBuffer[rxBufferLen] = d_tmp;
rxBufferLen++;
rxBuffer[rxBufferLen] = d_tmp;
rxBufferLen++;
}
}
if (fifo_len > 0) {
system_os_post(0, 2, 0);
system_os_post(0, 2, 0);
}
WRITE_PERI_REG(UART_INT_CLR(UART0), UART_RXFIFO_FULL_INT_CLR|UART_RXFIFO_TOUT_INT_CLR);
uart_rx_intr_enable(UART0);
#endif
}else if(events->sig == 1){
#if UART_BUFF_EN
//already move uart buffer output to uart empty interrupt
//already move uart buffer output to uart empty interrupt
//tx_start_uart_buffer(UART0);
#else
@ -573,7 +573,7 @@ tx_buff_enq(char* pdata, uint16 data_len )
}
#if 0
if(pTxBuffer->Space <= URAT_TX_LOWER_SIZE){
set_tcp_block();
set_tcp_block();
}
#endif
SET_PERI_REG_MASK(UART_CONF1(UART0), (UART_TX_EMPTY_THRESH_VAL & UART_TXFIFO_EMPTY_THRHD)<<UART_TXFIFO_EMPTY_THRHD_S);
@ -723,7 +723,7 @@ UART_WaitTxFifoEmpty(uint8 uart_no , uint32 time_out_us) //do not use if tx flow
if(( system_get_time() - t_s )> time_out_us){
break;
}
WRITE_PERI_REG(0X60000914, 0X73);//WTD
WRITE_PERI_REG(0X60000914, 0X73);//WTD
}
}
@ -749,7 +749,7 @@ UART_CheckOutputFinished(uint8 uart_no, uint32 time_out_us)
if( system_get_time() - t_start > time_out_us){
return FALSE;
}
WRITE_PERI_REG(0X60000914, 0X73);//WTD
WRITE_PERI_REG(0X60000914, 0X73);//WTD
}
}
@ -815,7 +815,7 @@ uart_init_2(UartBautRate uart0_br, UartBautRate uart1_br)
* Discard any data in the RX buffer.
*/
int uart_rx_discard() {
int oldRxBufferLen = rxBufferLen;
rxBufferLen = 0;
return oldRxBufferLen;
int oldRxBufferLen = rxBufferLen;
rxBufferLen = 0;
return oldRxBufferLen;
}

View File

@ -51,13 +51,13 @@ static os_timer_t mainLoopSuspendTimer;
* Here we want to pass that line to the JS parser for processing.
*/
static void telnetLineCB(char *line) {
jsiConsolePrintf("LineCB: %s", line);
// Pass the line to the interactive module ...
jsiConsolePrintf("LineCB: %s", line);
// Pass the line to the interactive module ...
jshPushIOCharEvents(jsiGetConsoleDevice(), line, strlen(line));
//jspEvaluate(line, true);
//jsiDumpState();
telnet_send("JS> ");
jshPushIOCharEvents(jsiGetConsoleDevice(), line, strlen(line));
//jspEvaluate(line, true);
//jsiDumpState();
telnet_send("JS> ");
} // End of lineCB
@ -66,7 +66,7 @@ static void telnetLineCB(char *line) {
* there is little we can do at the network level until we have an IP.
*/
static void gotIpCallback() {
telnet_startListening(telnetLineCB);
telnet_startListening(telnetLineCB);
} // End of gotIpCallback
#endif
@ -85,19 +85,19 @@ static char *flash_maps[] = {
* This function retrieves that data and logs it.
*/
static void dumpRestart() {
struct rst_info *rstInfo = system_get_rst_info();
os_printf("Restart info:\n");
os_printf(" reason: %d=%s\n", rstInfo->reason, rst_codes[rstInfo->reason]);
os_printf(" exccause: %x\n", rstInfo->exccause);
os_printf(" epc1: %x\n", rstInfo->epc1);
os_printf(" epc2: %x\n", rstInfo->epc2);
os_printf(" epc3: %x\n", rstInfo->epc3);
os_printf(" excvaddr: %x\n", rstInfo->excvaddr);
os_printf(" depc: %x\n", rstInfo->depc);
struct rst_info *rstInfo = system_get_rst_info();
os_printf("Restart info:\n");
os_printf(" reason: %d=%s\n", rstInfo->reason, rst_codes[rstInfo->reason]);
os_printf(" exccause: %x\n", rstInfo->exccause);
os_printf(" epc1: %x\n", rstInfo->epc1);
os_printf(" epc2: %x\n", rstInfo->epc2);
os_printf(" epc3: %x\n", rstInfo->epc3);
os_printf(" excvaddr: %x\n", rstInfo->excvaddr);
os_printf(" depc: %x\n", rstInfo->depc);
uint32_t fid = spi_flash_get_id();
os_printf("Flash map %s, manuf 0x%02lX chip 0x%04lX\n", flash_maps[system_get_flash_size_map()],
fid & 0xff, (fid&0xff00)|((fid>>16)&0xff));
uint32_t fid = spi_flash_get_id();
os_printf("Flash map %s, manuf 0x%02lX chip 0x%04lX\n", flash_maps[system_get_flash_size_map()],
fid & 0xff, (fid&0xff00)|((fid>>16)&0xff));
}
@ -105,7 +105,7 @@ static void dumpRestart() {
* Queue a task for the main loop.
*/
static void queueTaskMainLoop() {
system_os_post(TASK_APP_QUEUE, TASK_APP_MAINLOOP, 0);
system_os_post(TASK_APP_QUEUE, TASK_APP_MAINLOOP, 0);
}
@ -113,10 +113,10 @@ static void queueTaskMainLoop() {
* Suspend processing the main loop for a period of time.
*/
void suspendMainLoop(
uint32 interval //!< suspension interval in milliseconds
) {
suspendMainLoopFlag = true;
os_timer_arm(&mainLoopSuspendTimer, interval, 0 /* No repeat */);
uint32 interval //!< suspension interval in milliseconds
) {
suspendMainLoopFlag = true;
os_timer_arm(&mainLoopSuspendTimer, interval, 0 /* No repeat */);
}
@ -124,21 +124,21 @@ void suspendMainLoop(
* Enable main loop processing.
*/
static void enableMainLoop() {
suspendMainLoopFlag = false;
queueTaskMainLoop();
suspendMainLoopFlag = false;
queueTaskMainLoop();
}
/**
* Idle callback from the SDK, triggers an idle loop iteration
*/
static void idle(void) {
// The idle callback comes form the SDK's ets_run function just before it puts the
// processor to sleep waiting for an interrupt to occur. I.e. it's really a
// "I am about to idle the processor" interrupt not a persistent "I am idle"
// callback that comes over and over.
// We thus have to use this callback to trigger something so it doesn't in fact go
// idle.
system_os_post(TASK_APP_QUEUE, TASK_APP_MAINLOOP, 0);
// The idle callback comes form the SDK's ets_run function just before it puts the
// processor to sleep waiting for an interrupt to occur. I.e. it's really a
// "I am about to idle the processor" interrupt not a persistent "I am idle"
// callback that comes over and over.
// We thus have to use this callback to trigger something so it doesn't in fact go
// idle.
system_os_post(TASK_APP_QUEUE, TASK_APP_MAINLOOP, 0);
}
@ -146,32 +146,32 @@ static void idle(void) {
* The event handler for ESP8266 tasks as created by system_os_post() on the TASK_APP_QUEUE.
*/
static void eventHandler(
os_event_t *pEvent //!<
) {
os_event_t *pEvent //!<
) {
switch (pEvent->sig) {
// Handle the main loop event.
case TASK_APP_MAINLOOP:
mainLoop();
break;
// Handle the event to process received data.
case TASK_APP_RX_DATA:
{
// Get the data from the UART RX buffer. If the size of the returned data is
// not zero, then push it onto the Espruino processing queue for characters.
char pBuffer[100];
int size = getRXBuffer(pBuffer, sizeof(pBuffer));
if (size > 0) {
jshPushIOCharEvents(jsiGetConsoleDevice(), pBuffer, size);
}
}
break;
// Handle the unknown event type.
default:
os_printf("user_main: eventHandler: Unknown task type: %d",
pEvent->sig);
break;
}
switch (pEvent->sig) {
// Handle the main loop event.
case TASK_APP_MAINLOOP:
mainLoop();
break;
// Handle the event to process received data.
case TASK_APP_RX_DATA:
{
// Get the data from the UART RX buffer. If the size of the returned data is
// not zero, then push it onto the Espruino processing queue for characters.
char pBuffer[100];
int size = getRXBuffer(pBuffer, sizeof(pBuffer));
if (size > 0) {
jshPushIOCharEvents(jsiGetConsoleDevice(), pBuffer, size);
}
}
break;
// Handle the unknown event type.
default:
os_printf("user_main: eventHandler: Unknown task type: %d",
pEvent->sig);
break;
}
}
@ -183,22 +183,22 @@ static uint32 lastTime = 0;
* as often as possible.
*/
static void mainLoop() {
if (suspendMainLoopFlag == true) {
return;
}
jsiLoop();
if (suspendMainLoopFlag == true) {
return;
}
jsiLoop();
#ifdef EPS8266_BOARD_HEARTBEAT
if (system_get_time() - lastTime > 1000 * 1000 * 5) {
lastTime = system_get_time();
os_printf("tick: %ld, heap: %ld\n",
(uint32)(jshGetSystemTime()), system_get_free_heap_size());
}
if (system_get_time() - lastTime > 1000 * 1000 * 5) {
lastTime = system_get_time();
os_printf("tick: %ld, heap: %ld\n",
(uint32)(jshGetSystemTime()), system_get_free_heap_size());
}
#endif
// Setup for another callback
//queueTaskMainLoop();
suspendMainLoop(0); // HACK to get around SDK 1.4 bug
// Setup for another callback
//queueTaskMainLoop();
suspendMainLoop(0); // HACK to get around SDK 1.4 bug
}
@ -208,28 +208,28 @@ static void mainLoop() {
* we can assume that the ESP8266 is fully ready to do work for us.
*/
static void initDone() {
os_printf("initDone invoked\n");
os_printf("initDone invoked\n");
// Discard any junk data in the input as this is a boot.
//uart_rx_discard();
// Discard any junk data in the input as this is a boot.
//uart_rx_discard();
jshInit(); // Initialize the hardware
jsvInit(); // Initialize the variables
jsiInit(true); // Initialize the interactive subsystem
jshInit(); // Initialize the hardware
jsvInit(); // Initialize the variables
jsiInit(true); // Initialize the interactive subsystem
// Register the event handlers.
system_os_task(eventHandler, TASK_APP_QUEUE, taskAppQueue, TASK_QUEUE_LENGTH);
// Register the event handlers.
system_os_task(eventHandler, TASK_APP_QUEUE, taskAppQueue, TASK_QUEUE_LENGTH);
// At this point, our JavaScript environment should be up and running.
// At this point, our JavaScript environment should be up and running.
// Initialize the networking subsystem.
jswrap_ESP8266WiFi_init();
// Initialize the networking subsystem.
jswrap_ESP8266WiFi_init();
// Register the idle callback handler to run the main loop
//ets_set_idle_cb(idle_cb, NULL); //
queueTaskMainLoop(); // get things going without idle callback
// Register the idle callback handler to run the main loop
//ets_set_idle_cb(idle_cb, NULL); //
queueTaskMainLoop(); // get things going without idle callback
return;
return;
}
@ -239,7 +239,7 @@ static void initDone() {
* before user_init() is called.
*/
void user_rf_pre_init() {
os_printf("Time sys=%lu rtc=%lu\n", system_get_time(), system_get_rtc_time());
os_printf("Time sys=%lu rtc=%lu\n", system_get_time(), system_get_rtc_time());
}
@ -248,24 +248,24 @@ void user_rf_pre_init() {
* It is where the logic of ESP8266 starts.
*/
void user_init() {
system_timer_reinit(); // use microsecond os_timer_*
// Initialize the UART devices
uart_init(BIT_RATE_115200, BIT_RATE_115200);
os_delay_us(10000); // give the uart a break
UART_SetPrintPort(1);
system_set_os_print(1);
system_timer_reinit(); // use microsecond os_timer_*
// Initialize the UART devices
uart_init(BIT_RATE_115200, BIT_RATE_115200);
os_delay_us(10000); // give the uart a break
UART_SetPrintPort(1);
system_set_os_print(1);
// Dump the restart exception information.
dumpRestart();
os_printf("Heap: %d\n", system_get_free_heap_size());
os_printf("Variables: %d @%dea = %ldbytes\n", JSVAR_CACHE_SIZE, sizeof(JsVar),
JSVAR_CACHE_SIZE * sizeof(JsVar));
os_printf("Time sys=%lu rtc=%lu\n", system_get_time(), system_get_rtc_time());
// Dump the restart exception information.
dumpRestart();
os_printf("Heap: %d\n", system_get_free_heap_size());
os_printf("Variables: %d @%dea = %ldbytes\n", JSVAR_CACHE_SIZE, sizeof(JsVar),
JSVAR_CACHE_SIZE * sizeof(JsVar));
os_printf("Time sys=%lu rtc=%lu\n", system_get_time(), system_get_rtc_time());
// Register the ESP8266 initialization callback.
system_init_done_cb(initDone);
// Register the ESP8266 initialization callback.
system_init_done_cb(initDone);
// Do NOT attempt to auto connect to an access point.
//wifi_station_set_auto_connect(0);
os_timer_setfn(&mainLoopSuspendTimer, enableMainLoop, NULL);
// Do NOT attempt to auto connect to an access point.
//wifi_station_set_auto_connect(0);
os_timer_setfn(&mainLoopSuspendTimer, enableMainLoop, NULL);
}