본문 바로가기
임베디드.일렉트로닉스

BLE Protocol Stack - Bluetooth Low Energy. GAP, GATT, Profile, Service, Characteristic

by i.got.it 2015. 6. 21.

 

 

개요

 

블루투스 스펙 4.0, 4.1, 4.2 에서는 이전 스펙들에서의 BR/EDR 에 추가로 Bluetooth Low Energy (BLE) 가 추가되었다.

- BR/EDR : Basic Rate/Enhanced Data Rate

BLE system 은 저전력으로 한번에 극히 작은 데이터를 전송함에 최적화 되어있다. 이름 그대로 저전력 응용에 적합하다.

블루투스 기기가 BR/EDR 과 BLE 모두 지원하는 것을 Bluetooth Smart Ready 라고 한다. Dual Mode 라고도 한다.

블루투스 기기가 BLE 만 지원하는 것을 Bluetooth Smart 라고 한다. Single Mode 라고도 부른다.

 

 

 

 

 

본 글에서는 BLE Protocol Stack 의 전체 구조 및 각 요소들에 대하여 단순 명료하게 정리한다.

 

 


 

BLE Protocol Stack Architecture

   

BLE Protocol Stack Architecture.

 

 

Controller, Host

BLE Protocol Stack 을 2 그룹으로 분류하자면, Controller , Host 로 나뉜다. 위 그림에서 아래 부분을 Controller, 윗부분은 Host.

- Controller, Host 로 구분하는 것은 종래의 Bluetooth BR/EDR 에서도 동일하며, BLE만의 특수한 것은 아님.

- BLE의 모든 profile 과 application 은 Host의 상위 계층인 GAP, GATT 의 상위에서 구현된다.

 

 

BLE Protocol Stack 의 Controller 구성요소 3개.

 

1. PHY (Physical Layer) : Radio operating. 2.4GHz ISM밴드, 1Mbps adaptive frequency hopping GFSK (Gaussian Frequency Shift Keying).

 

2. LL (Link Layer) : RF state 제어. RF State 5 = standby, advertising, scanning, initiating, connected.

Advertiser 는 connection 아닌 상태에서 데이터 전송한다.

Scanner 는 advertiser 를 Listen 한다. 

Initiator : Advertiser 에 반응하여 connection  요청하는 측을 Initiator 라 한다.

initiator 의 연결요청에 Advertiser 가 수락(accepts) 하면 advertiser 와 initiator 는 connceted 상태가 된다.

connection 된 경우 기기는 2개의role master, slave 중의 어느 하나의 역할을 하게되며, initiator(connection을 개시한) 가  master이며, advertiser (initiator 가 연결요청한 것에 수락한) 가 slave 이다.

 

3. HCI(Host Contoller Interface) : Host 와 Controller 사의 통신수단을 제공한다. software API 로 제공될 수 도 있고(Host와 Controller 가 1개의 칩내에서 구현된 경우), UART, SPI, USB 등일 수도 있다(Cnntroller 만 별도 칩으로 구현된 경우).

standard  HCI Command , events 는 Bluetooth Core Spec 에 정의되어있다.  

 

BLE Protocol Stack 의 Host  구성요소 5개.

 

1. L2CAP (link logical control and adaption protocol)

상위 계층으로 data encapsulation services 를 제공한다.

 

2. SM (security manager)

pairing and Key distributuiion 방법을 정의하고 있으며, 다른 기기와  secure connect & data 교환이 가능하게 해준다.

- Encryption and Authentification.

- Pairing and Bonding. Pass Key and Out of band bonding.

- Key Generation for a device identity resolution, data signing and encryption.

- Pairing method selection based on the IO capabiltity of the GAP central and GAP Peripheral device.

 

3. GAP (generic access protocol)

application , profiles  과 직접적 interface 되어 , 기기 discovery, connection-related service 를 핸들링한다. 또한, GAP 은 security 를 initiation  한다.

 

4. ATT (attribute protocol)

다른 기기로 "attributes" 라는 데이터를 노출시킨다.

 

