Skip to content

Latest commit

ย 

History

History
401 lines (242 loc) ยท 16.6 KB

Whats-New-in-Core-Bluetooth.md

File metadata and controls

401 lines (242 loc) ยท 16.6 KB

What's New in Core Bluetooth

๐Ÿ“… 2020.6.9 (TUE)

๐Ÿ—‚ WWDC2017 | Session : 712 | Category : System Frameworks

๐Ÿ”— https://developer.apple.com/videos/play/wwdc2017/712/

๐Ÿ”– Discover how watchOS 4 makes it possible for a watchOS app to communicate with Bluetooth Low Energy accessories. Learn about changes to Core Bluetooth that improve reliability and enable high performance streaming connections with Bluetooth Low Energy Accessories. Understand the best practices in Bluetooth Low Energy accessory design.


Centrals and Peripherals

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled.png

Bluetooth Low Energy has two roles

  • Central : look for devices that are around your environment
  • Peripherals : beacon to the world, send out data or just let their presence be known

Bluetooth Low Energy ์˜ ๋‘๊ฐ€์ง€ ์—ญํ• 

  • Central :์ฃผ๋ณ€์— ์žˆ๋Š” ๋””๋ฐ”์ด์Šค ํƒ์ƒ‰
  • Peripherals : ์‹ ํ˜ธ ๋ณด๋‚ด๊ธฐ, ๋ฐ์ดํ„ฐ ์ „์†ก, ์กด์žฌ ์•Œ๋ฆฌ๊ธฐ

GATT Database

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%201.png

After you find this device that's around you, you can connect to your device and then you have bidirectional communication through what's called the GATT Protocol(takes all of your data and expose them in a hierarchy called services and characteristics).

CGService : contain characteristics inside of it

์ฃผ๋ณ€์— ์žˆ๋Š” ๋””๋ฐ”์ด์Šค๋ฅผ ์ฐพ์œผ๋ฉด, ๋„ˆ์˜ ๊ธฐ๊ธฐ์— ์—ฐ๊ฒฐ ํ•  ์ˆ˜ ์žˆ๊ณ , GATT ํ”„๋กœํ† ์ฝœ์„ ํ†ตํ•ด ์–‘๋ฐฉํ–ฅ ์†Œํ†ต์ด ๊ฐ€๋Šฅํ•˜๋‹ค. GATT ํ”„๋กœํ† ์ฝœ์€ ๋„ˆ์˜ ๋ชจ๋“  ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ง€๊ณ  ์žˆ๊ณ  services and characteristics ๋ผ๊ณ  ๋ถˆ๋ฆฌ๋Š” ๊ณ„์ธต์— ๋…ธ์ถœํ•œ๋‹ค.

CBSerivce ๋Š” CBCharacteristic ์„ ํฌํ•จํ•˜๊ณ  ์žˆ๋‹ค.

๋Œ€๋ถ€๋ถ„์˜ ๊ฒฝ์šฐ, ๋„ˆ์˜ ์• ํ”Œ ๋””๋ฐ”์ด์Šค๋Š” ์—ฐ๊ฒฐ์˜ ์ค‘๊ฐ„ ์—ญํ• ์„ ํ•  ๊ฒƒ์ด๊ณ  peripheral ์— ์—ฐ๊ฒฐ ํ•  ๊ฒƒ์ด๋‹ค. ๋ฐ˜๋Œ€์˜ ๊ฒฝ์šฐ๋„ ๋  ์ˆ˜ ์žˆ๋‹ค.

Reading Characteristics as a Central

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%202.png

retrieveConnectedPeripherals : ์—ฐ๊ฒฐ ๋˜์–ด์žˆ๋Š” peripheral ๋“ค์„ ๊ฒ€์ƒ‰ ํ•  ์ˆ˜ ์žˆ๋‹ค.

