remedying issue caused by go mod tidy, improper/temporary fix

this is not how you're supposed to use git
This commit is contained in:
kayos 2021-05-12 16:28:17 -07:00
parent ad3f615a71
commit 32763a515e
7 changed files with 61 additions and 26 deletions

5
go.sum

@ -125,6 +125,7 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
@ -148,6 +149,7 @@ github.com/muka/go-bluetooth v0.0.0-20200619025933-f6113f7141c5/go.mod h1:yV39+E
github.com/muka/go-bluetooth v0.0.0-20201211051136-07f31c601d33 h1:p3srutpE8TpQmOUQ5Qw94jYFUdoG2jBbILeYLroQNoI= github.com/muka/go-bluetooth v0.0.0-20201211051136-07f31c601d33 h1:p3srutpE8TpQmOUQ5Qw94jYFUdoG2jBbILeYLroQNoI=
github.com/muka/go-bluetooth v0.0.0-20201211051136-07f31c601d33/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0= github.com/muka/go-bluetooth v0.0.0-20201211051136-07f31c601d33/go.mod h1:dMCjicU6vRBk34dqOmIZm0aod6gUwZXOXzBROqGous0=
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e h1:fD57ERR4JtEqsWbfPhv4DMiApHyliiK5xCTNVSPiaAs=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U= github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn4U=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
@ -216,7 +218,6 @@ github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoH
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY= github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
@ -381,6 +382,7 @@ google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ij
gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f h1:BLraFXnmrev5lT+xlilqcH8XK9/i0At2xKjWk4p6zsU=
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.51.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
@ -392,7 +394,6 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

