Pages: [1]   Go Down
Author Topic: connecting to the Arduino server using its IP with android  (Read 233 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

HI, I would really thankful  if someone could help me regarding  IP connectivity .
Lets sat that there is an arduino web server using the Ethernet shield and a web page which switching on/off a LED with its IP ( 192.168.3.10) . so when I enter this IP in  a browser I could see the page and control the LED. Now lets say I wana turn this web page to an android App using PhoneGap.
 What code should I use at the top of the HTML code so  the app connects to the arduino IP automatically when it is started ? in other word do the same thing as entering the IP in the browser?
 I’ve tried :

socket = new Socket("192.168.3.10", [80]);

but its not working.
THANKS in advance.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you are using the Droid's cellular provider for the data connection, you can't use a 192.168.x.x ip. Those are localnet ips.

You basically have two choices:
1) Port forward a port on your public ip (WAN interface on the router) to the port on your Arduino and use the public ip:port.
or
2) Connect to the same router's wifi and use it for the data connection using the 192.168.x.x ip.

That works with my CrackBerry.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks a lot for your response,
actually I am trying to do the 2nd solution that you've  provided here but i dont know the coding. i may not explained it well.
I convert the web page to an App, then as the phone is connected to the router through a Wifi i wana use a code that when i start the app it automatically connects to the shield as the shield is also connected to the same router and is waiting for a client.
in the Head part of the HTML coding of the web page which i am going to convert it to an android app, what code should i use ?
something like :

<head>
<script>
socket = new Socket("192.168.3.10", [80]);
.
.
</script>
</head>

?

Thanks.
Logged

Miramar Beach, Florida
Offline Offline
Faraday Member
**
Karma: 139
Posts: 5860
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Then you have already gotten the http connection to the Arduino working with your Android? If not, work on that first. Otherwise you could end up chasing your tail. On your Droid web browser:
http://192.168.3.10
Logged

Pages: [1]   Go Up
Jump to: