Skip to content

Commit

Permalink
feat: add stop service advertisement for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
John Brandt committed Jul 25, 2024
1 parent a668e1b commit 40dfdeb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions adapter_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/go-ole/go-ole"
"github.com/saltosystems/winrt-go"
"github.com/saltosystems/winrt-go/windows/devices/bluetooth/advertisement"
"github.com/saltosystems/winrt-go/windows/devices/bluetooth/genericattributeprofile"
"github.com/saltosystems/winrt-go/windows/foundation"
)

Expand All @@ -16,6 +17,8 @@ type Adapter struct {
connectHandler func(device Device, connected bool)

defaultAdvertisement *Advertisement

gattServiceProvider *genericattributeprofile.GattServiceProvider
}

// DefaultAdapter is the default adapter on the system.
Expand Down
6 changes: 6 additions & 0 deletions gatts_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ func (a *Adapter) AddService(s *Service) error {
return err
}

a.gattServiceProvider = serviceProvider

localService, err := serviceProvider.GetService()
if err != nil {
return err
Expand Down Expand Up @@ -237,6 +239,10 @@ func (a *Adapter) AddService(s *Service) error {
return serviceProvider.StartAdvertisingWithParameters(params)
}

func (a *Adapter) StopServiceAdvertisement() error {
return a.gattServiceProvider.StopAdvertising()
}

// Write replaces the characteristic value with a new value.
func (c *Characteristic) Write(p []byte) (n int, err error) {
length := len(p)
Expand Down

0 comments on commit 40dfdeb

Please sign in to comment.