Skip to content

Commit

Permalink
Add LnxSetScanParameters to allow setting scan parameters of device
Browse files Browse the repository at this point in the history
  • Loading branch information
mwohlert committed Apr 22, 2021
1 parent 7a3c1c5 commit 5e87537
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
9 changes: 9 additions & 0 deletions option_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ func LnxSetAdvertisingParameters(c *cmd.LESetAdvertisingParameters) Option {
}
}

// LnxSetScanParameters sets the scan parameters to the HCI device.
// This option can be used with NewDevice or Option on Linux implementation.
func LnxSetScanParameters(c *cmd.LESetScanParameters) Option {
return func(d Device) error {
d.(*device).scanParam = c
return nil
}
}

// LnxSendHCIRawCommand sends a raw command to the HCI device
// This option can be used with NewDevice or Option on Linux implementation.
func LnxSendHCIRawCommand(c cmd.CmdParam, rsp io.Writer) Option {
Expand Down
13 changes: 13 additions & 0 deletions option_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,19 @@ func ExampleLnxSetAdvertisingParameters() {
d.Option(o) // Or dynamically with Option.
}

func ExampleLnxSetScanParameters() {
o := LnxSetScanParameters(&cmd.LESetScanParameters{
LEScanType: 0x01, // [0x00]: passive, 0x01: active
LEScanInterval: 0x0010, // [0x10]: 0.625ms * 16
LEScanWindow: 0x0010, // [0x10]: 0.625ms * 16
OwnAddressType: 0x00, // [0x00]: public, 0x01: random
ScanningFilterPolicy: 0x00, // [0x00]: accept all, 0x01: ignore non-white-listed.
})

d, _ := NewDevice(o) // Can be used with NewDevice.
d.Option(o) // Or dynamically with Option.
}

func ExampleLnxSendHCIRawCommand_predefinedCommand() {
// Send a predefined command of cmd package.
c := &cmd.LESetScanResponseData{
Expand Down

0 comments on commit 5e87537

Please sign in to comment.