"Go" "iOS Official Document Translator" Basic concept of iOS Bluetooth

Source: Internet
Author: User

Original address: http://blog.csdn.net/dolacmeng/article/details/46489823

1. Central devices and peripherals and their role in Bluetooth communication.

There are 2 main roles involved in all ble (Bluetooth low energy, Bluetooth 4.0) communications: Central devices and peripherals. It is based on the traditional customer-server (master-slave) structure, in general, the peripherals have the data required by other devices, the central device uses the data provided by the peripheral equipment to accomplish specific tasks. As shown, the heart rate monitor has useful data that the Mac or iOS app needs to show the user's heart rate.

2. Center device search and connect the ad's peripheral devices

A new noun is introduced here: Advertising (advertise).

Data in the form of external broadcast advertising packets (advertising packets), an ad pack is a relatively small bundle of data containing peripheral information, such as the name of a peripheral device and its main functions. For example, a digital thermostat will advertise (advertise) that it provides the room's current temperature data, and in Bluetooth 4.0, advertising is the main method that peripherals allow other devices to discover.

On the other hand, the central device can scan and listen to any peripheral devices in advertising (advertising), such as. A central device can request a connection to any peripheral device it discovers is advertising

Three. Data structure of peripheral devices

Here are two words: service (services) and features (characteristics).

The purpose of connecting peripherals is to explore and interact with the data, and before we begin, we'll start by understanding the data composition of the next peripheral device.

The perimeter device contains one or more services and provides the strength of the connection signal. A service is a collection of data that is the function of a device to perform a specific behavior. For example, a heart rate meter's service is to read data from a heart rate sensor.

The service consists of a feature (characteristics). A feature provides more detailed information about the perimeter device service. For example, the heart rate service simply means that it contains a characteristic describing the body part of the heart rate sensor and a transmission heart rate measurement data. Figure 1-3 shows the relationship structure of a heart rate sensor service and feature

4. The central device detects and interacts with the peripheral devices

Once a central device is connected to a peripheral device, you can search for all the services and features provided by the peripheral device. (The ad's data may contain only a subset of the available services). A central device can also interact with peripheral devices by reading and writing the features of the service. For example, your app can request the current room temperature from a digital temperature regulator, or you can provide a value to set the room temperature.

5. Representation of central equipment, peripherals and peripheral data

What objects in the core Bluetooth framework are the main Bluetooth participants and related data?

5.1. Center Equipment

When you use a local hub device to interact with external peripherals, you'll need to write code on this side of the Bluetooth hub device, unless you're building a local peripheral (described in 5.2), or most of your Bluetooth transmissions will be on the central device side.

For information on how to implement the central device role in your app, see the performing Common centrally role Tasks (my previous translation) andbest practices for interacting with a Remote Perip Heral Device

5.1.1 Local center devices and remote peripherals

On the central device side, a local hub device is represented by a Cbcentralmanager object that manages the discovery and connection of remote devices (represented by Cbperipheral objects), including searching, discovering, and connecting peripherals that are advertising. For example, displays the representation of the local hub device and remote peripherals in the core Bluetooth framework.

5.1.2 Remote peripheral data is represented by Cbservice and cbcharacteristic

When you interact with the peripheral device (the Cbperipheral object), you need to process its services and features (characteristics), in the core Bluetooth framework, Services for peripherals are represented by Cbservice objects. The same,

The features of peripheral devices are represented by Cbcharacteristic objects. For example, represents the basic structure of the service and characteristics of a remote peripheral device.

5.2 Objects corresponding to peripheral devices

Starting with OS X10.9 and IOS6, Mac and iOS devices can be used as peripheral devices for Bluetooth 4.0 to provide data for other devices, including other Macs, iphones, and ipad devices. When you set up your device as a peripheral role, you need to implement some processing of the peripheral devices.

5.2.1 Local peripherals and external center devices

On the peripheral side, local peripherals are represented by Cbperipheralmanager objects, which are used to manage services and characteristics in the perimeter device database, and to broadcast these services to external central devices (Cbcentral objects). Peripheral Management objects can also respond to read and write requests from remote devices, showing the representation of local peripherals and remote center devices in the Core Bluetooth framework

5.2.2 data for local peripherals is represented using Cbmutableservice and Cbmutablecharacteristic objects

When you set up a local peripheral (Cbperipheralmanager object) and interact with the data, you need to deal with its services and characteristics. In the core Bluetooth framework, services for local peripherals are represented by Cbmutableservice objects. Similarly, a service feature is represented by a Cbmutablecharacteristic object, and Figure 1-7 is the basic structure of the services and features of the local peripherals

"Go" "iOS Official Document Translator" Basic concept of iOS Bluetooth

Related Article

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.