diff --git a/examples/Bootstrap/Bootstrap.ino b/examples/Bootstrap/Bootstrap.ino index 633152e..f2393e4 100644 --- a/examples/Bootstrap/Bootstrap.ino +++ b/examples/Bootstrap/Bootstrap.ino @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include diff --git a/examples/Electron/Electron.ino b/examples/Electron/Electron.ino new file mode 100644 index 0000000..5db456d --- /dev/null +++ b/examples/Electron/Electron.ino @@ -0,0 +1,37 @@ +/**************************************************************************\ +* Pinoccio Library * +* https://github.com/Pinoccio/library-pinoccio * +* Copyright (c) 2014, Pinoccio Inc. All rights reserved. * +* ------------------------------------------------------------------------ * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the MIT License as described in license.txt. * +\**************************************************************************/ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "version.h" + +void *e_debug(const char *file, int line, const char *function, const char * format, ...) +{ + Serial.print(file); + Serial.print(" "); + Serial.println(line); +} + +void setup() { + Scout.setup(SKETCH_NAME, SKETCH_REVISION, SKETCH_BUILD); + // Add custom setup code here + e_t e = e_val(NULL,"foo bar, boo baz, \"biz\":424242",0); + Serial.println(e_count(e)); +} + +void loop() { + Scout.loop(); + // Add custom loop code here +} diff --git a/examples/Electron/version.h b/examples/Electron/version.h new file mode 100644 index 0000000..8fcf115 --- /dev/null +++ b/examples/Electron/version.h @@ -0,0 +1,3 @@ +#define SKETCH_NAME "Custom" +#define SKETCH_BUILD -1 +#define SKETCH_REVISION "unknown" diff --git a/src/Scout.h b/src/Scout.h index a8c7571..ac0f608 100644 --- a/src/Scout.h +++ b/src/Scout.h @@ -9,6 +9,9 @@ #ifndef LIB_PINOCCIO_SCOUT_H_ #define LIB_PINOCCIO_SCOUT_H_ +#include +#include + #include #include #include @@ -24,6 +27,7 @@ #include "peripherals/halFuelGauge.h" #include "peripherals/halRgbLed.h" + // This is a temporary hack to check the result of snprintf and print an // error /* diff --git a/src/ScoutHandler.cpp b/src/ScoutHandler.cpp index 413ebfb..f6ca1a3 100644 --- a/src/ScoutHandler.cpp +++ b/src/ScoutHandler.cpp @@ -7,8 +7,8 @@ * under the terms of the BSD License as described in license.txt. * \**************************************************************************/ #include -#include #include +#include #include "SleepHandler.h" #include "backpack-bus/PBBP.h" #include "util/StringBuffer.h" @@ -554,7 +554,7 @@ void leadIncoming(const char *packet, size_t len, unsigned short *index) { if (strcmp(type, "online") == 0) { // fire the online event for everyone - Shell.eval(F("command.all(\"hq.online\",2)")); +// Shell.eval(F("command.all(\"hq.online\",2)")); } if (strcmp(type, "command") == 0) { diff --git a/src/Shell.cpp b/src/Shell.cpp index dcc9131..89f0095 100644 --- a/src/Shell.cpp +++ b/src/Shell.cpp @@ -13,8 +13,7 @@ #include "hq/HqHandler.h" #include "backpacks/Backpacks.h" #include "backpacks/wifi/WifiModule.h" -#include "bitlash.h" -#include "src/bitlash.h" +#include #include "util/String.h" #include "util/PrintToString.h" #include "modules/ModuleHandler.h" @@ -32,6 +31,13 @@ static bool isMeshVerbose = 0; * HELPER FUNCTIONS * \****************************/ +void *e_debug(const char *file, int line, const char *function, const char * format, ...) +{ + Serial.print(file); + Serial.print(" "); + Serial.println(line); +} + static void printSpaces(int8_t number) { while (number-- > 0) Serial.write(' '); diff --git a/src/Shell.h b/src/Shell.h index b4dbadb..33a4f5a 100644 --- a/src/Shell.h +++ b/src/Shell.h @@ -9,8 +9,8 @@ #ifndef LIB_PINOCCIO_SHELL_H_ #define LIB_PINOCCIO_SHELL_H_ -#include "bitlash.h" -#include "src/bitlash.h" +#include +#include "Scout.h" #include "lwm/sys/sysConfig.h" #include "lwm/phy/phy.h" @@ -167,30 +167,15 @@ static void evalPrint(uint8_t c) { evalOutput->write(c); } +static e_t ele_stack = NULL; inline numvar PinoccioShell::eval(Print *out, const String &cmd) { - if (isVerbose) { Serial.print(F("running eval of: ")); Serial.println((char*)cmd.c_str()); - } - if (out) { - evalOutput = out; - setOutputHandler(evalPrint); - }else if(isMuted){ - // print nowhere - evalOutput = NULL; - setOutputHandler(evalPrint); - } + ele_stack = e_val(ele_stack, (char*)cmd.c_str(), 0); + out->write(e_vchar(ele_stack),e_vlen(ele_stack)); - numvar ret = doCommand((char*)cmd.c_str()); - - if (out || isMuted) - resetOutputHandler(); - - // important, if we eval'd a new function update our cache - if(cmd.startsWith("function ")) refresh(); - - return ret; + return 0; } #endif