retrievePeripherals(withIdentifiers :) : ํ˜ธ์ถœ ํ•  ์ˆ˜ ์žˆ๋Š” ใ…Šใ…Š์˜ identifier์„ ๊ฐ€์ง€๊ณ  ์žˆ์œผ๋ฉด peripheral ์„ ๊ฐ€์ ธ ์˜ฌ ์ˆ˜ ์žˆ๋‹ค.

Enhanced Reliability

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%203.png

๋””๋ฐ”์ด์Šค๋ฅผ ํ•˜๋ฃจ ์ข…์ผ ์—ฐ๊ฒฐ์‹œ์ผœ ๋†“๊ณ  ์‹ถ์–ดํ•œ๋‹ค. ์ฐจ๊ณ  ์žˆ๋Š” ๋™์•ˆ์ด๋‚˜ ์ž๋Š” ๋™์•ˆ์—๋„ ๋ฐ์ดํ„ฐ์— ์ ‘๊ทผํ•˜๊ณ  ์‹ถ์–ดํ•˜๋ฉฐ ์•ก์„ธ์„œ๋ฆฌ์™€์˜ ์—ฐ๊ฒฐ์ด ์‹ ๋ขฐ๋˜์–ด์•ผ ํ•œ๋‹ค.

Backrounded Apps

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%204.png

CGCentralManager restoration

  • Central operation s can continue when your app is not running
    • Scan for new devices with services
    • Connect to an already known device

Central์€ ์ƒˆ๋กœ์šด ๊ธฐ๊ธฐ๋ฅผ ์Šค์บ” ํ•  ์ˆ˜ ์žˆ๊ณ , ๋„ˆ์˜ ์•ฑ์ด ๋ฉ”๋ชจ๋ฆฌ ์ด์Šˆ ๋“ฑ์ด ์žˆ์„ ๋•Œ Core Blutooth๊ฐ€ ๊ณ„์† ๋„ ์œ„ํ•ด ๋””๋ฐ”์ด์Šค๋ฅผ ์ฐพ์•„ ์ค„ ๊ฒƒ์ด๋‹ค.

public let CBCentralManagerOptionRestoreIdentifierKey: String

optional public func centralManager(_ central: CBCentralManager, 
																		willRestoreState dict: [String: Any])

CGCentralManager๋ฅผ ์ดˆ๊ธฐํ™” ํ•  ๋•Œ restoreIdentifier ๋ฅผ ์ „๋‹ฌํ•œ๋‹ค. ์•ก์„ธ์„œ๋ฆฌ์— ์—ฐ๊ฒฐํ•˜๋Š” ๋“ฑ์˜ ์•ก์…˜์ด ๋๋‚˜๋ฉด, ์•ฑ์ด ์‹คํ–‰ ๋˜๊ณ  ์˜ค๋ž˜ ์ง€๋‚ฌ๋”๋ผ๋„, ์šฐ๋ฆฌ๋Š” ์•ฑ์„ ์žฌ์‹คํ–‰ ํ•˜๊ณ  ์ฝœ๋ฐฑ์„ ๋ณด๋‚ด ์ค€๋‹ค.

CentralManager๊ฐ€ state๋ฅผ ๋ณต์› ํ•  ๊ฒƒ์ด๋‹ค.

  • Peripheral operations can continue when your app is not running
    • Publish local services
    • Advertise service UUID

Peripheral์€ ์•ฑ์ด ๋”์ด์ƒ ์ž‘๋™ํ•˜๊ณ  ์žˆ์ง€ ์•Š๋”๋ผ๋„ ๋ฌด์–ธ๊ฐ€๋ฅผ ๊ณ„์† ํ•  ์ˆ˜ ์žˆ๊ณ  ์•ฑ์ด ํ•„์š” ํ•  ๋•Œ ์žฌ์‹คํ–‰ ํ•  ๊ฒƒ์ด๋‹ค.

public let CBPeripheralManagerOptionRestoreIdentifierKey: String

