2019-11-16 21:02:11 +03:00
|
|
|
// +build !baremetal
|
|
|
|
|
|
|
|
package bluetooth
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/muka/go-bluetooth/api/service"
|
|
|
|
)
|
|
|
|
|
|
|
|
// AddService creates a new service with the characteristics listed in the
|
|
|
|
// Service struct.
|
|
|
|
//
|
|
|
|
// TODO: add support for characteristics on Linux.
|
|
|
|
func (a *Adapter) AddService(s *Service) error {
|
2020-05-25 01:06:02 +03:00
|
|
|
app, err := service.NewApp(service.AppOptions{
|
|
|
|
AdapterID: a.id,
|
|
|
|
})
|
2019-11-16 21:02:11 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-05-25 01:06:02 +03:00
|
|
|
bluezService, err := app.NewService(s.UUID.String())
|
2019-11-16 21:02:11 +03:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: add support for characteristics
|
|
|
|
|
|
|
|
err = app.AddService(bluezService)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return app.Run()
|
|
|
|
}
|