Skip to content

Add smart_wifi_connect package and ensemble_wifi module#2273

Draft
sharjeelyunus wants to merge 2 commits into
mainfrom
cursor/wifi-connect-module-913d
Draft

Add smart_wifi_connect package and ensemble_wifi module#2273
sharjeelyunus wants to merge 2 commits into
mainfrom
cursor/wifi-connect-module-913d

Conversation

@sharjeelyunus

Copy link
Copy Markdown
Member

Description

Creates a lightweight Flutter plugin (smart_wifi_connect) for connecting to Wi-Fi networks by SSID/password, and integrates it into Ensemble as the ensemble_wifi module with a connectToWifi action.

Related Issue

Fixes #2229

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

What Has Changed

smart_wifi_connect package (packages/smart_wifi_connect/)

  • Dart API: SmartWifiConnect.connect(ssid, password, joinOnce, rememberNetwork) returning SmartWifiConnectResult
  • Android (Kotlin): Uses WifiNetworkSpecifier (API 29+) with NEARBY_WIFI_DEVICES permission on Android 13+ (neverForLocation flag) and ACCESS_FINE_LOCATION capped at SDK 32
  • iOS (Swift): Uses NEHotspotConfigurationManager with joinOnce support, graceful handling of user denial and alreadyAssociated
  • Result model: SmartWifiConnectResult with success, status enum, message, platformCode
  • Status enum: connected, permissionDenied, userCancelled, unsupported, invalidArguments, failed
  • Tests: 6 unit tests (empty SSID validation, method channel args, platform exceptions, missing plugin, permission denied, result serialization)
  • Example app: Simple SSID/password form with connect button
  • README: Full documentation including platform setup, permissions explanation, and security notes

Core ensemble changes (modules/ensemble/)

  • Stub: WifiManager abstract class + WifiManagerStub in lib/framework/stub/wifi_manager.dart
  • Module: WifiModule + WifiModuleStub in lib/module/wifi_module.dart
  • Action: ConnectToWifiAction in lib/action/wifi_action.dart — parses YAML properties, evaluates expressions via scopeManager.dataContext.eval(), calls WifiManager.connect(), fires onSuccess/onError with EnsembleEvent
  • Registration: connectToWifi added to ActionType enum, fromActionType() factory, and ActionInvokable methods list

ensemble_wifi module (modules/ensemble_wifi/)

  • WifiManagerImpl: bridges WifiManager stub to SmartWifiConnect.connect()
  • WifiModuleImpl: registers WifiManagerImpl via GetIt

Starter wiring

  • useWifi flag and WifiModule registration added to EnsembleModules
  • Commented ensemble_wifi dependency in starter/pubspec.yaml

Proposed YAML Action

connectToWifi:
  ssid: ${newSSID}
  password: ${newPassword}
  joinOnce: false
  rememberNetwork: true
  onSuccess:
    executeCode:
      body: |
        console.log('Connected to Wi-Fi');
  onError:
    executeCode:
      body: |
        console.log('Failed: ' + event.error);

Security & Privacy

  • Wi-Fi passwords are never logged
  • No Wi-Fi scanning is performed
  • No location data is collected or inferred
  • neverForLocation flag used on Android 13+
  • Permissions requested only at connect time

How to Test

  1. Run melos bootstrap from repo root
  2. flutter test in packages/smart_wifi_connect/ — 6 tests pass
  3. flutter analyze on all new files — no issues
  4. flutter build web in starter/ — builds successfully
  5. For device testing: enable ensemble_wifi in starter, add Wi-Fi permissions, and test connectToWifi action on Android 10+/iOS

Checklist

  • I have run flutter analyze and addressed any new warnings
  • I have run flutter test and all tests pass
  • I have tested my changes on the relevant platform(s)
  • I have updated documentation if needed
  • My changes do not introduce new warnings or errors
Open in Web Open in Cursor 

cursoragent and others added 2 commits June 10, 2026 21:51
Create smart_wifi_connect Flutter plugin:
- Dart API: SmartWifiConnect.connect() with ssid, password, joinOnce, rememberNetwork
- Android: WifiNetworkSpecifier (API 29+), NEARBY_WIFI_DEVICES (API 33+)
- iOS: NEHotspotConfigurationManager
- Structured SmartWifiConnectResult with status enum
- 6 unit tests covering API, error handling, and edge cases

Create ensemble_wifi module:
- WifiManager stub + WifiManagerStub in core ensemble
- WifiModule abstraction (WifiModuleStub for disabled state)
- ConnectToWifiAction with onSuccess/onError callbacks
- Register connectToWifi in ActionType enum and ActionInvokable
- WifiModuleImpl bridging to smart_wifi_connect package

Wire up in starter:
- Add useWifi flag and registration in EnsembleModules
- Add commented ensemble_wifi dependency in starter pubspec

Fixes #2229

Co-authored-by: Sharjeel Yunus <sharjeelyunus@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create smart_wifi_connect Flutter Package and Ensemble Wi-Fi Connect Module

2 participants