aboutsummaryrefslogtreecommitdiff
path: root/ble/OsxBluetooth.mm
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2015-07-10 09:23:49 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2015-07-10 09:23:49 +0200
commitd945dee5b039e9e2d51b36852ef58a812acab302 (patch)
tree3f7a977b67d2d51726b349088075b23da73592ad /ble/OsxBluetooth.mm
parent441cd0b11186d66493798551e1102eb246f1af9f (diff)
downloadble-toys-ios.tar.gz
ble-toys-ios.tar.bz2
ble-toys-ios.tar.xz
ble-toys-ios.zip
o Some iOS experiments. Very WiP.ios
Diffstat (limited to 'ble/OsxBluetooth.mm')
-rw-r--r--ble/OsxBluetooth.mm41
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) {