LOGIN
Steven Reubenstone
Mechanical Engineer & Collaborizm Mentor. Join our iOT Hackathon! (Project Leader)
 · New YorkU.S.
Share
Get Link
Report
QUESTION
Open

Questions (I am using these for learning purposes) Harsha Alva

  1. Can you explain what the checkMemState(); function does?

  2. Are you saying that the arduino automatically allocates memory to delimited strings…so this is why you transmit it via the delimited string to the arduino?

0 like 
Like
Harsha Alva
Mechanical Engineer + Software Dev
 · MangaluruIndia
Share
Get Link
Report

Hi Steven Reubenstone

  1. It checks free RAM and resets the Arduino if it goes below 300 bytes. Otherwise, the Arduino will hang, parsed output will be garbage and LCD output will be blank.

  2. No, the Arduino doesn’t allocate memory statically for delimited strings.
    I have second thoughts about using delimited strings.
    TODO: There is a library that handles JSON and manages memory at low-level. I’ll try that and compare with the present sketch
    DONE: Parsing JSON on Arduino is much easier and simpler than using delimited strings. 😃

1 like 
Steven Reubenstone
Mechanical Engineer & Collaborizm Mentor. Join our iOT Hackathon! (Project Leader)
 · New YorkU.S.
Share
Get Link
Report

Harsha Alva so this is the actually http request? What would it look like as one string sent to the server? I am trying to understand how the request functions. Also, the web server is programmed now to only out put from one form of “request” which is what I assume is happening here. So essentially we send a specifically formatted request to web server, server spits out 1 json response, which contains our event data.

Am I current in that the database only stores newest event/entry?

/*** Connect to server ***/
  checkMemState();
  wdtResetIfWaitShort();
  // Send GET REQUEST
  if (WebClient.connect(gServerName, gServerPort)) {
    WebClient.println("GET " + gServerRestPath + " HTTP/1.1");
    WebClient.println("Host: " + String(gServerRestPath));
    WebClient.println("Connection: close");
    WebClient.println();
  } else {
    serialOutF(F("Connection failed"));
    lcdOutF2(F("Local Server"), F("CXN Failure"));
    windUpOnError();
    return;
  }

  wdtResetDisable();
  serialOutF(F("Connected to Local Server"));
  lcdOutF2(F("Local Server"), F("CXN Success"));
  /*** End Connect to server ***/


  /*** Data Integrity check ***/
  checkMemState();
  wdtResetIfWaitShort();

  WebClient.setTimeout(HTTP_TIMEOUT);
  bool ok = WebClient.find(CHR_CONTENT_START);
  if (!ok) {
    serialOutF(F("No data or invalid data received from Local Server. Retrying..."));
    lcdOutF2(F("Local Server"), F("RX data null"));
    windUpOnError();
    return;
  }
0 like 
Harsha Alva
Mechanical Engineer + Software Dev
 · MangaluruIndia
Share
Get Link
Report

Hello Steven Reubenstone. Here are my replies to your questions.

Harsha Alva so this is the actually http request? What would it look like as one string sent to the server? I am trying to understand how the request functions. Also, the web server is programmed now to only out put from one form of “request” which is what I assume is happening here. So essentially we send a specifically formatted request to web server, server spits out 1 json response, which contains our event data.

There are 4 REST endpoints in total for our database, 2 of which are for querying events.

  1. /events? This endpoint allows you to use parameters to specify constraints or conditions to select a JSON array of events.

  2. /events/arduino This endpoint is for low memory devices like Arduino/NodeMcu. Sending a large array of JSON would be an overkill for a device with just 2 KB of memory.
    So this endpoint only spits out a JSON object that will be directly displayed on a screen.

The screenshot below shows the 2 different endpoints in action.

You can find more info about the endpoints in the README, section 4 under Important Stuff.

 

Am I current in that the database only stores newest event/entry?

Not exactly. it downloads all new events that are added to Mixpanel after the last update timestamp. Only required events (Ex: “Reply”, etc) are downloaded from Mixpanel.
You can configure the required Mixpanel event names in Node_Server\mixpanel.js (line 16)

0 like 
Leave a reply...
DISCOVER
CHAT
ALERTS
DISCUSSIONS
FEED