パッケージ、リポジトリ、アプリカテゴリを検索

パッケージ詳細v1.1.0

esp_provisioning_ble

Bluetooth Low Energy (BLE) を使用して、ESP32 モジュールのプロビジョニング構成を簡素化する Flutter プラグインです。

AndroidiOS
30日間ダウンロード
606
いいね数
27
Pub ポイント
130

パッケージをインストール

flutter pub add esp_provisioning_ble

パッケージ概要

公開情報に基づく選定ガイドです。参考としてご利用ください。

Bluetooth Low Energy (BLE) を通じて ESP32 モジュールの設定を簡素化するための Flutter プラグインです。デバイスが ESP32 ユニットを検出・接続・設定できるシンプルかつ一貫したインターフェースを提供し、シームレスなオーバー・ザ・エア設定を実現します。複雑な配線や手動でのネットワーク入力なしに、迅速な展開とデバイスオンボーディングが必要な IoT プロジェクトに最適です。プラグインは Android および iOS の両方のプラットフォームをサポートしており、モバイル環境における広範な互換性を確保しています。

用途

  • IoTデバイスのオンボーディング
  • ワイヤレスESP32の設定
  • スマートホームデバイスのセットアップ
  • 自動ファームウェアプロビジョニング
  • リモートデバイス管理

主な機能

  • BLEベースのデバイスプロビジョニング
  • クロスプラットフォーム対応(Android および iOS)
  • デバイス検出のためのシンプルな API
  • セキュアな接続処理
  • リアルタイムのステータスフィードバック

適している対象

  • IoT開発者
  • 組み込みシステムエンジニア
  • スマートデバイス用モバイルアプリ開発者
  • ハードウェアスタートアップ
  • 現場技術者が接続デバイスを展開する

注意事項

  • BLE対応デバイスが必要です
  • 互換ファームウェアを搭載したESP32モジュールに限定
  • バックグラウンドモードには追加の構成が必要になる場合があります
  • Androidで必要なネットワーク権限
  • iOSのバックグラウンド実行制限

元の README

関連するソースリポジトリの README 原文のスナップショットです。最新の内容はリポジトリをご覧ください。

esp_provisioning_ble

A library for provisioning a ESP32 with Bluetooth BLE

#IMPORTANT!!!!!!

#IMPORTANT!!!!!!

The officially repository is

https://github.com/ESP-Provisioning-BLE/esp_provisioning_ble

#IMPORTANT!!!!!!

#IMPORTANT!!!!!!

Getting Started

Create an EspProv Instance

The package has an abstract class called ProvTransport, that you need to implement using your preferred Bluetooth package. In the example

folder there is an implementation of ProvTransport using the package flutter_ble_lib_ios_15

prov = EspProv(
    transport: TransportBLE(peripheral),
    security: Security1(
        pop: pop,
    ),
);

The transport attribute accepts only the ProvTransport type, and the security attribute accepts only the ProvSecurity type, which has an implementation called Security1 that you will use to pass the Proof-of-Possession (PoP).

Establish a session with the device:

After that, you will need to establish a session with the device. You can do this using the establishSession function, which returns three types of EstablishSessionStatus:

  1. Connected: When the device establishes a connection successfully.
  2. Disconnected: When an error occurs while establishing a connection with the device.
  3. KeyMismatch: When the Proof-of-Possession (PoP) is incorrect.
var sessionStatus = await prov.establishSession();
log.d("Session Status = $sessionStatus");
switch (sessionStatus) {
    case EstablishSessionStatus.Connected:
        emit(BleWifiEstablishedConnectionState());
    case EstablishSessionStatus.Disconnected:
        emit(BleWifiEstablishedConnectionFailedState());
    case EstablishSessionStatus.Keymismatch:
        emit(BleWifiEstablishedConnectionKeyMismatch());
}
Scan networks from the device:

To scan Wi-Fi networks, use the startScanWifi function, which returns a list of WifiAp objects, each of which has the following attributes:

  1. String ssid
  2. int rssi
  3. bool active
  4. bool private
