-
Notifications
You must be signed in to change notification settings - Fork 1
[RSDK-13175] Add API key BT characteristic #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| part of '../viam_bluetooth_provisioning.dart'; | ||
|
|
||
| class APIKey { | ||
| final String id; | ||
| final String key; | ||
|
|
||
| APIKey({required this.id, required this.key}); | ||
|
|
||
| String toJson() { | ||
| return jsonEncode({'id': id, 'key': key}); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ class _ProvisionPeripheralScreen extends State<ProvisionPeripheralScreen> { | |
| final TextEditingController _partIdTextController = TextEditingController(); | ||
| final TextEditingController _secretTextController = TextEditingController(); | ||
| final TextEditingController _appAddressTextController = TextEditingController(); | ||
| final TextEditingController _apiKeyIdTextController = TextEditingController(); | ||
| final TextEditingController _apiKeyKeyTextController = TextEditingController(); | ||
|
|
||
| List<String> _networkList = []; | ||
|
|
||
|
|
@@ -47,6 +49,8 @@ class _ProvisionPeripheralScreen extends State<ProvisionPeripheralScreen> { | |
| _partIdTextController.dispose(); | ||
| _secretTextController.dispose(); | ||
| _appAddressTextController.dispose(); | ||
| _apiKeyIdTextController.dispose(); | ||
| _apiKeyKeyTextController.dispose(); | ||
| super.dispose(); | ||
| } | ||
|
|
||
|
|
@@ -137,10 +141,18 @@ class _ProvisionPeripheralScreen extends State<ProvisionPeripheralScreen> { | |
| final partId = _partIdTextController.text; | ||
| final secret = _secretTextController.text; | ||
| final appAddress = _appAddressTextController.text; | ||
| final apiKeyId = _apiKeyIdTextController.text.trim(); | ||
| final apiKeyKey = _apiKeyKeyTextController.text.trim(); | ||
|
|
||
| APIKey? apiKey; | ||
| if (apiKeyId.isNotEmpty && apiKeyKey.isNotEmpty) { | ||
| apiKey = APIKey(id: apiKeyId, key: apiKeyKey); | ||
| } | ||
| await widget.device.writeRobotPartConfig( | ||
| partId: partId, | ||
| secret: secret, | ||
| appAddress: appAddress, | ||
| apiKey: apiKey, | ||
| ); | ||
| _showSnackBar('Wrote robot part config'); | ||
| } catch (e) { | ||
|
|
@@ -230,6 +242,14 @@ class _ProvisionPeripheralScreen extends State<ProvisionPeripheralScreen> { | |
| controller: _secretTextController, | ||
| decoration: const InputDecoration(labelText: 'Secret'), | ||
| ), | ||
| TextField( | ||
| controller: _apiKeyIdTextController, | ||
| decoration: const InputDecoration(labelText: 'API Key ID', hintText: '(will be used instead of secret if provided)'), | ||
| ), | ||
| TextField( | ||
| controller: _apiKeyKeyTextController, | ||
| decoration: const InputDecoration(labelText: 'API Key', hintText: '(will be used instead of secret if provided)'), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, it does seem that we will still write the secret if it's present - but we talked and that doesn't seem like an issue. You could take the writing logic one step further and avoid writing secret if an APIKey is passed in
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Avoiding that for now since older |
||
| ), | ||
| TextField( | ||
| controller: _appAddressTextController, | ||
| decoration: const InputDecoration(labelText: 'App Address'), | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thinking to make this optional since everything else was written to be backwards compatible with secrets, and if an
apiKeyis included then it will be used oversecretso I don't want to force api key usage before these changes have been fully validated