# Sending data from RN-171 in adhoc mode

First, I'd like to note that I'm a software engineer by profession and haven't had anything but trivial experience in interfacing with hardware.

With that said, I'm looking at getting a prototype going with an electrical engineer.

Basically, we have an RN-171 WiFi module that we need to communicate with an iPhone.

I'm not sure why the exact module was chosen as it's made to connect to WiFi network and GET and POST information to it. We want to use it differently however, we want it to broadcast a network in Adhoc mode and connect an iPhone to it which was trivial.

The next step is, once the iPhone is connected, we need to be able to retrieve data from the device. The device is hooked up to a microprocessor which is hooked up to some monitoring devices. The idea is, the device saves monitoring data to a memory card, a user comes along and wants to check the logs, so he connects to the Adhoc network using his iPhone, sends a request to the RN-171 which then somehow sends a message to the microprocessor asking it to send through the log data to the iPhone over WiFi (can't assume there will be any other device other than the iPhone and can't assume a 3G network is available).

The thing is, the device isn't programmable as far as I can tell so I have no idea how I can achieve that. To be honest, I don't care how the RN-171 communicates to the iPhone.

I noticed that port 80 was open so I tried to access the device through the web browser but all I'm getting is an empty screen and I don't think there's any way to get it to display any info (although it would be good if I could...).

The device also interfaces over port 2000 so I connected to it via that port using telnet and could see messages from my laptop connected to the device (which I'm testing with) but I could figure out, again, how to send it to send messages to the device.

I did realize, however, that there is a command set comm remote <message> where message can be a 32 character long string of choice. So far that looks to be my best way to communicate to the device (assuming ios can talk to the device over port 20) that I've found which is pretty sad. Basically, I'll have to connect and disconnect from the port, each time receiving up to 32 length of character data which sounds ridiculous.

So yeah, it may be quite obvious that I don't have much idea where I'm heading so any information will be very appreciated as to where I can go from here and what my options are using this device.

EDIT: The issue is how to communicate from the device to the iPhone. The remote message I mentioned is shown up when a TCP connection is established to the device. For example, if I set the message to TEST, when I telnet to the device over port 2000, I'll get back TEST. Obviously this isn't meant to be a way for the device to communicate data to a device connected in Adhoc mode.

The ideal scenario is when the connected device makes a HTTP request to the WiFi device, I get back some custom infomation (for example a table of data). If not, then any other method of communication is okay. Basically I want to know how to communicate information from the WiFi device to the iPhone when the iPhone requests information.

• I assume you're talking about the Roving Networks module. Are you following the procedures in the user manual? It would be helpful if you could tell us which step is failing and what exactly you are or are not seeing. – Dave Tweed Sep 7 '12 at 14:34
• @Nraf: I've worked on iPhone-RNXV interaction, but please clarify what your question is exactly. – boardbite Sep 7 '12 at 14:50

I noticed that port 80 was open

On an RN-171? This module supports HTTP client mode only and has no HTTP server, unless we talk about custom firmware.

somehow sends a message to the microprocessor

Sounds like you really need to read the (WiFly) manual again. The RN-171 has a UART interface, and you can use it to talk through the WLAN module from our microcontroller to your iPhone, in both ways. In short, you open a tcp port on your phone and use it like an oldschool serial port that is connected to your MCU.

• ... and just to add to that, there's no reason at all your microcontroller couldn't be running an HTTP server over that UART connection, so that if your iPhone's browser is directed to port 2000 on the RN-171, it could get web pages from the microcontroller. HTTP is just a layer on top of TCP/IP, so you can have the RN-171 doing the latter while your microcontroller does the former. – Dave Tweed Sep 7 '12 at 20:39
• Nice idea, but a HTTP server is tough to implement on a microcontroller - even when you don't have to fiddle with TCP/IP. – Turbo J Sep 7 '12 at 20:55
• Not true! First of all, the OP hasn't told us what kind of microcontroller he's using; it could be a relatively powerful PIC32 or ARM running an operating system. Secondly, I have seen some very effective web-based user interfaces implemented on 8-bit micros. The HTTP server itself can be very bare-bones, and you can push a lot of fancy functionality onto the browser using JavaScript and AJAX-like techniques. – Dave Tweed Sep 7 '12 at 21:05
• Hmm... it's not so much that I didn't read the manual. I didn't know what UART was. Do you have useful resources where I can get started? – NRaf Sep 7 '12 at 23:28
• @NRaf: Geez, where to start? That's really a conversation you should be having with your electrical engineer, who will be able to direct you to resouces specific to the microcontroller you're using. – Dave Tweed Sep 8 '12 at 0:46

I've managed to get this working. I could host a web server on the iPhone using CocoaHTTPServer and then send requests to it from the device.

I have experimented with RN-171. It has built-in HTTP client that reports the status of it's i/o pins to host server by using GET or POST. I saw folks at http://iturniton.com did something similar for Android.