Connect iOS application to the module

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

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

thanks

+7
source share
2 answers

First you (or your user) need to manually connect to the ad-hoc Wifly network in the Wi-Fi settings. Then, in order to contact your application in Wifly, you need to open a TCP or UDP socket and send messages through it. I used the excellent CocoaAsyncSocket library for this: https://github.com/robbiehanson/CocoaAsyncSocket

Setting up the Wifly radio station correctly was the most difficult part, the documentation is horrific. But here is an example configuration from my website that works well for an iPhone application: http://www.curiousmarc.com/dome-automation/building-marcduino-boards/setting-up-the-wifly-radio

Edit 08/2014: the new Wi-Fi firmware 4.01 and higher is deprecated from using ad-hoc, now WiFly can be configured as real access points. Makes life easier. New instructions for setting up WiFly are given on my site above. The rest remains unchanged, open the TCP socket and off. What you send is output to the serial port on WiFly.

Edit 03/2017: I had reliability issues related to WiFly, it is very unstable in access point mode. Switching to the much better Xbee S6B radio solved the communication problems.

+1
source

Using Wifly, As soon as your iOS device connects to the Ad-Hoc network with the network (and this can be through the "Settings" outside your application), your application can initiate a TCP Socket Client in the Wifly local ip ip on port 2000 (by default) , from there you can work normally, as if you were reporting through a serial terminal

Using the installed TCP socket, you can transfer it to the "CommandMode" (if you want to configure it remotely) by writing $$$ to the Socket TCP stream, or you can simply contact it by sending data to the stream.

Note. If you do not know the local IP address of your device, you can configure it via the serial interface after using "CommandMode".

0
source

All Articles