FireBLE/protocol stack

来自Firefly wiki
跳转至: 导航搜索


The BLE protocol stack architecture is illustrated of LL、L2CAP、SMP、ATT、GATT、GAP.

BLE protocol stack struct.png

Link Layer (LL)

  • Packet scheduling over the air.
  • Link establishment and maintenance.
  • Frequency hopping calculation.
  • Packet construction and recovery.
  • Encryption and decryption.
  • Link Control procedures (connection update, channel map update, encryption, feature

exchange, version exchange, and termination).

  • Device filtering policy applies based on device white list.

BLE LL.png

Link Layer has five possible states which are controlled by a state machine describing the operation of the link layer. The Link Layer state machine allows only one state to be active at a time.

  1. standby:Device has no activity. Do not transmit or receive any packet.
  2. advertising:Device sends advertising packets,Device can receive scan request,and return scan response,Device can accept connection request
  3. scanning:Device waits to receive advertising packets,Device can respond with scan request, and wait for scan response
  4. initiating:Device waits to receive advertising packet from a specific device, and responds with connection request
  5. connection:Device exchanges data. Two roles are defined, master role and slave role. When entered from the Initiating State, the Connection State shall be in the Master Role. When entered from the Advertising State, the Connection State shall be in the Slave Role.

L2CAP Layer

  • Provide connection-oriented data services to upper layer protocols.
  • Provide a mean to set or change the connection parameters of the data link.
  • Support protocol and/or channel multiplexing (fixed channels – ATT, SMP, SIGNAL).
  • The application shall not exchange message with link layer directly.

SMP Layer

  • Pairing algorithm
  • Key distribution and usage
  • Signing and resolving signature
  • Generating and resolving resolvable randoma ddress
  • The application is keeper ofkeys:
  • LTK
  • IRK
  • CSRK

ATT Layer

  • Exchange attribute information between peers
  • Client‐server model
  • Manipulation
  • Discovery attribute
  • Read attribute
  • Write attribute
  • Indicate,Confirm
  • Notify

GATT Layer

  • Define service framework using attribute layer
  • Gathering of data to accomplish a particular function or feature
  • Feature
  • Server configuration
  • Service Discovery
  • Characteristic Discovery
  • Characteristic Descriptor Discovery
  • Read Characteristics Value
  • Write Characteristics Value
  • Indicate and Notify

GAP Layer

  • Supported all GAP roles
  • Central
  • Peripheral
  • Observer
  • Broadcaster
  • Device discovery
  • Link establishment and management
  • Security mode and level
  • Privacy

Exchange Information

APP and LE profiles do not use these manipulation directly.They use GATT which operate APP protocol.
BLE frame strcuture.png

We can understand the parameters first.We must first understand what is the properties and the database.

Attribute And Database

In ATT layer to achieve the client/server framework(Has nothing to do with master-slave relationship, this framework is to build a link between the equipment of the definition of job assignments). a client can communicate with a server. The server contains a number of attributes, and the GATT Profile defines how to use the Attribute Protocol to discover, read, write and obtain indications of these attributes, as well as configuring broadcast of attributes.

In the ATT layer, use the attribute to provides data.The server provides attribute,and the Client access the attribute.

  • type: identified by UUID,what does this value means.
  • value:discrete value with attribute,octet array.
  • handle:identifier of the attribute,16‐ bit value, how to address it.
  • permission:specifies security level access(rd,wr,ind,notif).

Attribute Manipulation : Request,response,command,notification indication confirmation
BLE ser-cli.png

Server and Characteristic

Server is a gathering of data to accomplish a particular function or feature,it contains server define,include define and Characteristic define.

  • Service definition
  • Include definition
  • Characteristic definition
  1. Characteristic declaration
  2. Characteristic value declaration
  3. Characteristic descriptor declarations

BLE server struct.png

GATT provide:

  1. MTU exchange
  2. Service Discovery
  • Discover ALL services
  • Discovery All services by UUID
  1. Characteristic Discovery
  • Discover ALL characteristics of a service
  • Discover ALL characteristics descriptors
  1. Read/Write Characteristics Value
  2. Notify and Indicate Characteristics value

To be a gathering of data to accomplish a particular function or feature ,Server will be relatively independent,Function is not too complicated.APP Does not use the service directly,it limited by profile.


profile Implemente of the service combination and restriction,to Implemente more complex functions.In the profile of proxr,it contains three services,They are independent of each other and work together.