ble: move new ble client device creation under Gobot's own control
Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
parent
82542abd68
commit
2568aedc17
|
@ -8,10 +8,14 @@ import (
|
|||
"time"
|
||||
|
||||
blelib "github.com/currantlabs/ble"
|
||||
"github.com/currantlabs/ble/examples/lib/dev"
|
||||
"github.com/pkg/errors"
|
||||
)
|
||||
|
||||
// newBLEDevice is constructor about blelib HCI device connection
|
||||
func newBLEDevice(impl string) (d blelib.Device, err error) {
|
||||
return defaultDevice(impl)
|
||||
}
|
||||
|
||||
// ClientAdaptor represents a Client Connection to a BLE Peripheral
|
||||
type ClientAdaptor struct {
|
||||
name string
|
||||
|
@ -44,7 +48,7 @@ func (b *ClientAdaptor) Address() string { return b.address }
|
|||
|
||||
// Connect initiates a connection to the BLE peripheral. Returns true on successful connection.
|
||||
func (b *ClientAdaptor) Connect() (err error) {
|
||||
d, err := dev.NewDevice("default")
|
||||
d, err := newBLEDevice("default")
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "can't new device")
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
package ble
|
||||
|
||||
// import (
|
||||
// "github.com/currantlabs/gatt"
|
||||
// )
|
||||
//
|
||||
// var DefaultClientOptions = []gatt.Option{
|
||||
// gatt.MacDeviceRole(gatt.CentralManager),
|
||||
// }
|
||||
import (
|
||||
blelib "github.com/currantlabs/ble"
|
||||
"github.com/currantlabs/ble/darwin"
|
||||
)
|
||||
|
||||
func defaultDevice(impl string) (d blelib.Device, err error) {
|
||||
return darwin.NewDevice()
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
package ble
|
||||
|
||||
// import (
|
||||
// "github.com/currantlabs/gatt"
|
||||
// )
|
||||
//
|
||||
// // TODO: handle other OS defaults besides Linux
|
||||
// var DefaultClientOptions = []gatt.Option{
|
||||
// gatt.LnxMaxConnections(1),
|
||||
// gatt.LnxDeviceID(-1, false),
|
||||
// }
|
||||
import (
|
||||
blelib "github.com/currantlabs/ble"
|
||||
"github.com/currantlabs/ble/linux"
|
||||
)
|
||||
|
||||
func defaultDevice(impl string) (d blelib.Device, err error) {
|
||||
return linux.NewDevice()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue