Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
Slavey Karadzhov committed Mar 8, 2017
2 parents b17cee7 + 7dec45f commit 49b5172
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 8 deletions.
1 change: 1 addition & 0 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ n/a = The selected SDK is not available on that OS
- Custom Heap Allocation:(default:off) If your application is experiencing heap fragmentation then you can try the Umm Malloc heap allocation. To enable it compile Sming with ENABLE_CUSTOM_HEAP=1. In order to use it in your sample/application make sure to compile the sample with ENABLE_CUSTOM_HEAP=1. Avoid enabling your custom heap allocation AND -mforce-l32 compiler flag.
- Debug information log level and format: There are four debug levels: debug=3, info=2, warn=1, error=0. Using DEBUG_VERBOSE_LEVEL you can set the desired level (0-3). For example DEBUG_VERBOSE_LEVEL=2 will show only info messages and above. Another make directive is DEBUG_PRINT_FILENAME_AND_LINE=1 which enables printing the filename and line number of every debug line. This will require extra space on flash. Note: You can compile the Sming library with a set of debug directives and your project with another settings, this way you can control debugging sepparately for sming and your application code.
- Debug information for custom LWIP: If you use custom LWIP(see above) some debug information will be printed for critical errors and situations. You can enable debug information printing altogether using ENABLE_LWIPDEBUG=1. To increase debugging for certain areas you can modify debug options in third-party/esp-open-lwip/include/lwipopts.h
- CommandExecutor feature disabling. This feature enables execution of certain commands by registering token handlers for text received via serial, websocket or telnet connection. If this feature is not used additional RAM/Flash can be obtained by setting ENABLE_CMD_EXECUTOR=0. This will save ~1KB RAM and ~3KB of flash memory.
</p></details>

## Compilation and flashing
Expand Down
5 changes: 4 additions & 1 deletion Sming/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,9 @@ DEBUG_PRINT_FILENAME_AND_LINE ?= 0
# Defaut debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0
DEBUG_VERBOSE_LEVEL ?= 2

# Disable CommandExecutor functionality if not used and save some ROM and RAM
ENABLE_CMD_EXECUTOR ?= 1

RELOAD_MKFILE = 0

# Sming Framework Path
Expand Down Expand Up @@ -198,7 +201,7 @@ ifeq ($(ENABLE_CUSTOM_PWM), 1)
endif

# compiler flags using during compilation of source files. Add '-pg' for debugging
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL)
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR)
ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
Expand Down
5 changes: 4 additions & 1 deletion Sming/Makefile-project.mk
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ COM_SPEED_ESPTOOL ?= $(COM_SPEED)
# Default COM port speed (used in code)
COM_SPEED_SERIAL ?= $(COM_SPEED)

# Disable CommandExecutor functionality if not used and save some ROM and RAM.
ENABLE_CMD_EXECUTOR ?= 1

## Flash parameters
# SPI_SPEED = 40, 26, 20, 80
SPI_SPEED ?= 40
Expand Down Expand Up @@ -202,7 +205,7 @@ endif
LIBS = microc microgcc hal phy pp net80211 $(LIBLWIP) wpa $(LIBMAIN) $(LIBSMING) crypto $(LIBPWM) smartconfig $(EXTRA_LIBS)

# compiler flags using during compilation of source files
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS)
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR)
ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
Expand Down
5 changes: 4 additions & 1 deletion Sming/Makefile-rboot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ DEBUG_PRINT_FILENAME_AND_LINE ?= 0
# Defaut debug verbose level is INFO, where DEBUG=3 INFO=2 WARNING=1 ERROR=0
DEBUG_VERBOSE_LEVEL ?= 2

# Disable CommandExecutor functionality if not used and save some ROM and RAM
ENABLE_CMD_EXECUTOR ?= 1

