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

房东的猫 提交于 2019-12-03 04:30:56

问题


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

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).


回答1:


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

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

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

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




回答2:


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.

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

Once you initialize a GKSession just set a GKSessionDelegate and set the session's available property to YES. Check out the four required GKSessionDelegate methods and the Beam It! sample code.

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




回答3:


Your best bet is to study Apple's WiTap sample 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.



来源:https://stackoverflow.com/questions/9132174/ios-receive-data-from-bluetooth-and-then-send-information-to-a-database-on-anoth

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!