optional public func peripheralManager(_ peripheral: CGPeripheralManager,
																			 willRestoreState dict: [String: Any])

์—ฌ๊ธฐ์„œ๋„ ์‹œ์Šคํ…œ์˜ ์œ ๋‹ˆํฌํ•œ restoreIdentifier๊ฐ€ ์žˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  ๋Œ์•„์™”์„ ๋•Œ ํ˜„์žฌ state๋ฅผ CBPeripheralManagerRestoredServiceKey:๋ฅผ ํ†ตํ•ด ์•Œ๋ ค์ฃผ๊ณ , ์–ด๋–ค ์„œ๋น„์Šค๊ฐ€ ์—ฌ์ „ํžˆ publishํ•˜๋Š”์ง€ ์•Œ๋ ค์ค€๋‹ค.

๐Ÿ†• State Preservation and Restoration

Works across device reboot or Bluetooth system events

  • Try to ask for as few system resources as possible
  • Background activities will be stopped if
    • User force quits the app
    • User disables Bluetooth

๋””๋ฐ”์ด์Šค๊ฐ€ ์žฌ์‹œ๋™ ๋˜์–ด๋„ ์—ฐ๊ฒฐ์„ ์œ ์ง€ ์‹œ์ผœ ์ค„ ๊ฒƒ์ด๋‹ค! scan ํ•  ์ˆ˜ ์žˆ๋Š” ์„œ๋น„์Šค์˜ ๊ฐœ์ˆ˜๋ฅผ ์ œํ•œ ํ–ˆ๋‹ค.

๐Ÿ†• Write Without Response

  • Write Without Response would be dropped due to memory pressure
  • New property will tell your app if more data can be sent
open class CBPeripheral: CGPeer {
	open var canSendWriteWithoutResponse: Bool { get }
}

public protocol CBPeripheralDelegate: NSObjectProtocol {
	optional public fund preipheralIsReady(toSendWriteWithoutReponse peripheral: CGPeripheral)
}

canSendWriteWithoutResponse : write ํ•˜๊ธฐ ์ „์— ํ˜ธ์ถœ

yes ๋ฅผ ๋ฆฌํ„ดํ•˜๋ฉด, ๋„ˆ์˜ data๋ฅผ remote peripheral๋กœ ์ „์†กํ•  ๊ธฐํšŒ๊ฐ€ ์˜ค๊ธฐ ์ „๊นŒ์ง€๋Š” ์†Œํ”„ํŠธ์›จ์–ด๋กœ drop๋˜์ง€ ์•Š๋Š”๋‹ค.

no ๋ฅผ ๋ฆฌํ„ดํ•˜๋ฉด, ready ์ƒํƒœ์ผ ๋•Œ delegate๋กœ preipheralIsReady ์ฝœ๋ฐฑ์„ ๋ฐ›๋Š”๋‹ค

Platform Support

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%205.png

iOS + macOS

  • Foreground and background apps
  • Central and Peripheral
  • 15 ms minimum connection interval
  • State Preservation and Restoration on iOS

tvOS

  • Foreground app only
  • Central role only
  • Limited to 2 simultaneous connections
  • 30 ms minimum connection interva
  • Peripheral disconnected when app is moved to the backgroudn

๐Ÿ†• watchOS

  • Access dictated by system runtime policies
  • Central role only
  • Limited to 2 simultaneous connections
  • 30 ms minimum connection interval
  • Peripherals disconnected when app is suspended
  • Supported on Apple Watch Series 2

๐Ÿ†• L2CAP Channels

L2CAP Connection Oriented Channels

  • Bluetooth SIG Protocol underlying all communication
  • Logical Link Control and Adaptation Protocol
  • Stream between two devices
  • Introduced for LE in Bluetooth Core Spec 4.1

