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 { type UpdateValueEvent struct {
Peripheral Peripheral
Characteristic *ns.CBCharacteristic
Data []byte Data []byte
} }
@ -247,6 +249,9 @@ func (b *BLE) StopScan() {
func CancelConnection(p Peripheral) { func CancelConnection(p Peripheral) {
b := pdLookup[p.p.Ptr()] b := pdLookup[p.p.Ptr()]
if b == nil {
return
}
b.connections.Lock() b.connections.Lock()
var ch chan string; var ch chan string;
for _, item := range b.connections.items { 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()] b := pdLookup[p.Ptr()]
v := chr.Value() v := chr.Value()
b.events <-UpdateValueEvent{ b.events <-UpdateValueEvent{
Peripheral: newPeripheral(p),
Characteristic: chr,
Data: C.GoBytes(v.Bytes(), (C.int)(v.Length())), Data: C.GoBytes(v.Bytes(), (C.int)(v.Length())),
} }
} }