Debian Codegraph @

option_linux.go

raw symbols SCIP
1 package gatt
2
3 import (
4 "errors"
5 "io"
6
7 "github.com/paypal/gatt/linux/cmd"
8 )
9
10 // LnxDeviceID specifies which HCI device to use.
11 // If n is set to -1, all the available HCI devices will be probed.
12 // If chk is set to true, LnxDeviceID checks the LE support in the feature list of the HCI device.
13 // This is to filter devices that does not support LE. In case some LE driver that doesn't correctly
14 // set the LE support in its feature list, user can turn off the check.
15 // This option can only be used with NewDevice on Linux implementation.
16 func LnxDeviceID(n int, chk bool) Option {
17 return func(d Device) error {
18 d.(*device).devID = n
19 d.(*device).chkLE = chk
20 return nil
21 }
22 }
23
24 // LnxMaxConnections is an optional parameter.
25 // If set, it overrides the default max connections supported.
26 // This option can only be used with NewDevice on Linux implementation.
27 func LnxMaxConnections(n int) Option {
28 return func(d Device) error {
29 d.(*device).maxConn = n
30 return nil
31 }
32 }
33
34 // LnxSetAdvertisingEnable sets the advertising data to the HCI device.
35 // This option can be used with Option on Linux implementation.
36 func LnxSetAdvertisingEnable(en bool) Option {
37 return func(d Device) error {
38 dd := d.(*device)
39 if dd == nil {
40 return errors.New("device is not initialized")
41 }
42 if err := dd.update(); err != nil {
43 return err
44 }
45 return dd.hci.SetAdvertiseEnable(en)
46 }
47 }
48
49 // LnxSetAdvertisingData sets the advertising data to the HCI device.
50 // This option can be used with NewDevice or Option on Linux implementation.
51 func LnxSetAdvertisingData(c *cmd.LESetAdvertisingData) Option {
52 return func(d Device) error {
53 d.(*device).advData = c
54 return nil
55 }
56 }
57
58 // LnxSetScanResponseData sets the scan response data to the HXI device.
59 // This option can be used with NewDevice or Option on Linux implementation.
60 func LnxSetScanResponseData(c *cmd.LESetScanResponseData) Option {
61 return func(d Device) error {
62 d.(*device).scanResp = c
63 return nil
64 }
65 }
66
67 // LnxSetAdvertisingParameters sets the advertising parameters to the HCI device.
68 // This option can be used with NewDevice or Option on Linux implementation.
69 func LnxSetAdvertisingParameters(c *cmd.LESetAdvertisingParameters) Option {
70 return func(d Device) error {
71 d.(*device).advParam = c
72 return nil
73 }
74 }
75
76 // LnxSendHCIRawCommand sends a raw command to the HCI device
77 // This option can be used with NewDevice or Option on Linux implementation.
78 func LnxSendHCIRawCommand(c cmd.CmdParam, rsp io.Writer) Option {
79 return func(d Device) error {
80 b, err := d.(*device).SendHCIRawCommand(c)
81 if rsp == nil {
82 return err
83 }
84 rsp.Write(b)
85 return err
86 }
87 }