(Beginner) Help required for storing data + using Twilio

I’m a huge beginner in Squirrel/C, so thanks for your patience. My basic use case:

  1. Door sensor recognizes when open or closed (works)
  2. Every time door is opened, log time stamp and store data (works with server log but not with Twilio just yet)
    3*. If door is opened for too long, inform agent and send Twilio notification (This is a big problem at the moment)
  3. At the end of day, at 11:59pm, send twilio text notification with all time stamps that door was opened in that day (Seem to have no problem storing data into an array, but not quite working yet)
  4. Wipe any time stamp data after 11:59pm to allow room for tomorrow’s time stamps

For (3) I am unsure how to use the device.on / agent.send combo for device to tell agent to run the function that sends the twilio notification — I do not need to pass any data parameter in this case.

For (4) preliminary testing I printed the server log and it returned (array : 0x7fce843d8640) instead of a timestamp

I’ll be honest and say I’m not even sure how to approach (5), as I am unfamiliar with the device storage of the Imp004m other than that it has little memory. I figure I will run into issues if I don’t wipe time stamps daily.

  1. Just call agent.send() with a message name and some small dummy data. I usually do, eg. agent.send("end.of.day", true); and then have device.on("end.of.day", function(ignoredValue) { ... }{;, ie. don’t do anything with the true.

  2. This is because you’re sending an array to the agent (serializedData) and just logging its reference (passedValueCopy) — you want to do server.log(passedValueCopy[0]); to output the first item in the array.

As a beginner you might want to check out the Squirrel Programming Guide in the Dev Center, where there’s also some Twilio-oriented sample code.