-
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?
Conversation
|
|
||
| if (apiKey != null) { | ||
| final encodedApiKey = encoder.process(utf8.encode('$psk:${apiKey.toJson()}')); | ||
| final apiKeyCharacteristic = bleService.characteristics.firstWhere( | ||
| (char) => char.uuid.str == ViamBluetoothUUIDs.apiKeyCredsUUID, | ||
| orElse: () => throw Exception('apiKeyCharacteristic not found'), | ||
| ); | ||
| await apiKeyCharacteristic.write(encodedApiKey); | ||
| } |
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 apiKey is included then it will be used over secret so I don't want to force api key usage before these changes have been fully validated
| // Definitions | ||
|
|
||
| class APIKey { | ||
| final String id; | ||
| final String key; | ||
|
|
||
| APIKey({required this.id, required this.key}); | ||
|
|
||
| String toJson() { | ||
| return jsonEncode({'id': id, 'key': key}); | ||
| } | ||
| } | ||
|
|
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.
This is probably better in it's own separate file, this file is for extension methods on BluetoothDevice
kevin49999
left a comment
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.
few small comments but looks great! ty for the contribution
| ), | ||
| TextField( | ||
| controller: _apiKeyKeyTextController, | ||
| decoration: const InputDecoration(labelText: 'API Key', hintText: '(will be used instead of secret if provided)'), |
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.
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
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.
Avoiding that for now since older viam-server versions don't how to handle only api keys
Co-authored-by: Kevin Johnson <[email protected]>
Description
RSDK-13175
apiKeyCredsKeyBT characteristicViamBluetoothUUIDsapiKeyparam towriteRobotPartConfigfor it to be written toapiKeyCredsKeycharTesting
viam-serverwith a healthy app connection