Skip to content

Commit

Permalink
Saved some SRAM
Browse files Browse the repository at this point in the history
  • Loading branch information
stanleyhuangyc committed Jan 6, 2017
1 parent 4b0c2c6 commit 30f1cf4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
6 changes: 3 additions & 3 deletions firmware_v4/telelogger_esp8266/config.h
Expand Up @@ -5,7 +5,7 @@
* Data logging settings
**************************************/
#define ENABLE_DATA_CACHE 1
#define CACHE_SIZE 384 /* bytes */
#define CACHE_SIZE 256 /* bytes */
#define ENABLE_DATA_OUT 0
#define STREAM_BAUDRATE 115200
#define STREAM_FORMAT FORMAT_TEXT
Expand All @@ -19,7 +19,7 @@
#define WIFI_SSID "SSID"
#define WIFI_PASSWORD "PASSWORD"
// change YOUR_SERVER_KEY to your server key
#define SERVER_KEY "YOUR_SERVER_KEY"
#define SERVER_KEY "TEST_SERVER_KEY"
#define SERVER_URL "hub.freematics.com"
#define SERVER_PORT 80

Expand Down Expand Up @@ -56,7 +56,7 @@
/**************************************
* Other options
**************************************/
#define MIN_LOOP_TIME 500 /* ms */
#define MIN_LOOP_TIME 200 /* ms */
#define COOLING_DOWN_TEMP 65 /* celsius degrees */

#endif // CONFIG_H_INCLUDED
30 changes: 13 additions & 17 deletions firmware_v4/telelogger_esp8266/telelogger_esp8266.ino
Expand Up @@ -161,9 +161,11 @@ public:
byte checkbuffer(const char* expected, unsigned int timeout = 2000)
{
// check if expected string is in reception buffer
/*
if (strstr(buffer, expected)) {
return 1;
}
*/
// if not, receive a chunk of data from xBee module and look for expected string
byte ret = xbReceive(buffer, sizeof(buffer), 0, expected) != 0;
if (ret == 0) {
Expand Down Expand Up @@ -271,19 +273,6 @@ public:
{
// action == 0 for registering a data feed, action == 1 for de-registering a data feed

// retrieve VIN
char vin[20] = {0};
if (action == 0) {
// retrieve VIN
if (getVIN(buffer, sizeof(buffer))) {
strncpy(vin, buffer, sizeof(vin) - 1);
Serial.print("#VIN:");
Serial.println(vin);
}
} else {
if (feedid == 0) return;
}

for (byte n = 0; ;n++) {
// make sure OBD is still accessible
if (readSpeed() == -1) {
Expand All @@ -292,9 +281,11 @@ public:
// start a HTTP connection (TCP)
tcpConnect();
byte ret;
do {
delay(100);
} while ((ret = tcpIsConnected()) == 0);
for (byte n = 0; n < 10 && (ret = tcpIsConnected()) == 0; n++) {
Serial.print('.');
delay(1000);
}
Serial.println();
if (ret == 2) {
Serial.println(buffer);
Serial.println("Unable to connect");
Expand All @@ -308,7 +299,12 @@ public:

// generate HTTP request path
if (action == 0) {
sprintf_P(buffer, PSTR("/%s/reg?vin=%s"), SERVER_KEY, vin);
char vin[20] = {0};
byte n = sprintf_P(buffer, PSTR("/%s/reg?vin="), SERVER_KEY);
// retrieve VIN and append it to URL
getVIN(buffer + n, sizeof(buffer) - n - 1);
Serial.print("#VIN:");
Serial.println(buffer + n);
} else {
sprintf_P(buffer, PSTR("/%s/reg?id=%d&off=1"), SERVER_KEY, feedid);
}
Expand Down

0 comments on commit 30f1cf4

Please sign in to comment.