Add the Peripheral and the Characteristic to UpdateValueEvent.

This commit is contained in:
Greg 2019-10-25 14:59:13 -04:00
parent fbb58a8d99
commit 5955e369e4
1 changed files with 7 additions and 0 deletions

View File

@ -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())),
}
}