ble/ns/exports.go

116 lines
3.7 KiB
Go
Raw Permalink Normal View History

2019-10-23 18:28:19 -04:00
package ns
/*
#cgo CFLAGS: -x objective-c -fno-objc-arc
#cgo LDFLAGS: -framework Foundation -framework CoreBluetooth
#pragma clang diagnostic ignored "-Wformat-security"
#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>
*/
import "C"
import (
"unsafe"
"fmt"
2019-10-23 18:28:19 -04:00
)
//export CBDelegateCentralManagerDidConnectPeripheral
func CBDelegateCentralManagerDidConnectPeripheral(o unsafe.Pointer, central unsafe.Pointer, peripheral unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].CentralManagerDidConnectPeripheral
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
2019-10-23 18:28:19 -04:00
a1 := &CBCentralManager{}; a1.ptr = central
a2 := &CBPeripheral{}; a2.ptr = peripheral
cb(self, a1, a2)
2019-10-23 18:28:19 -04:00
}
//export CBDelegateCentralManagerDidDisconnectPeripheral
func CBDelegateCentralManagerDidDisconnectPeripheral(o unsafe.Pointer, central unsafe.Pointer, peripheral unsafe.Pointer, error unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].CentralManagerDidDisconnectPeripheral
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
a1 := &CBCentralManager{}; a1.ptr = central
a2 := &CBPeripheral{}; a2.ptr = peripheral
a3 := &NSError{}; a3.ptr = error
cb(self, a1, a2, a3)
}
2019-10-23 18:28:19 -04:00
//export CBDelegateCentralManagerDidDiscoverPeripheral
func CBDelegateCentralManagerDidDiscoverPeripheral(o unsafe.Pointer, central unsafe.Pointer, peripheral unsafe.Pointer, advertisementData unsafe.Pointer, RSSI unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].CentralManagerDidDiscoverPeripheral
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
2019-10-23 18:28:19 -04:00
a1 := &CBCentralManager{}; a1.ptr = central
a2 := &CBPeripheral{}; a2.ptr = peripheral
a3 := &NSDictionary{}; a3.ptr = advertisementData
a4 := &NSNumber{}; a4.ptr = RSSI
cb(self, a1, a2, a3, a4)
}
//export CBDelegateCentralManagerDidUpdateState
func CBDelegateCentralManagerDidUpdateState(o unsafe.Pointer, central unsafe.Pointer) {
fmt.Print("CentralManagerDidUpdateState")
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].CentralManagerDidUpdateState
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
a1 := &CBCentralManager{}; a1.ptr = central
cb(self, a1)
2019-10-23 18:28:19 -04:00
}
//export CBDelegatePeripheralDidDiscoverServices
func CBDelegatePeripheralDidDiscoverServices(o unsafe.Pointer, peripheral unsafe.Pointer, error unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].PeripheralDidDiscoverServices
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
2019-10-23 18:28:19 -04:00
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &NSError{}; a2.ptr = error
cb(self, a1, a2)
2019-10-23 18:28:19 -04:00
}
//export CBDelegatePeripheralDidDiscoverCharacteristicsForService
func CBDelegatePeripheralDidDiscoverCharacteristicsForService(o unsafe.Pointer, peripheral unsafe.Pointer, service unsafe.Pointer, error unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].PeripheralDidDiscoverCharacteristicsForService
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
2019-10-23 18:28:19 -04:00
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &CBService{}; a2.ptr = service
a3 := &NSError{}; a3.ptr = error
cb(self, a1, a2, a3)
2019-10-23 18:28:19 -04:00
}
//export CBDelegatePeripheralDidUpdateValueForCharacteristic
func CBDelegatePeripheralDidUpdateValueForCharacteristic(o unsafe.Pointer, peripheral unsafe.Pointer, characteristic unsafe.Pointer, error unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].PeripheralDidUpdateValueForCharacteristic
CBDelegateMux.RUnlock()
if cb == nil { return }
self := CBDelegate{}
self.ptr = o
2019-10-23 18:28:19 -04:00
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &CBCharacteristic{}; a2.ptr = characteristic
a3 := &NSError{}; a3.ptr = error
cb(self, a1, a2, a3)
2019-10-23 18:28:19 -04:00
}