@ -8,10 +8,9 @@ import (
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log" "github.com/rs/zerolog/log"
"tinygo.org/x/bluetooth"
"time" "time"
"tinygo.org/x/bluetooth"
) )
type Meta struct { type Meta struct {

@ -12,7 +12,7 @@ import (
type Adapter struct { type Adapter struct {
adapter *adapter.Adapter1 adapter *adapter.Adapter1
id string ID string
cancelChan chan struct{} cancelChan chan struct{}
defaultAdvertisement *Advertisement defaultAdvertisement *Advertisement
@ -32,12 +32,12 @@ var DefaultAdapter = &Adapter{
// Enable configures the BLE stack. It must be called before any // Enable configures the BLE stack. It must be called before any
// Bluetooth-related calls (unless otherwise indicated). // Bluetooth-related calls (unless otherwise indicated).
func (a *Adapter) Enable() (err error) { func (a *Adapter) Enable() (err error) {
if a.id == "" { if a.ID == "" {
a.adapter, err = api.GetDefaultAdapter() a.adapter, err = api.GetDefaultAdapter()
if err != nil { if err != nil {
return return
} }
a.id, err = a.adapter.GetAdapterID() a.ID, err = a.adapter.GetAdapterID()
} }
return nil return nil
} }

64
vendor/tinygo.org/x/bluetooth/gap.go generated vendored

@ -123,6 +123,9 @@ type AdvertisementPayload interface {
// UUIDs and 128-bit UUIDs. // UUIDs and 128-bit UUIDs.
HasServiceUUID(UUID) bool HasServiceUUID(UUID) bool
//Optputs what i think is the raw data packet
ServiceUUIDOut() []UUID
// Bytes returns the raw advertisement packet, if available. It returns nil // Bytes returns the raw advertisement packet, if available. It returns nil
// if this data is not available. // if this data is not available.
Bytes() []byte Bytes() []byte
@ -164,6 +167,16 @@ func (p *advertisementFields) HasServiceUUID(uuid UUID) bool {
return false return false
} }
func (p *advertisementFields) ServiceUUIDOut() []UUID {
return p.AdvertisementFields.ServiceUUIDs
}
/*
func (p *advertisementFields) ServiceUUIDOut() []UUID {
return p.AdvertisementFields.ServiceUUIDs
}
*/
// Bytes returns nil, as structured advertisement data does not have the // Bytes returns nil, as structured advertisement data does not have the
// original raw advertisement data available. // original raw advertisement data available.
func (p *advertisementFields) Bytes() []byte { func (p *advertisementFields) Bytes() []byte {
@ -174,13 +187,13 @@ func (p *advertisementFields) Bytes() []byte {
// get the data (such as LocalName()) will parse just the needed field. Scanning // get the data (such as LocalName()) will parse just the needed field. Scanning
// the data should be fast as most advertisement packets only have a very small // the data should be fast as most advertisement packets only have a very small
// (3 or so) amount of fields. // (3 or so) amount of fields.
type rawAdvertisementPayload struct { type RawAdvertisementPayload struct {
data [31]byte data [31]byte
len uint8 len uint8
} }
// Bytes returns the raw advertisement packet as a byte slice. // Bytes returns the raw advertisement packet as a byte slice.
func (buf *rawAdvertisementPayload) Bytes() []byte { func (buf *RawAdvertisementPayload) Bytes() []byte {
return buf.data[:buf.len] return buf.data[:buf.len]
} }
@ -188,7 +201,7 @@ func (buf *rawAdvertisementPayload) Bytes() []byte {
// //
// See this list of field types: // See this list of field types:
// https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/ // https://www.bluetooth.com/specifications/assigned-numbers/generic-access-profile/
func (buf *rawAdvertisementPayload) findField(fieldType byte) []byte { func (buf *RawAdvertisementPayload) FindField(fieldType byte) []byte {
data := buf.Bytes() data := buf.Bytes()
for len(data) >= 2 { for len(data) >= 2 {
fieldLength := data[0] fieldLength := data[0]
@ -206,12 +219,12 @@ func (buf *rawAdvertisementPayload) findField(fieldType byte) []byte {
// LocalName returns the local name (complete or shortened) in the advertisement // LocalName returns the local name (complete or shortened) in the advertisement
// payload. // payload.
func (buf *rawAdvertisementPayload) LocalName() string { func (buf *RawAdvertisementPayload) LocalName() string {
b := buf.findField(9) // Complete Local Name b := buf.FindField(9) // Complete Local Name
if len(b) != 0 { if len(b) != 0 {
return string(b) return string(b)
} }
b = buf.findField(8) // Shortened Local Name b = buf.FindField(8) // Shortened Local Name
if len(b) != 0 { if len(b) != 0 {
return string(b) return string(b)
} }
@ -221,11 +234,11 @@ func (buf *rawAdvertisementPayload) LocalName() string {
// HasServiceUUID returns true whether the given UUID is present in the // HasServiceUUID returns true whether the given UUID is present in the
// advertisement payload as a Service Class UUID. It checks both 16-bit UUIDs // advertisement payload as a Service Class UUID. It checks both 16-bit UUIDs
// and 128-bit UUIDs. // and 128-bit UUIDs.
func (buf *rawAdvertisementPayload) HasServiceUUID(uuid UUID) bool { func (buf *RawAdvertisementPayload) HasServiceUUID(uuid UUID) bool {
if uuid.Is16Bit() { if uuid.Is16Bit() {
b := buf.findField(0x03) // Complete List of 16-bit Service Class UUIDs b := buf.FindField(0x03) // Complete List of 16-bit Service Class UUIDs
if len(b) == 0 { if len(b) == 0 {
b = buf.findField(0x02) // Incomplete List of 16-bit Service Class UUIDs b = buf.FindField(0x02) // Incomplete List of 16-bit Service Class UUIDs
} }
uuid := uuid.Get16Bit() uuid := uuid.Get16Bit()
for i := 0; i < len(b)/2; i++ { for i := 0; i < len(b)/2; i++ {
@ -236,9 +249,9 @@ func (buf *rawAdvertisementPayload) HasServiceUUID(uuid UUID) bool {
} }
return false return false
} else { } else {
b := buf.findField(0x07) // Complete List of 128-bit Service Class UUIDs b := buf.FindField(0x07) // Complete List of 128-bit Service Class UUIDs
if len(b) == 0 { if len(b) == 0 {
b = buf.findField(0x06) // Incomplete List of 128-bit Service Class UUIDs b = buf.FindField(0x06) // Incomplete List of 128-bit Service Class UUIDs
} }
uuidBuf1 := uuid.Bytes() uuidBuf1 := uuid.Bytes()
for i := 0; i < len(b)/16; i++ { for i := 0; i < len(b)/16; i++ {
@ -258,8 +271,27 @@ func (buf *rawAdvertisementPayload) HasServiceUUID(uuid UUID) bool {
} }
} }
/// Very dumb attempts at reworking this code ************************************************
var FUUID uint16
func (buf *RawAdvertisementPayload) FindServiceUUIDInfo(uuid UUID) uint16 {
if uuid.Is16Bit() {
b := buf.FindField(0x03) // Complete List of 16-bit Service Class UUIDs
if len(b) == 0 {
b = buf.FindField(0x02) // Incomplete List of 16-bit Service Class UUIDs
}
for i := 0; i < len(b)/2; i++ {
foundUUID := uint16(b[i*2]) | (uint16(b[i*2+1]) << 8)
FUUID = foundUUID
}
}
return FUUID
}
// reset restores this buffer to the original state. // reset restores this buffer to the original state.
func (buf *rawAdvertisementPayload) reset() { func (buf *RawAdvertisementPayload) reset() {
// The data is not reset (only the length), because with a zero length the // The data is not reset (only the length), because with a zero length the
// data is undefined. // data is undefined.
buf.len = 0 buf.len = 0
@ -268,7 +300,7 @@ func (buf *rawAdvertisementPayload) reset() {
// addFromOptions constructs a new advertisement payload (assumed to be empty // addFromOptions constructs a new advertisement payload (assumed to be empty
// before the call) from the advertisement options. It returns true if it fits, // before the call) from the advertisement options. It returns true if it fits,
// false otherwise. // false otherwise.
func (buf *rawAdvertisementPayload) addFromOptions(options AdvertisementOptions) (ok bool) { func (buf *RawAdvertisementPayload) addFromOptions(options AdvertisementOptions) (ok bool) {
buf.addFlags(0x06) buf.addFlags(0x06)
if options.LocalName != "" { if options.LocalName != "" {
if !buf.addCompleteLocalName(options.LocalName) { if !buf.addCompleteLocalName(options.LocalName) {
@ -290,7 +322,7 @@ func (buf *rawAdvertisementPayload) addFromOptions(options AdvertisementOptions)
// addFlags adds a flags field to the advertisement buffer. It returns true on // addFlags adds a flags field to the advertisement buffer. It returns true on
// success (the flags can be added) and false on failure. // success (the flags can be added) and false on failure.
func (buf *rawAdvertisementPayload) addFlags(flags byte) (ok bool) { func (buf *RawAdvertisementPayload) addFlags(flags byte) (ok bool) {
if int(buf.len)+3 > len(buf.data) { if int(buf.len)+3 > len(buf.data) {
return false // flags don't fit return false // flags don't fit
} }
@ -304,7 +336,7 @@ func (buf *rawAdvertisementPayload) addFlags(flags byte) (ok bool) {
// addCompleteLocalName adds the Complete Local Name field to the advertisement // addCompleteLocalName adds the Complete Local Name field to the advertisement
// buffer. It returns true on success (the name fits) and false on failure. // buffer. It returns true on success (the name fits) and false on failure.
func (buf *rawAdvertisementPayload) addCompleteLocalName(name string) (ok bool) { func (buf *RawAdvertisementPayload) addCompleteLocalName(name string) (ok bool) {
if int(buf.len)+len(name)+2 > len(buf.data) { if int(buf.len)+len(name)+2 > len(buf.data) {
return false // name doesn't fit return false // name doesn't fit
} }
@ -319,7 +351,7 @@ func (buf *rawAdvertisementPayload) addCompleteLocalName(name string) (ok bool)
// addServiceUUID adds a Service Class UUID (16-bit or 128-bit). It has // addServiceUUID adds a Service Class UUID (16-bit or 128-bit). It has
// currently only been designed for adding single UUIDs: multiple UUIDs are // currently only been designed for adding single UUIDs: multiple UUIDs are
// stored in separate fields without joining them together in one field. // stored in separate fields without joining them together in one field.
func (buf *rawAdvertisementPayload) addServiceUUID(uuid UUID) (ok bool) { func (buf *RawAdvertisementPayload) addServiceUUID(uuid UUID) (ok bool) {
// Don't bother with 32-bit UUID support, it doesn't seem to be used in // Don't bother with 32-bit UUID support, it doesn't seem to be used in
// practice. // practice.
if uuid.Is16Bit() { if uuid.Is16Bit() {

@ -59,7 +59,7 @@ func (a *Advertisement) Start() error {
if a.advertisement != nil { if a.advertisement != nil {
panic("todo: start advertisement a second time") panic("todo: start advertisement a second time")
} }
_, err := api.ExposeAdvertisement(a.adapter.id, a.properties, uint32(a.properties.Timeout)) _, err := api.ExposeAdvertisement(a.adapter.ID, a.properties, uint32(a.properties.Timeout))
if err != nil { if err != nil {
return err return err
} }
@ -219,6 +219,8 @@ func makeScanResult(props *device.Device1Properties) ScanResult {
serviceUUIDs = append(serviceUUIDs, parsedUUID) serviceUUIDs = append(serviceUUIDs, parsedUUID)
} }
//var ManufactuerData UUID
a := Address{MACAddress{MAC: addr}} a := Address{MACAddress{MAC: addr}}
a.SetRandom(props.AddressType == "random") a.SetRandom(props.AddressType == "random")

@ -39,6 +39,7 @@ func (s *DeviceService) UUID() UUID {
// services haven't been resolved yet) and uses this list of cached services. // services haven't been resolved yet) and uses this list of cached services.
func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) { func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
for { for {
resolved, err := d.device.GetServicesResolved() resolved, err := d.device.GetServicesResolved()
if err != nil { if err != nil {
return nil, err return nil, err
@ -47,7 +48,6 @@ func (d *Device) DiscoverServices(uuids []UUID) ([]DeviceService, error) {
break break
} }
// This is a terrible hack, but I couldn't find another way. // This is a terrible hack, but I couldn't find another way.
time.Sleep(50 * time.Millisecond) time.Sleep(50 * time.Millisecond)
} }
@ -245,3 +245,4 @@ func (c *DeviceCharacteristic) Read(data []byte) (int, error) {
copy(data, result) copy(data, result)
return len(result), nil return len(result), nil
} }

@ -18,7 +18,7 @@ type Characteristic struct {
// Service struct. // Service struct.
func (a *Adapter) AddService(s *Service) error { func (a *Adapter) AddService(s *Service) error {
app, err := service.NewApp(service.AppOptions{ app, err := service.NewApp(service.AppOptions{
AdapterID: a.id, AdapterID: a.ID,
}) })
if err != nil { if err != nil {
return err return err