Internet of Things (IoT). Bluetooth devices, WIFI devices. Bluetooth is a wireless technology standard that enables short distance data exchange between fixed devices, mobile devices, and personal domain networks in buildings. Bluetooth can connect multiple devices, overcoming the problem of data synchronization. The general distance of Bluetooth is 40-50m, but the actual use is within 10m, so the signal is relatively normal. Bluetooth is managed by the Bluetooth Technology Consortium. The Bluetooth Technology Alliance oversees the development of bluetooth specifications, administers certification programs, and defends trademark rights. Manufacturers’ devices must meet the Standards of the Bluetooth Technology Alliance to enter the market as “Bluetooth devices”. Bluetooth technology has a proprietary network that can be issued to standards-compliant devices.
Bluetooth 4.0 is the latest bluetooth version in 2012, which is an upgrade of 3.0. It saves more power, costs less, has a low latency of 3 ms, long effective connection distance, aes-128 encryption, etc. Usually used in Bluetooth headset, Bluetooth speaker, smart hardware and other devices.
Bluetooth communication flow
A server (peripheral) is a device that provides data and broadcasts information outwards
The client (center) scans and listens for broadcasts of interest
After finding the peripherals that the client is interested in, the client can connect the peripherals and scan the specific services and communication channels of the peripherals. After that, the client can send and receive data through communication protocols.
The following is apple’s official interaction process:
Central Peripheral
CoreBluetooth framework structure
Center equipment
When you interact with remote peripherals using a local central device, you perform operations on a central device with Bluetooth low-power communication. Unless you set up the local peripheral (and use it to respond to requests from the central device), Bluetooth interactions will take place on the central device.
CBCentralManager: Bluetooth center device management class for unified scheduling center device development (scanning, connecting, etc.) CBPeripheral: Bluetooth peripherals for managing discovered or connected remote peripherals, including scanning, discovering, and connecting to advertising peripherals. Examples include bluetooth sphygmomanometers and heart rate monitors. CBService: indicates the services of bluetooth peripherals. The number of services can be 0 N. CBCharacteristic: Features of a service. Each Bluetooth service can have 0 N features, including data information. It has properties such as read, write, and notification. CBUUID: Id card of a service or feature, used to select the desired service and feature. For example, the heart rate monitor service UUID: 0x180D.
A peripheral device
CBPeripheralManager: A central management class for Bluetooth peripherals. CBCentral: Bluetooth central device, such as a mobile phone used to connect to a Bluetooth bracelet. CBMutableService: Peripheral development can add multiple services, can be used to create services CBMutableCharacteristic: each service has multiple features, use this class to add features to the service. CBATTRequest: read or write requests. Its instance object has a value property that is used to load data from a peripheral for bluetooth read or write requests, usually in the callback method for the peripheral to write or read.
Custom UUID
Service Characteristics of the development peripheral are not included in the common bluetooth UUID. You can open the Terminal command and use the uuidgen command to generate a 128-bit UUID. 2516E2ED-CD3C-4DD0-826A-A4FEA79B4377
CoreBluetooth Programming Guide CoreBluetooth Framework Official website