Преглед изворни кода

Rebased against current dev, tweaks for clean compile

Terry Ellison пре 4 година
родитељ
комит
08426e48f1
5 измењених фајлова са 9 додато и 8 уклоњено
  1. 5 7
      app/coap/endpoints.c
  2. 1 1
      app/lua/lua.h
  3. 1 0
      app/modules/http.c
  4. 1 0
      app/platform/u8x8_nodemcu_hal.c
  5. 1 0
      app/platform/ucg_nodemcu_hal.c

+ 5 - 7
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);
     }

+ 1 - 1
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)

+ 1 - 0
app/modules/http.c

@@ -3,6 +3,7 @@
  * vowstar@gmail.com
  * 2015-12-29
 *******************************************************************************/
+#include <string.h>
 #include <stdlib.h>
 #include "module.h"
 #include "lauxlib.h"

+ 1 - 0
app/platform/u8x8_nodemcu_hal.c

@@ -9,6 +9,7 @@
 #include <stdlib.h>
 
 #include "platform.h"
+#include "user_interface.h"
 
 #define U8X8_USE_PINS
 #define U8X8_WITH_USER_PTR

+ 1 - 0
app/platform/ucg_nodemcu_hal.c

@@ -8,6 +8,7 @@
 #include <stdlib.h>
 
 #include "platform.h"
+#include "user_interface.h"
 
 #define USE_PIN_LIST
 #include "ucg_nodemcu_hal.h"