Commit a7ed9d7e authored by Nelso Jost's avatar Nelso Jost

FIX arduino trim() line

parent bd3b45ff
...@@ -2,7 +2,7 @@ include ../utils/platformio/Makefile ...@@ -2,7 +2,7 @@ include ../utils/platformio/Makefile
INOPROJECT = meteorolog INOPROJECT = meteorolog
BAUD = 9600 BAUD = 115200
BOARD = uno BOARD = uno
monitor: qtmonitor monitor: qtmonitor
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
#include "mysensors.h" #include "mysensors.h"
#include "boardcommands.h" #include "boardcommands.h"
#define BAUDRATE 9600 #define BAUDRATE 115200
String stream_line; String stream_line;
...@@ -25,6 +25,6 @@ void loop() ...@@ -25,6 +25,6 @@ void loop()
if (Serial.available()) if (Serial.available())
{ {
stream_line = Serial.readString(); stream_line = Serial.readString();
Serial.println(execute_board_command(stream_line)); Serial.println(execute_board_command(stream_line.trim()));
} }
} }
...@@ -45,7 +45,7 @@ String read_BMP085_PRESSURE() ...@@ -45,7 +45,7 @@ String read_BMP085_PRESSURE()
else else
{ {
return String("<bmp085_not_found>"); return String("<bmp085_not_found>");
} }
} }
// === RTC_DS1307 SETUP =========================================== // === RTC_DS1307 SETUP ===========================================
...@@ -56,16 +56,11 @@ RTC_DS1307 rtc; ...@@ -56,16 +56,11 @@ RTC_DS1307 rtc;
String read_RTC_DS1307() String read_RTC_DS1307()
{ {
//if (!rtc.isrunning())
//{
//return String("<RTC_DS1307_not_found>");
//}
return get_datetime_str(rtc.now()); return get_datetime_str(rtc.now());
if (rtc.isrunning())
{
return get_datetime_str(rtc.now());
}
else
{
return String("<RTC_DS1307_not_found>");
}
} }
String get_datetime_str(DateTime dt) String get_datetime_str(DateTime dt)
...@@ -96,7 +91,7 @@ String set_time_from_csv(String s) ...@@ -96,7 +91,7 @@ String set_time_from_csv(String s)
return String("<RTC_DS1307_not_found>"); return String("<RTC_DS1307_not_found>");
} */ } */
DateTime dt; DateTime dt;
int i_month = s.indexOf(CSV_SEP); int i_month = s.indexOf(CSV_SEP);
int i_day = s.indexOf(CSV_SEP, i_month + 1); int i_day = s.indexOf(CSV_SEP, i_month + 1);
......
...@@ -21,15 +21,17 @@ ...@@ -21,15 +21,17 @@
#define PIN_LED D3 #define PIN_LED D3
#define PIN_BUTTON D0 #define PIN_BUTTON D0
#define ARDUINO_TX D1 // (soft RX) #define ARDUINO_TX D1 // (soft RX)
#define ARDUINO_RX D2 // (soft TX) #define ARDUINO_RX D2 // (soft TX)
#define ARDUINO_BAUDRATE 115200
const int chipSelect = 4; const int chipSelect = 4;
void REPL_ARDUINO(REPL * repl); void REPL_ARDUINO(REPL * repl);
void REPL_METEOROLOG(REPL * repl); void REPL_METEOROLOG(REPL * repl);
typedef struct typedef struct
{ {
REPL * repl; REPL * repl;
...@@ -38,10 +40,12 @@ typedef struct ...@@ -38,10 +40,12 @@ typedef struct
String board_hash; String board_hash;
} METEOROLOG_args; } METEOROLOG_args;
void meteorolog_callback(METEOROLOG_args * args); void meteorolog_callback(METEOROLOG_args * args);
void sd_datalog(String datalog, REPL * repl); void sd_datalog(String datalog, REPL * repl);
void server_datalog(String datalog, REPL * repl); void server_datalog(String datalog, REPL * repl);
REPL_COMMAND commands[] =\ REPL_COMMAND commands[] =\
{ {
ALLCMD_REPL_GPIO, ALLCMD_REPL_GPIO,
...@@ -51,7 +55,7 @@ REPL_COMMAND commands[] =\ ...@@ -51,7 +55,7 @@ REPL_COMMAND commands[] =\
{"arduino", REPL_ARDUINO, "arduino <command>", {"arduino", REPL_ARDUINO, "arduino <command>",
"Send command to Arduino via software serial."}, "Send command to Arduino via software serial."},
{"meteorolog", REPL_METEOROLOG, "meteorolog <interval> <command>", {"meteorolog", REPL_METEOROLOG, "meteorolog <interval_secs> <arduino_command>",
"Activate meterolog timer on given interval (seconds)."}, "Activate meterolog timer on given interval (seconds)."},
{NULL} {NULL}
...@@ -69,7 +73,7 @@ SoftwareSerial arduinoSerial(ARDUINO_TX, ARDUINO_RX); // RX, TX ...@@ -69,7 +73,7 @@ SoftwareSerial arduinoSerial(ARDUINO_TX, ARDUINO_RX); // RX, TX
void setup() void setup()
{ {
Serial.begin(BAUDRATE); Serial.begin(BAUDRATE);
arduinoSerial.begin(9600); arduinoSerial.begin(ARDUINO_BAUDRATE);
if (!SD.begin(chipSelect)) if (!SD.begin(chipSelect))
{ {
...@@ -184,12 +188,12 @@ void sd_datalog(String datalog, REPL * repl) ...@@ -184,12 +188,12 @@ void sd_datalog(String datalog, REPL * repl)
{ {
repl->log("\n[ERROR] Unable to open '" + String(DATALOG_FILENAME) + "'"); repl->log("\n[ERROR] Unable to open '" + String(DATALOG_FILENAME) + "'");
return; return;
} }
int written = sd_file.println(datalog); int written = sd_file.println(datalog);
sd_file.close(); sd_file.close();
repl->log("\n[INFO] " + String(written) + " bytes written at '" + repl->log("\n[INFO] " + String(written) + " bytes written at '" +
String(DATALOG_FILENAME) + "'"); String(DATALOG_FILENAME) + "'");
} }
...@@ -199,4 +203,6 @@ void server_datalog(String datalog, REPL * repl) ...@@ -199,4 +203,6 @@ void server_datalog(String datalog, REPL * repl)
String response = String("POST emm/api/post/rawsensordata HTTP/1.1\r\n") + \ String response = String("POST emm/api/post/rawsensordata HTTP/1.1\r\n") + \
"Host: dados.cta.if.ufrgs.br" + \ "Host: dados.cta.if.ufrgs.br" + \
"Content-type: Application/JSON"; "Content-type: Application/JSON";
// TODO: IMPLEMENT HTML CLIENT REST API
} }
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
"Print WiFi connection status (debug)."} "Print WiFi connection status (debug)."}
#define CMD_REPL_WIFICONNECT {\ #define CMD_REPL_WIFICONNECT {\
"wificonnect", REPL_WIFICONNECT, "wificonnect <ssid> <password>" \ "wificonnect", REPL_WIFICONNECT, "wificonnect <ssid> <password>", \
"Connect to a wifi network. If successful (threshold 10 sec), " \ "Connect to a wifi network. If successful (threshold 10 sec), " \
"it will autoconnect if board reseted."} "it will autoconnect if board reseted."}
......
...@@ -15,8 +15,8 @@ install-pip: ...@@ -15,8 +15,8 @@ install-pip:
sudo python get-pip.py && rm get-pip.py sudo python get-pip.py && rm get-pip.py
install-platformio: install-platformio:
which pip || $(MAKE) install-pip which pip2 || $(MAKE) install-pip
sudo pip install platformio sudo pip2 install platformio
sudo usermod -a -G dialout $$USER sudo usermod -a -G dialout $$USER
wget https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules wget https://raw.githubusercontent.com/platformio/platformio/develop/scripts/99-platformio-udev.rules
sudo mv -v 99-platformio-udev.rules /etc/udev/rules.d sudo mv -v 99-platformio-udev.rules /etc/udev/rules.d
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment