Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

connecting an iOS app to wifly module

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

like image 703
thebiglebowski11 Avatar asked Nov 04 '12 01:11

thebiglebowski11


Video Answer


1 Answers

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.

like image 116
CuriousMarc Avatar answered Sep 25 '22 07:09

CuriousMarc