Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions gap.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ func NewDuration(interval time.Duration) Duration {
// Connection is a numeric identifier that indicates a connection handle.
type Connection uint16

// GAPDevice is the shared interface that all platform-specific Device types must implement.
type GAPDevice interface {
DiscoverServices(uuids []UUID) ([]DeviceService, error)
RequestConnectionParams(params ConnectionParams) error
Disconnect() error
}

// ScanResult contains information from when an advertisement packet was
// received. It is passed as a parameter to the callback of the Scan method.
type ScanResult struct {
Expand Down
2 changes: 2 additions & 0 deletions gap_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ func (a *Adapter) StopScan() error {
return nil
}

var _ GAPDevice = Device{}

// Device is a connection to a remote peripheral.
type Device struct {
Address Address
Expand Down
2 changes: 2 additions & 0 deletions gap_hci.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,8 @@ type notificationRegistration struct {
callback func([]byte)
}

var _ GAPDevice = Device{}

// Device is a connection to a remote peripheral.
type Device struct {
Address Address
Expand Down
2 changes: 2 additions & 0 deletions gap_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ func makeScanResult(props map[string]dbus.Variant) ScanResult {
}
}

var _ GAPDevice = Device{}

// Device is a connection to a remote bluetooth device.
type Device struct {
Address Address // the MAC address of the device
Expand Down
18 changes: 18 additions & 0 deletions gap_nrf51.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,3 +108,21 @@ func (a *Adapter) SetRandomAddress(mac MAC) error {
}
return nil
}

// Disconnect from the BLE device.
func (d Device) Disconnect() error {
return errNotYetImplmented
}

// DiscoverServices starts a service discovery procedure.
func (d Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
return nil, errNotYetImplmented
}

// RequestConnectionParams requests a different connection latency and timeout
// of the given device connection.
func (d Device) RequestConnectionParams(params ConnectionParams) error {
return errNotYetImplmented
}

type DeviceService struct{}
28 changes: 28 additions & 0 deletions gap_s113v7.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//go:build softdevice && s113v7

package bluetooth

/*
// Add the correct SoftDevice include path to CFLAGS, so #include will work as
// expected.
#cgo CFLAGS: -Is113_nrf52_7.0.1/s113_nrf52_7.0.1_API/include
*/
import "C"

// Disconnect from the BLE device.
func (d Device) Disconnect() error {
return errNotYetImplmented
}

// DiscoverServices starts a service discovery procedure.
func (d Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
return nil, errNotYetImplmented
}

// RequestConnectionParams requests a different connection latency and timeout
// of the given device connection.
func (d Device) RequestConnectionParams(params ConnectionParams) error {
return errNotYetImplmented
}

type DeviceService struct{}
2 changes: 2 additions & 0 deletions gap_sd.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ package bluetooth
*/
import "C"

var _ GAPDevice = Device{}

// Device is a connection to a remote peripheral or central.
type Device struct {
Address Address
Expand Down
2 changes: 2 additions & 0 deletions gap_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,8 @@ func (a *Adapter) StopScan() error {
return a.watcher.Stop()
}

var _ GAPDevice = Device{}

// Device is a connection to a remote peripheral.
type Device struct {
ctx context.Context
Expand Down
Loading