Over the last couple days I’ve been working on a web app for my buddy’s remote starter project. I tried to make everything easily customize-able all in one file and one place in the user editable data of the index.html file.
If you’re looking for a simple way to interface some controls and feedback in your project, this might be right up your alley.
Try out this ready to go example, and then start hacking on it to suit your needs: https://github.com/technobly/Remote-Spark
(A Remote Starter example that’s a customize-able simple Spark Core web app controller with feedback through Variables.)
Designed to work well on the iPhone 5s. Let me know how it works on your smartphone as well.
Thanks to jflasher for his really great Spark Helper web app that was the starting point for this project!
I see you use integers to return the states Spark.variable("startstate", &startState, INT);.
I like to return a value from an analog port, do you know if it is possible to return other data types (e.g.Floats or Strings)?
Thanks for this @BDub. I’ve just cusomised it to show the readings from my weather station:
I have a question, for you or anyone to answer. If I publish this to web, it would be easy for anyone to view the source and find my core id and access token. I assume that’s why you said “upload to a secret URL”. But if I want to make the data available to anyone, how can I protect my core?
If you look at the way he did his communication from client Spark to index.php you can do something similar from your client app to an index.php. But instead of communicating to the bus website, you will be communicating to the spark API.
This probably needs a nice example done for it if you are not too familiar with web development. Let me know if you want to take a stab at it or still need help.
Sorry @BDub, maybe I’m being a bit thick! I can’t see an index.php on @Coffee’s github repository. If I follow one of the links there to an older Arduino repository, there is an index.php there, but I don’t think its Spark Core related
I though that must have been what happened. Your link is the file I mentioned in my post earlier. Its an Arduino application and doesn’t show any example calls to spark cloud, so its only so much use to me as an example, unfortunately.
So… PHP… another new language to get to grips with!
Thanks @Coffee. Despite not knowing any PHP, I think I follow what it is doing. I could hide the core id too, by changing it to not expect that as a parameter, and adding it to the forwarded request, just like the access token.
Last time I used PHP, my goto method for securing config data was to make a “config.php” file somewhere out of the web root (depends on how you’re hosting it), and readable by the web-server uid, and include a reference to that in your page. In theory your web server should be sensible enough to not serve php source, but in the event that fails somehow at least your config file is not visible without some other more extensive hack.
Technically it depends how your web server is configured, but generally when a server is set up to run a program like a PHP script it won’t respond with the source of the program itself, but rather run the program and send the result to the client. So, the privacy of your token depends on the resistance of your web server to hacking or other malicious activity.
Thanks @amanfredi, yes, that’s what seem to happen when I try to view the .php file using my browser. I’m no hacker though, so I don’t know how securely my web server is set up. I pay for it anually, I certainly didn’t set it up myself!