L2CAP์˜ ๊ฐ€์žฅ ๋ฐ‘๋‹จ์€ ๋‘ ๊ธฐ๊ธฐ๊ฐ„์˜ ๋ฐ์ดํ„ฐ์˜ stream ์ด๊ณ , ์ด ๊ธฐ๊ธฐ๋“ค ๊ฐ„ ์†Œํ†ต์„ ์œ„ํ•ด ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœํ† ์ฝœ์ด๋‹ค.

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%206.png

๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ€์ ธ์˜ค๊ธฐ ์œ„ํ•ด์„œ GATT Database ์™€ ๋‹ฌ๋ฆฌ, L2CAP Channels ์€ frame ์ œํ•œ์ด๋‚˜ ํŒจํ‚ท ์‚ฌ์ด์ฆˆ ์ œํ•œ ์—†์ด side channel์„ ์—ด์–ด์„œ ์ง์ ‘ ์ฝ๊ณ  ์“ฐ๊ธฐ๋ฅผ ๊ฐ€๋Šฅํ•˜๊ฒŒ ํ•œ๋‹ค.

Central Slide L2CAP

Open an L2CAP Channel on an existing CBPeripheral connection

open class CBPeripheral: CBPeer {
	open func openL2CAPChannel(_ PSM: CBL2CAPPSM)
}

public protocol CBPeriphralDelegate: NSObjectProtocol {
	optional public func periphral(_ peripheral: CGPeripheral,
																didOpen channel: CGL2CAPChannel?, error: Error?)

์ด๋ฏธ peripheral์— ์—ฐ๊ฒฐ ๋˜์—ˆ๋‹ค๋ฉด, openL2CAPChannel ๋งŒ ํ˜ธ์ถœ ํ•˜๋ฉด ๋œ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ์ฝœ๋ฐฑ ๋ฐ์ดํ„ฐ๋ฅผ ๋ฐ›๊ณ  openL2CAPChannel ์ด channel์„ ์ „๋‹ฌํ•œ๋‹ค.

PSM (Protocol Service Multiplexer)

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%207.png

TCP ํฌํŠธ์™€ ์œ ์‚ฌํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋ฉด ๋œ๋‹ค. ํฅ๋ฏธ๋กœ์šด๊ฑด Bluใ„ทใ„ทtooth SIG์— ์˜ํ•ด publish๋œ profile ๋“ค ๋ช‡๋ช‡์€ PSM์ด ํ•˜๋“œ์ฝ”๋”ฉ ๋˜์–ด ์žˆ๋‹ค.

๊ทธ๋ž˜์„œ Object Transfer Protocol ๊ฐ™์€ ๊ฒƒ์„ ์‹œ๋„ ํ•œ๋‹ค๋ฉด, ๋””๋ฐ”์ด์Šค์— ์—ฐ๊ฒฐ ํ•˜๊ธฐ ์ „์— PSM์€ ์ด๋ฏธ ์•Œ๊ณ  ์žˆ์„ ๊ฒƒ์ด๋‹ค. ํ•˜์ง€๋งŒ PSM์€ ํ†ต์‹ ํ•˜๋Š” device์— ๋Œ€ํ•ด uniqueํ•œ ๊ฐ’์ด๊ณ , ๊ทธ๊ฒƒ์€ ๋กœ์ปฌ์— ํ• ๋‹น๋˜์–ด ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์˜๋ฏธํ•˜๊ณ  ๊ทธ๋Ÿฌ๋ฉด ๋‹ค๋ฅธ ์•ฑ์— ์˜ํ•ด์„œ ์žฌ์‚ฌ์šฉ ๋  ์ˆ˜ ์žˆ๋‹ค.

CBUUIDL2CAPCharacteristicString : CGSerivce์™€ ๊ด€๋ จ๋œ ์–ด๋–ค PSM ์„ ์—ด๊ฒƒ์ธ์ง€์— ๋Œ€ํ•œ ๊ตฌ๋ถ„์„ ํ•ด์คŒ

Peripheral Slide L2CAP

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%208.png

publishL2CAPChannel : ์‹œ์Šคํ…œ์— ์˜ํ•ด ์–ด๋–ค PSM๊ฐ€ ํ• ๋‹น๋˜์–ด ์žˆ๋Š”์ง€ ์ฝœ๋ฐฑ

Opening an L2CAP Channel

Peripheral

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%209.png

Peripheral ์—ญํ• ์ด๋ผ๋ฉด, ์‹œ์Šคํ…œ์—๊ฒŒ L2CAP Channel์„ publish ํ•˜๋„๋ก ์š”์ฒญ ํ•  ๊ฒƒ์ด๋‹ค.

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2010.png

์„ฑ๊ณตํ•˜๋ฉด, peripheralManager didPublishL2CAPChannel ์ฝœ๋ฐฑ์„ ๋ฐ›๋Š”๋‹ค.

๊ทธ๋ฆฌ๊ณ  ์–ด๋–ค ๋กœ์ปฌ์—์„œ ์–ด๋–ค PSM ์ด ๋„ˆ์˜ ์„œ๋น„์Šค์— ํ• ๋‹น ๋˜์–ด ์žˆ๋Š”์ง€ ์•Œ๋ ค์ค€๋‹ค.

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2011.png

์ด ๋•Œ, PSM ๋“ค์–ด์˜จ ์—ฐ๊ฒฐ์— ๋Œ€ํ•ด ์•Œ๊ฒŒ ํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐํšŒ์ด๋‹ค. ๋„ˆ์˜ ์„œ๋น„์Šค์— ๊ด€๋ จํ•ด์„œ ์–ด๋–ค ์ฑ„๋„์„ ์—ด์–ด์•ผ ํ• ์ง€ ๋ฐœ๊ฒฌํ•˜๋„๋ก

Central

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2012.png

Central ์€, PSM ์„ ์ฝ์„ ์ˆ˜ ์žˆ๊ณ , ๊ทธ๊ฒƒ์ด ์ฑ„๋„์„ ์—ด๊ธฐ ์œ„ํ•œ ๋ชจ๋“  ์ •๋ณด์ด๋‹ค.

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2013.png

didOpenL2CAPChannel ์ฝœ๋ฐฑ์„ ๋ฐ›์„ ๊ฒƒ์ด๋‹ค

@available(macOS 10.13, iOS 11.0, *)
open class CBL2CAPChannel: NSObject {
	open var peer: CBPeer! { get }

