Have a working proto type of remote valve operator. Open, close, state and flow detected….
Not a fan of the architecture I am using and looking for other ideas, especially with Ledger and logic in Beta. Today’s architecture uses particle variables and webhooks to execute and extract data from the Boron, Electron…. All works great. To expose this to the end user there is a light sail instance that is vending an index.html that also has a css and a JavaScript file. That JS file has the code that is executed on a button push if the passcode is correct…. It creates a new Particle device, then calls particle.callfunction (…). In this case it will call into the API and fire a relay on the particle board.
Here are the issues with my architecture as I see them.
JS is client side and accessing a data sets for “passcode” seems less secure.
Today, the JS has a hardcoded passcode in it, to scale these need to come from a DB or data store.
The files, index.html, Index.css and index.js are all on a Wordpress site, just dropped a static page out there. It seems like I could use WP rest calls to make calls from the WP server into the particle cloud instead of using client side code. I am by no means a JS programmer so there is a lot of trial and error in that but it does work. The JS file has my AUTH token, my device id…. Seems like a poor architecture to me.
Long term there are multiple users, each user has access to 1 or more end devices.
As an example
User 1 User 2 and User 3 can have access to devices (boron) 1-10, 11-20 and 21-30 respectively
Admin 1 has access to 1-20
Admin 2 has access to 21-30
Super user has access to all device
Looking for insight from people who have built a multi device deployment:
Did you use Node as your intermediate code, bridge to the particle cloud?
Wordpress anyone?
Did you do custom back office system in Java, C…. That does all the business logic?
JS code….
…
Var particle = new Particle(); …
…
Cycle.addEventListener("click", function (){
console.log("in test3");
var tmpCode = document.getElementById("passcode").value
console.log("Code typed in %s", tmpCode);
if ( tmpCode == 1234 ){
name.style.color = "Purple";
setTimeout(resetColor, 9000);
//console.log("Passcode matches Issuing Relay to ID : %s, Auth %s", ID, AUTH);
particle.callFunction({ deviceId: ID, name: 'Relay', argument:'cycle', auth: AUTH});
} else {
name.style.color = "red";
setTimeout(resetColor, 2000);
}