ble/ns/exports.go
2019-10-23 18:28:19 -04:00

88 lines
2.9 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"
)
//export CBDelegateCentralManagerDidUpdateState
func CBDelegateCentralManagerDidUpdateState(o unsafe.Pointer, central unsafe.Pointer) {
CBDelegateMux.RLock()
cb := CBDelegateLookup[o].CentralManagerDidUpdateState
CBDelegateMux.RUnlock()
if cb == nil { return }
a1 := &CBCentralManager{}; a1.ptr = central
cb(a1)
}
//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 }
a1 := &CBCentralManager{}; a1.ptr = central
a2 := &CBPeripheral{}; a2.ptr = peripheral
cb(a1, a2)
}
//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 }
a1 := &CBCentralManager{}; a1.ptr = central
a2 := &CBPeripheral{}; a2.ptr = peripheral
a3 := &NSDictionary{}; a3.ptr = advertisementData
a4 := &NSNumber{}; a4.ptr = RSSI
cb(a1, a2, a3, a4)
}
//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 }
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &NSError{}; a2.ptr = error
cb(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 }
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &CBService{}; a2.ptr = service
a3 := &NSError{}; a3.ptr = error
cb(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 }
a1 := &CBPeripheral{}; a1.ptr = peripheral
a2 := &CBCharacteristic{}; a2.ptr = characteristic
a3 := &NSError{}; a3.ptr = error
cb(a1, a2, a3)
}