iOS开发---蓝牙实现(一)基本概念

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/szk972092933/article/details/82798363

Core Bluetooth是基于蓝牙4.0标准来实现的。在蓝牙功能的交互中,主要有两种设备,中心(Central)和外设(Peripheral)。类似于服务器-客户端架构,Peripheral实现类似于服务端的功能,主要用来提供数据,而Central实现类似于客户端的功能,用来获取外设提供的数据。

Figure 1-1  Central and peripheral devices

 外设向外广播数据,而中心设备可以搜索附近正在发送广播的外设,并根据需要建立连接,当建立连接后可以读取和修改外设的数据。

Figure 1-2  Advertising and discovery

一个外设提供的数据是封装在名字为service的数据结构中, 一个service就是一个代表外设功能和特征的数据集合。services可以包含另一个service也可以包含characteristics。characteristic提供详细的数据。

Figure 1-3  A peripheral’s service and characteristics

 在Centrals端,使用CBCentralManager来管理与peripheral的连接,一个peripheral可能包含多个serivices

Figure 1-5  A remote peripheral’s tree of services and characteristics

 若要实现Peripherals角色,需要使用CBPeripheralManager类来管理,发送广播,实现service等功能。,使用service和characteristic的可变类型来实现服务的数据。

Figure 1-7  A local peripheral’s tree of services and characteristics

猜你喜欢

转载自blog.csdn.net/szk972092933/article/details/82798363