ble: move new ble client device creation under Gobot's own control

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2017-01-14 12:57:37 +01:00
parent 82542abd68
commit 2568aedc17
3 changed files with 22 additions and 18 deletions

View File

@ -8,10 +8,14 @@ import (
"time" "time"
blelib "github.com/currantlabs/ble" blelib "github.com/currantlabs/ble"
"github.com/currantlabs/ble/examples/lib/dev"
"github.com/pkg/errors" "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 // ClientAdaptor represents a Client Connection to a BLE Peripheral
type ClientAdaptor struct { type ClientAdaptor struct {
name string 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. // Connect initiates a connection to the BLE peripheral. Returns true on successful connection.
func (b *ClientAdaptor) Connect() (err error) { func (b *ClientAdaptor) Connect() (err error) {
d, err := dev.NewDevice("default") d, err := newBLEDevice("default")
if err != nil { if err != nil {
return errors.Wrap(err, "can't new device") return errors.Wrap(err, "can't new device")
} }

View File

@ -1,9 +1,10 @@
package ble package ble
// import ( import (
// "github.com/currantlabs/gatt" blelib "github.com/currantlabs/ble"
// ) "github.com/currantlabs/ble/darwin"
// )
// var DefaultClientOptions = []gatt.Option{
// gatt.MacDeviceRole(gatt.CentralManager), func defaultDevice(impl string) (d blelib.Device, err error) {
// } return darwin.NewDevice()
}

View File

@ -1,11 +1,10 @@
package ble package ble
// import ( import (
// "github.com/currantlabs/gatt" blelib "github.com/currantlabs/ble"
// ) "github.com/currantlabs/ble/linux"
// )
// // TODO: handle other OS defaults besides Linux
// var DefaultClientOptions = []gatt.Option{ func defaultDevice(impl string) (d blelib.Device, err error) {
// gatt.LnxMaxConnections(1), return linux.NewDevice()
// gatt.LnxDeviceID(-1, false), }
// }