iOS Bluetooth Programming Guide-Core Bluetooth overview

Source: Internet
Author: User

Kohiki

With the enthusiasm of wearable devices and smart home, the development of Bluetooth app is also very hot, based on the development of iOS Bluetooth has a lot of data, but the most worthy of learning is the Apple's own documentation, my previous project based on Bluetooth 4.0, the development process used in the Core Bluetooth framework, is my study notes it! Involves several parts, I intend to separate them out, this article through the translation of the core Bluetooth Programming Guide, to introduce some of the iOS Bluetooth 4.0 programming terminology and concepts, follow-up article will be a brief introduction to the code of the process. I have limited strength, the depth of understanding is not very wide, but also please crossing light point to shoot bricks!

Talk not much, let's get to the point:

Note: This article is from core Bluetooth Programming Guide Core bluetooth® overview

Core BluetoothThe framework enables your Mac/ios app to communicate with low-power Bluetooth devices. For example, your app can search, explore, and interact with low-power Bluetooth devices, the L-rate listener, the digital thermostat, and even the ability to interact with other iOS devices.

The framework is based on the BLE4.0 specification and is directly applicable to the use of Bluetooth low power devices. That said, the framework hides the underlying implementation details of many development specifications, making it easier for you to develop apps that interact with Bluetooth low-power devices. Because some of the concepts and terminology related to the Bluetooth framework in this note have been widely adopted in this note, this article will introduce you to Core Bluetooth some of the key terms and concepts in this framework.

The role of central and peripheral in Bluetooth interaction

There are two main roles in all interactions involving Bluetooth low power: center Central and peripheral devices Perpheral . According to some traditional 客户端-服务端 structure, Peripheral usually has the data which other equipment needs, but Central usually uses Perpheral the information to realize some certain function. As shown, for example, a heart rate listener may contain some useful information, and your Mac/ios app may need to display the user's heart rate in a user-friendly manner.


Alt Textcentral Discover and connect peripheral in the broadcast

PeripheralTo broadcast data in the form of some ad packets, the ad package is a relatively small bundle that may contain Peripheral useful information such as the name of the peripheral and the main function. For example, a digital thermostat can advertise the instant temperature of one of the rooms. In low power Bluetooth, broadcast is Peripheral the primary way to be learned.

On the other hand, Central you can scan and listen for any interest in broadcast content Peripheral . For example, Central you can request a connection to any external broadcast content Peripheral .


How ALT text data is formed in peripheral

The purpose of the connection Peripheral is to explore and interact with the data it provides. Before that, it would be helpful to understand how the data Peripheral is formed in the middle.

PeripheralContains one or more Service useful information about the strength of its connection signal. Servicerefers to the collection of data and related behaviors of a device (or part of a device) that implements a function or function. For example, a heart rate listener Service might contain heart rate data collected from a listening heart rate sensor.

And Service Characteristic is composed of or otherwise contained Service . Characteristicprovides more detailed information about the Peripheral Service . For example, the heart rate service you just described could include a heart rate sensor that describes the device's physical location characteristic or contains a measurement of heart rate data Characteristic . For example, indicates that a heart rate listener may contain the Service and Characteristic .


ALT textcentral Data Exploration and interaction on peripheral

Centralafter a successful and Peripheral established connection, you will be able to discover Peripheral all the Service and Characteristic . (Broadcast data may contain only a subset of the visible Service )

CentralCan be interacted with by reading or writing Service Characteristic value Peripheral . For example, your app might request the current room temperature from a digital thermostat, or provide a value for the thermostat to set the room temperature.

How central,peripherals and peripheral data are represented

Key roles and data in low-power Bluetooth interactions are Core Bluetooth expressed in a straightforward way.

Objects on the central side

When you use local Central and remote Peripheral interaction, you will perform the operation on the low power Bluetooth Central side. Most Bluetooth interactions are done by the end unless you are building a local Peripheral device and making it respond by one Central -side request Central .

Local Central and Remote peripheral

On the Central end, the local Central device is represented as Cbcentralmanager. These objects are used to manage the discovery or connection of remote Peripheral devices (represented as cbperipheral), including scans, discoveries, and connections in the broadcast Peripheral . As shown in the following:


ALT text remote peripheral data represented as Cbservice and cbcharacteristic

When you interact with a remote Peripheral (expressed as CBPeripheral ) data, you will handle its Service and Characteristic . In the Core Bluetooth framework, Peripheral the remote Service representation is CBService . Similarly, Peripheral Service the representation in the remote is Characteritic CBCharacteristic . As shown in the following:


Alt Textperipheral End-of-object

OS X v10.9 and iOS6 Mac/ios devices can be set to low power Bluetooth Peripheral , transmitting data to other mac/iphone/ipad. When you set up your device to make it achievable Peripheral , you can end up with low-power Bluetooth interaction Peripheral .

Local peripheral and Remote central

At the Peripheral end, a Peripheral device is represented asCBPeripheralManager
。 This object is used to manage those that contain local Peripheral devices Service and data that are Characteristic Service published to remote Central devices (represented as) by broadcasting these services CBCentral . Peripheral managerThe object can also respond to remote Central read and write requests. As shown in the following:


Alt text Local peripheral data represented as Cbmutableservice and cbmutablecharacteristic

When you set up and interact with local Peripheral (expressed as CBPeripheralManager ) data, you can work with Service Characteristic the mutable version. In the Core Bluetooth framework, Peripheral The local Service representation is CBMutableService . In the same way Peripheral , Service the representation in the local is Characteristic CBMutableCharacteristic . As shown in the following:

iOS Bluetooth Programming Guide-Core Bluetooth overview

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.