Merge branch 'blessed'
This commit is contained in:
commit
81be281bcd
|
@ -283,24 +283,7 @@ func goOnScan(cname, cid *C.char, rssi C.int, dev C.jobject) {
|
||||||
func goOnConnect(gatt C.jobject, cid *C.char) {
|
func goOnConnect(gatt C.jobject, cid *C.char) {
|
||||||
id := C.GoString(cid)
|
id := C.GoString(cid)
|
||||||
|
|
||||||
var peripheral Peripheral
|
peripheral := gBLE.retrievePeripheral(id, p)
|
||||||
found := false
|
|
||||||
|
|
||||||
gBLE.peripherals.Lock()
|
|
||||||
for n, item := range gBLE.peripherals.items {
|
|
||||||
if item.p.Identifier == id {
|
|
||||||
peripheral = item.p
|
|
||||||
peripheral.gatt = gatt
|
|
||||||
gBLE.peripherals.items[n].p = peripheral
|
|
||||||
found = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
gBLE.peripherals.Unlock()
|
|
||||||
|
|
||||||
if !found {
|
|
||||||
log.Printf("Go: peripheral not found!")
|
|
||||||
}
|
|
||||||
|
|
||||||
if peripheral.gatt == 0 {
|
if peripheral.gatt == 0 {
|
||||||
log.Printf("goOnConnect(): gatt == null")
|
log.Printf("goOnConnect(): gatt == null")
|
||||||
|
@ -396,15 +379,22 @@ func goOnCharacteristicChanged(cid, ccuuid *C.char, char C.jobject, cvalue *C.ch
|
||||||
|
|
||||||
// internal convenience functions
|
// internal convenience functions
|
||||||
|
|
||||||
func (b *BLE) retrievePeripheral(id string) Peripheral {
|
func (b *BLE) retrievePeripheral(id string, devs ...C.jobject) Peripheral {
|
||||||
|
var dev C.jobject
|
||||||
|
if len(devs) > 0 {
|
||||||
|
dev = devs[0]
|
||||||
|
}
|
||||||
|
|
||||||
found := false
|
found := false
|
||||||
var peripheral Peripheral
|
var peripheral Peripheral
|
||||||
|
|
||||||
gBLE.peripherals.Lock()
|
gBLE.peripherals.Lock()
|
||||||
for _, item := range gBLE.peripherals.items {
|
for i, item := range gBLE.peripherals.items {
|
||||||
if item.p.Identifier == id {
|
if item.p.Identifier == id {
|
||||||
peripheral = item.p
|
peripheral = item.p
|
||||||
|
peripheral.peripheral = dev
|
||||||
found = true
|
found = true
|
||||||
|
gBLE.peripherals.items[i].p = peripheral
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user