QSG108:Silicon Labs の Bluetooth
®
ソフ
トウェアのご使用について
このドキュメントでは、Wireless Gecko 用の Silicon Labs の
Bluetooth スタック、SDK(ソフトウェア開発キット)、および開
発ツールについて説明します。ドキュメント全体と最後のセクシ
ョンのリファレンスでは、
次のステップについて説明しています。
このドキュメントは、Silicon Labs Bluetooth SDK v.2.10.0 以降を対象に書かれていま す。
要点
• Silicon Labs の Bluetooth スタックの概要 • Bluetooth API の説明
• Bluetooth SDK の概要 • 開発ツールの説明 • 資料ガイド
第
1 章 Silicon Labs の Bluetooth スタック
Silicon Labs の Bluetooth スタックは、Bluetooth 低エネルギー規格を満たす高度な Bluetooth 5 準拠のプロトコル・スタックです。こ の Bluetooth スタックは、複数接続、コンカレント・セントラル、ペリフェラル、ブロードキャスター、およびオブザーバーの役割を サポートします。Silicon Labs の Bluetooth スタックは、Silicon Labs の Wireless Gecko SoC およびモジュール用です。
Silicon Labs の Bluetooth スタックは、開発者が Bluetooth 機能にアクセスするための複数の API を提供します。2 つのモードがサポー トされています。
1. スタンドアロン・モードでは、Bluetooth スタックとアプリケーションの両方を Wireless Gecko SoC またはモジュールで実行しま す。このアプリケーションは C プログラミング言語で開発できます。
2. ネットワーク・コプロセッサ (NCP) モードでは、Bluetooth スタックを Wireless Gecko で実行し、アプリケーションを別のホス ト MCU で実行します。この使用事例の場合、Bluetooth スタックは NCP モードに構成でき、UART などのシリアル・インターフ ェイスを介して API が公開されます。
Silicon Labs の Bluetooth スタックの機能を以下の表に示します。
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Silicon Labs の Bluetooth スタック
表 1.1. Bluetooth Stack Features
Feature Value and comments
Bluetooth version Bluetooth 5
Bluetooth features
Bluetooth 5 2M PHY (EFR32xG12 and EFR32xG13) Bluetooth 5 LE Long Range (only EFR32xG13 products) Bluetooth 5 advertisement sets and scan event reporting Concurrent central, peripheral, broadcaster and observer modes LE secure connections
LE Privacy 1.2 (peripheral) LE packet length extensions
LE dual topology up to 8 master connections
Simulations connections Up to 8 with simultaneous master and slave connections Maximum throughput 1300 kbps over 2M PHY (Software 2.6.x and newer)
700 kbps over 1M PHY (Software 2.6.x and newer)
Encryption AES-128
Pairing modes Just works
Man-in-the-Middle with numeric comparison and passkey Number of simultaneous bondings Up to 14
Link Layer packet size
Up to 128 B ((Software 2.3.x) Up to 160 B (Software 2.4.x)
Up to 251 B (Software 2.6.x and newer)
ATT protocol packet size
Up to 58 B (Software 2.0.x) Up to 126 B (Software 2.1.x)
Up to 250 B (Software 2.3.x and newer)
Supported Bluetooth profiles and services All GATT based profiles and services are supported
Apple HomeKit
Apple HomeKit R12-compliant implementation Implements all Apple HomeKit profiles and services Available separately for Apple MFi licensees
Host (NCP) interfaces
4-wire UART with RTS/CTS control 2-wire UART
GPIOs for sleep and wake-up management Bootloaders
Secure Gecko Bootloader supporting authenticated and encrypted updates over OTA or UART and Secure Boot. The Gecko Bootloader also supports flash partitioning and both internal and external (SPI) flash.
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Silicon Labs の Bluetooth スタック
Feature Value and comments
Bluetooth QDIDs
Link layer QDID (Bluetooth 4.2): 81105 Host stack QDID (Bluetooth 4.2): 91422 Link layer QDID (Bluetooth 5): 99504 Host stack QDID (Bluetooth 5): 101550 1.1 Bluetooth スタック API
このセクションでは、開発者が使用できるさまざまなソフトウェア API について簡単に説明します。 1.1.1 BGAPI Bluetooth API
BGAPI は、Silicon Labs の Bluetooth スタックによって提供される Bluetooth API です。BGAPI は、汎用アクセス・プロファイル (GAP)、接続マネージャ、セキュリティ・マネージャ (SM)、および GATT クライアントとサーバーなど、Bluetooth スタックによって 実装されるすべての Bluetooth 機能へのアクセスを提供します。
Bluetooth API に加えて、BGAPI は、RF テスト用のダイレクト・テスト・モード (DTM) API、デバイス・フラッシュ・メモリの読み取 り/書き込みキー用の固定ストア (PS) API、フィールド・ファームウェア・アップデート用の DFU(デバイス・ファームウェア・アッ プデート)API、およびさまざまなシステム・レベル機能のシステム API など、その他の機能へのアクセスも提供します。
1.1.2 CMSIS および emlib
Cortex マイクロコントローラ・ソフトウェア・インターフェイス規格 (CMSIS) は、すべての ARM Cortex デバイスに共通のコーディ ング規格です。Silicon Labs が提供している CMSIS ライブラリには、ヘッダー・ファイル、定義(ペリフェラル、レジスタ、およびビ ットフィールド用)、およびすべてのデバイスのスタートアップ・ファイルが含まれます。さらに CMSIS には、すべての Cortex デバ イスに共通の機能 (割り込み処理や固有機能など) が含まれています。ハード・コードされたアドレスとデータ値を使用してレジスタに 書き込むことができますが、コードの移植性と読みやすさを保証するために定義の使用が推奨されます。
Wireless Gecko のプログラミングを簡素化するために、Silicon Labs では emlib という完全な C 関数ライブラリを開発・管理していま す。これにより、すべてのペリフェラルやデバイスのコア機能への効率的、明確、そして堅固なアクセスと制御が可能になります。こ のライブラリは、SDK の em_xxx.c(em_dac.c など)および em_xxx.h ファイル内にあります。
emlib ドキュメントは、Silicon Labs のウェブサイト から入手できます。
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Silicon Labs の Bluetooth スタック
1.1.3 BGAPI シリアル・プロトコルおよび BGLIB ホスト API
NCP(ネットワーク・コプロセッサ)モードで構成された Bluetooth スタックは、BGAPI シリアル・プロトコルも実装します。これに より、UART などのシリアル・インターフェイスを介して、EFM32 マイクロコントローラなどの別のホストから Bluetooth スタックを 制御できます。BGAPI シリアル・プロトコルは、スタンドアロン・モードで使用する場合、UART を介して、BGAPI API と完全に同 一の Bluetooth API を提供します。
BGAPI シリアル・プロトコルは、ホストからの BGAPI コマンドを Bluetooth スタックに受け渡し、Bluetooth スタックからの応答およ びイベントをホストに返すライトウェイトのバイナリ・プロトコルです。
Bluetooth SDK は、BGLIB という既製の BGAPI シリアル・プロトコル・パーサ実装を提供します。これにより、シリアル・プロトコ ル・パーサや、Bluetooth スタックによって提供されるすべての API 用の C 言語関数とイベントが実装されます。BGLIB の上で開発さ れたホスト・コードは、Wireless Gecko のコードと同じになるように記述することができるため、Wireless Gecko から別のホスト(ま たは別のホストから Wireless Gecko)にアプリケーション・コードを簡単に移植できます。 図 1.1. BGAPI シリアル・プロトコル・メッセージ交換 BGAPI シリアル・プロトコル・パケット構造を以下に説明します。 表 1.2. BGAPI パケット構造 バイト バイト 0 バイト 1 バイト 2 バイト 3 バイト 4 ~ 255 説明 メッセージ・タイプ 最小ペイロード長 メッセージ・クラス メッセージ ID ペイロード 値 0x20:コマンド 0x20:応答 0xA0:イベント 0x00 ~ 0xFF 0x00 ~ 0xFF 0x00 ~ 0xFF コマンド、応答、またはイ ベントに固有
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Silicon Labs の Bluetooth スタック
1.1.4 Bluetooth Profile Toolkit GATT ビルダ
Bluetooth Profile Toolkit は、 XML ベースのシンプルな API および記述言語です。これを使用することで、コードで書き込むことなく、 GATT ベースのサービスおよび特性を簡単に記述できます。XML ファイルの書き込みは手動で簡単に行えます。または、本書の後半で 説明する Bluetooth Developer Studio で自動生成することもできます。
Profile Toolkit で開発された GATT データベースは、.c ファイルと .h ファイルに変換され、ファームウェアのコンパイル時にビルド前 のステップとしてアプリケーション・プロジェクトに含まれます。これで、Bluetooth スタック GATT API またはリモート Bluetooth デ バイスを使用して GATT にアクセスできます。
図 1.2. 汎用アクセス・サービスの例
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Silicon Labs の Bluetooth スタック
第
2 章 Bluetooth ソフトウェア開発キット (SDK)
Bluetooth SDK は、C プログラミング言語を使用して Bluetooth スタック上でアプリケーションを開発することができる完全なソフト ウェア開発キットです。SDK は、スタンドアロン・アプリケーション(Bluetooth スタックとアプリケーションの両方を Wireless Gecko で実行します)の作成、またはネットワーク・コプロセッサ (NCP) アーキテクチャ(アプリケーションを外部ホストで実行し、Bluetooth スタックを Wireless Gecko で実行します)の作成もサポートします。 2.1 SDK の内容 このセクションでは、SDK のフォルダ構造と内容について説明します。 2.1.1 ライブラリ 以下のライブラリが Bluetooth SDK と共に提供されます。これらのライブラリは、C アプリケーション・プロジェクトに含める必要が あります。
Library Explanation Mandatory
libbluetooth.a Bluetooth stack library Yes
librail_efr32xg1_gcc_release.a RAIL library for GCC Yes for GCC projects on EFR32xG1 platform librail_efr32xg12_gcc_release.a RAIL library for GCC Yes for GCC projects on EFR32xG12 platform librail_efr32xg13_gcc_release.a RAIL library for GCC Yes for GCC projects on EFR32xG13 platform librail_efr32xg14_gcc_release.a RAIL library for GCC Yes for GCC projects on EFR32xG14 platform librail_efr32xg1_iar_release.a RAIL library for IAR Yes for IAR projects on EFR32xG1 platform librail_efr32xg12_iar_release.a RAIL library for IAR Yes for IAR projects on EFR32xG12 platform librail_efr32xg13_iar_release.a RAIL library for IAR Yes for IAR projects on EFR32xG13 platform librail_efr32xg14_iar_release.a RAIL library for IAR Yes for IAR projects on EFR32xG14 platform
libmbedtls.a mbedtls library Yes
libpsstore.a PSStore library Yes
binapploader.o Apploader for OTA updates No libcoex.a Wi-Fi and Bluetooth coexistence No
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Bluetooth ソフトウェア開発キット (SDK)
2.1.2 含めるファイル
以下のファイルが Bluetooth SDK と共に提供されます。これらのファイルは、C アプリケーション・プロジェクトに含める必要があり ます。
Library Explanation When needed
native_gecko.h Bluetooth stack API for standalone applicationswithout Micrium RTOS
Must be included in standalone C applications where both Bluetooth stack and application run in a Wireless Gecko.
rtos_gecko.h Bluetooth stack API for standalone applicationswith Micrium RTOS Required when the Bluetooth stack is usedtogether with Micrium RTOS.
ncp_gecko.h Bluetooth stack API for NCP applications
Must be included in NCP applications where the host controls the device via BGAPI protocol over UART
gecko_configuration.h Bluetooth stack configuration Included automatically. bg_errorcodes.h Error codes produced by the Bluetooth stack Included automatically. bg_gattdb_def.h Bluetooth GATT database structure definition Included automatically. bg_types.h Simple data type definitions and structures Included automatically. gecko_bglib.h An adaptation layer between host application and
BGAPI serial protocol
Must be included in C applications developed for external hosts.
host_gecko.h Bluetooth API for host (NCP) applications Must be included in C applications developed for external hosts.
2.1.3 プラットフォーム・コンポーネント
Bluetooth SDK では以下のコンポーネントが提供されます。プラットフォームのコンポーネントは、「プラットフォーム」フォルダにあ ります。
Folder Explanation
bootloader Gecko Bootloader source code and project files. CMSIS Silicon Laboratories CMSIS-CORE device headers.
Documentation
Device EFR32BG and EFR32MG device files. Documentation
emdrv
A set of function-specific high performance drivers for EFR32 on-chip peripherals. Drivers are typically DMA based and are using all available low-energy features. For most drivers, the API offers both synchronous and asynchronous functions.
Documentation
emlib
A low-level peripheral support library that provides a unified API for all EFM32, EZR32 and EFR32 MCUs and SoCs from Silicon Laboratories.
Documentation
middleware Display driver for WSTK development kits.
radio Silicon Labs RAIL (Radio Abstraction Interface Layer) library 2.1.4 例とデモ・アプリケーション
Folder Explanation
examples_btds A placeholder folder for Bluetooth Developer Studio-generated C projects. When the projects are generatedto this folder they compile without any modifications to the project files.
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Bluetooth ソフトウェア開発キット (SDK)
Folder Explanation
examples_ncp_host
Host code examples demonstrating NCP usage and other use cases.
Empty: Minimalistic host code demonstrating advertisements and connections over NCP.
ota_dfu: An application using WSTK in NCP mode to discover and perform an OTA update to a remote device.
uart_dfu: An application demonstrating how to make firmware update over UART interface.
voice_over_bluetooth_low_energy_app: GATT client side application for “Voice over Bluetooth Low Energy” example for Thunderboard Sense.
2.1.5 Bluetooth Developer Studio プラグイン
Silicon Labs の Bluetooth Developer Studio プラグインは、SDK の btds_plugins フォルダにあります。これを使用するには、Bluetooth Developer Studio のインストール・フォルダにある Plugins という名前のサブフォルダにコピーします (通常は、C:\Program Files (x86)\Bluetooth SIG\Bluetooth Developer Studio\Plugins です)。
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
Bluetooth ソフトウェア開発キット (SDK)
第
3 章 開発ツール
このセクションに記載されているツールを使用して開発を開始するには、『QSG139:Simplicity Studio を使用した Bluetooth® 開発』 を参照してください。
汎用 Bluetooth C アプリケーションの開発については、『UG136:Silicon Labs Bluetooth C アプリケーション開発者ガイド』を参照し てください。
ネットワーク・コプロセッサ・モードによる開発の詳細については、『AN1042:ネットワーク・コプロセッサ・モードで Silicon Labs
の Bluetooth® スタックを使用する』を参照してください。 3.1 Simplicity Studio
Simplicity Studio は、Silicon Labs が無償で提供する統合開発環境 (IDE) です。Bluetooth アプリケーションの開発、デバッグ、分析に 使用できる多くの付加価値ツールを提供します。
Bluetooth SDK 2.3.0 以降では、GCC または IAR C コンパイラのいずれかを Simplicity Studio で使用することができます。SDK のバー ジョンと互換性のあるコンパイラ・バージョンを使用する必要があります。バージョンの互換性については、SDK のリリース・ノート を参照してください。
図 3.1. Simplicity Studio v4
Simplicity Studio は、http://www.silabs.com/simplicity-studio からダウンロードしてインストールできます。
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
開発ツール
3.1.1 IDE とデバッガ
Simplicity Studio には、Wireless Gecko 用 C アプリケーションの開発およびデバッグに使用できる Eclipse ベースの IDE が含まれてい ます。
図 3.2. Simplicity Studio IDE とデバッガ
3.1.2 グラフィカルな GATT エディタ
Bluetooth SDK 2.1.0 リリース以降、Simplicity Studio には、グラフィカルな Bluetooth GATT データベース・エディタが含まれていま す。これを使用すると、ビルド・プロセスで使用された XML ファイルを直接編集しなくても、Bluetooth のプロファイル、サービス、 および特性を簡単に構成できます。また、GATT エディタを使用すると、サービスおよび特性のすべてのオプション(UUID、セキュリ ティ、属性プロトコルのプロパティなど)や、その他のオプションも構成できます。
図 3.3. Simplicity Studio の GATT エディタ
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
開発ツール
3.1.3 Multi-Node Energy Profiler
Multi-Node Energy Profiler を使用すると、個々のデバイス、対象システムの複数のデバイス、相互作用するワイヤレス・デバイスのネ ットワークなどの電力消費量を視覚化し、これらのシステムの電力性能を分析して改善することができます。電力消費量のリアルタイ ム情報に基づいてプログラム・カウンタが動作するため、高度なエネルギー・ソフトウェア監視機能を利用できます。詳細については、 『UG343:Multi-Node Energy Profiler ユーザ・ガイド』を参照してください。
Multi-Node Energy Profiler ユーザ・インターフェイスでは、1 つのビューに複数の表示が組み合わされて表示されます。
• クイック・アクセス・メニュー – Multi-Node Energy Profiler で最もよく使用するメニュー(上部のメニュー・バーの「プロファイ ラ」メニューからもアクセスできます)。 • ビュー・セレクタ – 単一ノード、マルチノード、またはスコープ・ビューを選択します。 • データ・コントロール – ユーザ・インターフェイスとディスクへのデータ・フローを有効または無効にするコントロール。 • 統計 – 波形のエネルギー・データ。 • コード相関 – 電源消費量に関連する機能を実行します。 • エディタ – プログラムのソース・コード。コード相関ビューと連動します。
図 3.4. Multi-Node Energy Profiler
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
開発ツール
3.1.4 パケット・トレース
Silicon Labs のネットワーク・アナライザは、無償のパケット・キャプチャおよびデバッグ・ツールです。これを使用して、Wireless Gecko とその他の Bluetooth デバイス間の Bluetooth 接続をデバッグすることができます。ネットワーク・トラフィック、アクティビ ティ、および継続時間をグラフィカルに表示することで、ネットワークとアプリケーションの開発プロセスを大幅に高速化できます。 パケット・トレース・アプリケーションは、Wireless Gecko SoC およびモジュールで使用できるパケット・トレース・インターフェ イス (PTI) からパケットを直接キャプチャします。このため、無線ベースのキャプチャに比べて、高い精度でパケットをキャプチャで きます。 図 3.5. パケット・トレースでの Bluetooth トラフィック・キャプチャ 3.1.5 Simplicity Commander Simplicity Commander は、ファームウェア・イメージのフラッシュ、フラッシュの消去、デバッグ・アクセスのロックとロック解除、 および J-Link インターフェイスを介したフラッシュ・ページの書き込み保護を行うために使用できる簡易なフラッシング・ツールで す。GUI と CLI(コマンド・ライン・インターフェイス)の両方を使用できます。詳細については、『UG162:Simplicity Commander
リファレンス・ガイド』を参照してください。
図 3.6. Simplicity Commander
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
開発ツール
3.1.6 BGTool アプリケーション
BGTool アプリケーションは、Bluetooth SoC およびモジュールのテストと評価に使用できます。また、BGAPI シリアル・プロトコル (NCP) を使用する Bluetooth ハードウェアをシリアル/UART インターフェイス経由で制御するためにも使用できます。
図 3.7. BGTool アプリケーション
3.2 IAR Embedded Workbench
IAR の Embedded Workbench は、Bluetooth アプリケーションの開発およびデバッグを行うための IDE として使用することもできま す。SDK のバージョンと互換性のある IAR バージョンを使用する必要があります。バージョンの互換性については、SDK のリリー ス・ノートを参照してください。
図 3.8. IAR Embedded Workbench
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
開発ツール
3.3 Bluetooth Developer Studio
Note: Bluetooth Developer Studio のサポートは、SDK バージョン 2.10.0 で廃止される予定です。
Bluetooth Developer Studio は、Bluetooth SIG から提供されている強力なアプリケーション開発およびデバッグ・ツールです。アプリ ケーションのニーズに基づいて Bluetooth サービスと特性を追加および変更するためのシンプルなインターフェイスを提供します。 Silicon Labs では、Bluetooth Developer Studio 用のプラグインを提供しています。このプラグインは、選択した構成のサービスおよび 特性ハンドラを実装する SDK、および C アプリケーション・コードによって使用される GATT データベースを XML 形式で自動生成し ます。
Bluetooth Developer Studio を使用すると、Bluetooth アプリケーションの開発時間を大幅に短縮して、簡素化することができます。
図 3.9. Bluetooth Developer Studio Bluetooth Developer Studio の使用につきましては、以下のリンクにアクセスしてください。 https://www.bluetooth.com/~/media/developer-studio/index
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
開発ツール
第
4 章 資料
QSG108:Silicon Labs の Bluetooth ソフトウェアのご使用について
資料
http://www.silabs.com
Silicon Laboratories Inc. 400 West Cesar Chavez Austin, TX 78701 USA
Smart.
Connected.
Energy-Friendly.
Productswww.silabs.com/products www.silabs.com/qualityQuality Support and Communitycommunity.silabs.com Disclaimer
Silicon Labs intends to provide customers with the latest, accurate, and in-depth documentation of all peripherals and modules available for system and software implementers using or intending to use the Silicon Labs products. Characterization data, available modules and peripherals, memory sizes and memory addresses refer to each specific device, and "Typical" parameters provided can and do vary in different applications. Application examples described herein are for illustrative purposes only. Silicon Labs reserves the right to make changes without further notice and limitation to product information, specifications, and descriptions herein, and does not give warranties as to the accuracy or completeness of the included information. Silicon Labs shall have no liability for the consequences of use of the information supplied herein. This document does not imply or express copyright licenses granted hereunder to design or fabricate any integrated circuits. The products are not designed or authorized to be used within any Life Support System without the specific written consent of Silicon Labs. A "Life Support System" is any product or system intended to support or sustain life and/or health, which, if it fails, can be reasonably expected to result in significant personal injury or death. Silicon Labs products are not designed or authorized for military applications. Silicon Labs products shall under no circumstances be used in weapons of mass destruction including (but not limited to) nuclear, biological or chemical weapons, or missiles capable of delivering such weapons.
Trademark Information
Silicon Laboratories Inc.® , Silicon Laboratories®, Silicon Labs®, SiLabs® and the Silicon Labs logo®, Bluegiga®, Bluegiga Logo®, Clockbuilder®, CMEMS®, DSPLL®, EFM®, EFM32®, EFR, Ember®, Energy Micro, Energy Micro logo and combinations thereof, "the world’s most energy friendly microcontrollers", Ember®, EZLink®, EZRadio®, EZRadioPRO®, Gecko®, ISOmodem®, Micrium, Precision32®, ProSLIC®, Simplicity Studio®, SiPHY®, Telegesis, the Telegesis Logo®, USBXpress®, Zentri, Z-Wave and others are trademarks or registered trademarks of Silicon Labs. ARM, CORTEX, Cortex-M3 and THUMB are trademarks or registered trademarks of ARM Holdings. Keil is a registered trademark of ARM Limited. All other products or brand names mentioned herein are trademarks of their respective holders.