Our senior design group is currently working on a project with the spark core and Android. We have done a lot of research in trying to get our android application to use curl, for more general to try to get out android application to send commands to the spark cloud. If anyone has any information or has gotten this to work, we would great appreciate any help!
Interesting project, it sounds like you want to be calling Cloud API endpoints from an arduino? This might be tough depending on which arduino board you’re using. The API requires https, so you might have more luck talking to the core directly over TCP/UDP, or by sending commands to a server you have running somewhere that can hit the API for you.
If the board you’re using can do https requests, then it’s just a matter of what language is available to you on that platform. I’m guessing they probably have a tutorial on doing http GET/POST requests from that board?
Thanks for the rely Dave! Well we want our android application to be able to send curl commands. I believe the only way to talk to the spark cloud is through curl. And the spark cloud talks to our sparkcore. We have looked into talking to the core directly over TCP/UDP but from the research we have done we need to be on the Sam network as our sparkcore. Unless we are mistaken. We would like our android application to be able to control our sparkcore on any network. We have thought about setting up our own server as a last resort.
Ahh, in that case, you don’t need curl, curl is just an application that makes it easy to make HTTP requests. If you’re looking to make API requests from and Android (sorry I misread earlier), then here are some examples that should help:
Thanks for the fast reply! I was looking more closely into the post link you sent.
Just to get this strainghtened out say
curl https://api.spark.io/v1/devices/“Device ID goes here”/fn_r -d access_token=“AcessToken goes here” -d params=rainbow
I was looking at some more of the documentation on the httppost, and I am just a little confused still. Is httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); part of the code that would set the -d parameters and token parameters and what not? Assuming our nameValuePairs are set to for example nameValuePairs.add(new BasicNameValuePair("-d", “access_token=“AcessToken goes here””))?
@zach: I’ve downloaded the android-app source and I tried to follow the instructions but got a bit stuck with this part:
You must add smartconfiglib.jar to the SparkCore/libs directory.
To get the SmartConfig library, go to the CC3000 Wi-Fi Downloads page. Search the page for the Android SmartConfig Application. Download and unpack the app, which will require Windows. :-/ You can find smartconfiglib.jar in the libs directory of TI's app.
I could only find “CC3000_Android_App_Setup_v1_1.zip and .exe” and “SmartConfigJavaApplet-1_1-windows-installer.exe”, where the first does not seem to contain anything like SmartConfigLib.jar and it does not setup on my Win8.1 32bit. The the other one only contains a SmartConfig.html and SmartConfig.jar - which does not exactly seem to be the one.
Am I missing somethig here?
Edit: YES, I was missing something
If I just had drilled down a bit deeper into the zip, I would have finally found it here
So you don’t need to install the app on a Windows machine. Just rename the .exe to .zip and keep digging down the above path, then you can pull out the desired file only
Hi, but when i click the libs_zg_ia_sf.jar, it says it’s corrupted. I cannot open that file, what’s wrong with that? Is it supposed to be a executable jar file?
im also doing a protect with spark and android. i will like to ask you how do yo meme that app send the command to the spark ?
i try this code, it doesn’t show any errors but the spark not receive the command.
new Thread()
{ @Override
public void run() {
// Create a new HttpClient and Post Header
HttpClient httpclient = new DefaultHttpClient();
HttpPost httppost = new HttpPost(“https://api.spark.io/v1/devices/53ff7006667574827312567/led”);
try {
// Add your data
//llena los espacios vacios usando como ejemplo front
List nameValuePairs = new ArrayList(2);
nameValuePairs.add(new BasicNameValuePair(“access_token”, “6f1d9f90811315d1f854cbc286a43d4”));
nameValuePairs.add(new BasicNameValuePair(“params”, “l1,HIGH”));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
// Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
} catch (IOException e) {
// TODO Auto-generated catch block
}
}
}.start();