	open var inputStream: InputStream! { get }

	open var outputStream: OutputStream! { get }

	open var psm: CBL2CAPPSM { get } 
}

CBL2CAPChannel ์€ ๋„ˆ๊ฐ€ ๋ˆ„๊ตฌ์™€ ํ†ต์‹ ํ•˜๊ณ  ์žˆ๋Š”์ง€, ์–ด๋–ป๊ฒŒ ํ†ต์‹  ํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์•Œ๊ธฐ ์œ„ํ•ด ํ•„์š”ํ•œ ๋ชจ๋“  ์ •๋ณด๋ฅผ ์บก์Šํ™” ํ•œ๋‹ค

Stream Events

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2014.png

Closing Channels

Channels may be closed due to

  • Link loss
  • Central close
  • Peripheral unpublished
  • Peripheral object is released

When Should L2CAP Be Used?

  • Use GATT where it makes sense
  • Lowest overhead
  • Best performance
  • Best for large data transfers
  • Great for stream protocols

์ด๋ฏธ GATT ์„ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๊ณ  ๋ฐ์ดํ„ฐ ๋ชจ๋ธ์ด GATT ๊ณ  ์ž˜ ๋งž๋Š”๋‹ค๋ฉด ๊ณ„์† ์‚ฌ์šฉํ•ด๋ผ. GATT์€ ๋ฐ์ดํ„ฐ๋ฅผ ์ฐพ๋Š” ๊ฒƒ์ด ๊ต‰์žฅํžˆ ๊ฐ„ํŽธํ•˜๊ณ , ๋น ๋ฅธ ์—…๋ฐ์ดํŠธ๋ฅผ ์ œ๊ณตํ•œ๋‹ค.

L2GAP Channel์€ ์•ก์„ธ์„œ๋ฆฌ ๊ฐ„ ์†Œํ†ต ์‹œ, ์ตœ์†Œ์˜ ์˜ค๋ฒ„ํ—ค๋“œ๋กœ ์ตœ๊ณ ์˜ ์„ฑ๋Šฅ์„ ๊ฐ–๊ฒŒ ํ•ด์ค€๋‹ค.

๊ทธ๋ฆฌ๊ณ  ํฐ ๋ฐ์ดํ„ฐ๋“ค์„ ์ „์†กํ•  ๋•Œ ๊ต‰์žฅํžˆ ๋น ๋ฅด๋‹ค.

Best practices

Time to Discover

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2015.png

๋‘๊ฐœ์˜ ๋””๋ฐ”์ด์Šค๊ฐ€ ์—ฐ๊ฒฐ๋˜๊ธฐ ์ „์—, ๊ฐ๊ฐ ๊ทธ๋“ค๋งŒ์˜ ํƒ€์ž„๋ผ์ธ์—์„œ ์ž‘๋™ํ•˜๊ณ  ์žˆ๋‹ค. Peripheral ์€ advertise ํ•˜๊ณ , ๋„ˆ์˜ Central ์ฃผ๋ณ€์˜ ๋””๋ฐ”์ด์Šค๋ฅผ ์ฐพ์„ ๊ฒƒ์ด๋‹ค.

ํ•˜์ง€๋งŒ ๊ฐ๊ฐ ์ž‘์€ window๋ฅผ ์‚ฌ์šฉํ•ด์„œ, ๋‘๊ฐœ์˜ ์ด๋ฒคํŠธ๊ฐ€ ๊ฐ™์€ ๋ผ์ธ์— ์˜ค๊ธฐ ์ „๊นŒ์ง€๋Š” ์•ก์„ธ์„œ๋ฆฌ ์ฐพ์„ ์ˆ˜ ์—†๋‹ค.

Connection Spped