## ESP_HOME sets the path where ESP tools and SDK are located.
## Windows:
# ESP_HOME = c:/Espressif
Expand Down Expand Up @@ -188,7 +191,7 @@ EXTRA_INCDIR += $(SMING_HOME)/include $(SMING_HOME)/ $(LWIP_INCDIR) $(SMING_HOME
USER_LIBDIR = $(SMING_HOME)/compiler/lib/

# compiler flags using during compilation of source files
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS)
CFLAGS = -Wpointer-arith -Wundef -Werror -Wl,-EL -nostdlib -mlongcalls -mtext-section-literals -finline-functions -fdata-sections -ffunction-sections -D__ets__ -DICACHE_FLASH -DARDUINO=106 -DCOM_SPEED_SERIAL=$(COM_SPEED_SERIAL) $(USER_CFLAGS) -DENABLE_CMD_EXECUTOR=$(ENABLE_CMD_EXECUTOR)
ifeq ($(SMING_RELEASE),1)
# See: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
# for full list of optimization options
Expand Down
1 change: 0 additions & 1 deletion Sming/Services/CommandProcessing/CommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,4 @@ void CommandHandler::processCommandOptions(String commandLine ,CommandOutput* c
}
}


CommandHandler commandHandler;
2 changes: 2 additions & 0 deletions Sming/SmingCore/Debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ DebugClass::~DebugClass()

void DebugClass::initCommand()
{
#if ENABLE_CMD_EXECUTOR
commandHandler.registerCommand(CommandDelegate("debug","New debug in development","Debug",commandFunctionDelegate(&DebugClass::processDebugCommands,this)));
#endif
}

