From 522b1d00767561c7e30bbad714266f78a1072e88 Mon Sep 17 00:00:00 2001 From: Terry Ellison Date: Tue, 23 Jul 2019 21:22:59 +0100 Subject: [PATCH] Rebased against current dev, tweaks for clean compile --- app/coap/endpoints.c | 12 +++++------- app/lua/lua.h | 2 +- app/modules/http.c | 1 + app/platform/u8x8_nodemcu_hal.c | 1 + app/platform/ucg_nodemcu_hal.c | 1 + 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/coap/endpoints.c b/app/coap/endpoints.c index 1ec88287..ce62dda6 100644 --- a/app/coap/endpoints.c +++ b/app/coap/endpoints.c @@ -162,8 +162,6 @@ end: return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_NOT_FOUND, COAP_CONTENTTYPE_NONE); } -extern int lua_put_line(const char *s, size_t l); - static const coap_endpoint_path_t path_command = {2, {"v1", "c"}}; static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo) { @@ -171,11 +169,11 @@ static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scra return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_BAD_REQUEST, COAP_CONTENTTYPE_TEXT_PLAIN); if (inpkt->payload.len > 0) { - char line[LUA_MAXINPUT]; - if (!coap_buffer_to_string(line, LUA_MAXINPUT, &inpkt->payload) && - lua_put_line(line, strlen(line))) { - NODE_DBG("\nResult(if any):\n"); - system_os_post (LUA_TASK_PRIO, LUA_PROCESS_LINE_SIG, 0); + char line[LUA_MAXINPUT+1]; + if (!coap_buffer_to_string(line, LUA_MAXINPUT, &inpkt->payload)) { + int l = strlen(line); + line[l] = '\n'; + lua_input_string(line, l+1); } return coap_make_response(scratch, outpkt, NULL, 0, id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_TEXT_PLAIN); } diff --git a/app/lua/lua.h b/app/lua/lua.h index 874f0fc4..46b5dc35 100644 --- a/app/lua/lua.h +++ b/app/lua/lua.h @@ -277,7 +277,7 @@ LUA_API void lua_setallocf (lua_State *L, lua_Alloc f, void *ud); #define lua_istable(L,n) (lua_type(L, (n)) == LUA_TTABLE) #define lua_isrotable(L,n) (lua_type(L, (n)) == LUA_TROTABLE) #define lua_isanytable(L,n) (lua_istable(L,n) || lua_isrotable(L,n)) -#define lua_islightuserdata(L,n) (lua_type(L, (n) == LUA_TLIGHTUSERDATA) +#define lua_islightuserdata(L,n) (lua_type(L, (n)) == LUA_TLIGHTUSERDATA) #define lua_isnil(L,n) (lua_type(L, (n)) == LUA_TNIL) #define lua_isboolean(L,n) (lua_type(L, (n)) == LUA_TBOOLEAN) #define lua_isthread(L,n) (lua_type(L, (n)) == LUA_TTHREAD) diff --git a/app/modules/http.c b/app/modules/http.c index fddc902a..7b2ff115 100644 --- a/app/modules/http.c +++ b/app/modules/http.c @@ -3,6 +3,7 @@ * vowstar@gmail.com * 2015-12-29 *******************************************************************************/ +#include #include #include "module.h" #include "lauxlib.h" diff --git a/app/platform/u8x8_nodemcu_hal.c b/app/platform/u8x8_nodemcu_hal.c index 82a5a81b..11000195 100644 --- a/app/platform/u8x8_nodemcu_hal.c +++ b/app/platform/u8x8_nodemcu_hal.c @@ -9,6 +9,7 @@ #include #include "platform.h" +#include "user_interface.h" #define U8X8_USE_PINS #define U8X8_WITH_USER_PTR diff --git a/app/platform/ucg_nodemcu_hal.c b/app/platform/ucg_nodemcu_hal.c index a72990f6..b54a133e 100644 --- a/app/platform/ucg_nodemcu_hal.c +++ b/app/platform/ucg_nodemcu_hal.c @@ -8,6 +8,7 @@ #include #include "platform.h" +#include "user_interface.h" #define USE_PIN_LIST #include "ucg_nodemcu_hal.h"