1
1
/*jshint loopfunc: true */
2
2
3
- var debug = require ( 'debug' ) ( 'yosemite -bindings' ) ;
3
+ var debug = require ( 'debug' ) ( 'highsierra -bindings' ) ;
4
4
5
5
var child_process = require ( 'child_process' ) ;
6
6
var events = require ( 'events' ) ;
@@ -74,25 +74,18 @@ blenoBindings.init = function() {
74
74
}
75
75
}
76
76
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
+ } ) ;
81
84
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
- }
92
85
} . bind ( this ) ) ;
93
86
} ;
94
87
95
- blenoBindings . on ( 'kCBMsgId6 ' , function ( args ) {
88
+ blenoBindings . on ( 'kCBMsgId4 ' , function ( args ) {
96
89
var state = [ 'unknown' , 'resetting' , 'unsupported' , 'unauthorized' , 'poweredOff' , 'poweredOn' ] [ args . kCBMsgArgState ] ;
97
90
debug ( 'state change ' + state ) ;
98
91
this . emit ( 'stateChange' , state ) ;
@@ -110,35 +103,27 @@ blenoBindings.startAdvertising = function(name, serviceUuids) {
110
103
}
111
104
}
112
105
113
- this . sendCBMsg ( 8 , advertisement ) ;
106
+ this . sendCBMsg ( 16 , advertisement ) ;
114
107
} ;
115
108
116
109
blenoBindings . startAdvertisingIBeacon = function ( data ) {
117
110
var args = { } ;
118
111
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
+ ] ) ;
127
116
128
- this . sendCBMsg ( 8 , args ) ;
117
+ this . sendCBMsg ( 16 , args ) ;
129
118
} ;
130
119
131
120
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 , {
137
122
kCBAdvDataAppleMfgData : advertisementData
138
123
} ) ;
139
124
} ;
140
125
141
- blenoBindings . on ( 'kCBMsgId16 ' , function ( args ) {
126
+ blenoBindings . on ( 'kCBMsgId27 ' , function ( args ) {
142
127
var result = args . kCBMsgArgResult ;
143
128
var error = null ;
144
129
@@ -150,15 +135,15 @@ blenoBindings.on('kCBMsgId16', function(args) {
150
135
} ) ;
151
136
152
137
blenoBindings . stopAdvertising = function ( ) {
153
- this . sendCBMsg ( 9 , null ) ;
138
+ this . sendCBMsg ( 17 , null ) ;
154
139
} ;
155
140
156
- blenoBindings . on ( 'kCBMsgId17 ' , function ( args ) {
141
+ blenoBindings . on ( 'kCBMsgId28 ' , function ( args ) {
157
142
this . emit ( 'advertisingStop' ) ;
158
143
} ) ;
159
144
160
145
blenoBindings . setServices = function ( services ) {
161
- this . sendCBMsg ( 12 , null ) ; // remove all services
146
+ this . sendCBMsg ( 19 , null ) ; // remove all services
162
147
163
148
services = services || [ ] ;
164
149
var attributeId = 1 ;
@@ -260,7 +245,7 @@ blenoBindings.setServices = function(services) {
260
245
attributeId ++ ;
261
246
}
262
247
263
- this . sendCBMsg ( 10 , arg ) ;
248
+ this . sendCBMsg ( 18 , arg ) ;
264
249
}
265
250
} else {
266
251
this . emit ( 'servicesSet' ) ;
@@ -271,13 +256,13 @@ blenoBindings.updateRssi = function() {
271
256
if ( this . _deviceUUID === null ) {
272
257
this . emit ( 'rssiUpdate' , 127 ) ; // not supported
273
258
} else {
274
- this . sendCBMsg ( 44 , {
259
+ this . sendCBMsg ( 61 , {
275
260
kCBMsgArgDeviceUUID : this . _deviceUUID
276
261
} ) ;
277
262
}
278
263
} ;
279
264
280
- blenoBindings . on ( 'kCBMsgId18 ' , function ( args ) {
265
+ blenoBindings . on ( 'kCBMsgId29 ' , function ( args ) {
281
266
var attributeId = args . kCBMsgArgAttributeID ;
282
267
var result = args . kCBMsgArgResult ;
283
268
@@ -296,7 +281,7 @@ blenoBindings.on('kCBMsgId18', function(args) {
296
281
}
297
282
} ) ;
298
283
299
- blenoBindings . on ( 'kCBMsgId53 ' , function ( args ) {
284
+ blenoBindings . on ( 'kCBMsgId57 ' , function ( args ) {
300
285
var deviceUUID = args . kCBMsgArgDeviceUUID . toString ( 'hex' ) ;
301
286
var mtu = args . kCBMsgArgATTMTU ;
302
287
@@ -309,14 +294,14 @@ blenoBindings.on('kCBMsgId53', function(args) {
309
294
} . bind ( this ) ) ;
310
295
} ) ;
311
296
312
- blenoBindings . on ( 'kCBMsgId19 ' , function ( args ) {
297
+ blenoBindings . on ( 'kCBMsgId30 ' , function ( args ) {
313
298
var attributeId = args . kCBMsgArgAttributeID ;
314
299
var offset = args . kCBMsgArgOffset || 0 ;
315
300
var transactionId = args . kCBMsgArgTransactionID ;
316
301
317
302
var callback = ( function ( attributeId , transactionId ) {
318
303
return function ( result , data ) {
319
- this . sendCBMsg ( 13 , {
304
+ this . sendCBMsg ( 21 , {
320
305
kCBMsgArgAttributeID : attributeId ,
321
306
kCBMsgArgData : data ,
322
307
kCBMsgArgResult : result ,
@@ -328,7 +313,7 @@ blenoBindings.on('kCBMsgId19', function(args) {
328
313
this . _attributes [ attributeId ] . emit ( 'readRequest' , offset , callback ) ;
329
314
} ) ;
330
315
331
- blenoBindings . on ( 'kCBMsgId20 ' , function ( args ) {
316
+ blenoBindings . on ( 'kCBMsgId31 ' , function ( args ) {
332
317
var attWrites = args . kCBMsgArgATTWrites ;
333
318
var transactionId = args . kCBMsgArgTransactionID ;
334
319
@@ -343,7 +328,7 @@ blenoBindings.on('kCBMsgId20', function(args) {
343
328
var callback = ( function ( attributeId , transactionId , ignoreResponse ) {
344
329
return function ( result ) {
345
330
if ( ! ignoreResponse ) {
346
- this . sendCBMsg ( 13 , {
331
+ this . sendCBMsg ( 21 , {
347
332
kCBMsgArgAttributeID : attributeId ,
348
333
kCBMsgArgData : null ,
349
334
kCBMsgArgResult : result ,
@@ -357,13 +342,13 @@ blenoBindings.on('kCBMsgId20', function(args) {
357
342
}
358
343
} ) ;
359
344
360
- blenoBindings . on ( 'kCBMsgId21 ' , function ( args ) {
345
+ blenoBindings . on ( 'kCBMsgId32 ' , function ( args ) {
361
346
var attributeId = args . kCBMsgArgAttributeID ;
362
347
var maxValueSize = 20 ;
363
348
364
349
var callback = ( function ( attributeId ) {
365
350
return function ( data ) {
366
- this . sendCBMsg ( 15 , {
351
+ this . sendCBMsg ( 22 , {
367
352
kCBMsgArgAttributeID : attributeId ,
368
353
kCBMsgArgData : data ,
369
354
kCBMsgArgUUIDs : [ ]
@@ -374,13 +359,13 @@ blenoBindings.on('kCBMsgId21', function(args) {
374
359
this . _attributes [ attributeId ] . emit ( 'subscribe' , maxValueSize , callback ) ;
375
360
} ) ;
376
361
377
- blenoBindings . on ( 'kCBMsgId22 ' , function ( args ) {
362
+ blenoBindings . on ( 'kCBMsgId33 ' , function ( args ) {
378
363
var attributeId = args . kCBMsgArgAttributeID ;
379
364
380
365
this . _attributes [ attributeId ] . emit ( 'unsubscribe' ) ;
381
366
} ) ;
382
367
383
- blenoBindings . on ( 'kCBMsgId23 ' , function ( args ) {
368
+ blenoBindings . on ( 'kCBMsgId34 ' , function ( args ) {
384
369
var attributeId = args . kCBMsgArgAttributeID ;
385
370
var attribute = this . _attributes [ attributeId ] ;
386
371
@@ -393,7 +378,7 @@ blenoBindings.on('kCBMsgId23', function(args) {
393
378
}
394
379
} ) ;
395
380
396
- blenoBindings . on ( 'kCBMsgId55 ' , function ( args ) {
381
+ blenoBindings . on ( 'kCBMsgId71 ' , function ( args ) {
397
382
var rssi = args . kCBMsgArgData ;
398
383
399
384
this . emit ( 'rssiUpdate' , rssi ) ;
0 commit comments