iPhone corebluetooth central Manager send data to peripheral

好久不见. 提交于 2019-12-02 19:32:21

In Core Bluetooth you need to use the characteristics for communication. There is no standard stream based API like in the External Accessory Framework and I don't know of any open source libraries that implement something like that.

Basic operation

Peripheral -> Central:

  1. Central subscribes to characteristic (either with notifications or indications)
  2. Peripheral receives the subscribed callback so knows that the central is listening
  3. Peripheral updates characteristic
  4. Central receives characteristic updated notification

Central -> Peripheral:

  1. Central writes characteristic
  2. Peripheral receives write request update

The actual speed you can achieve depends on various factors. With indications the data is never lost (like TCP) but notifications don't have such guarantees (like UDP).

More info

I suggest you check out the official Core Bluetooth Programming Guide and concentrate on the

sections. But better would be studying the whole guide as is. For a working example, check out the BTLE Transfer example from Apple, as well.

If i understand you correctly you want the central to send data to your peripheral.

for that you use this method:

[peripheral writeValue:dataPacket forCharacteristic:writeChar type:CBCharacteristicWithResponse]

This is pretty compelling video to watch and know what exactly goes in iOS bluetooth framework. Its clearly explained what operations can be performed by central and peripheral systems.

https://developer.apple.com/videos/play/wwdc2012-705/

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