FireBLE/First app for IOS
Bluetooth is a wireless technology standard for exchanging data over short distances (Usually within 10meter) from mobile devices,PDA,wireless headset and laptop. The Bletooth Special Interest Group ( SIG ) formalized it and announced its official use on May, 1998. It was established by Ericsson, IBM, Intel, Toshiba and Nokia, and later joined by many other companies. The purpose was to provide a short distance and lowcost wireless application technology.From 1998 to now, Bluetooth V1.0 was upgraded to Bluetooth 4.1, Bluetooth Core Specification version 4.0 (called Bluetooth Smart), Bluetooth low energy, previously known as BLE4.0
A piconet is a computer network which links a wireless user group of devices using Bluetooth technology protocols. A piconet consists of two or more devices occupying the same physical channel.It allows one master device(central) to interconnect with up to several active slave devices(Peripheral). When Peripherals give signal,the central will scan and connect.
When the advertise signal sent out from the node,including some additional information such as the device address and device name,etc. The master node will ask for scan request to the slave node.The slave node respond to the request,then the connection is finished.
To be safe,it requires authentication for some data accessing.It works as follow: One party(it could be the master node or the slave node) will ask another party for a 6 digits password, and then they will exchange password for security and authentication.This process is called matching. The process of authentication is very complicated. BLE protocol allows two nodes to keep the password of authentication.(General stored in Nonvolatile memory) In order to help these two nodes to finish authentication after connecting. This is data-binding technology. The connecting procession is shown below:
Most of communication, especially TCP/IP. Packets are the medium of exchanging date.During Bluetooth communication, engineer can not find the way to visit packet,then they doubt.Actually the lowest level of Bluetooth is base on wireless packet exchanging, but after being packed one by one,the API interface for engineers is turning into a method of client visiting server.
There are 2 frames of ISO support Bluetooth to connect with peripherals. One is ExternalAccessory。Start from IOS3.0，this mode was used most before iphone4s came out.Its weakness is the External Accessory need the MFI certification of Apple Inc. Another Frame is CoreBluetooth, Start from iphone4s, specially used in BLE device communication.（As its API is base on BLE）。No need of MFI，and now many Bluetooth supports 4.0,so it is another development method that IOS suggest.
Introduction of CoreBluetooth
Roles and Responsibility
The frame of Core Bluetooth is peripheral and central, it can be considered as the slave node and master node of Peripheral.Inside the Bluetooth network nodes,there are only one Central and mutli-peripheral. Peripheral send out the signal and Central scan and ask for connection. There are one set of relevant API and class，Just as the image showed below:
If using a cellphone as Central, you need to use the API of the left side. On the contrary,use the API of right side. Although,both communication of Central and peripheral are CS construction. But their roles are not set. The one who is sending massage,it is the client part and vice versa.
Two key concepts of BLE4.O: Service and Characteristic
All BLE4.0 devices distinguish themselves via service and characteristic. A single device can support one or more services,each service has a set of characteristics associated with it. Characteristic is the smallest units of interacting with the outside world. For example,one BLE4.0 device shows its factory version via Characteristic A, then it will send and receive date with devices via Characteristic B.
Service and Characteristic are identified only by UUID. The Bluetooth SIG have reserved a range of UUIDs for standard service attributes. Such as blood pressure measurement and devices which measure heart rate.
There two ways to collect date via characteristics: One is Read, another is subscription. Read:[peripheral readValueForCharacteristic:characteristic]; Subscription:[peripheral setNotifyValue:YES forCharacteristic:characteristic];