New Framework Agenda • Tizen Bluetooth Stack Overview

• Why we need Bluetooth Framework?

• Current Bluetooth Framework Desgin

• New Tizen Bluetooth Framework

• New Tizen Bluetooth Framework PoC 0.1 release Some Concepts • OSP/Native Apps

• WRT(Web Run Time) Apps

• In House/(System) Apps

• CAPI

• Tizen Service Tizen Bluetooth Stack

Tizen BT APIs In House Native Apps Web Run Time Bluetooth apps

Plugin Bluetooth-UG

CAPI Bluetooth-service Bluetoothd Obexd Bluetooth Framework

Kernel The Role of Bluetooth Framework in Tizen • Provides Simple, Uniform, Stable CAPI interfac e for Apps/UI

• Integrates BlueZ into Tizen elegantly and Han dles Tizen specific Bluetooth operations – Easy to maintain, extend – High performance, low memory consumption

• Easily to port to different verticals/branch/Plat form Bluetooth Framework and BlueZ • Integrate BlueZ into Tizen elegantly

• Focus on Tizen specific operation

• And by no means replacing and modify any logics of BlueZ

5 Current Bluetooth Framework Design

Bluetooth Bluetooth Share UI UI Gadget

Music App.

System Bluetooth Contact, Email, Call App. Bluetooth Popup Core Message Framework Share System popup

Bluetooth Service EFL check logic Bluetooth (Call System popup or Send the Bluetooth Phonebook/ event to application) HFP Agent Multimedia MAP Agent Framework

User ObexD BluetoothD PulseAudio space

Bluetooth Subsystem INPUT ALSA Kernel Mouse, Driver space Keyboard, Bluetooth Driver (UART) AVRCP

BlueZ Project UI Gadget Daemon API/Callback DBUS

Application Framework System Call/Events IPC Where We Can Improve (2-1)

• Over complicated, performance issue, maintaining issue

• Bluetooth-Service daemon should not wrap entire BlueZ and proxy all the BlueZ operations and events. • That makes Bluetooth-Service daemon over complicated • And difficult to maintain and migrate to latest version of BlueZ • Impact performance a lot • Apps should access BlueZ directly in most situations

• Non-UI operations should be merged into Bluetooth-Service • To reduce memory consumption • and improve performance • Easy to maintain

• Difficult to migrate to new version of BlueZ

• Difficult to port to other Tizen verticals or branches • Verticals/branches may have different apps/UI, vconf, configure … Where We Can Improve (2-2)

• No unified interface for apps/UI • Some apps call CAPI; while others access Bluetooth-service daemon • Apps/UI are not easy to write and maintain

• Bluetooth-Service uses Dbus-glib, which has been replaced by GDbus lib • Please see Tizen Telephony core code • Also see • https://developer.gnome.org/gio/2.30/ch29.html • http://www.freedesktop.org/wiki/Software/DBusBindings/ New Tizen Bluetooth Framework

Paring/OPP Bluetooth server UI Bluetooth Call App. Share UI UI Gadget (System Popup) Music App.

Bluetooth CAPI

Vertical Manager(Bluetooth Core) Plugin (Vertical specific operation PBAP/ OPP HFP Paring SPP … Call System popup MAP Agent Relay Agent Relay Send the event to Multimedia application) Framework Bluetooth Service Daemon

BlueZ Lib

Obexd Bluetoothd PulseAudio Bluetooth Framework

BlueZ Project UI Gadget Daemon API/Callback DBUS

Application Framework System Call/Events Lib/API New Design Philosophy (2-1)

• Unified CAPI for Apps/UI

• All Tizen specific non-UI functions are merged in Bluetooth- service daemon

• Apps/UI access BlueZ directly • with help functions CAPI/BlueZ-lib

• Bluetooth-Service only proxy paring and OPP operations for BlueZ

• BlueZ-lib facilitates BlueZ services access • Hide the DBus operation detail • Easily to migrate to new version of BlueZ New Design Philosophy (2-2) • Vertical plugin • Easy to port to other vertical/platform

• Bluetooth-Service is modulated • Easy to add new feature • Module load/unload runtime

• A2DP(Pulse Audio) uses upstream solution • Pulse Audio accesses BlueZ directly and independent from the Bluetooth Framework

• NAP/Panu • Using ConnMan based tethering over bluetooth • ConnMan accesses BlueZ dreictly and independnt from Bl uetooth Framwork New Design Saves >50% Memory

6,000 5,390 5,070 5,000

3,793 4,000

2,775 3,000 Bluetooth Framework New Generation

1,900 2,014 2,000 Bluetooth Framwork @ Tizen 2.x

