From d945dee5b039e9e2d51b36852ef58a812acab302 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 10 Jul 2015 09:23:49 +0200 Subject: o Some iOS experiments. Very WiP. --- ble/OsxBluetooth.mm | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) (limited to 'ble/OsxBluetooth.mm') diff --git a/ble/OsxBluetooth.mm b/ble/OsxBluetooth.mm index e94edaf..32645d5 100644 --- a/ble/OsxBluetooth.mm +++ b/ble/OsxBluetooth.mm @@ -1,14 +1,32 @@ -#import -#import -#import -#import +#include -#import "BluetoothImpl.h" -#import "OsxBluetooth.h" +#include "BluetoothImpl.h" +#include "OsxBluetooth.h" +#include "OsxBluetoothImpl.h" #include + using namespace std; +@implementation InquiryDelegateWrapper + +- (id) initWithCPPInstance:(trygvis::bluetooth::osx::InquiryDelegate*)_adapter +{ + self = [super init]; + if (self) { + adapter = _adapter; + } + return self; +} + +- (void)deviceInquiryStarted:(IOBluetoothDeviceInquiry *)sender; +{ + if (adapter) + adapter->deviceInquiryStarted(); +} + +@end + namespace trygvis { namespace bluetooth { namespace osx { @@ -74,7 +92,16 @@ void OsxBluetoothAdapter::startScan() { void OsxBluetoothAdapter::stopScan() { } -void OsxBluetoothAdapter::runScan(std::function) { +void OsxBluetoothAdapter::runScan(std::function callback) { + auto y = new InquiryDelegate(*this, callback); + id x = [InquiryDelegateWrapper ::initWithCPPInstance:y]; + inq = [IOBluetoothDeviceInquiry inquiryWithDelegate:x]; + if(!inq) { + throw BluetoothException(&adapter, "Could not initialize inquery"); + } +} + +void InquiryDelegate::deviceInquiryStarted() { } BluetoothDevice &OsxBluetoothAdapter::getDevice(Mac &mac) { -- cgit v1.2.3