void DebugClass::start()
Expand Down
13 changes: 11 additions & 2 deletions Sming/SmingCore/HardwareSerial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,11 @@ void HardwareSerial::callbackHandler(uart_t *uart) {
lastPos = uart->rx_buffer->size;
}
uint8_t receivedChar = uart->rx_buffer->buffer[lastPos-1];
if ((memberData[uart->uart_nr].HWSDelegate) || (memberData[uart->uart_nr].commandExecutor)) {
if ((memberData[uart->uart_nr].HWSDelegate)
#if ENABLE_CMD_EXECUTOR
|| (memberData[uart->uart_nr].commandExecutor)
#endif
) {
uint32 serialQueueParameter;
uint16 cc = uart_rx_available(uart);
serialQueueParameter = (cc * 256) + receivedChar; // can be done by bitlogic, avoid casting to ETSParam
Expand All @@ -193,9 +197,11 @@ void HardwareSerial::callbackHandler(uart_t *uart) {
if (memberData[uart->uart_nr].HWSDelegate) {
system_os_post(USER_TASK_PRIO_0, SERIAL_SIGNAL_DELEGATE, serialQueueParameter);
}
#if ENABLE_CMD_EXECUTOR
if (memberData[uart->uart_nr].commandExecutor) {
system_os_post(USER_TASK_PRIO_0, SERIAL_SIGNAL_COMMAND, serialQueueParameter);
}
#endif
}
}

Expand Down Expand Up @@ -227,6 +233,7 @@ void HardwareSerial::resetCallback()

void HardwareSerial::commandProcessing(bool reqEnable)
{
#if ENABLE_CMD_EXECUTOR
if (reqEnable)
{
if (!memberData[uartNr].commandExecutor)
Expand All @@ -239,6 +246,7 @@ void HardwareSerial::commandProcessing(bool reqEnable)
delete memberData[uartNr].commandExecutor;
memberData[uartNr].commandExecutor = nullptr;
}
#endif
}

void HardwareSerial::delegateTask (os_event_t *inputEvent)
Expand All @@ -258,10 +266,11 @@ void HardwareSerial::delegateTask (os_event_t *inputEvent)
break;

case SERIAL_SIGNAL_COMMAND:

#if ENABLE_CMD_EXECUTOR
if (memberData[uartNr].commandExecutor) {
memberData[uartNr].commandExecutor->executorReceive(rcvChar);
}
#endif
break;

default:
Expand Down
7 changes: 6 additions & 1 deletion Sming/SmingCore/Network/HttpServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,13 @@ bool HttpServer::initWebSocket(HttpServerConnection& connection, HttpRequest& re

wsocks.addElement(sock);
if (wsConnect) wsConnect(*sock);

if (wsCommandEnabled && (request.getQueryParameter(wsCommandRequestParam) == "true"))
{
#if ENABLE_CMD_EXECUTOR
debugf("WebSocket Commandprocessor started");
#else
debugf("WebSocket Commandprocessor support DISABLED via ENABLE_CMD_EXECUTOR");
#endif
sock->enableCommand();
}
}
Expand Down Expand Up @@ -148,7 +151,9 @@ void HttpServer::processWebSocketFrame(pbuf *buf, HttpServerConnection& connecti
msg.setString((char*)data, size);
debugf("WS: %s", msg.c_str());
if (sock && wsMessage) wsMessage(*sock, msg);
#if ENABLE_CMD_EXECUTOR
if (sock && sock->commandExecutor) sock->commandExecutor->executorReceive(msg+"\r");
#endif
}
else if (frameType == WS_BINARY_FRAME)
{
Expand Down
9 changes: 8 additions & 1 deletion Sming/SmingCore/Network/TelnetServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ void TelnetServer::enableDebug(bool reqStatus)

void TelnetServer::enableCommand(bool reqStatus)
{
#if ENABLE_CMD_EXECUTOR
if (reqStatus && curClient && !commandExecutor)
{
commandExecutor = new CommandExecutor(curClient);
Expand All @@ -43,6 +44,7 @@ void TelnetServer::enableCommand(bool reqStatus)
delete commandExecutor;
commandExecutor = nullptr;
}
#endif
telnetCommand = reqStatus;
}
void TelnetServer::onClient(TcpClient *client)
Expand All @@ -64,7 +66,9 @@ void TelnetServer::onClient(TcpClient *client)
curClient->sendString("Welcome to Sming / ESP6266 Telnet\r\n");
if (telnetCommand)
{
#if ENABLE_CMD_EXECUTOR
commandExecutor = new CommandExecutor(client);
#endif
}
if (telnetDebug)
{
Expand All @@ -78,8 +82,10 @@ void TelnetServer::onClientComplete(TcpClient& client, bool succesfull)
{
if ( &client == curClient)
{
#if ENABLE_CMD_EXECUTOR
delete commandExecutor;
commandExecutor = nullptr;
#endif
curClient = nullptr;
debugf("TelnetServer onClientComplete %s", client.getRemoteIp().toString().c_str() );
}
Expand All @@ -104,10 +110,11 @@ bool TelnetServer::onClientReceive (TcpClient& client, char *data, int size)
{
debugf("TelnetServer onClientReceive : %s, %d bytes \r\n",client.getRemoteIp().toString().c_str(),size );
debugf("Data : %s", data);
#if ENABLE_CMD_EXECUTOR
if (commandExecutor)
{
commandExecutor->executorReceive(data,size);
}

#endif
return true;
}
4 changes: 4 additions & 0 deletions Sming/SmingCore/Network/WebSocket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ WebSocket::WebSocket(HttpServerConnection* conn)

WebSocket::~WebSocket()
{
#if ENABLE_CMD_EXECUTOR
if (commandExecutor)
{
delete commandExecutor;
}
#endif
}

bool WebSocket::initialize(HttpRequest& request, HttpResponse& response)
Expand Down Expand Up @@ -65,10 +67,12 @@ void WebSocket::sendBinary(const uint8_t* data, int size)

void WebSocket::enableCommand()
{
#if ENABLE_CMD_EXECUTOR
if (!commandExecutor)
{
commandExecutor = new CommandExecutor(this);
}
#endif
}

void WebSocket::close()
Expand Down

0 comments on commit 49b5172

Please sign in to comment.