Skip to content

Instantly share code, notes, and snippets.

@skystream
Last active December 23, 2015 16:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save skystream/db379cce759362404acc to your computer and use it in GitHub Desktop.
Save skystream/db379cce759362404acc to your computer and use it in GitHub Desktop.

[fit]Port Bluedroid to RTOS






by スカイストリーム せきね


Bluedroid


  • Protocols
  • ATT AVCTP AVDTP BNEP BTM L2CAP MCAP OBEX RFCOMM SDP SMP
  • Profiles
  • A2DP AVRCP BIP BPP CTP DI DUN FTP GAP GATT GOEP HCRP HDP HFP HIDP HSP ICP LAP MAP OPP PAN PBAP SAP SPP SYNCH VDP
  • Bluedroidの開発は2015-03で停止したがsystem/btとして開発が継続 (link)

GOOD

  • Apachie License 2
  • BT/BLE dual stack
  • 対応しているプロトコル・Profileが多い
  • 必要なプロトコル・プロファイルのみのコンフィグできる
  • 独自のメモリ管理機構があるのでmallocが無いOSでも動作

BAD

  • ドキュメント無し
  • コミュニティ無し
  • テストコード無し
  • Bluetoohロゴ認証テストコード無し

SOURCE CODE

言語:だいたいC言語 規模:18万行ぐらい (clocで調査)

bta/ 抽象化レイヤ btif/ 上位向けAPI hci/ HCIドライバ gki/ OS依存コード stack/ プロトコル・プロファイル


TASK

inline


GKI

Generic Kernel Interface

  • タスク管理
  • タスク間通信
  • タイマ
  • メモリ管理

PORTING

  • Linuxで最小限のソースコードになるようにする
  • btif->bta->stackの順でコンパイルエラーを取る
  • HCIとドライバを接続する
  • GKIを移植する
  • 動かしならがデバッグする。

PORTING RESULT

  • ターゲット

  • CPU ARM

  • OS uITRON4.0互換OS

  • コンパイラ ARM Realview

  • BLEのみに変更

  • ソースコード 9万行

  • ROM 約100KB / RAM 約100KB


Bluetooth SIG Qualification

  • テストプランを入手し、どのテストを受験するか決める
  • テストのシーケンスを行うプログラムを開発
  • PTSで自分でテストする
  • テストラボで本番テストをする

認証はpassできた


sample code

    btgatt_srvc_id_t servc_id1 =  {
        {
                {0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xFF, 0xEF, 0x00, 0x00},
                0,
        },
    bt_uuid_t app_uuid1 = {{ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x19, 0x2a, 0x00, 0x00 }};
    bt_uuid_t app_uuid1 = {{ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0x19, 0x2b, 0x00, 0x00 }};
        
    btIf = get_bluetooth_interface();
    sGattIf->init(&sGattCallbacks);
    btIf->enable();
    sGattIf = btIf->get_profile_interface(BT_PROFILE_GATT_ID);
    sGattIf->server->register_server(&app_uuid1);
    sGattIf->server->add_service(4 , &servc_id1, 24);
    sGattIf->server->add_characteristic(4, 40, &app_uuid2, 0x02+0x10, 0x01);
    sGattIf->server->start_service(4, 40, 1);
    sGattIf->client->set_adv_data(
                                            5 /* client_if */,
                                            0 /* set_scan_resp */,
                                            1 /* include_name */,
                                            0 /* include_txpower */,
                                            0x20  /* min_interval */,
                                            0x100 /* max_interval */,
                                            0 /* appearance */,
                                            0 /* manifactureer_len */,
                                            NULL /* manifacturer_data */,
                                            0 /* service_data_len */,
                                            NULL /* service_data */, 
                                            0 /* service_uuid_len */, 
                                            NULL /* service_uuid */ 
                                           );
    sGattIf->client->listen(
                                        5 /* server_if */,
                                        1 /* start */
                                     );

PR

スカイストリームでは、

  • Bluedroid の各種OSへの移植
  • Bluetooth認証のサポート
  • 技術基準適合証明 / FCC / CE のサポート
  • Wi-Fi認証のサポート

を行っています

お問い合わせ:http://www.skystream.co.jp/

人材も募集中です


おまけ


モバイルプラットフォームのBluetoothプロトコルスタック

  • iOS : Bluemagic -> Apple?
  • Android : BlueZ -> Bluedroid -> system/bt
  • Windows Mobile : Microsoft?
  • Firefox OS : BlueZ -> Bluedroid
  • Tizen : BlueZ
  • Ubuntu touch : BlueZ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment