Skip to content

Commit b7c395f

Browse files
committed
Add manufacturer/model/fragment_id characteristics
1 parent 014073e commit b7c395f

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

subsystems/networking/bluetooth_characteristics_linux.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ const (
3030
appAddressKey = "app_address"
3131
availableWiFiNetworksKey = "networks"
3232
statusKey = "status"
33+
manufacturerKey = "manufacturer"
34+
modelKey = "model"
35+
fragmentKey = "fragment_id"
3336
errorsKey = "errors"
3437
cryptoKey = "pub_key"
3538
)
3639

3740
var (
3841
characteristicsWriteOnly = []string{ssidKey, pskKey, robotPartIDKey, robotPartSecretKey, appAddressKey}
39-
characteristicsReadOnly = []string{cryptoKey, statusKey, availableWiFiNetworksKey, errorsKey}
42+
characteristicsReadOnly = []string{cryptoKey, statusKey, manufacturerKey, modelKey, fragmentKey, availableWiFiNetworksKey, errorsKey}
4043
)
4144

4245
type btCharacteristics struct {
@@ -107,6 +110,15 @@ func (b *btCharacteristics) initCrypto() error {
107110
return err
108111
}
109112

113+
func (b *btCharacteristics) initDevInfo(cfg utils.NetworkConfiguration) error {
114+
b.mu.Lock()
115+
defer b.mu.Unlock()
116+
_, err1 := b.writables[manufacturerKey].Write([]byte(cfg.Manufacturer))
117+
_, err2 := b.writables[modelKey].Write([]byte(cfg.Model))
118+
_, err3 := b.writables[fragmentKey].Write([]byte(cfg.FragmentID))
119+
return errors.Join(err1, err2, err3)
120+
}
121+
110122
// initWriteOnlyCharacteristic returns a bluetooth characteristic config.
111123
func (b *btCharacteristics) initWriteOnlyCharacteristic(cName string) bluetooth.CharacteristicConfig {
112124
// Generate predictable (v5) UUID from common namespace+cName

subsystems/networking/bluetooth_linux.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ func (n *Networking) initializeBluetoothService(deviceName string, characteristi
7979
if err := adv.Configure(opts); err != nil {
8080
return fmt.Errorf("failed to configure default advertisement: %w", err)
8181
}
82-
err := n.btChar.initCrypto()
83-
if err != nil {
82+
if err := n.btChar.initCrypto(); err != nil {
83+
return err
84+
}
85+
if err := n.btChar.initDevInfo(n.Config()); err != nil {
8486
return err
8587
}
8688

0 commit comments

Comments
 (0)