core: Refactor BLE platform for new Adaptor/Driver creation signatures

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram 2016-09-25 20:14:05 +02:00
parent 3119824a5e
commit 11fded18d5
6 changed files with 104 additions and 106 deletions

View File

@ -6,41 +6,41 @@ import (
"github.com/hybridgroup/gobot"
)
var _ gobot.Driver = (*BLEBatteryDriver)(nil)
var _ gobot.Driver = (*BatteryDriver)(nil)
type BLEBatteryDriver struct {
type BatteryDriver struct {
name string
connection gobot.Connection
gobot.Eventer
}
// NewBLEBatteryDriver creates a BLEBatteryDriver by name
func NewBLEBatteryDriver(a *BLEClientAdaptor, name string) *BLEBatteryDriver {
n := &BLEBatteryDriver{
name: name,
// NewBatteryDriver creates a BatteryDriver
func NewBatteryDriver(a *ClientAdaptor, name string) *BatteryDriver {
n := &BatteryDriver{
connection: a,
Eventer: gobot.NewEventer(),
}
return n
}
func (b *BLEBatteryDriver) Connection() gobot.Connection { return b.connection }
func (b *BLEBatteryDriver) Name() string { return b.name }
func (b *BatteryDriver) Connection() gobot.Connection { return b.connection }
func (b *BatteryDriver) Name() string { return b.name }
func (b *BatteryDriver) SetName(n string) { b.name = n }
// adaptor returns BLE adaptor
func (b *BLEBatteryDriver) adaptor() *BLEClientAdaptor {
return b.Connection().(*BLEClientAdaptor)
func (b *BatteryDriver) adaptor() *ClientAdaptor {
return b.Connection().(*ClientAdaptor)
}
// Start tells driver to get ready to do work
func (b *BLEBatteryDriver) Start() (errs []error) {
func (b *BatteryDriver) Start() (errs []error) {
return
}
// Halt stops battery driver (void)
func (b *BLEBatteryDriver) Halt() (errs []error) { return }
func (b *BatteryDriver) Halt() (errs []error) { return }
func (b *BLEBatteryDriver) GetBatteryLevel() (level uint8) {
func (b *BatteryDriver) GetBatteryLevel() (level uint8) {
var l uint8
c, _ := b.adaptor().ReadCharacteristic("180f", "2a19")
buf := bytes.NewBuffer(c)

View File

@ -9,36 +9,36 @@ import (
"github.com/hybridgroup/gobot"
)
var _ gobot.Adaptor = (*BLEClientAdaptor)(nil)
var _ gobot.Adaptor = (*ClientAdaptor)(nil)
// Represents a Client Connection to a BLE Peripheral
type BLEClientAdaptor struct {
type ClientAdaptor struct {
name string
uuid string
device gatt.Device
peripheral gatt.Peripheral
services map[string]*BLEService
services map[string]*Service
connected bool
ready chan struct{}
}
// NewBLEClientAdaptor returns a new BLEClientAdaptor given a name and uuid
func NewBLEClientAdaptor(name string, uuid string) *BLEClientAdaptor {
return &BLEClientAdaptor{
name: name,
// NewClientAdaptor returns a new ClientAdaptor given a uuid
func NewClientAdaptor(uuid string) *ClientAdaptor {
return &ClientAdaptor{
uuid: uuid,
connected: false,
ready: make(chan struct{}),
services: make(map[string]*BLEService),
services: make(map[string]*Service),
}
}
func (b *BLEClientAdaptor) Name() string { return b.name }
func (b *BLEClientAdaptor) UUID() string { return b.uuid }
func (b *BLEClientAdaptor) Peripheral() gatt.Peripheral { return b.peripheral }
func (b *ClientAdaptor) Name() string { return b.name }
func (b *ClientAdaptor) SetName(n string) { b.name = n }
func (b *ClientAdaptor) UUID() string { return b.uuid }
func (b *ClientAdaptor) Peripheral() gatt.Peripheral { return b.peripheral }
// Connect initiates a connection to the BLE peripheral. Returns true on successful connection.
func (b *BLEClientAdaptor) Connect() (errs []error) {
func (b *ClientAdaptor) Connect() (errs []error) {
device, err := gatt.NewDevice(DefaultClientOptions...)
if err != nil {
log.Fatalf("Failed to open BLE device, err: %s\n", err)
@ -63,7 +63,7 @@ func (b *BLEClientAdaptor) Connect() (errs []error) {
// Reconnect attempts to reconnect to the BLE peripheral. If it has an active connection
// it will first close that connection and then establish a new connection.
// Returns true on Successful reconnection
func (b *BLEClientAdaptor) Reconnect() (errs []error) {
func (b *ClientAdaptor) Reconnect() (errs []error) {
if b.connected {
b.Disconnect()
}
@ -71,20 +71,20 @@ func (b *BLEClientAdaptor) Reconnect() (errs []error) {
}
// Disconnect terminates the connection to the BLE peripheral. Returns true on successful disconnect.
func (b *BLEClientAdaptor) Disconnect() (errs []error) {
func (b *ClientAdaptor) Disconnect() (errs []error) {
b.peripheral.Device().CancelConnection(b.peripheral)
return
}
// Finalize finalizes the BLEAdaptor
func (b *BLEClientAdaptor) Finalize() (errs []error) {
func (b *ClientAdaptor) Finalize() (errs []error) {
return b.Disconnect()
}
// ReadCharacteristic returns bytes from the BLE device for the
// requested service and characteristic
func (b *BLEClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data []byte, err error) {
func (b *ClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data []byte, err error) {
if !b.connected {
log.Fatalf("Cannot read from BLE device until connected")
return
@ -107,7 +107,7 @@ func (b *BLEClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data
// WriteCharacteristic writes bytes to the BLE device for the
// requested service and characteristic
func (b *BLEClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data []byte) (err error) {
func (b *ClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data []byte) (err error) {
if !b.connected {
log.Fatalf("Cannot write to BLE device until connected")
return
@ -130,7 +130,7 @@ func (b *BLEClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data
// Subscribe subscribes to notifications from the BLE device for the
// requested service and characteristic
func (b *BLEClientAdaptor) Subscribe(sUUID string, cUUID string, f func([]byte, error)) (err error) {
func (b *ClientAdaptor) Subscribe(sUUID string, cUUID string, f func([]byte, error)) (err error) {
if !b.connected {
log.Fatalf("Cannot subscribe to BLE device until connected")
return
@ -155,7 +155,7 @@ func (b *BLEClientAdaptor) Subscribe(sUUID string, cUUID string, f func([]byte,
return
}
func (b *BLEClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State) {
func (b *ClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State) {
fmt.Println("State:", s)
switch s {
case gatt.StatePoweredOn:
@ -167,7 +167,7 @@ func (b *BLEClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State) {
}
}
func (b *BLEClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int) {
func (b *ClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int) {
// try looking by local name
if a.LocalName == b.UUID() {
b.uuid = p.ID()
@ -186,7 +186,7 @@ func (b *BLEClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertise
p.Device().Connect(p)
}
func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) {
func (b *ClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) {
fmt.Printf("\nConnected Peripheral ID:%s, NAME:(%s)\n", p.ID(), p.Name())
b.peripheral = p
@ -203,7 +203,7 @@ func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error) {
outer:
for _, s := range ss {
b.services[s.UUID().String()] = NewBLEService(s.UUID().String(), s)
b.services[s.UUID().String()] = NewService(s.UUID().String(), s)
cs, err := p.DiscoverCharacteristics(nil, s)
if err != nil {
@ -225,12 +225,12 @@ outer:
close(b.ready)
}
func (b *BLEClientAdaptor) DisconnectHandler(p gatt.Peripheral, err error) {
func (b *ClientAdaptor) DisconnectHandler(p gatt.Peripheral, err error) {
fmt.Println("Disconnected")
}
// Finalize finalizes the BLEAdaptor
func (b *BLEClientAdaptor) lookupCharacteristic(sUUID string, cUUID string) *gatt.Characteristic {
// Finalize finalizes the ClientAdaptor
func (b *ClientAdaptor) lookupCharacteristic(sUUID string, cUUID string) *gatt.Characteristic {
service := b.services[sUUID]
if service == nil {
log.Printf("Unknown service ID: %s\n", sUUID)
@ -247,15 +247,15 @@ func (b *BLEClientAdaptor) lookupCharacteristic(sUUID string, cUUID string) *gat
}
// Represents a BLE Peripheral's Service
type BLEService struct {
type Service struct {
uuid string
service *gatt.Service
characteristics map[string]*gatt.Characteristic
}
// NewBLEAdaptor returns a new BLEService given a uuid
func NewBLEService(sUuid string, service *gatt.Service) *BLEService {
return &BLEService{
// NewService returns a new BLE Service given a uuid
func NewService(sUuid string, service *gatt.Service) *Service {
return &Service{
uuid: sUuid,
service: service,
characteristics: make(map[string]*gatt.Characteristic),

View File

@ -6,13 +6,12 @@ import (
"github.com/hybridgroup/gobot/gobottest"
)
func initTestBLEClientAdaptor() *BLEClientAdaptor {
a := NewBLEClientAdaptor("bot", "D7:99:5A:26:EC:38")
func initTestBLEClientAdaptor() *ClientAdaptor {
a := NewClientAdaptor("D7:99:5A:26:EC:38")
return a
}
func TestBLEClientAdaptor(t *testing.T) {
a := NewBLEClientAdaptor("bot", "D7:99:5A:26:EC:38")
gobottest.Assert(t, a.Name(), "bot")
a := NewClientAdaptor("D7:99:5A:26:EC:38")
gobottest.Assert(t, a.UUID(), "D7:99:5A:26:EC:38")
}

View File

@ -9,9 +9,9 @@ import (
"github.com/hybridgroup/gobot"
)
var _ gobot.Driver = (*BLEMinidroneDriver)(nil)
var _ gobot.Driver = (*MinidroneDriver)(nil)
type BLEMinidroneDriver struct {
type MinidroneDriver struct {
name string
connection gobot.Connection
stepsfa0a uint16
@ -64,10 +64,9 @@ func validatePitch(val int) int {
return val
}
// NewBLEMinidroneDriver creates a BLEMinidroneDriver by name
func NewBLEMinidroneDriver(a *BLEClientAdaptor, name string) *BLEMinidroneDriver {
n := &BLEMinidroneDriver{
name: name,
// NewMinidroneDriver creates a MinidroneDriver
func NewMinidroneDriver(a *ClientAdaptor) *MinidroneDriver {
n := &MinidroneDriver{
connection: a,
Pcmd: Pcmd{
Flag: 0,
@ -87,16 +86,17 @@ func NewBLEMinidroneDriver(a *BLEClientAdaptor, name string) *BLEMinidroneDriver
return n
}
func (b *BLEMinidroneDriver) Connection() gobot.Connection { return b.connection }
func (b *BLEMinidroneDriver) Name() string { return b.name }
func (b *MinidroneDriver) Connection() gobot.Connection { return b.connection }
func (b *MinidroneDriver) Name() string { return b.name }
func (b *MinidroneDriver) SetName(n string) { b.name = n }
// adaptor returns BLE adaptor
func (b *BLEMinidroneDriver) adaptor() *BLEClientAdaptor {
return b.Connection().(*BLEClientAdaptor)
func (b *MinidroneDriver) adaptor() *ClientAdaptor {
return b.Connection().(*ClientAdaptor)
}
// Start tells driver to get ready to do work
func (b *BLEMinidroneDriver) Start() (errs []error) {
func (b *MinidroneDriver) Start() (errs []error) {
b.Init()
b.FlatTrim()
b.StartPcmd()
@ -106,14 +106,14 @@ func (b *BLEMinidroneDriver) Start() (errs []error) {
}
// Halt stops minidrone driver (void)
func (b *BLEMinidroneDriver) Halt() (errs []error) {
func (b *MinidroneDriver) Halt() (errs []error) {
b.Land()
<-time.After(500 * time.Millisecond)
return
}
func (b *BLEMinidroneDriver) Init() (err error) {
func (b *MinidroneDriver) Init() (err error) {
b.GenerateAllStates()
// subscribe to battery notifications
@ -140,7 +140,7 @@ func (b *BLEMinidroneDriver) Init() (err error) {
return
}
func (b *BLEMinidroneDriver) GenerateAllStates() (err error) {
func (b *MinidroneDriver) GenerateAllStates() (err error) {
b.stepsfa0b++
buf := []byte{0x04, byte(b.stepsfa0b), 0x00, 0x04, 0x01, 0x00, 0x32, 0x30, 0x31, 0x34, 0x2D, 0x31, 0x30, 0x2D, 0x32, 0x38, 0x00}
err = b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, buf)
@ -152,7 +152,7 @@ func (b *BLEMinidroneDriver) GenerateAllStates() (err error) {
return
}
func (b *BLEMinidroneDriver) TakeOff() (err error) {
func (b *MinidroneDriver) TakeOff() (err error) {
b.stepsfa0b++
buf := []byte{0x02, byte(b.stepsfa0b) & 0xff, 0x02, 0x00, 0x01, 0x00}
err = b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, buf)
@ -164,7 +164,7 @@ func (b *BLEMinidroneDriver) TakeOff() (err error) {
return
}
func (b *BLEMinidroneDriver) Land() (err error) {
func (b *MinidroneDriver) Land() (err error) {
b.stepsfa0b++
buf := []byte{0x02, byte(b.stepsfa0b), 0x02, 0x00, 0x03, 0x00}
err = b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, buf)
@ -172,7 +172,7 @@ func (b *BLEMinidroneDriver) Land() (err error) {
return err
}
func (b *BLEMinidroneDriver) FlatTrim() (err error) {
func (b *MinidroneDriver) FlatTrim() (err error) {
b.stepsfa0b++
buf := []byte{0x02, byte(b.stepsfa0b) & 0xff, 0x02, 0x00, 0x00, 0x00}
err = b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, buf)
@ -180,7 +180,7 @@ func (b *BLEMinidroneDriver) FlatTrim() (err error) {
return err
}
func (b *BLEMinidroneDriver) StartPcmd() {
func (b *MinidroneDriver) StartPcmd() {
go func() {
// wait a little bit so that there is enough time to get some ACKs
<-time.After(500 * time.Millisecond)
@ -194,55 +194,55 @@ func (b *BLEMinidroneDriver) StartPcmd() {
}()
}
func (b *BLEMinidroneDriver) Up(val int) error {
func (b *MinidroneDriver) Up(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Gaz = validatePitch(val)
return nil
}
func (b *BLEMinidroneDriver) Down(val int) error {
func (b *MinidroneDriver) Down(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Gaz = validatePitch(val) * -1
return nil
}
func (b *BLEMinidroneDriver) Forward(val int) error {
func (b *MinidroneDriver) Forward(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Pitch = validatePitch(val)
return nil
}
func (b *BLEMinidroneDriver) Backward(val int) error {
func (b *MinidroneDriver) Backward(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Pitch = validatePitch(val) * -1
return nil
}
func (b *BLEMinidroneDriver) Right(val int) error {
func (b *MinidroneDriver) Right(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Roll = validatePitch(val)
return nil
}
func (b *BLEMinidroneDriver) Left(val int) error {
func (b *MinidroneDriver) Left(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Roll = validatePitch(val) * -1
return nil
}
func (b *BLEMinidroneDriver) Clockwise(val int) error {
func (b *MinidroneDriver) Clockwise(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Yaw = validatePitch(val)
return nil
}
func (b *BLEMinidroneDriver) CounterClockwise(val int) error {
func (b *MinidroneDriver) CounterClockwise(val int) error {
b.Pcmd.Flag = 1
b.Pcmd.Yaw = validatePitch(val) * -1
return nil
}
func (b *BLEMinidroneDriver) Stop() error {
func (b *MinidroneDriver) Stop() error {
b.Pcmd = Pcmd{
Flag: 0,
Roll: 0,
@ -256,48 +256,48 @@ func (b *BLEMinidroneDriver) Stop() error {
}
// StartRecording not supported
func (b *BLEMinidroneDriver) StartRecording() error {
func (b *MinidroneDriver) StartRecording() error {
return nil
}
// StopRecording not supported
func (b *BLEMinidroneDriver) StopRecording() error {
func (b *MinidroneDriver) StopRecording() error {
return nil
}
// HullProtection not supported
func (b *BLEMinidroneDriver) HullProtection(protect bool) error {
func (b *MinidroneDriver) HullProtection(protect bool) error {
return nil
}
// Outdoor not supported
func (b *BLEMinidroneDriver) Outdoor(outdoor bool) error {
func (b *MinidroneDriver) Outdoor(outdoor bool) error {
return nil
}
func (b *BLEMinidroneDriver) FrontFlip() (err error) {
func (b *MinidroneDriver) FrontFlip() (err error) {
return b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, b.generateAnimation(0).Bytes())
}
func (b *BLEMinidroneDriver) BackFlip() (err error) {
func (b *MinidroneDriver) BackFlip() (err error) {
return b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, b.generateAnimation(1).Bytes())
}
func (b *BLEMinidroneDriver) RightFlip() (err error) {
func (b *MinidroneDriver) RightFlip() (err error) {
return b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, b.generateAnimation(2).Bytes())
}
func (b *BLEMinidroneDriver) LeftFlip() (err error) {
func (b *MinidroneDriver) LeftFlip() (err error) {
return b.adaptor().WriteCharacteristic(DroneCommandService, CommandCharacteristic, b.generateAnimation(3).Bytes())
}
func (b *BLEMinidroneDriver) generateAnimation(direction int8) *bytes.Buffer {
func (b *MinidroneDriver) generateAnimation(direction int8) *bytes.Buffer {
b.stepsfa0b++
buf := []byte{0x02, byte(b.stepsfa0b) & 0xff, 0x02, 0x04, 0x00, 0x00, byte(direction), 0x00, 0x00, 0x00}
return bytes.NewBuffer(buf)
}
func (b *BLEMinidroneDriver) generatePcmd() *bytes.Buffer {
func (b *MinidroneDriver) generatePcmd() *bytes.Buffer {
b.stepsfa0a++
cmd := &bytes.Buffer{}

View File

@ -6,70 +6,69 @@ import (
"github.com/hybridgroup/gobot"
)
var _ gobot.Driver = (*BLEDeviceInformationDriver)(nil)
var _ gobot.Driver = (*DeviceInformationDriver)(nil)
type BLEDeviceInformationDriver struct {
type DeviceInformationDriver struct {
name string
connection gobot.Connection
gobot.Eventer
}
// NewBLEDeviceInformationDriver creates a BLEDeviceInformationDriver
// by name
func NewBLEDeviceInformationDriver(a *BLEClientAdaptor, name string) *BLEDeviceInformationDriver {
n := &BLEDeviceInformationDriver{
name: name,
// NewDeviceInformationDriver creates a DeviceInformationDriver
func NewDeviceInformationDriver(a *ClientAdaptor) *DeviceInformationDriver {
n := &DeviceInformationDriver{
connection: a,
Eventer: gobot.NewEventer(),
}
return n
}
func (b *BLEDeviceInformationDriver) Connection() gobot.Connection { return b.connection }
func (b *BLEDeviceInformationDriver) Name() string { return b.name }
func (b *DeviceInformationDriver) Connection() gobot.Connection { return b.connection }
func (b *DeviceInformationDriver) Name() string { return b.name }
func (b *DeviceInformationDriver) SetName(n string) { b.name = n }
// adaptor returns BLE adaptor for this device
func (b *BLEDeviceInformationDriver) adaptor() *BLEClientAdaptor {
return b.Connection().(*BLEClientAdaptor)
func (b *DeviceInformationDriver) adaptor() *ClientAdaptor {
return b.Connection().(*ClientAdaptor)
}
// Start tells driver to get ready to do work
func (b *BLEDeviceInformationDriver) Start() (errs []error) {
func (b *DeviceInformationDriver) Start() (errs []error) {
return
}
// Halt stops driver (void)
func (b *BLEDeviceInformationDriver) Halt() (errs []error) { return }
func (b *DeviceInformationDriver) Halt() (errs []error) { return }
func (b *BLEDeviceInformationDriver) GetModelNumber() (model string) {
func (b *DeviceInformationDriver) GetModelNumber() (model string) {
c, _ := b.adaptor().ReadCharacteristic("180a", "2a24")
buf := bytes.NewBuffer(c)
val := buf.String()
return val
}
func (b *BLEDeviceInformationDriver) GetFirmwareRevision() (revision string) {
func (b *DeviceInformationDriver) GetFirmwareRevision() (revision string) {
c, _ := b.adaptor().ReadCharacteristic("180a", "2a26")
buf := bytes.NewBuffer(c)
val := buf.String()
return val
}
func (b *BLEDeviceInformationDriver) GetHardwareRevision() (revision string) {
func (b *DeviceInformationDriver) GetHardwareRevision() (revision string) {
c, _ := b.adaptor().ReadCharacteristic("180a", "2a27")
buf := bytes.NewBuffer(c)
val := buf.String()
return val
}
func (b *BLEDeviceInformationDriver) GetManufacturerName() (manufacturer string) {
func (b *DeviceInformationDriver) GetManufacturerName() (manufacturer string) {
c, _ := b.adaptor().ReadCharacteristic("180a", "2a29")
buf := bytes.NewBuffer(c)
val := buf.String()
return val
}
func (b *BLEDeviceInformationDriver) GetPnPId() (model string) {
func (b *DeviceInformationDriver) GetPnPId() (model string) {
c, _ := b.adaptor().ReadCharacteristic("180a", "2a50")
buf := bytes.NewBuffer(c)
val := buf.String()

View File

@ -43,10 +43,9 @@ type packet struct {
checksum uint8
}
// NewSpheroOllieDriver creates a SpheroOllieDriver by name
func NewSpheroOllieDriver(a *BLEClientAdaptor, name string) *SpheroOllieDriver {
// NewSpheroOllieDriver creates a SpheroOllieDriver
func NewSpheroOllieDriver(a *ClientAdaptor) *SpheroOllieDriver {
n := &SpheroOllieDriver{
name: name,
connection: a,
Eventer: gobot.NewEventer(),
packetChannel: make(chan *packet, 1024),
@ -56,10 +55,11 @@ func NewSpheroOllieDriver(a *BLEClientAdaptor, name string) *SpheroOllieDriver {
}
func (b *SpheroOllieDriver) Connection() gobot.Connection { return b.connection }
func (b *SpheroOllieDriver) Name() string { return b.name }
func (b *SpheroOllieDriver) SetName(n string) { b.name = n }
// adaptor returns BLE adaptor
func (b *SpheroOllieDriver) adaptor() *BLEClientAdaptor {
return b.Connection().(*BLEClientAdaptor)
func (b *SpheroOllieDriver) adaptor() *ClientAdaptor {
return b.Connection().(*ClientAdaptor)
}
// Start tells driver to get ready to do work