Cloud vs. Android API vs Local Net Access via HTTP Request by user

First, thanks to Spark Team & community for this wonderful technology game changer. ! WiFi in control at Micro scale.

My questions are:

Can the spark core be access via a HTTP request to turn on and off Digital or Analog pins and set output using a ported version of Arduino’s Wireless or Ethernet Library ?

Will a Web based user control option be provided other than the Cloud API for smart devices so users on a local network using a “Personal Computer” be able to control the Spark Core ?

There is Android App, iOS App. There is already TCP, UDP built-in. Plus there are Node.js and Json user libraries. There are some technical limitations, but Spark Team is making a progress each Sprint. Local communication with PC example.

Yes, pretty much anything you can code it to do, you can make it remote controllable via the web. See the Spark.function() explanation in the Docs. Also check out the Tinker API and how that uses Functions to control the digital I/O. Also check out my simple remote control and remote spark web apps.

This is all baked in, no need for Arduino's Wireless or Ethernet Library

curl https://api.spark.io/v1/devices/0123456789abcdef01234567/digitalwrite \
  -d access_token=1234123412341234123412341234123412341234 -d params=D0,HIGH

If you know HTTP, you probably know what is GET and POST request, right? Curl is a must-have utility - http://curl.haxx.se/download.html (Windows download at the bottom). I don’t like dumb people, who wants to develop and maybe sell software solution and not to be a software programmer or pay one. It starts with asking on forums how to do their job without RTFM and ends by hundreds of security holes on end user stations IMHO :smiley:

I don’t want my customers to have to hire a software programmer either. And, yes I know curl / POST & GET request but at a basic level using forms in PHP. And how is someone suppose to obtain the token to insert in to their webage to control pins on a Spark Core ? Hire a programmer to accomplish this.

Who’s selling software here ? All this has to do is this, very simple,

Is there an option (or will be offered in the future) to allow a user inside a local network “Standard Business Class Environment” the ability to control the pins on Spark Core from a Personal Computer ?

90% of the companies I work will will not allow external control of this device via Spark’s Cloud.

@skydrop, can you give a real example of controlling Arduino using just http requests?

You definitely need to have some firmware code in the core or any other devices to het things working.

Having the access token gives security of the application and you wont want people to just control anyhow, anyone.

Maybe with a real example I can help you :slight_smile:

And finally we’ve got a dedicated thread to deal with your question after scattering answers on three other threads
[this][1], [this][2] and [this][3]

Maybe this way it gets sorted to your satisfaction :wink:

BTW @kennethlimcp in post 12 of the first thread you’d find the example you asked for here :smile:
[1]: https://community.spark.io/t/extended-android-spark-tinker-app-rgb-led-rx-tx-pins/2899/13
[2]: https://community.spark.io/t/how-to-connect-to-spark-cloud-and-pass-the-info-from-smart-device/3168/10
[3]: https://community.spark.io/t/question-about-android-source-usage-in-homecontroller-project/2922

Porting is over didn’t take too long :smiley:

Do you need a pull-request? :spark:

I both understand and appreciate the token key security and persistent connection that the spark core maintains to the Spark Cloud and that will be very beneficial on some projects especially the fact that a user does not have to open a port in their router manually. However, as everyone does know security is not an issue behind a properly configured router / switch and local control of Spark Digital & Analog from a personal computer would be most beneficial to all users. A simple interface for all users is an HTML webpage or could be a Android App.

Spark Core is proposed to be a device that should be placed with production hardware and that is simple enough but, if a custom Android API has to be created and compile for each and every application isn’t that a lot to expect from hobbyist and others who can do it with HTML under Arduino ?

Well, I’m not sure just yet. I have digest what it was that you did to port this image. Hello to you to :sunny:

Basically, i just changed the Ethernet library to the :spark: TCP library. There’s not secret and you can see it here:

https://gist.github.com/kennethlimcp/8a2e47c496165825cc08

@spydrop At some point you would need a local server to host the :spark: cloud locally and make use of the API feature to control your cores.

That’s gonna change things a lot and make things much easier to manage than to have a TCPserver running on each core!

have fun :slight_smile:

WOW ! and thanks a lot. I will test this weekend.

I have clients that won’t allow external control of any device via a cloud type system external to their corporate network.

Thanks Again,

Bobby

Hi, Kenneth. Sense the Spark Core can run a local TCP server IP on a local network can I also setup a static IP on my router to the Core TCP Server and use Zachary’s discover Core IP --> TCP Server Code. Listed below. Then I can run HTML commands from a client browser to the appropriate http://IP./?button1on… ?

Zachary’s Discover Core ----> TCP Server on local network:

TCPClient client;

void ipArrayFromString(byte ipArray[], String ipString) {
int dot1 = ipString.indexOf(’.’);
ipArray[0] = ipString.substring(0, dot1).toInt();
int dot2 = ipString.indexOf(’.’, dot1 + 1);
ipArray[1] = ipString.substring(dot1 + 1, dot2).toInt();
dot1 = ipString.indexOf(’.’, dot2 + 1);
ipArray[2] = ipString.substring(dot2 + 1, dot1).toInt();
ipArray[3] = ipString.substring(dot1 + 1).toInt();
}

int connectToMyServer(String ip) {
byte serverAddress[4];
ipArrayFromString(serverAddress, ip);

if (client.connect(serverAddress, 9000)) {
return 1; // successfully connected
} else {
return -1; // failed to connect
}
}

void setup() {
Spark.function(“connect”, connectToMyServer);