Reload webview

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

Reload webview

Post by lazer » Thu Feb 09, 2012 5:29 pm

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: 735
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul » Fri Feb 10, 2012 10:39 am

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: 735
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul » Fri Feb 10, 2012 11:13 am

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 » Thu Feb 16, 2012 9:16 pm

Thanks a lot guys. I will look into this.

paul
Site Admin
Posts: 735
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul » Sun Feb 19, 2012 1:36 pm

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 » Mon Feb 20, 2012 11:57 am

Where?

paul
Site Admin
Posts: 735
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul » Mon Feb 20, 2012 1:09 pm

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 » Mon Feb 20, 2012 8:26 pm

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: 735
Joined: Mon May 12, 2008 4:19 pm

Re: Reload webview

Post by paul » Tue Feb 21, 2012 1:27 pm

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