diff options
Diffstat (limited to 'ble/OsxBluetooth.mm')
-rw-r--r-- | ble/OsxBluetooth.mm | 41 |
1 files changed, 34 insertions, 7 deletions
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 <CoreFoundation/CoreFoundation.h> -#import <IOBluetooth/IOBluetoothUtilities.h> -#import <IOBluetooth/objc/IOBluetoothSDPUUID.h> -#import <IOBluetooth/objc/IOBluetoothSDPServiceRecord.h> +#include <CoreBluetooth/CBAdvertisementData.h> -#import "BluetoothImpl.h" -#import "OsxBluetooth.h" +#include "BluetoothImpl.h" +#include "OsxBluetooth.h" +#include "OsxBluetoothImpl.h" #include <map> + 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(BluetoothDevice &device)>) { +void OsxBluetoothAdapter::runScan(std::function<void(BluetoothDevice &device)> 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) { |