I’m working on an application of the notecard for remote control of an entry gate. I’ve used the Notehub JS library to create a simple webpage that contains a ‘gate open’ button that sends a {“command”: “open”} pair to Notehub and receive it in a data.qi file. This part works. I now need to get that to the Notecard and the Swan MCU to process it. I’m by no means a software developer, so please keep that in mind. In reading though the various guides, I see information that appears slightly different and I am not knowledgeable enough to know if both are correct and are different methods or why one is used over the other. Here is what I am talking about:
In the Notecard API documentation for note.get it provides this C code:
J *req = NoteNewRequest(“note.get”);
JAddStringToObject(req, “file”, “requests.qi”);
JAddBoolToObject(req, “delete”, true);
NoteRequest(req);
In this guide, Remote Command and Control - Blues Developers, it shows this:
J *req = notecard.newRequest(“note.get”);
JAddStringToObject(req, “file”, “data.qi”);
JAddBoolToObject(req, “delete”, true);
Why the two different versions of the J *req line? Which to use?
Also, for my application, the usage will be very low, maybe once or twice every couple of weeks or even months. It would seem that having the Notecard in continuous mode may not be necessary, but a proper periodic timeframe is impossible to know. Having my webpage also send a ‘wake up to continuous mode’ before initiating the open gate sequence would seem a logical thing to do. I searched thru the forum and found some references to using the reserved environmental variables to do this (I think). In this topic, Remote control notecard - #4 by tjvantoll, TJ suggests that
" The environment variables allow you to remotely switch your Notecard’s mode
, and to change your inbound
and outbound
values. However, you need to run a {"req":"hub.set","reset":true}
request after enabling continuous mode, as the Notecard requires a reset to set up a socket to listen for inbound .qi
changes."
How does one go about running the {“req”:“hub.set”,“reset”:true} request from code either at the Notehub level or webpage? After the gate actions are complete is there a similar way to set the Notecard back to periodic? Thanks.