Commit b4a677b0 authored by Josh Lubawy's avatar Josh Lubawy Committed by Kevin
Browse files

Add isConnected field to darwin.conn type (#25)

This prevents multiple evtPeripheralConnected events from causing a
deadlock.
parent 7370f1c5
......@@ -43,6 +43,8 @@ type conn struct {
notifiers map[uint16]ble.Notifier // central connection only
subs map[uint16]*sub
isConnected bool
}
func (c *conn) Context() context.Context {
......
......@@ -489,10 +489,15 @@ func (d *Device) HandleXpcEvent(event xpc.Dict, err error) {
d.conn(args).unsubscribed(d.chars[args.attributeID()])
case evtPeripheralConnected:
d.chConn <- d.conn(args)
c := d.conn(args)
if !c.isConnected {
c.isConnected = true
d.chConn <- c
}
case evtPeripheralDisconnected:
c := d.conn(args)
c.isConnected = false
select {
case c.rspc <- m:
// Canceled by local central synchronously
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment