日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

ios蓝牙开发学习笔记(一)蓝牙概述

發(fā)布時(shí)間:2023/12/20 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ios蓝牙开发学习笔记(一)蓝牙概述 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

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設(shè)備和他們?cè)谒{(lán)牙通訊中的角色

藍(lán)牙通訊中的兩個(gè)重要的角色,central和peripheral。相對(duì)于傳統(tǒng)的client-server架構(gòu),peripheral代表著擁有數(shù)據(jù)的一方并且外界是需要這數(shù)據(jù)的。central代表著使用數(shù)據(jù)方,從peripheral那里獲得數(shù)據(jù)并完成特定的事情。如圖1-1所示。心率監(jiān)測(cè)器有數(shù)據(jù),你的mac和ios app 需要這些數(shù)據(jù)。

Figure 1-1 Central and peripheral devices

Centrals Discover and Connect to Peripherals That Are Advertising

centrals發(fā)現(xiàn)并連接到正在廣播的peripherals

peripheral在廣播包中廣播他們的數(shù)據(jù)。廣告包中應(yīng)該包含一些有用的信息,比如peripheral的名稱(chēng)和主要功能等。比如,數(shù)字恒溫器可能就廣播當(dāng)前的溫度。在低功耗藍(lán)牙中廣播是periphera被發(fā)現(xiàn)的主要方式。

central,可以掃描和監(jiān)聽(tīng)任何他感興趣的peripheral設(shè)備。如圖1-2,central可以要求連接到任何他發(fā)現(xiàn)廣播包的peripheral.

Figure 1-2 Advertising and discovery

How the Data of a Peripheral Is Structured

peripheral如何組織數(shù)據(jù)

peripheral可以包含一個(gè)或多個(gè)services或提供它們連接信號(hào)強(qiáng)度的信息。service是數(shù)據(jù)和輔助行為的集合。比如,一個(gè)心率監(jiān)控器的服務(wù)用來(lái)輸出心率數(shù)據(jù)。
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提供服務(wù)的詳細(xì)的信息。比如,心率服務(wù)可能包含一個(gè)特征值用來(lái)描述目標(biāo)的位置,同時(shí)包含另一個(gè)特征值用來(lái)傳輸心率的數(shù)據(jù)。圖1-3描述這種組織結(jié)構(gòu)

Figure 1-3 A peripheral’s service and characteristics

Centrals Explore and Interact with the Data on a Peripheral

central檢索并與peripheral交互數(shù)據(jù)

建立連接之后,就可以discover所有的services和characteristics(廣播中可能只包含部分services)

central可以通過(guò)services的characteristic來(lái)讀或?qū)憯?shù)據(jù)。你的應(yīng)用可以從恒溫器那邊讀取到當(dāng)前的溫度,也可以設(shè)置你想要的目標(biāo)溫度。

How Centrals, Peripherals, and Peripheral Data Are Represented

centrals,peripherals 和 peripheral的數(shù)據(jù)如何表示

角色和數(shù)據(jù)在藍(lán)牙框架中以一種簡(jiǎn)單直接的方式表示。

Objects on the Central Side

central端的對(duì)象

當(dāng)你使用central來(lái)與peripheral通訊,你執(zhí)行的是central端的操作。

Local Centrals and Remote Peripherals

在central端,設(shè)備用CBCentralManager對(duì)象代表。這個(gè)對(duì)象用來(lái)管理被發(fā)現(xiàn)的已連接的peripherals。圖1-4顯示藍(lán)牙框架中如何表示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的數(shù)據(jù)用CBService和CBCharacteristic來(lái)表示。

當(dāng)你與peripheral交互時(shí),你需要使用他的sevices和characteristics。在藍(lán)牙sdk中service用CBService對(duì)象表示,characteristic用CBCharacteristic對(duì)象表示。圖1-5描述這種結(jié)構(gòu)

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

Objects on the Peripheral Side

peripheral 端的對(duì)象

如果是安裝OS X v10.9 或 iOS6,那你的mac和ios設(shè)備就可以作為peripheral端設(shè)備,為其他設(shè)別提供數(shù)據(jù)。讓你的設(shè)備實(shí)現(xiàn)peripheral角色,執(zhí)行peripheral端的功能。

Local Peripherals and Remote Centrals

本地peripherals和遠(yuǎn)端centrals

在peripheral端,peripheral設(shè)備用CBPeripheralManager對(duì)象表示。這個(gè)對(duì)象用來(lái)管理發(fā)布services和characteristics,并發(fā)出廣播。同時(shí)peripheral manager可用來(lái)響應(yīng)讀和寫(xiě)請(qǐng)求。圖1-6顯示這種關(guān)系

Figure 1-6 Core Bluetooth objects on the peripheral side

A Local Peripheral’s Data Are Represented by CBMutableService and CBMutableCharacteristic Objects

本地peripheral的數(shù)據(jù)用CBMutableService和CBMutableCharacteristic對(duì)象表示

當(dāng)你創(chuàng)建并想設(shè)置peripheral的數(shù)據(jù)。你需要處理peripheral manager 對(duì)象的services (CBMutableService實(shí)例),同樣,characteristic的實(shí)例也是CBMutableCharacteristic對(duì)象。圖1-7說(shuō)明這種關(guān)系

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

總結(jié)

以上是生活随笔為你收集整理的ios蓝牙开发学习笔记(一)蓝牙概述的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。