  • Use the shortest advertising interval possible
  • Optimize for when users are trying to use your accessory
  • See the Bluetooth Accessory Design Guidelines for power-efficient advertising intervals

short advertising interval ์€ ์•ก์„ธ์„œ๋ฆฌ์— ์ถ”๊ฐ€์ ์ธ ๋ฒ ํ„ฐ๋ฆฌ๋ฅผ ์†Œ๋ชจํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ํ•ญ์ƒ ํ•  ์ˆœ ์—†๋‹ค.

์œ ์ €๊ฐ€ ์•ก์„ธ์„œ๋ฆฌ๋ฅผ ํ„ฐ์น˜ํ•˜๊ฑฐ๋‚˜, ๋“ค๊ฑฐ๋‚˜, accelerometer, ๋ฒ„ํŠผ ๋“ฑ์„ aggressive advertising์„ ์œ„ํ•œ ์ง€ํ‘œ๋กœ ์‚ฌ์šฉํ•˜๋ฉด ๋ฒ ํ„ฐ๋ฆฌ๋ฅผ ์ ˆ์•ฝ ํ•  ์ˆ˜ ์žˆ๋‹ค.

Reconnecting devices

  • No need to scan for a peripheral for reconnect
  • Retrieve the peripheral and directly connect
let identifier = UUID()

let peripheral = central.retrievePeripheral(withIdentifiers: [identifier])

central.connect(peripheral[0])

Service Discovery Speed

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2016.png

Service Change Characteristic ๋Š” ๋””๋ฐ”์ด์Šค์˜ service์™€ characteristic ๊ฐ€ ์–ธ์ œ ๋ณ€ํ•˜๊ณ  GATT Database์˜ ๋งˆ์ง€๋ง‰ ๋ฒ„์ „์„ ์–ธ์ œ ์žฌ์‚ฌ์šฉ ํ•˜๋Š”๊ฒŒ ์•ˆ์ „ ํ•œ์ง€ ์•Œ๋„๋ก ํ•ด์ฃผ๋Š” Bluetooth Spec ์˜ ๋ถ€๋ถ„์ด๋‹ค.

New Accessory Recommendations

