iOS 从蓝牙接收数据,然后通过 wi-fi 将信息发送到另一台服务器上的数据库

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9132174/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:40:31  来源:igfitidea点击:

iOS receive data from bluetooth and then send information to a database on another server through wi-fi

iosdatabasebluetoothwifi

提问by Aneem

Which libraries should I look into for the following tasks?

我应该为以下任务寻找哪些库?

  1. I want to receive a string from another device via Bluetooth (this will require looking at a list of nearby devices and choosing the right one.
  2. I then want to send the String to a database via Wi-fi
  1. 我想通过蓝牙从另一台设备接收一个字符串(这需要查看附近设备的列表并选择正确的设备。
  2. 然后我想通过 Wi-fi 将字符串发送到数据库

This is a simple version of what I actually want to do, but I need to know how to do those things first. Also, any design tips would be greatly appreciated (like having multiple screens, which classes to write, etc).

这是我真正想做的事情的一个简单版本,但我需要先知道如何做这些事情。此外,任何设计技巧将不胜感激(例如有多个屏幕,要编写哪些类等)。

采纳答案by EricS

The ordinary iOS Bluetooth APIs are only available if you enter into Apple's "Made for iPod" program. See MFi Program

普通的 iOS 蓝牙 API 仅在您进入 Apple 的“Made for iPod”计划后才可用。请参阅MFi 计划

If your device can use the newer "low energy" Bluetooth LE, you can look in the corebluetooth framework

如果您的设备可以使用较新的“低功耗”蓝牙 LE,您可以查看corebluetooth 框架

There is an example of a Bluetooth LE heart rate monitor program here.

有蓝牙LE心脏监测仪程序的例子在这里

For WiFi, you can use any of several APIs from Apple and others: Berkeley unix sockets, NSURLConnection, CFNetwork, AsyncSocket, etc.

对于 WiFi,您可以使用 Apple 和其他公司提供的多种 API 中的任何一种:Berkeley unix sockets、NSURLConnection、CFNetwork、AsyncSocket 等。

回答by RyanM

If you mean receive a string from another iOS device, the statement here about needing to be a part of the "Made For iPod" program is incorrect. This would be required if you mean you are trying to build an accessory for iPhone, iPad, or iPod.

如果您的意思是从另一台 iOS 设备接收字符串,那么此处关于需要成为“Made For iPod”计划一部分的声明是不正确的。如果您的意思是要尝试为 iPhone、iPad 或 iPod 构建配件,那么这将是必需的。

The easiest way to "discover" other iOS devices (running your app) and transfer data between them is GKSessionfrom the GameKit Framework. Beam It! is pretty good example code for this.

“发现”其他 iOS 设备(运行您的应用程序)并在它们之间传输数据的最简单方法GKSession来自 GameKit 框架。光束它!是很好的示例代码。

Once you initialize a GKSessionjust set a GKSessionDelegateand set the session's availableproperty to YES. Check out the four required GKSessionDelegate methods and the Beam It! sample code.

初始化 a 后,GKSession只需设置 aGKSessionDelegate并将会话的available属性设置为YES. 查看四个必需的 GKSessionDelegate 方法和 Beam It!示例代码。

http://arctouch.com/beamit///Beam It! code

http://arctouch.com/beamit///Beam It!代码

回答by user523234

Your best bet is to study Apple's WiTapsample app. That will answer your question #1. For question 2, you can use Apple's coredata. If you are not familiar with coredata, check out this site's tutorials.

最好的办法是研究 Apple 的WiTap示例应用程序。这将回答您的问题#1。对于问题 2,您可以使用 Apple 的 coredata。如果您不熟悉 coredata,请查看此站点的教程。