From 5955e369e4eb378cd51b39e01225e2e03a0e0440 Mon Sep 17 00:00:00 2001 From: Greg Date: Fri, 25 Oct 2019 14:59:13 -0400 Subject: [PATCH] Add the Peripheral and the Characteristic to UpdateValueEvent. --- ble_darwin.go | 7 +++++++ 1 file changed, 7 insertions(+) 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())), } }