1,000

0 Adapter On(KBytes) OPP Send File(KBytes) Paring(KBytes)

New Design Memory Consumption Breakdown Old Design Memory Consumption Breakdown Adapter ON Adapter ON Bluetooth-service 1,170k Bt-service 760k Bluetoothd 730k Bt-core 290k Sum 1,900k Bluetooth-share 1614k Bluetooth-hfp-agent 1129k Bluetoothd 718k OPP Send File Sum 3,793k Bluetooth-service 1,499k Bluetoothd 754k OPP Send File Bt-service 774k Obexd 522k Bt-core 289k Sum 2,775k Bluetooth-share 1,848k Bluetooth-hfp-agent 1,129k OPP Receive File Bluetoothd 884k Bluetooth-service 1,582k Obexd-client 466k Bluetoothd 956k Sum 5,390k Obexd 515k Paring Sum 3,053k Bt-service 763k Bt-core 289k Bluetooth-share 1,875k Paring Bluetooth-hfp-agent 1,120k Bluetooth-service 1,262k Bluetoothd 1023k Bluetoothd 752k Sum 5,070k Sum 2,014k Operation Simplified

Bluetooth Framework NG Bluetooth Framework

BlueZ UG/UI Other-Service Bluetooth-Service BlueZ

UG/UI CAPI/BlueZ-lib DBus Request

api() DBus Request

DBus Request DBus Request

CallBack() DBus Response DBus Response signal DBus Response

DBus Response Upgrading BlueZ more easily

Upgrading to BlueZ 5.x

Bluetooth Framework NG Bluetooth Framework

2 person week 2 person month Touch 2 files ~60 patches New Tizen Bluetooth Framework PoC 0.1 Release

• We have finished 0.1 PoC release • This release includes: – framework • Enhanced CAPI • Refined Bluetooth service Daemon • Bluez lib – basic Bluetooth Profiles • Adapter functionality • Device functionality • Paring • Data share(OPP client/server) • SDP • HID – New Bluetooth-UG(UI Gadget) – New Paring/OPP apps (system popup) – Basing on latest upstream BlueZ(5.x) • Q/A Backup Bluetooth Service: Manager Module (Bluetooth Core)

• Bluetooth Service: Manager module replaces Bluetooth Core

• Manager Main Function: void EnableBluetoothService() Starts bluetooth service daemons like Bluetoothd and Obexd Power on the default adapter. Loads the service objects of bluetooth-servcie. After property InService changes to ture, bluetooth service will be ready for use.

• Bluetooth Service Daemon only loads manager module on system start up. And all the other daemon including Bluetoothd Obexd will be started through Dbus after apps/UI call EnableBluetoothService(), So Bluetooth subsystem will not impact system boot up time. And almost consume no resource when Bluetooth is not used

• “Bluetooth core” system() trigged “startup script” is abandoned

• Use built in driver, not to load/unload driver runtime • Load/unload driver runtime is dangerous Bluetooth Service Startup

Bluetooth-Service

UG/UI CAPI

Bt_adpater_enable() Manager EnableBluetoothService()

Invoke BlueZ Services Obexd/Bluetoothd Request Power On Adapter

Adapter On signal

Load Function Modules General Operations: Access BlueZ Service Directly

Obexd/Bluetoothd

UG/UI CAPI/BlueZ-lib

api()

DBus Request

CallBack() DBus Response Paring: PoPup/Paring UI-> Bluetooth Service -> Bluetoothd

UG CAPI Bluetooth-Service Bluetoothd

bt_device_create_bound() Paring Relay paring.pare()

Paring agent Request

Invoke Paring APP/UI Vertical Paring UI/ Plugin Sys Popup CAPI

Paring.RegisterRelayAgent() Paring Relay Relay Paring agent Operation

Paring agent Response OPP Send File: UG->Bluetooth Service->Obexd

UG CAPI Bluetooth-Service Obexd Notification

bt_opp_client_push_file()

OPP opp.send_file() Relay

Transfer State

Vertical Plugin Notify transfer state Bluetooth Share UI/Cancel Transfer

BT-Share-UI CAPI Bluetooth-Service Obexd

Transfer State

bt_opp_transfer_state_cb()

bt_opp_transfer_cancel()

opp.CancelTransfer () OPP Relay OPP Server: Obexd->Bluetooth Service-> Syspop/OPP UI

Obexd Bluetooth-Service

Obex agent OPP Request Sending file Relay

Vertical Invoke OPP_Service APP/UI Plugin (System Popup) CAPI OPP/syspopup UI

OPP Opp.RegisterOPPAgent() Relay OPP relay agent operation Obex agent Response Sending file