  • Use the newest chipset / Bluetooth standard avaliable
  • 4.2 and 5.0 are backward compatible
  • Follow these best practices

Getting the Most out of Core Bluetooth

1MB = 3,240 seconds

2.5 kbps

Protocol Overhead

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2017.png

Bluethooth Specification ๋Š” LE maximum application datalink๋ฅผ 27 ๋ฐ”์ดํŠธ๋กœ ์ •์˜ ํ–ˆ์ง€๋งŒ, ๋ฐ์ดํ„ฐ๊ฐ€ GATT, ATT, L2CAP ์„ ํ†ต๊ณผํ•˜์—ฌ ์•ฑ์„ ๊ฐ€๋กœ์งˆ๋Ÿฌ์•ผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์— 7์„ ์žƒ๋Š”๋‹ค. ํŒจํ‚ท์˜ 25% ์ •๋„๋ฅผ ์žƒ๋Š” ๊ฒƒ์ด๊ณ  ๋งˆ์ง€๋ง‰์— ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐ์ดํ„ฐ์˜ ๊ธธ์ด๊ฐ€ ๊ฒจ์šฐ 20 ๋ฐ”์ดํŠธ ์ผ๊ฒƒ์ด๋‹ค.

๋”ฐ๋ผ์„œ ๋ฐ์ดํ„ฐ๊ฐ€ ์ปจํŠธ๋กค๋Ÿฌ๋ฅผ ์ง€๋‚˜๋ฉด, ํ•˜๋“œ์›จ์–ด ํŒจํ‚ท์„ ์ „์†กํ•˜๋Š”๋ฐ ๋” ๋งŽ์€ ์‹œ๊ฐ„์ด ํ•„์š”ํ•œ security ์™€ CRC ์— ๋˜ํ•œ ๋ ˆ์ด์–ด๋ฅผ ์—ฐ๊ฒฐ์„ ์ถ”๊ฐ€ํ•œ๋‹ค.

์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ, ์†Œํ”„ํŠธ์›จ์–ด์™€ ํ•˜๋“œ์›จ์–ด ๋ชจ๋‘์˜ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ์ค„์—ฌ์•ผ ํ•œ๋‹ค.

Write With Response

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2018.png

์™„๋ฃŒ๋ฅผ ์œ„ํ•ด write, wait 2๊ฐœ์˜ interval ์„ ๊ฐ–๋Š”๋‹ค. write ๊ฐ€ ๋„ˆ๋ฌด ๋ถ€์กฑ.

์‚ฌ์šฉ๊ฐ€๋Šฅํ•œ bandwidth๋ฅผ ์ถฉ๋ถ„ํžˆ ํ™œ์šฉํ•˜๊ณ  ์žˆ์ง€ ์•Š๋‹ค.

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2019.png

interval ๋งˆ๋‹ค ์ „์†กํ•˜๊ธฐ ์œ„ํ•œ ๊ธฐํšŒ๊ฐ€ ๋งŽ๊ธฐ ๋•Œ๋ฌธ์— ๋ชจ๋“  connection event์— ๋Œ€ํ•ด ๊ฐ€๋Šฅํ•œ ๋งŽ์ด write๋ฅผ ๊ฐ์‹ธ๊ณ  ์‹ถ์–ด ํ•œ๋‹ค.

Write Without Response

