• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to connect Android device to a WiFly set up as an Access Point and transfer data

 
Geoff Champion
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am developing an Android app to control a distant PIC device via WiFi from an Android tablet. Input to the PIC is a WiFly RN-131 set up as an Access Point. The Android device sees the WiFly and can connect to it OK. My app can see the device but I am at a loss as to how to have the app actually connect to the WiFly and transmit simple character strings back and forth. Guidance would be appreciated. I need a tutorial on transferring character data over wifi. developer.android.com concentrates on p2p but does not appear to have anything on basic wifi.
 
Maneesh Godbole
Saloon Keeper
Posts: 11312
16
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!

As a developer, you need not worry about the actual WiFi connectivity. As long as you provide the proper permissions to your app, the connectivity is automatic for you.
Check out how to connect over the net and exchange data here http://developer.android.com/training/basics/network-ops/connecting.html
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Wifi is just the transport mechanism, it is not a protocol for exchanging data. I'm not sure what "The Android device sees the WiFly and can connect to it OK" means exactly, but if you have the IP address of the device you should be able to open a socket connection to whatever port it is listening.
 
Geoff Champion
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ulf

The project I am working on is a completely standalone system of an Android tablet, with WiFi capability, communicating with a PIC microprocessor at a distance of 200 to 300 metres. The PIC is interfaced with a WiFly module RN 131 There is no involvement of the internet or any other network.
The data is simple ascii strings.

At the tablet end I have tried a number of possibilities:
Firstly, setting the PIC end WiFly as an Access Point and acquiring it via the tablet app I am writing.
Secondly, the app accessing a second WiFly at the tablet end via USB and then communicating to the PIC end.
Thirdly, The app accessing a commercial wifi router at the tablet end via ethernet.

I have had success with each method in establishing a connection. The problem I am having is how to actually send the data. I read of setting up sockets and using http clients. Rather than a http client, is there a serial client. Are there any tutorials on this?

Thank you for your help so far.
 
Ron McLeod
Bartender
Pie
Posts: 1030
64
Android Eclipse IDE Java Linux MySQL Database Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Geoff Champion wrote:I have had success with each method in establishing a connection.

If you can explain what kind of connection you established, someone might be able to help figure-out how to send/receive data accross that connection.
 
Geoff Champion
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the first configuration the PIC WiFLY is SSID Scorer_3 and the following code finds Scorer_3 in WiFiReceiver:


 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I read of setting up sockets and using http clients. Rather than a http client, is there a serial client. Are there any tutorials on this?

If you have an Ethernet connection then plain socket communication should be possible, without the need for HTTP. Serial communication is not possible as it's not a serial connection. If you search for "socket communication android" you'll find many examples, or go straight to the Java Tutorial: http://docs.oracle.com/javase/tutorial/networking/sockets/index.html.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic