7

I have a Wifly module that is in AdHoc mode (i.e. it creates its own local wifi network) and I would like to program into my iOS app the ability to connect to the Wifly and send data back and forth.

When communicating with the Wifly from a computer, you have to send command through a terminal emulator. Does anyone know how to do this from an iOS app?

Thanks

El Developer
  • 3,345
  • 1
  • 21
  • 40
thebiglebowski11
  • 1,451
  • 10
  • 41
  • 76
  • You cant connect to a wifi network from inside the app. The libraries for managing networks are private. After you connect manually you can comunicate freely but I dont know how. Comunicating thru the cloud is always an option. – pedros Nov 07 '12 at 03:36
  • Something on this. Not sure what exactly is it. https://github.com/furious-luke/arduino-wifly#readme – iDev Nov 07 '12 at 19:03
  • Possible duplicate question: http://stackoverflow.com/questions/7057053/does-iphone-support-wifi-ad-hoc-mode – fishinear Nov 11 '12 at 20:17

2 Answers2

1

You (or your user) first need to connect manually to the ad-hoc Wifly network in the wifi settings. Then, to communicate from your app to the Wifly, you need to open a TCP or a UDP socket and send messages through it. I used the excellent CocoaAsyncSocket library to do that: https://github.com/robbiehanson/CocoaAsyncSocket

Configuring the Wifly radio correctly was the most difficult part, the documentation is horrendous. But here is an example config from my web site that works well for an iPhone app: http://www.curiousmarc.com/dome-automation/building-marcduino-boards/setting-up-the-wifly-radio

Edit 08/2014: the new WiFly firmware 4.01 and higher has deprecated the use of ad-hoc, the WiFly can now be configured as a real access points. Makes life simpler. New configuration instructions for the WiFly are on my website above. The rest remains the same, open a TCP socket and away you go. What you send comes out to the serial port on the WiFly.

Edit 03/2017: I had reliability problems connecting to the WiFly, it's very flaky in access point mode. Switching to the much better Xbee S6B radio solved the communication problems.

CuriousMarc
  • 501
  • 6
  • 11
0

Using Wifly, Once your iOS device is connected to the wifly Ad-Hoc network (And it can, through "Settings", outside your app), your app can initiate a TCP Socket Client to the Wifly local network ip on port 2000 (by default), from there, you can proceed normally as if you were communicating via serial+terminal

Using the established TCP Socket, you can pass the wifly into "CommandMode" (If you want to config it remotely) by writing $$$ to the TCP Socket stream, or you could simply communicate with it by sending data to the stream.

Note: If you don't know the local ip address of your wifly, you can config it through serial after by using the "CommandMode".

Alon Amir
  • 4,913
  • 9
  • 47
  • 86