  • Reliable with Core Bluetooth flow control
  • Use all available connection events to trasmit
  • Takes advantage of larger Connection Event length

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2020.png

๋ชจ๋“  interval ์˜ connection event ๋ฅผ ๋ชจ๋‘ ๊ฐ์‹ธ๋ฉด, ์ฒ˜๋ฆฌ๋Ÿ‰์ด 2.5์—์„œ 37 kbps ๋กœ ํ–ฅ์ƒ ๋  ๊ฒƒ์ด๋‹ค.

MTU ์˜ ์ฒซ๋ฒˆ์งธ fragment์˜ ์˜ค๋ฒ„ํ—ค๋“œ๋งŒ ์žˆ๊ณ  ๋‚˜๋จธ์ง€ fragment๋Š” 27 bytes ์ผ ๊ฒƒ์ด๋‹ค, ๊ทธ๋Ÿฌ๋ฉด ์ฒ˜๋ฆฌ๋Ÿ‰์ด 48 kbps ๊นŒ์ง€ ํ–ฅ์ƒ ๋  ๊ฒƒ์ด๋‹ค.

Fitting your data

  • Apple devices determine the optimal MTU
  • Accessories should support a large MTU
  • Use large attributes aligned to MTU

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2021.png

Extended Data Length

  • New Feature in Bluetooth 4.2
  • Much larger packets (251 vs 27 bytes)
  • Transparent to the application
  • 4x throughput with the same radio time
  • Available on iPhone 7 and Apple Watch Series 2

L2CAP Connection Oriented Channels

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2022.png

์ด์ „์— GATT ๊ณผ ATT ์—์„œ ์žˆ๋˜ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ์ œ๊ฑฐํ•˜๊ณ , ๋” GATT ์˜ ์ตœ๋Œ€ 512 ์‚ฌ์ด์ฆˆ ์†์„ฑ ๊ฐ™์€ ์ œํ•œ๊ณผ ์ œ์•ฝ์„ ์ œ๊ฑฐํ•ด์ค€๋‹ค. ๊ทธ๋ž˜์„œ ๋” ํฐ ๊ฐ’๋“ค์„ write ํ•  ์ˆ˜ ์žˆ๊ณ  ๋” ๋งŽ์€ MTU ๋ฅผ ์‚ฌ์šฉ ํ•  ์ˆ˜ ์žˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด ์ฒ˜๋ฆฌ๋Ÿ‰์€ ๊ฑฐ์˜ 200kbp ๊นŒ์ง€ ์ƒ์Šนํ•  ๊ฒƒ์ด๋‹ค.

Faster Connection Interval

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2023.png

์„ฑ๋Šฅ์„ ํ–ฅ์ƒ์‹œํ‚ค๋Š” ๋˜ ๋‹ค๋ฅธ ๋ฐฉ๋ฒ•์€ ๋” ๋น ๋ฅธ connection interval๋ฅผ ์š”์ฒญ ํ•˜๋Š” ๊ฒƒ์ด๋‹ค.

Core Bluetooth ์—์„œ iOS ์— ๋Œ€ํ•ด connection interval minimum ์„ 15 ms ๋กœ ์ค„์˜€๋‹ค.

์ด๋ฅผ ํ†ตํ•ด ์ฒ˜๋ฆฌ๋Ÿ‰์ด 394 kpbs ๋กœ ๊ฑฐ์˜ ๋‘๋ฐฐ๊ฐ€ ๋˜์—ˆ๋”ฐ.

Throughput

/WWDC2017/images/Whats-New-in-Core-Bluetooth/Untitled%2024.png

Wrap Up

Key Takeaways

  • Check out State Restoration
  • Expand your app to tvOS and watchOS
  • Use L2CAP for stream protocols or large data tranfers
  • Use the newest Bluetooth chipset available
  • Follow the Bluetooth Accessory Design Guidelines