ios蓝牙开发学习笔记(一)蓝牙概述
https://developer.apple.com/library/prerelease/content/documentation/NetworkingInternetWeb/Conceptual/CoreBluetooth_concepts/CoreBluetoothOverview/CoreBluetoothOverview.html#//apple_ref/doc/uid/TP40013257-CH2-SW1
Core Bluetooth Overview
概覽 略
Central and Peripheral Devices and Their Roles in Bluetooth Communication
central和peripheral設備和他們在藍牙通訊中的角色
藍牙通訊中的兩個重要的角色,central和peripheral。相對于傳統的client-server架構,peripheral代表著擁有數據的一方并且外界是需要這數據的。central代表著使用數據方,從peripheral那里獲得數據并完成特定的事情。如圖1-1所示。心率監測器有數據,你的mac和ios app 需要這些數據。
Figure 1-1 Central and peripheral devices

Centrals Discover and Connect to Peripherals That Are Advertising
centrals發現并連接到正在廣播的peripherals
peripheral在廣播包中廣播他們的數據。廣告包中應該包含一些有用的信息,比如peripheral的名稱和主要功能等。比如,數字恒溫器可能就廣播當前的溫度。在低功耗藍牙中廣播是periphera被發現的主要方式。
central,可以掃描和監聽任何他感興趣的peripheral設備。如圖1-2,central可以要求連接到任何他發現廣播包的peripheral.
Figure 1-2 Advertising and discovery

How the Data of a Peripheral Is Structured
peripheral如何組織數據
peripheral可以包含一個或多個services或提供它們連接信號強度的信息。service是數據和輔助行為的集合。比如,一個心率監控器的服務用來輸出心率數據。
Peripherals may contain one or more services or provide useful information about their connected signal strength. A service is a collection of data and associated behaviors for accomplishing a function or feature of a device (or portions of that device). For example, one service of a heart rate monitor may be to expose heart rate data from the monitor’s heart rate sensor.
service本身由characteristics和引用的services組成。characteristic提供服務的詳細的信息。比如,心率服務可能包含一個特征值用來描述目標的位置,同時包含另一個特征值用來傳輸心率的數據。圖1-3描述這種組織結構
Figure 1-3 A peripheral’s service and characteristics

Centrals Explore and Interact with the Data on a Peripheral
central檢索并與peripheral交互數據
建立連接之后,就可以discover所有的services和characteristics(廣播中可能只包含部分services)
central可以通過services的characteristic來讀或寫數據。你的應用可以從恒溫器那邊讀取到當前的溫度,也可以設置你想要的目標溫度。
How Centrals, Peripherals, and Peripheral Data Are Represented
centrals,peripherals 和 peripheral的數據如何表示
角色和數據在藍牙框架中以一種簡單直接的方式表示。
Objects on the Central Side
central端的對象
當你使用central來與peripheral通訊,你執行的是central端的操作。
Local Centrals and Remote Peripherals
在central端,設備用CBCentralManager對象代表。這個對象用來管理被發現的已連接的peripherals。圖1-4顯示藍牙框架中如何表示central和peripheral.
Figure 1-4 Core Bluetooth objects on the central side

A Remote Peripheral’s Data Are Represented by CBService and CBCharacteristic Objects
peripheral的數據用CBService和CBCharacteristic來表示。
當你與peripheral交互時,你需要使用他的sevices和characteristics。在藍牙sdk中service用CBService對象表示,characteristic用CBCharacteristic對象表示。圖1-5描述這種結構
Figure 1-5 A remote peripheral’s tree of services and characteristics

Objects on the Peripheral Side
peripheral 端的對象
如果是安裝OS X v10.9 或 iOS6,那你的mac和ios設備就可以作為peripheral端設備,為其他設別提供數據。讓你的設備實現peripheral角色,執行peripheral端的功能。
Local Peripherals and Remote Centrals
本地peripherals和遠端centrals
在peripheral端,peripheral設備用CBPeripheralManager對象表示。這個對象用來管理發布services和characteristics,并發出廣播。同時peripheral manager可用來響應讀和寫請求。圖1-6顯示這種關系
Figure 1-6 Core Bluetooth objects on the peripheral side

A Local Peripheral’s Data Are Represented by CBMutableService and CBMutableCharacteristic Objects
本地peripheral的數據用CBMutableService和CBMutableCharacteristic對象表示
當你創建并想設置peripheral的數據。你需要處理peripheral manager 對象的services (CBMutableService實例),同樣,characteristic的實例也是CBMutableCharacteristic對象。圖1-7說明這種關系
Figure 1-7 A local peripheral’s tree of services and characteristics

總結
以上是生活随笔為你收集整理的ios蓝牙开发学习笔记(一)蓝牙概述的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【接口文档】Django restful
- 下一篇: 多继承以及MRO顺序【super().的