Bluetoothサービス¶
Bluetooth Service
このサービスはBluetoothデバイスとのインターフェース専用であり、以下を提供します:
This service is dedicated to interface with Bluetooth devices and provides:
- Bluetooth接続を使用してマルチメディアオーディオのストリーミングを実装するA2DP(Advanced Audio Distribution Profile);
  A2DP (Advanced Audio Distribution Profile), that implements streaming of multimedia audio using a Bluetooth connection; 
- AVRCP(オーディオ/ビデオリモートコントロールプロファイル)は、ヘッドフォン、カーオーディオシステム、スピーカーなどのデバイスのリモートコントロールにA2DPと一緒に使用されます。
  AVRCP (Audio/Video Remote Control Profile) used together with A2DP for remote control of devices such as headphones, car audio systems, or speakers. 
アプリケーション例¶
Application Example
このAPIの実装は、次の例で示されています:
Implementation of this API is demonstrated in the following example:
関数¶
Functions
- 
esp_err_t bluetooth_service_start(bluetooth_service_cfg_t *config)¶
- Bluetoothサービスを初期化して開始します。 この関数は1回だけ呼び出すことができ、 - bluetooth_service_destroyは使用後に呼び出す必要があります。- Initialize and start the Bluetooth service. This function can only be called for one time, and - bluetooth_service_destroymust be called after use.- Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- config: 構成- config: The configuration
 
 
- 
audio_element_handle_t bluetooth_service_create_stream()¶
- Bluetoothストリームを作成します。Bluetoothサービスが開始されたときに有効になります。 返されたオーディオストリームは、既存のオーディオストリームと互換性があり、オーディオパイプラインで使用できます。 - Create Bluetooth stream, it is valid when Bluetooth service has started. The returned audio stream compatible with existing audio streams and can be used with the Audio Pipeline. - Return
- オーディオエレメントハンドル
  The Audio Element handle 
 
- 
esp_periph_handle_t bluetooth_service_create_periph()¶
- Bluetooth周辺機器を作成します。Bluetoothサービスが開始されたときに有効になります。 返送されたBluetoothペリフェラルは、既存のペリフェラルと互換性があり、ESPペリフェラルで使用できます。 - Create Bluetooth peripheral, it is valid when Bluetooth service has started. The returned bluetooth peripheral compatible with existing peripherals and can be used with the ESP Peripherals. - Return
- ペリフェラルハンドル
  The Peripheral handle 
 
- 
esp_err_t periph_bluetooth_play(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(PLAY)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (PLAY) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_pause(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(PAUSE)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (PAUSE) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_stop(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(STOP)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (STOP) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_next(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(NEXT)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (NEXT) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_prev(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(PREV)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (PREV) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_rewind(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(REWIND)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (REWIND) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_fast_forward(esp_periph_handle_t periph)¶
- AVRCパススルーコマンド(FAST FORWARD)をBluetoothデバイスに送信します。 - Send the AVRC passthrough command (FAST FORWARD) to the Bluetooth device. - Return
- ESP_OK
- ESP_FAIL
 
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_discover(esp_periph_handle_t periph)¶
- デバイス検出を開始します。 - Start device discovery. - Return
- ESP_OK : 成功する
  ESP_OK : Succeed 
- ESP_ERR_INVALID_STATE: Bluetoothスタックがまだ有効になっていない場合
  ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled 
- ESP_ERR_INVALID_ARG: 無効なパラメーターが指定された場合
  ESP_ERR_INVALID_ARG: if invalid parameters are provided 
- ESP_FAIL: その他
  ESP_FAIL: others 
 
- ESP_OK : 成功する
  
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_cancel_discover(esp_periph_handle_t periph)¶
- デバイス検出をキャンセルします。 - Cancel device discovery. - Return
- ESP_OK : 成功する
  ESP_OK : Succeed 
- ESP_ERR_INVALID_STATE: Bluetoothスタックがまだ有効になっていない場合
  ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled 
- ESP_FAIL: その他
  ESP_FAIL: others 
 
- ESP_OK : 成功する
  
- Parameters
- periph: ペリフ- periph: The periph
 
 
- 
esp_err_t periph_bluetooth_connect(esp_periph_handle_t periph, bluetooth_addr_t remote_bda)¶
- リモートデバイスを接続します。 - Connect remote Device. - Return
- ESP_OK : 成功する
  ESP_OK : Succeed 
- ESP_ERR_INVALID_STATE: Bluetoothスタックがまだ有効になっていない場合
  ESP_ERR_INVALID_STATE: if bluetooth stack is not yet enabled 
- ESP_FAIL: その他
  ESP_FAIL: others 
 
- ESP_OK : 成功する
  
- Parameters
- periph: ペリフ- periph: The periph
- remote_bda: リモートBluetoothデバイスアドレス- remote_bda: remote Bluetooth device address
 
 
- 
esp_err_t bluetooth_service_destroy()¶
- Bluetoothサービスを破棄してクリーンアップします。この関数は、 - bluetooth_service_create_streamと- bluetooth_service_create_periphによって作成されたBluetoothストリームとBluetoothペリフェラルを破棄した後に呼び出す必要があります。- Destroy and cleanup bluetooth service, this function must be called after destroying the Bluetoth Stream and Bluetooth Peripheral created by - bluetooth_service_create_streamand- bluetooth_service_create_periph- Return
- ESP_OK
- ESP_FAIL
 
 
構造体¶
Structures
- 
struct bluetooth_service_cfg_t¶
- 簡単なBluetoothサービス構成 - brief Bluetooth service configuration - Public Members - 
const char *device_name¶
- Bluetoothローカルデバイス名 - Bluetooth local device name 
 - 
const char *remote_name¶
- Bluetoothリモートデバイス名 - Bluetooth remote device name 
 - 
bluetooth_service_mode_t mode¶
- Bluetooth動作モード - Bluetooth working mode 
 
- 
const char *
タイプ定義¶
Type Definitions
- 
typedef uint8_t bluetooth_addr_t[BLUETOOTH_ADDR_LEN]¶
- 簡単なBluetoothデバイスアドレス - brief Bluetooth device address 
Enumerations¶
- 
enum bluetooth_service_mode_t¶
- 簡単なBluetoothサービスの動作モード - brief Bluetooth service working mode - Values: - 
BLUETOOTH_A2DP_SINK¶
- A2DP Bluetoothシンクオーディオ、ESP32は他のBluetoothデバイスからオーディオデータを受信します - A2DP Bluetooth sink audio, ESP32 will receive audio data from other bluetooth devices 
 - 
BLUETOOTH_A2DP_SOURCE¶
- A2DP Bluetoothソースオーディオ、ESP32はオーディオデータを他のBluetoothデバイスに送信できます - A2DP Bluetooth source audio, ESP32 can send audio data to other bluetooth devices 
 
-