本文介绍了将 iOS 应用程序连接到 wifly 模块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个处于 AdHoc 模式的 Wifly 模块(即它创建了自己的本地 wifi网络),我想将连接到 Wifly 并来回发送数据的能力编程到我的 iOS 应用程序中.

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.

从计算机与 Wifly 通信时,您必须通过终端模拟器发送命令.有谁知道如何通过 iOS 应用执行此操作?

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?

谢谢

推荐答案

您(或您的用户)首先需要在 wifi 设置中手动连接到临时 Wifly 网络.然后,要从您的应用程序与 Wifly 通信,您需要打开一个 TCP 或 UDP 套接字并通过它发送消息.我使用了优秀的 CocoaAsyncSocket 库来做到这一点:https://github.com/robbiehanson/CocoaAsyncSocket

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

正确配置 Wifly 无线电是最困难的部分,文档非常糟糕.但这是我网站上的一个示例配置,它适用于 iPhone 应用程序:http://www.curiousmarc.com/dome-automation/building-marcduino-boards/setting-up-the-wifly-radio

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

编辑 08/2014:新的 WiFly 固件 4.01 及更高版本已弃用 ad-hoc,现在可以将 WiFly 配置为真正的接入点.让生活更简单.WiFly 的新配置说明在我上面的网站上.其余的保持不变,打开一个 TCP 套接字就可以了.您发送的内容会输出到 WiFly 上的串行端口.

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.

编辑 03/2017:我在连接到 WiFly 时遇到了可靠性问题,它在接入点模式下非常不稳定.切换到更好的 Xbee S6B 无线电解决了通信问题.

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.

这篇关于将 iOS 应用程序连接到 wifly 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-21 12:27