diff --git a/ble_darwin.go b/ble_darwin.go index 3196788..ed3b210 100644 --- a/ble_darwin.go +++ b/ble_darwin.go @@ -165,6 +165,8 @@ type DiscoverCharacteristicEvent struct { } type UpdateValueEvent struct { + Peripheral Peripheral + Characteristic *ns.CBCharacteristic Data []byte } @@ -247,6 +249,9 @@ func (b *BLE) StopScan() { func CancelConnection(p Peripheral) { b := pdLookup[p.p.Ptr()] + if b == nil { + return + } b.connections.Lock() var ch chan string; for _, item := range b.connections.items { @@ -494,6 +499,8 @@ func updateValue(p *ns.CBPeripheral, chr *ns.CBCharacteristic, e *ns.NSError) { b := pdLookup[p.Ptr()] v := chr.Value() b.events <-UpdateValueEvent{ + Peripheral: newPeripheral(p), + Characteristic: chr, Data: C.GoBytes(v.Bytes(), (C.int)(v.Length())), } }