Hello just purchased an android compatible board and am having trouble doing the following. I wrote a script that runs a command when a motion sensor detects motion. What do I tel the arduino board to do in order to reload a webview on my android device. Can I use a trigger?
Thanks
Reload webview
Re: Reload webview
I'm sorry to say that I can't don't have any advice lazer. We haven't done that much development on the Ardroid side of things.
Maybe someone else will answer here.
I'll write to Joshua Oster-Morris who posted the video with google maps (on the Host Board page on our site) and see if I can get him to post an answer.
Paul
Maybe someone else will answer here.
I'll write to Joshua Oster-Morris who posted the video with google maps (on the Host Board page on our site) and see if I can get him to post an answer.
Paul
Re: Reload webview
laser,
OK - here's kind of a high-level reply.
Joshua wrote
"What he needs to do is design and implement a data packet protocol that boths sides agree on, and then send the "motion happened" packet to the android device which would interpret that and reload the webview. "
Our sample code, based on Google ADK, has a communication protocol implemented - so you could just re-purpose a part of that, as a trigger.
Paul
OK - here's kind of a high-level reply.
Joshua wrote
"What he needs to do is design and implement a data packet protocol that boths sides agree on, and then send the "motion happened" packet to the android device which would interpret that and reload the webview. "
Our sample code, based on Google ADK, has a communication protocol implemented - so you could just re-purpose a part of that, as a trigger.
Paul
Re: Reload webview
Thanks a lot guys. I will look into this.
Re: Reload webview
laser:
code is here,
https://github.com/moderndevice/FreeduinoHostBoard
Note the notes above regarding compiling. I haven't gotten to the bottom of why it compiles fine on my machine, and others are having issues.
Paul
code is here,
https://github.com/moderndevice/FreeduinoHostBoard
Note the notes above regarding compiling. I haven't gotten to the bottom of why it compiles fine on my machine, and others are having issues.
Paul
Re: Reload webview
Oops forgot the link. It's there now.
Github and Modern Device in Google gets you there too.
Paul
Github and Modern Device in Google gets you there too.
Paul
Re: Reload webview
Thanks Paul,
I have the code right here that sends a data packet when button 1 is clicked right? msg[0] = 0x1;
b = digitalRead(BUTTON1);
if (b != b1) {
msg[1] = 0;
msg[2] = b ? 0 : 1;
acc.write(msg, 3);
b1 = b;
}
I am just trying to figure out how android understands that?
Thanks,
Ross
I have the code right here that sends a data packet when button 1 is clicked right? msg[0] = 0x1;
b = digitalRead(BUTTON1);
if (b != b1) {
msg[1] = 0;
msg[2] = b ? 0 : 1;
acc.write(msg, 3);
b1 = b;
}
I am just trying to figure out how android understands that?
Thanks,
Ross
Re: Reload webview
This appears to be the place that DemoKit
parses out the messages:
In DemoKitActivity.java
public void run() {
int ret = 0;
byte[] buffer = new byte[16384];
int i;
while (ret >= 0) {
try {
ret = mInputStream.read(buffer);
} catch (IOException e) {
break;
}
Log.d(TAG, "got bytes " + ret);
i = 0;
while (i < ret) {
int len = ret - i;
switch (buffer) {
case 0x1:
if (len >= 3) {
Message m = Message.obtain(mHandler, MESSAGE_SWITCH);
m.obj = new SwitchMsg(buffer[i+1], buffer[i+2]);
mHandler.sendMessage(m);
}
...
Paul
parses out the messages:
In DemoKitActivity.java
public void run() {
int ret = 0;
byte[] buffer = new byte[16384];
int i;
while (ret >= 0) {
try {
ret = mInputStream.read(buffer);
} catch (IOException e) {
break;
}
Log.d(TAG, "got bytes " + ret);
i = 0;
while (i < ret) {
int len = ret - i;
switch (buffer) {
case 0x1:
if (len >= 3) {
Message m = Message.obtain(mHandler, MESSAGE_SWITCH);
m.obj = new SwitchMsg(buffer[i+1], buffer[i+2]);
mHandler.sendMessage(m);
}
...
Paul