Skip to content

Commit 5424e7f

Browse files
authored
Update flutter_sdk example to include hotspot provisioning widget (#444)
* add in hotspot prov example app * updating dependencies * update readme * debug runner * add space * remove space * space * newline * add gitignore * Ignore .cxx/Debug build directory * gitignore * remove consts * Apply merged .gitignore and stop tracking ignored files * update gitignore * remove period * Update README.md
1 parent da0918a commit 5424e7f

File tree

136 files changed

+6336
-2
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

136 files changed

+6336
-2
lines changed

.vscode/launch.json

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,18 @@
2323
"request": "launch",
2424
"type": "dart",
2525
"flutterMode": "release"
26-
}
26+
},
27+
{
28+
"name": "viam_robot_example_app",
29+
"cwd": "example/viam_robot_example_app",
30+
"request": "launch",
31+
"type": "dart"
32+
},
33+
{
34+
"name": "hotspot_provisioning_example_app",
35+
"cwd": "example/hotspot_provisioning_example_app",
36+
"request": "launch",
37+
"type": "dart"
38+
},
2739
]
28-
}
40+
}

example/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,7 @@ This directory contains examples on how to use the Viam Flutter SDK.
66
- Start using the Viam SDK from scratch! This example will walk you through the canonical way of using the SDK, using API Keys with a fully documented example app.
77
- [Viam Robot Example App](https://github.com/viamrobotics/viam-flutter-sdk/tree/main/example/viam_robot_example_app)
88
- This example uses Location secrets to connect to a robot. It has a bit more customization, but is not as well documented.
9+
10+
- [Hotspot Provisioning Example App](https://github.com/viamrobotics/viam-flutter-sdk/tree/main/example/hotspot_provisioning_example_app)
11+
- This example demonstrates how to use the Hotspot Provisioning Widget to provision new machines, reconnect existing machines to new networks, and replace hardware while preserving machine configurations.
12+
Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
# Do not remove or rename entries in this file, only add new ones
2+
# See https://github.com/flutter/flutter/issues/128635 for more context.
3+
4+
# Miscellaneous
5+
*.class
6+
*.lock
7+
*.log
8+
*.pyc
9+
*.swp
10+
.DS_Store
11+
.atom/
12+
.build/
13+
.buildlog/
14+
.history
15+
.svn/
16+
.swiftpm/
17+
migrate_working_dir/
18+
19+
# As packages are no longer pinned, we use a lockfile for testing locally.
20+
# When unpinning packages, Using lockfiles ensures that failures in PRs are
21+
# actually due to those PRs, not due to a package being updated.
22+
!/pubspec.lock
23+
24+
# IntelliJ related
25+
*.iml
26+
*.ipr
27+
*.iws
28+
.idea/
29+
30+
# Visual Studio Code related
31+
.classpath
32+
.project
33+
.settings/
34+
.vscode/*
35+
.ccls-cache
36+
37+
# Flutter repo-specific
38+
/bin/internal/engine.version
39+
/bin/cache/
40+
/bin/internal/bootstrap.bat
41+
/bin/internal/bootstrap.sh
42+
/bin/internal/engine.realm
43+
/bin/mingit/
44+
/dev/benchmarks/mega_gallery/
45+
/dev/bots/.recipe_deps
46+
/dev/bots/android_tools/
47+
/dev/devicelab/ABresults*.json
48+
/dev/docs/doc/
49+
/dev/docs/api_docs.zip
50+
/dev/docs/flutter.docs.zip
51+
/dev/docs/lib/
52+
/dev/docs/pubspec.yaml
53+
/dev/integration_tests/**/xcuserdata
54+
/dev/integration_tests/**/Pods
55+
/packages/flutter/coverage/
56+
version
57+
analysis_benchmark.json
58+
59+
# packages file containing multi-root paths
60+
.packages.generated
61+
62+
# Flutter/Dart/Pub related
63+
**/doc/api/
64+
**/ios/Flutter/.last_build_id
65+
.dart_tool/
66+
.flutter-plugins
67+
.flutter-plugins-dependencies
68+
**/generated_plugin_registrant.dart
69+
.packages
70+
.pub-preload-cache/
71+
.pub-cache/
72+
.pub/
73+
build/
74+
flutter_*.png
75+
linked_*.ds
76+
unlinked.ds
77+
unlinked_spec.ds
78+
79+
# Android related
80+
**/android/**/gradle-wrapper.jar
81+
.gradle/
82+
**/android/captures/
83+
**/android/gradlew
84+
**/android/gradlew.bat
85+
**/android/**/GeneratedPluginRegistrant.java
86+
**/android/key.properties
87+
*.jks
88+
local.properties
89+
**/.cxx/
90+
/android/app/debug
91+
/android/app/profile
92+
/android/app/release
93+
94+
# iOS/Xcode related
95+
**/ios/**/*.mode1v3
96+
**/ios/**/*.mode2v3
97+
**/ios/**/*.moved-aside
98+
**/ios/**/*.pbxuser
99+
**/ios/**/*.perspectivev3
100+
**/ios/**/*sync/
101+
**/ios/**/.sconsign.dblite
102+
**/ios/**/.tags*
103+
**/ios/**/.vagrant/
104+
**/ios/**/DerivedData/
105+
**/ios/**/Icon?
106+
**/ios/**/Pods/
107+
**/ios/**/.symlinks/
108+
**/ios/**/profile
109+
**/ios/**/xcuserdata
110+
**/ios/.generated/
111+
**/ios/Flutter/.last_build_id
112+
**/ios/Flutter/App.framework
113+
**/ios/Flutter/Flutter.framework
114+
**/ios/Flutter/Flutter.podspec
115+
**/ios/Flutter/Generated.xcconfig
116+
**/ios/Flutter/ephemeral
117+
**/ios/Flutter/app.flx
118+
**/ios/Flutter/app.zip
119+
**/ios/Flutter/flutter_assets/
120+
**/ios/Flutter/flutter_export_environment.sh
121+
**/ios/ServiceDefinitions.json
122+
**/ios/Runner/GeneratedPluginRegistrant.*
123+
124+
# macOS
125+
**/Flutter/ephemeral/
126+
**/Pods/
127+
**/macos/Flutter/GeneratedPluginRegistrant.swift
128+
**/macos/Flutter/ephemeral
129+
**/xcuserdata/
130+
131+
# Windows
132+
**/windows/flutter/ephemeral/
133+
**/windows/flutter/generated_plugin_registrant.cc
134+
**/windows/flutter/generated_plugin_registrant.h
135+
**/windows/flutter/generated_plugins.cmake
136+
137+
# Linux
138+
**/linux/flutter/ephemeral/
139+
**/linux/flutter/generated_plugin_registrant.cc
140+
**/linux/flutter/generated_plugin_registrant.h
141+
**/linux/flutter/generated_plugins.cmake
142+
143+
# Coverage
144+
coverage/
145+
146+
# Symbols / Obfuscation
147+
app.*.symbols
148+
app.*.map.json
149+
150+
# Environment
151+
*.env
152+
153+
# Exceptions to above rules
154+
!**/ios/**/default.mode1v3
155+
!**/ios/**/default.mode2v3
156+
!**/ios/**/default.pbxuser
157+
!**/ios/**/default.perspectivev3
158+
!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages
159+
!/dev/ci/**/Gemfile.lock
160+
!.vscode/settings.json
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Viam Flutter Hotspot Provisioning Example
2+
This example project demonstrates how to use the Viam Flutter Hotspot Provisioning Widget to connect robots to the Viam platform.
3+
4+
## Getting Started
5+
6+
1. Ensure you have the required Viam API credentials configured in `lib/consts.dart`. This would be the `apiKeyId`, `apiKey`, and `organizationId`.
7+
2. Ensure you have both `hotspotPrefix` and `hotspotPassword` configured in `lib/consts.dart`.
8+
- These values should match the prefix and password that were set in the viam-defaults.json.
9+
- See the [Machine Setup section](../../README.md#machine-setup) for more info on the viam-defaults.json.
10+
2. Run the example app by running `flutter run`
11+
3. Choose "Provision New Machine", "Reconnect Machine", or "Replace Hardware"
12+
4. Follow the on-screen instructions
13+
14+
## Use Cases
15+
The app showcases three main use cases:
16+
17+
### 1. Provision a new machine
18+
This flow demonstrates how to connect a **new robot** to the Viam platform for the first time. The process:
19+
- Creates a new robot instance in your Viam organization
20+
- Initiates the hotspot provisioning flow to establish the initial connection
21+
- Guides the user through the connection process
22+
<img src="../../screenshots/provisioning_demo.gif" width="250" alt="Provisioning Flow">
23+
24+
### 2. Reconnect an existing machine
25+
This flow demonstrates how to **reconnect an existing robot** to a new wifi network. The process:
26+
- Lists all existing robots in your Viam organization
27+
- Shows their current connection status (online/offline/awaiting setup)
28+
- Allows you to select any robot and initiate the reconnection process
29+
- Uses the same hotspot provisioning flow but with an existing robot instance
30+
<img src="../../screenshots/reconnect_demo.gif" width="250" alt="Re-provisioning Flow">
31+
32+
### 3. Replace hardware
33+
This flow demonstrates how to **replace hardware** while preserving the robot's configuration. The process:
34+
- Saves the robot configuration from the old hardware
35+
- Creates a new robot instance for the replacement hardware
36+
- Applies the saved configuration to the new robot during provisioning
37+
- Ensures the new hardware has the same settings as the old hardware
38+
39+
## How It Works
40+
41+
All three flows utilize the same underlying `HotspotProvisioningFlow` widget, which:
42+
1. Connects to the robot's hotspot network
43+
2. Configures the robot's network settings
44+
3. Establishes a connection to the Viam platform
45+
4. Applies saved robot configuration (when replacing hardware)
46+
5. Returns the connection status
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# This file configures the analyzer, which statically analyzes Dart code to
2+
# check for errors, warnings, and lints.
3+
#
4+
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5+
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6+
# invoked from the command line by running `flutter analyze`.
7+
8+
# The following line activates a set of recommended lints for Flutter apps,
9+
# packages, and plugins designed to encourage good coding practices.
10+
include: package:flutter_lints/flutter.yaml
11+
12+
linter:
13+
# The lint rules applied to this project can be customized in the
14+
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
15+
# included above or to enable additional rules. A list of all available lints
16+
# and their documentation is published at https://dart.dev/lints.
17+
#
18+
# Instead of disabling a lint rule for the entire project in the
19+
# section below, it can also be suppressed for a single line of code
20+
# or a specific dart file by using the `// ignore: name_of_lint` and
21+
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
22+
# producing the lint.
23+
rules:
24+
# avoid_print: false # Uncomment to disable the `avoid_print` rule
25+
# prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
26+
27+
# Additional information about this file can be found at
28+
# https://dart.dev/guides/language/analysis-options
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
gradle-wrapper.jar
2+
/.gradle
3+
/captures/
4+
/gradlew
5+
/gradlew.bat
6+
/local.properties
7+
GeneratedPluginRegistrant.java
8+
9+
# Remember to never publicly share your keystore.
10+
# See https://flutter.dev/to/reference-keystore
11+
key.properties
12+
**/*.keystore
13+
**/*.jks
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
plugins {
2+
id "com.android.application"
3+
id "kotlin-android"
4+
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
5+
id "dev.flutter.flutter-gradle-plugin"
6+
}
7+
8+
android {
9+
namespace = "com.example.viam_example_app"
10+
compileSdk = flutter.compileSdkVersion
11+
ndkVersion = flutter.ndkVersion
12+
13+
compileOptions {
14+
sourceCompatibility = JavaVersion.VERSION_1_8
15+
targetCompatibility = JavaVersion.VERSION_1_8
16+
}
17+
18+
kotlinOptions {
19+
jvmTarget = JavaVersion.VERSION_1_8
20+
}
21+
22+
defaultConfig {
23+
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
24+
applicationId = "com.example.viam_example_app"
25+
// You can update the following values to match your application needs.
26+
// For more information, see: https://flutter.dev/to/review-gradle-config.
27+
minSdk = 29
28+
targetSdk = flutter.targetSdkVersion
29+
versionCode = flutter.versionCode
30+
versionName = flutter.versionName
31+
}
32+
33+
buildTypes {
34+
release {
35+
// TODO: Add your own signing config for the release build.
36+
// Signing with the debug keys for now, so `flutter run --release` works.
37+
signingConfig = signingConfigs.debug
38+
}
39+
}
40+
}
41+
42+
flutter {
43+
source = "../.."
44+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
2+
<!-- The INTERNET permission is required for development. Specifically,
3+
the Flutter tool needs it to communicate with the running application
4+
to allow setting breakpoints, to provide hot reload, etc.
5+
-->
6+
<uses-permission android:name="android.permission.INTERNET"/>
7+
</manifest>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2+
xmlns:tools="http://schemas.android.com/tools">
3+
<uses-permission android:name="android.permission.INTERNET"/>
4+
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
5+
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
6+
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
7+
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
8+
<application
9+
android:label="Hotspot Provisioning Example"
10+
android:name="${applicationName}"
11+
android:icon="@mipmap/ic_launcher">
12+
<activity
13+
android:name=".MainActivity"
14+
android:exported="true"
15+
android:launchMode="singleTop"
16+
android:taskAffinity=""
17+
android:theme="@style/LaunchTheme"
18+
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
19+
android:hardwareAccelerated="true"
20+
android:windowSoftInputMode="adjustResize">
21+
<!-- Specifies an Android theme to apply to this Activity as soon as
22+
the Android process has started. This theme is visible to the user
23+
while the Flutter UI initializes. After that, this theme continues
24+
to determine the Window background behind the Flutter UI. -->
25+
<meta-data
26+
android:name="io.flutter.embedding.android.NormalTheme"
27+
android:resource="@style/NormalTheme"
28+
/>
29+
<intent-filter>
30+
<action android:name="android.intent.action.MAIN"/>
31+
<category android:name="android.intent.category.LAUNCHER"/>
32+
</intent-filter>
33+
</activity>
34+
<!-- Don't delete the meta-data below.
35+
This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->
36+
<meta-data
37+
android:name="flutterEmbedding"
38+
android:value="2" />
39+
</application>
40+
<!-- Required to query activities that can process text, see:
41+
https://developer.android.com/training/package-visibility and
42+
https://developer.android.com/reference/android/content/Intent#ACTION_PROCESS_TEXT.
43+
44+
In particular, this is used by the Flutter engine in io.flutter.plugin.text.ProcessTextPlugin. -->
45+
<queries>
46+
<intent>
47+
<action android:name="android.intent.action.PROCESS_TEXT"/>
48+
<data android:mimeType="text/plain"/>
49+
</intent>
50+
</queries>
51+
</manifest>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.example.viam_example_app
2+
3+
import io.flutter.embedding.android.FlutterActivity
4+
5+
class MainActivity: FlutterActivity()

0 commit comments

Comments
 (0)