5. GATT (generic attributes protocol)

ATT를 이용하는 sub-procedure  를 정의하는 프레임워크이다.

BLE 기기간의 모든 통신은 GATT sub-procudure 로 핸들링되므로, application and/or profiles 는 GATT를 직접적으로 이용하게 된다.

 

 

 

 

 

 

 

 

GAP Role 4종 : Broadcaster, Observer, Peripheral, Central

 

GAP 은 아래와 4종의 Role 이 정의되고 있다.

 

1. Broadcaster : advertising event 를 송신한다. transmiiter 를 갖고있으며, 동시에 receiver 도 있을 수 있다.

 

2. Observer : advertising event 를 수신한다. receiver  를 갖고있으며, 동시에 transmitter도 있을 수 있다.

 

3. Peripheral

conection procedure 에서 수락하는 측을 Peripheral 이라 한다. Link Layer 에서의 Slave Role에 해당한다.

 

4. Central

connection procedure 를 개시하는 측을 Central 이라 한다. Link Layer  에서의 Master Role 에 해당한다.

 

 

 

 

 

 

 

GATT Role : Client, Server.

 

 

GATT Client

- GATT Server 에게 데이터 요청 개시 하여 데이터를 받아내는 측.

- GATT Server 에서 전송된 response, indication, notification 을 수신할 수 있다.

 

GATT Server

- 데이터를 보유하고 있고, GATT Client 의 요청을 받아들인다.

- GATT Client 에게 response, indication, notification 을 송신할 수 있다.

 

 

 

 

 

 

Profile, Service, Characteristic, Attribute 

 

Profile 및 이하 Service, Characteristic 은 상기 그림2에는 표현되어있는 것이 아니며 GAP, GATT 의 상위에 해당하는  Application 계층에 해당한다. Profile 이란 기기가 제공하는 Service들이 정의되고 각 Service 에 Characteristic 들이 정의된 것을 말한다.

 

Profile

기기에 어떻게  connect 하는지 기기가 제공하는 Service 들을 기술한다.

1개의 Profile에는 1개이상의 Service 가 정의될 수 있다.

 

Service

1개의 Service 에는 1개 이상의 Characteristic 이 정의될 수 있다. 

1개의 Service  마다 고유한 UUID가 할당된다.

SIG adopted 서비스 의 UUID는 16비트로 지정되어있다.

Custom Service 의 UUID는 128비트로 지정가능하다.

 

Characterisitc

Value 와 Descriptor 를 포함한다.

Descriptor  는 Value 를 설명하는 정보.

Charaterristic 은 고유 UUID 가 할당된다.

SIG adopted Characteristic 은 지정된 16bit UUID, Custom Characteristic 은 128 bit 로 지정가능하다.

 

Attribute

ATT/GATT 계층에서 정보 표현하는 최소단위.

Handle(2bytes), Type(2bytes), Value(0~512byte), Permission(상황따라 다름) 로 구성되어있다.

Handle : Attribute address

Atrtribute Type : 16bit UUID 지정되어있고, 이는 Bluetooth SIG에 발급한것임.

Value : 데이터. 

Permission : read/write, security 설정.

 

아래 Attributes 구조와 예를보임.

from : Cypress Application Note AN91267 Getting Started with psoc4 BLE.

 

아래 Characteristic 구조와 예를 보임.

from : Cypress Application Note AN91267 Getting Started with psoc4 BLE.

 

아래 Service 예를 보임.

from : Cypress Application Note AN91267 Getting Started with psoc4 BLE.

 

 

 

 

 

 

본 글이 포함된 상위 정리 글.

 

Connectivity : http://igotit.tistory.com/280

 

 

 

Reference.

1. TI CC2640 Bluetooth low energy Software Developer’s Guide SWRU393   의 페이지 9,10

2. http://www.cypress.com/file/157996/download 의 페이지 6~9

3. Cypress Application Note AN91267 Getting Started with psoc4 BLE.

 

///333.

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5