Skip to content

Conversation

@danielbotros
Copy link
Member

@danielbotros danielbotros commented Jan 14, 2026

Description

RSDK-13175

  • Adds apiKeyCredsKey BT characteristic ViamBluetoothUUIDs
  • Adds apiKey param to writeRobotPartConfig for it to be written to apiKeyCredsKey char
  • Updates example app and README to incorporate this apiKey
  • Relevant agent PR

Testing

  1. Ran agent binary with relevant changes on my pi in bluetooth provisioning mode
  2. Loaded app on my Phone, connected to and paired to pi
  3. Wrote machine config with API key, without API key, and with both API key and secret
  4. Validated agent was able to startup viam-server with a healthy app connection

Comment on lines +203 to +211

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);
}
Copy link
Member Author

@danielbotros danielbotros Jan 14, 2026

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

@danielbotros danielbotros changed the title Add API key BT characteristic and update examples / readme [RSDK-13175] Add API key BT characteristic Jan 15, 2026
@danielbotros danielbotros marked this pull request as ready for review January 15, 2026 16:37
Comment on lines 3 to 15
// Definitions

class APIKey {
final String id;
final String key;

APIKey({required this.id, required this.key});

String toJson() {
return jsonEncode({'id': id, 'key': key});
}
}

Copy link
Member

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

Copy link
Member

@kevin49999 kevin49999 left a 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)'),
Copy link
Member

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

Copy link
Member Author

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

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.

3 participants