ble/ns/exports.go

116 lines
3.7 KiB
Go

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"
)
//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
a1 := &CBCentralManager{}; a1.ptr = central
a2 := &CBPeripheral{}; a2.ptr = peripheral
cb(self, a1, a2)
}
//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)
}
//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
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)
}
//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
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &NSError{}; a2.ptr = error
cb(self, a1, a2)
}
//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
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &CBService{}; a2.ptr = service
a3 := &NSError{}; a3.ptr = error
cb(self, a1, a2, a3)
}
//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
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &CBCharacteristic{}; a2.ptr = characteristic
a3 := &NSError{}; a3.ptr = error
cb(self, a1, a2, a3)
}