var listWifi = await prov.startScanWiFi();
log.d('Found ${listWifi.length} Wi-Fi networks');
for (var obj in listWifi) {
    log.d('Wi-Fi network: ${obj.ssid}');
}
Send and Apply WI-Fi Config:

To send and apply config use the sendWifiConfig and applyWifiConfig functions, respectively.

await prov.sendWifiConfig(ssid: event.ssid, password: event.password);
await prov.applyWifiConfig();
Get the status of applying Wi-Fi Config:

To retrieve the status, use the getStatus function, which returns a ConnectionStatus type. ConnectionStatus has the following attributes:

  1. WifiConnectionState state: WifiConnectionState has four types of states:

    • Connected.
    • Connecting.
    • Disconnected.
    • ConnectionFailed: When the state is ConnectionFailed, the WifiConnectFailedReason attribute indicates the type of error.
  2. String? deviceIp: This registers the device's IP after provisioning.

  3. WifiConnectFailedReason? failedReason: WifiConnectFailedReason has two types of failed reasons:

    • AuthError: When the Wi-Fi password was incorrectly typed.
    • NetworkNotFound: When the Wi-Fi SSID was incorrectly typed.
ConnectionStatus status = await prov.getStatus();
switch (status.state) {
    case WifiConnectionState.Connecting:
    {
        add(BleWifiLoadingEvent());
    }
    case WifiConnectionState.Connected:
    {
        log.d("Device IP: ${status.deviceIp}");
        add(BleWifiConnectedEvent());
    }
    case WifiConnectionState.Disconnected:
    {
        add(BleWifiDisconnectedEvent());
    }
    case WifiConnectionState.ConnectionFailed:
    {
        add(
            BleWifiConnectionFailedEvent(
                failedReason: status.failedReason!,
            ),
        );
    }
}

Send custom data:

To send and receive a custom data, use the sendReceiveCustomData function

var customAnswerBytes = await prov.sendReceiveCustomData(
    Uint8List.fromList(
        utf8.encode(customSendMessage),
    ),
);
var customAnswer = utf8.decode(customAnswerBytes);
log.i("Custom data answer: $customAnswer");

Check example application.

Protocol Communication Overview

The Protocol Communication (protocomm) component manages secure sessions and provides the framework for multiple transports. The application can also use the protocomm layer directly to have application-specific extensions for the provisioning or non-provisioning use cases.

Following features are available for provisioning:

  • Communication security at the application level

    • protocomm_security0 (no security)

    • protocomm_security1 (Curve25519 key exchange + AES-CTR encryption/decryption)

    • protocomm_security2 (SRP6a-based key exchange + AES-GCM encryption/decryption)

  • Proof-of-possession (support with protocomm_security1 only)

  • Salt and Verifier (support with protocomm_security2 only)

Protocomm internally uses protobuf (protocol buffers) for secure session establishment. Users can choose to implement their own security (even without using protobuf). Protocomm can also be used without any security layer.

Protocomm provides the framework for various transports:

  • Bluetooth LE

  • Wi-Fi (SoftAP + HTTPD)

  • Console, in which case the handler invocation is automatically taken care of on the device side. See Transport Examples below for code snippets.

Note that for protocomm_security1 and protocomm_security2, the client still needs to establish sessions by performing the two-way handshake. See Unified Provisioning for more details about the secure handshake logic.

Comparasion:

Comparison with esp_provisioning_softap package:

Repo softap support ble support cryptography protobuf
esp_provisioning_softap ✔️ ✖️ ✔️ (2.0.1) ✔️ (2.0.0)
esp_provisioning_ble ✖️ ✔️ ✔️ (2.5.0) ✔️ (3.0.0)

Last update: 10/06/2023 (Octorber 6, 2023).

TODOS:
  • Test and create examples of the package with others Bluetooth packages.

    • flutter_blue_plus
  • Implement security 0

  • Implement security 2

Credits

カテゴリー

依存関係

依存関係一覧 3 件

ソースリポジトリ

このパッケージを使用しているプロジェクト

データはまだありません。