Skip to content

Commit 564b0ba

Browse files
committed
all: use 'debug' variable protected by build tags for debug logging
Signed-off-by: deadprogram <[email protected]>
1 parent dc7d1b4 commit 564b0ba

File tree

9 files changed

+99
-102
lines changed

9 files changed

+99
-102
lines changed

adapter.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package bluetooth
22

3-
// Set this to true to print debug messages, for example for unknown events.
4-
const debug = false
5-
63
// SetConnectHandler sets a handler function to be called whenever the adaptor connects
74
// or disconnects. You must call this before you call adaptor.Connect() for centrals
85
// or adaptor.Start() for peripherals in order for it to work.

adapter_ninafw.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ func (a *Adapter) startNotifications() {
155155
return
156156
}
157157

158-
if _debug {
158+
if debug {
159159
println("starting notifications...")
160160
}
161161

@@ -166,7 +166,7 @@ func (a *Adapter) startNotifications() {
166166
for {
167167
if err := a.att.poll(); err != nil {
168168
// TODO: handle error
169-
if _debug {
169+
if debug {
170170
println("error polling for notifications:", err.Error())
171171
}
172172
}
@@ -180,21 +180,21 @@ func (a *Adapter) startNotifications() {
180180
for {
181181
select {
182182
case not := <-a.att.notifications:
183-
if _debug {
183+
if debug {
184184
println("notification received", not.connectionHandle, not.handle, not.data)
185185
}
186186

187187
d := a.findDevice(not.connectionHandle)
188188
if d.deviceInternal == nil {
189-
if _debug {
189+
if debug {
190190
println("no device found for handle", not.connectionHandle)
191191
}
192192
continue
193193
}
194194

195195
n := d.findNotificationRegistration(not.handle)
196196
if n == nil {
197-
if _debug {
197+
if debug {
198198
println("no notification registered for handle", not.handle)
199199
}
200200
continue
@@ -215,7 +215,7 @@ func (a *Adapter) startNotifications() {
215215
func (a *Adapter) findDevice(handle uint16) Device {
216216
for _, d := range a.connectedDevices {
217217
if d.handle == handle {
218-
if _debug {
218+
if debug {
219219
println("found device", handle, d.Address.String(), "with notifications registered", len(d.notificationRegistrations))
220220
}
221221

0 commit comments

Comments
 (0)