Skip to content

Commit

Permalink
ble: use new improved default namer to avoid API conflicts
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Feb 2, 2017
1 parent 3be7c49 commit ddb889a
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion platforms/ble/battery_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type BatteryDriver struct {
// NewBatteryDriver creates a BatteryDriver
func NewBatteryDriver(a *ClientAdaptor) *BatteryDriver {
n := &BatteryDriver{
name: "Battery",
name: gobot.DefaultName("Battery"),
connection: a,
Eventer: gobot.NewEventer(),
}
Expand Down
3 changes: 2 additions & 1 deletion platforms/ble/battery_driver_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ble

import (
"strings"
"testing"

"gobot.io/x/gobot"
Expand All @@ -16,5 +17,5 @@ func initTestBatteryDriver() *BatteryDriver {

func TestBatteryDriver(t *testing.T) {
d := initTestBatteryDriver()
gobottest.Assert(t, d.Name(), "Battery")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Battery"), true)
}
4 changes: 3 additions & 1 deletion platforms/ble/ble_client_adaptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import (
"strings"
"time"

"gobot.io/x/gobot"

blelib "github.com/currantlabs/ble"
"github.com/pkg/errors"
)
Expand All @@ -32,7 +34,7 @@ type ClientAdaptor struct {
// NewClientAdaptor returns a new ClientAdaptor given an address or peripheral name
func NewClientAdaptor(address string) *ClientAdaptor {
return &ClientAdaptor{
name: "BLECLient",
name: gobot.DefaultName("BLEClient"),
address: address,
connected: false,
}
Expand Down
3 changes: 2 additions & 1 deletion platforms/ble/ble_client_adaptor_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ble

import (
"strings"
"testing"

"gobot.io/x/gobot"
Expand All @@ -17,7 +18,7 @@ func initTestBLEClientAdaptor() *ClientAdaptor {
func TestBLEClientAdaptor(t *testing.T) {
a := NewClientAdaptor("D7:99:5A:26:EC:38")
gobottest.Assert(t, a.Address(), "D7:99:5A:26:EC:38")
gobottest.Assert(t, a.Name(), "BLECLient")
gobottest.Assert(t, strings.HasPrefix(a.Name(), "BLEClient"), true)
}

func TestBLEClientAdaptorName(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion platforms/ble/device_information_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type DeviceInformationDriver struct {
// NewDeviceInformationDriver creates a DeviceInformationDriver
func NewDeviceInformationDriver(a *ClientAdaptor) *DeviceInformationDriver {
n := &DeviceInformationDriver{
name: "DeviceInformation",
name: gobot.DefaultName("DeviceInformation"),
connection: a,
Eventer: gobot.NewEventer(),
}
Expand Down
3 changes: 2 additions & 1 deletion platforms/ble/device_information_driver_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ble

import (
"strings"
"testing"

"gobot.io/x/gobot"
Expand All @@ -16,5 +17,5 @@ func initTestDeviceInformationDriver() *DeviceInformationDriver {

func TestDeviceInformationDriver(t *testing.T) {
d := initTestDeviceInformationDriver()
gobottest.Assert(t, d.Name(), "DeviceInformation")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "DeviceInformation"), true)
}
2 changes: 1 addition & 1 deletion platforms/ble/generic_access_driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type GenericAccessDriver struct {
// NewGenericAccessDriver creates a GenericAccessDriver
func NewGenericAccessDriver(a *ClientAdaptor) *GenericAccessDriver {
n := &GenericAccessDriver{
name: "GenericAccess",
name: gobot.DefaultName("GenericAccess"),
connection: a,
Eventer: gobot.NewEventer(),
}
Expand Down
3 changes: 2 additions & 1 deletion platforms/ble/generic_access_driver_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ble

import (
"strings"
"testing"

"gobot.io/x/gobot"
Expand All @@ -16,5 +17,5 @@ func initTestGenericAccessDriver() *GenericAccessDriver {

func TestGenericAccessDriver(t *testing.T) {
d := initTestGenericAccessDriver()
gobottest.Assert(t, d.Name(), "GenericAccess")
gobottest.Assert(t, strings.HasPrefix(d.Name(), "GenericAccess"), true)
}

0 comments on commit ddb889a

Please sign in to comment.