/
factory.go
31 lines (23 loc) · 1.05 KB
/
factory.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Copyright 2016 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package ble
import "v.io/v23/context"
type DriverFactory func(ctx *context.T, host string) (Driver, error)
var (
driverFactory DriverFactory = newDummyDriver
)
type dummyDriver struct{}
func (dummyDriver) AddService(uuid string, characteristics map[string][]byte) error { return nil }
func (dummyDriver) RemoveService(uuid string) {}
func (dummyDriver) StartScan(uuids []string, baseUuid, maskUUid string, handler ScanHandler) error {
return nil
}
func (dummyDriver) StopScan() {}
func (dummyDriver) DebugString() string { return "BLE not available" }
func newDummyDriver(ctx *context.T, host string) (Driver, error) { return dummyDriver{}, nil }
// SetPluginFactory sets the plugin factory with the given name.
// This should be called before v23.NewDiscovery() is called.
func SetDriverFactory(factory DriverFactory) {
driverFactory = factory
}