Reload webview

Post Reply
lazer
Posts: 4
Joined: Thu Feb 09, 2012 5:27 pm

Reload webview

Post by lazer »

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
paul
Site Admin
Posts: 775
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul »

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
paul
Site Admin
Posts: 775
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul »

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
lazer
Posts: 4
Joined: Thu Feb 09, 2012 5:27 pm

Re: Reload webview

Post by lazer »

Thanks a lot guys. I will look into this.
paul
Site Admin
Posts: 775
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul »

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
lazer
Posts: 4
Joined: Thu Feb 09, 2012 5:27 pm

Re: Reload webview

Post by lazer »

Where?
paul
Site Admin
Posts: 775
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul »

Oops forgot the link. It's there now.

Github and Modern Device in Google gets you there too.

Paul
lazer
Posts: 4
Joined: Thu Feb 09, 2012 5:27 pm

Re: Reload webview

Post by lazer »

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
paul
Site Admin
Posts: 775
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul »

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
Post Reply