Unverified Commit 3b8c738f authored by Eric Stutzenberger's avatar Eric Stutzenberger Committed by GitHub
Browse files

Merge pull request #2 from rigado/feature/options

Add options for setting scanning and advertising parameters.
parents f5f249d8 33ae558a
......@@ -38,3 +38,13 @@ func (d *Device) SetListenerTimeout(dur time.Duration) error {
func (d *Device) SetConnParams(param cmd.LECreateConnection) error {
return errors.New("Not supported")
}
// SetScanParams overrides default scanning parameters.
func (d *Device) SetScanParams(param cmd.LESetScanParameters) error {
return errors.New("Not supported")
}
// SetAdvParams overrides default advertising parameters.
func (d *Device) SetAdvParams(param cmd.LESetAdvertisingParameters) error {
return errors.New("Not supported")
}
......@@ -31,6 +31,18 @@ func (h *HCI) SetConnParams(param cmd.LECreateConnection) error {
return nil
}
// SetScanParams overrides default scanning parameters.
func (h *HCI) SetScanParams(param cmd.LESetScanParameters) error {
h.params.scanParams = param
return nil
}
// SetAdvParams overrides default advertising parameters.
func (h *HCI) SetAdvParams(param cmd.LESetAdvertisingParameters) error {
h.params.advParams = param
return nil
}
// SetPeripheralRole is not supported
func (h *HCI) SetPeripheralRole() error {
return errors.New("Not supported")
......
......@@ -12,6 +12,8 @@ type DeviceOption interface {
SetDialerTimeout(time.Duration) error
SetListenerTimeout(time.Duration) error
SetConnParams(cmd.LECreateConnection) error
SetScanParams(cmd.LESetScanParameters) error
SetAdvParams(cmd.LESetAdvertisingParameters) error
SetPeripheralRole() error
SetCentralRole() error
}
......@@ -51,6 +53,22 @@ func OptConnParams(param cmd.LECreateConnection) Option {
}
}
// OptScanParams overrides default scanning parameters.
func OptScanParams(param cmd.LESetScanParameters) Option {
return func(opt DeviceOption) error {
opt.SetScanParams(param)
return nil
}
}
// OptAdvParams overrides default advertising parameters.
func OptAdvParams(param cmd.LESetAdvertisingParameters) Option {
return func(opt DeviceOption) error {
opt.SetAdvParams(param)
return nil
}
}
// OptPeripheralRole configures the device to perform Peripheral tasks.
func OptPeripheralRole() Option {
return func(opt DeviceOption) error {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment