Recommendations on HTTP Bindings and Command Mapping

Usually when creating an app/driver I throw together a quick pseudo code of what I'm looking to do and then adjust it. Sometimes I see where this would not work and make adjustments before even coding.

In this case I would probably do the following.

Settings:  IP, Port  (this way you can create a different device for each sage install)
Capabilities:  pushableButton
Commands: sendCommand ["string"], push 

Then you can create a remote control in a dashboard and just add a bunch of buttons and make each button execute a different command which then gets processed from the push method.

(off the top of my head putting together ruff code)

def push(btn) {
       sendCommand(btn) // on the dashboard you can put a string in for the button
}

def sendCommand(cmd) {
  httpGet("<urlstuff>&cmd=${cmd}")
}

The only other thing I would recommend is using asynch httpGet commands. Its a lot easier on the system as it doesn't wait around for a response. And later on you can process other things in the callback method for added functionality.

You can take a look at my Fully Kiosk code to get some ideas if needed. Its a very simple driver too that just sends commands the same way.

Hopefully this makes sense and helps. Everybody thinks differently when it comes to thier coding process.

2 Likes