Thanks @zachary for open sourcing android-app.
It was a good incentive and a precious entry point for me to get my local toolchain and an Android IDE (both with Eclipse) up and running on my tablet
As a first output of this Iāve extended your Spark Tinker app and the Tinker FW a bit so that the Coreās RX/TX pins can be digitalRead/digitalWritten and also the RGB-LED got its dedicated controls
And this would be the required Tinker Firmware(works together with standard Tinker App, too - Android and iOS)
If youād like Iād clean this up a bit and āfileā a pull request - providing the adapted Tinker FW meets your standards and could make it into your application.cpp.
Thanks @chrisnet and @DanielBernard
Actually 99% of the credits has to go to for their own app - my humble contribution to this is that I changed the tinker_fragment.xml to accomodate the extra pins and LED symbol, to add some event listeners and tweak the analog output when selecting a color.
Together with a slightly tweaked Tinker firmware thatās all it needed.
So Iām not quite sure what @chrisnet more info I could give as āHowToā. If you could specify what youād be interested in in particular, Iād be happy to share my admittedly little insight
As for the finalized version, Iām near the finishing line and would appreciate any volunteers for testing it.
Just filed a PullRequest for the android-app - hope itāll be accepted.
To actually have it work with your Core, youād need the provided firmware (for link see first post - filed PR for that too).
Edit: ExtTinker firmware works together with standard Tinker App, too.
Next possible extension might be to incorporate the camera of the phone to acquire some color that could get transmitted to the Core which sets the RGB-LED accordingly
Obviously there must be something about light that gets peoples attention (which is true for me at least ;- ) - great job you put that RGB-LED on the Core to start with.
And what goes around comes around in a positive way, too.
Please post here if your forked Tinker App gets approved for use. As far as How to. I have very little understanding with Java / Android API but, have been developing PHP / HTML for years as well as interfacing Arduino pin control via HTML.
Is there no way to access the Spark Core except via the Cloud API ? If so, how are hardware guys going to implement Spark Core control - āHire a Software Guyā ?
Hi @spydrop,
glad to hear that there is some interest in this little project of mine
As for controlling the Core, how did you do it with the Arduinos?
Since the firmware sports TCP & UDP classes in addition to the Cloud API you should be able to do pritty much the same things as with Arduino + WiFi shield (I guess) - despite some possible āchildhoodā glitches
The Cloud API should actually make things easier than building your own TCP/UDP logic.
And for wired control there should be no problem what so ever.
The Arduino ethernet library allows me to use HTML links to control pins inside a local network. Here is the code I am using on one Ethernet Shield. It is also possible with the Wireless library as well. I am just looking for a simple user interface to control pins on a spark core inside a local network for my customers to use.
Hi again,
as said in the other thread this can be done.
Have a look at TCPClient - not sure how stable this is at the moment (? @Dave, @zach, @satishgn ?)
The side effect of this would be that you loose cloud API support - unless you take care of Spark.connect()/Spark.disconnect()-ing yourself.
Unfortunately my Pull Request didn't get pulled, since it doesn't fit design standards and would create a gap between Android and iOS app functionality *) - that's fair enough.
The other reason that it would make the app harder to understand for beginners I can't quite follow.
However, if someone likes to test the app (APK) before taking up the task of building locally, just send my a PM.
*) years later that doesn't seem to matter anymore as we now do have multiple discrepancies between iOS and Android which won't fix anytime soon.
So, from what I gather is Spark Team has no intentions to support any HTML, or Java, or PHP, or Python control of the Spark Core via the cloud. Only Android & iOS are official options ?
@spydrop, I would not say that.
As you have seen there are several threads dealing with different ways to use the cloud to communicate with the Core - and the cloud is the official way, no matter what system you use on your side.
As I understand it, the Android and iOS Tinker apps together with the standard Tinker firmware are merely a nice and easy sample application to get playing a bit - to unpack your fresh Core, plug it in and immediatel see that it works - and this via the Internet.
For me the Android app was a nice entry point into Android programing - I hadnāt done any real project before, just some āHello Worldā
I agree but, maybe you can help me with curl to control more than one Digital Pin at the same time ?
Here is my real life example: with the help of others @Dave@kennethlimcp@BDub@bko & YOU as I copied code from your extended Tinker App. Using PHP & Curl to execute it from my browser.
SPARK IDE APP
#define MAGICSTOP_EVENT "MagicStopEvent";
void setup() {
//Register all the Tinker functions
Spark.function("digitalwrite", magicstopDigitalWrite);
}
void loop() {
}
int magicstopDigitalWrite(String command) {
bool value = 0;
int pinNumber = command.charAt(1) - '0';
if (!(
((command.startsWith("D"))
&& 0 <= pinNumber && pinNumber <= 7)
))
return -1;
if (command.substring(3, 7) == "HIGH")
value = 1;
else if (command.substring(3, 6) == "LOW")
value = 0;
else
return -1;
pinMode(pinNumber, OUTPUT);
digitalWrite(pinNumber, value);
return value;
}
<PHP CODE + CURL----ā¦>
<?php
$post_params['D7'] = 'HIGH';
$post_params['D6'] = 'LOW';
$ch = curl_init("https://api.spark.io/v1/devices/48ff6f065067555028091087/digitalwrite");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "access_token=my_access_token_here¶ms=$post_params");
$output = curl_exec($ch);
curl_close($ch);
echo $output;
___________________________________
**Above PHP Does not work - Access token not found.**
**Below PHP does work but, only one pin is controlled.**
__________________________________
<?php
$ch = curl_init("https://api.spark.io/v1/devices/48ff6f065067555028091087/digitalwrite");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, "access_token=my_access_token_here¶ms=D7,HIGH");
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>
I and 95% of people who use micro-controllers are not programmers but, I am trying.
You can definitely update more than one pin at a time with a function. @ScruffR is right, and Tinker is meant to be a great starting point for your own custom applications, both on and off the Core. If youāre writing a PHP app, then this could also be a good time to write your own firmware for the core as well!