Skip to content

Commit c8ffc36

Browse files
change for high sierra
1 parent b67302b commit c8ffc36

File tree

1 file changed

+33
-48
lines changed

1 file changed

+33
-48
lines changed

lib/mac/highsierra.js

+33-48
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*jshint loopfunc: true */
22

3-
var debug = require('debug')('yosemite-bindings');
3+
var debug = require('debug')('highsierra-bindings');
44

55
var child_process = require('child_process');
66
var events = require('events');
@@ -74,25 +74,18 @@ blenoBindings.init = function() {
7474
}
7575
}
7676

77-
if (osRelease < 13) {
78-
debug('bleno warning: OS X < 10.9 detected');
79-
80-
console.warn('bleno requires OS X 10.9 or higher!');
77+
this.sendCBMsg(1, {
78+
kCBMsgArgName: 'node-' + (new Date()).getTime(),
79+
kCBMsgArgOptions: {
80+
kCBInitOptionShowPowerAlert: 1
81+
},
82+
kCBMsgArgType: 1
83+
});
8184

82-
this.emit('stateChange', 'unsupported');
83-
} else {
84-
this.sendCBMsg(1, {
85-
kCBMsgArgName: 'node-' + (new Date()).getTime(),
86-
kCBMsgArgOptions: {
87-
kCBInitOptionShowPowerAlert: 1
88-
},
89-
kCBMsgArgType: 1
90-
});
91-
}
9285
}.bind(this));
9386
};
9487

95-
blenoBindings.on('kCBMsgId6', function(args) {
88+
blenoBindings.on('kCBMsgId4', function(args) {
9689
var state = ['unknown', 'resetting', 'unsupported', 'unauthorized', 'poweredOff', 'poweredOn'][args.kCBMsgArgState];
9790
debug('state change ' + state);
9891
this.emit('stateChange', state);
@@ -110,35 +103,27 @@ blenoBindings.startAdvertising = function(name, serviceUuids) {
110103
}
111104
}
112105

113-
this.sendCBMsg(8, advertisement);
106+
this.sendCBMsg(16, advertisement);
114107
};
115108

116109
blenoBindings.startAdvertisingIBeacon = function(data) {
117110
var args = {};
118111

119-
if (osRelease >= 14) {
120-
args.kCBAdvDataAppleMfgData = Buffer.concat([
121-
new Buffer([data.length + 5, 0xff, 0x4c, 0x00, 0x02, data.length]),
122-
data
123-
]);
124-
} else {
125-
args.kCBAdvDataAppleBeaconKey = data;
126-
}
112+
args.kCBAdvDataAppleMfgData = Buffer.concat([
113+
new Buffer([data.length + 5, 0xff, 0x4c, 0x00, 0x02, data.length]),
114+
data
115+
]);
127116

128-
this.sendCBMsg(8, args);
117+
this.sendCBMsg(16, args);
129118
};
130119

131120
blenoBindings.startAdvertisingWithEIRData = function(advertisementData) {
132-
if (osRelease < 14) {
133-
throw new Error('startAdvertisingWithEIRData is only supported on OS X 10.10 and above!');
134-
}
135-
136-
this.sendCBMsg(8, {
121+
this.sendCBMsg(16, {
137122
kCBAdvDataAppleMfgData: advertisementData
138123
});
139124
};
140125

141-
blenoBindings.on('kCBMsgId16', function(args) {
126+
blenoBindings.on('kCBMsgId27', function(args) {
142127
var result = args.kCBMsgArgResult;
143128
var error = null;
144129

@@ -150,15 +135,15 @@ blenoBindings.on('kCBMsgId16', function(args) {
150135
});
151136

152137
blenoBindings.stopAdvertising = function() {
153-
this.sendCBMsg(9, null);
138+
this.sendCBMsg(17, null);
154139
};
155140

156-
blenoBindings.on('kCBMsgId17', function(args) {
141+
blenoBindings.on('kCBMsgId28', function(args) {
157142
this.emit('advertisingStop');
158143
});
159144

160145
blenoBindings.setServices = function(services) {
161-
this.sendCBMsg(12, null); // remove all services
146+
this.sendCBMsg(19, null); // remove all services
162147

163148
services = services || [];
164149
var attributeId = 1;
@@ -260,7 +245,7 @@ blenoBindings.setServices = function(services) {
260245
attributeId++;
261246
}
262247

263-
this.sendCBMsg(10, arg);
248+
this.sendCBMsg(18, arg);
264249
}
265250
} else {
266251
this.emit('servicesSet');
@@ -271,13 +256,13 @@ blenoBindings.updateRssi = function() {
271256
if (this._deviceUUID === null) {
272257
this.emit('rssiUpdate', 127); // not supported
273258
} else {
274-
this.sendCBMsg(44, {
259+
this.sendCBMsg(61, {
275260
kCBMsgArgDeviceUUID: this._deviceUUID
276261
});
277262
}
278263
};
279264

280-
blenoBindings.on('kCBMsgId18', function(args) {
265+
blenoBindings.on('kCBMsgId29', function(args) {
281266
var attributeId = args.kCBMsgArgAttributeID;
282267
var result = args.kCBMsgArgResult;
283268

@@ -296,7 +281,7 @@ blenoBindings.on('kCBMsgId18', function(args) {
296281
}
297282
});
298283

299-
blenoBindings.on('kCBMsgId53', function(args) {
284+
blenoBindings.on('kCBMsgId57', function(args) {
300285
var deviceUUID = args.kCBMsgArgDeviceUUID.toString('hex');
301286
var mtu = args.kCBMsgArgATTMTU;
302287

@@ -309,14 +294,14 @@ blenoBindings.on('kCBMsgId53', function(args) {
309294
}.bind(this));
310295
});
311296

312-
blenoBindings.on('kCBMsgId19', function(args) {
297+
blenoBindings.on('kCBMsgId30', function(args) {
313298
var attributeId = args.kCBMsgArgAttributeID;
314299
var offset = args.kCBMsgArgOffset || 0;
315300
var transactionId = args.kCBMsgArgTransactionID;
316301

317302
var callback = (function(attributeId, transactionId) {
318303
return function(result, data) {
319-
this.sendCBMsg(13, {
304+
this.sendCBMsg(21, {
320305
kCBMsgArgAttributeID: attributeId,
321306
kCBMsgArgData: data,
322307
kCBMsgArgResult: result,
@@ -328,7 +313,7 @@ blenoBindings.on('kCBMsgId19', function(args) {
328313
this._attributes[attributeId].emit('readRequest', offset, callback);
329314
});
330315

331-
blenoBindings.on('kCBMsgId20', function(args) {
316+
blenoBindings.on('kCBMsgId31', function(args) {
332317
var attWrites = args.kCBMsgArgATTWrites;
333318
var transactionId = args.kCBMsgArgTransactionID;
334319

@@ -343,7 +328,7 @@ blenoBindings.on('kCBMsgId20', function(args) {
343328
var callback = (function(attributeId, transactionId, ignoreResponse) {
344329
return function(result) {
345330
if (!ignoreResponse) {
346-
this.sendCBMsg(13, {
331+
this.sendCBMsg(21, {
347332
kCBMsgArgAttributeID: attributeId,
348333
kCBMsgArgData: null,
349334
kCBMsgArgResult: result,
@@ -357,13 +342,13 @@ blenoBindings.on('kCBMsgId20', function(args) {
357342
}
358343
});
359344

360-
blenoBindings.on('kCBMsgId21', function(args) {
345+
blenoBindings.on('kCBMsgId32', function(args) {
361346
var attributeId = args.kCBMsgArgAttributeID;
362347
var maxValueSize = 20;
363348

364349
var callback = (function(attributeId) {
365350
return function(data) {
366-
this.sendCBMsg(15, {
351+
this.sendCBMsg(22, {
367352
kCBMsgArgAttributeID: attributeId,
368353
kCBMsgArgData: data,
369354
kCBMsgArgUUIDs: []
@@ -374,13 +359,13 @@ blenoBindings.on('kCBMsgId21', function(args) {
374359
this._attributes[attributeId].emit('subscribe', maxValueSize, callback);
375360
});
376361

377-
blenoBindings.on('kCBMsgId22', function(args) {
362+
blenoBindings.on('kCBMsgId33', function(args) {
378363
var attributeId = args.kCBMsgArgAttributeID;
379364

380365
this._attributes[attributeId].emit('unsubscribe');
381366
});
382367

383-
blenoBindings.on('kCBMsgId23', function(args) {
368+
blenoBindings.on('kCBMsgId34', function(args) {
384369
var attributeId = args.kCBMsgArgAttributeID;
385370
var attribute = this._attributes[attributeId];
386371

@@ -393,7 +378,7 @@ blenoBindings.on('kCBMsgId23', function(args) {
393378
}
394379
});
395380

396-
blenoBindings.on('kCBMsgId55', function(args) {
381+
blenoBindings.on('kCBMsgId71', function(args) {
397382
var rssi = args.kCBMsgArgData;
398383

399384
this.emit('rssiUpdate', rssi);

0 commit comments

Comments
 (0)