Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions bleu-station/bleu-station.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ BleuStation.prototype.writeDataCharacteristic = function(uuid, data, callback) {

BleuStation.prototype.writeStringCharacteristic = function(uuid, value, callback) {
var valueLength = value.length;
var data = new Buffer(valueLength + 1);
var valueData = new Buffer(value);
var data = Buffer.alloc(valueLength + 1);
var valueData = Buffer.alloc(value);

data[0] = valueLength;
for (var i = 0; i < valueLength; i++) {
Expand All @@ -176,31 +176,31 @@ BleuStation.prototype.writeStringCharacteristic = function(uuid, value, callback
};

BleuStation.prototype.writeUInt16Characteristic = function(uuid, value, callback) {
var data = new Buffer(2);
var data = Buffer.alloc(2);

data.writeUInt16BE(value, 0);

this.writeDataCharacteristic(uuid, data, callback);
};

BleuStation.prototype.writeInt8Characteristic = function(uuid, value, callback) {
var data = new Buffer(1);
var data = Buffer.alloc(1);

data.writeInt8(value, 0);

this.writeDataCharacteristic(uuid, data, callback);
};

BleuStation.prototype.writeUInt8Characteristic = function(uuid, value, callback) {
var data = new Buffer(1);
var data = Buffer.alloc(1);

data.writeUInt8(value, 0);

this.writeDataCharacteristic(uuid, data, callback);
};

BleuStation.prototype.writeDoubleCharacteristic = function(uuid, value, callback) {
var data = new Buffer(8);
var data = Buffer.alloc(8);

data.writeDoubleLE(value, 0);

Expand All @@ -220,7 +220,7 @@ BleuStation.prototype.login = function(password, callback) {
}
}

clientCharacteristicConfigurationDescriptor.writeValue(new Buffer('0000', 'hex'), function(error) {
clientCharacteristicConfigurationDescriptor.writeValue(Buffer.from('0000', 'hex'), function(error) {
this.writeAdminPassword(password, function(result) {
callback(result === 0);
}.bind(this));
Expand Down Expand Up @@ -279,7 +279,7 @@ BleuStation.prototype.readAdminDeviceName = function(callback) {
};

BleuStation.prototype.writeUuid = function(uuid, callback) {
this.writeDataCharacteristic(ADMIN_IBEACON_UUID_UUID, new Buffer(uuid, 'hex'), callback);
this.writeDataCharacteristic(ADMIN_IBEACON_UUID_UUID, Buffer.from(uuid, 'hex'), callback);
};

BleuStation.prototype.writeMajor = function(major, callback) {
Expand Down
40 changes: 20 additions & 20 deletions bleu-station/pseudo.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,22 @@ bleno.on('advertisingStart', function(error) {
new BlenoCharacteristic({
uuid: '2a29',
properties: ['read'],
value: new Buffer('TwoCanoes')
value: Buffer.from('TwoCanoes')
}),
new BlenoCharacteristic({
uuid: '2a24',
properties: ['read'],
value: new Buffer('iBeacon Demo')
value: Buffer.from('iBeacon Demo')
}),
new BlenoCharacteristic({
uuid: '2a27',
properties: ['read'],
value: new Buffer('0.0.0')
value: Buffer.from('0.0.0')
}),
new BlenoCharacteristic({
uuid: '2a26',
properties: ['read'],
value: new Buffer('0.0.0')
value: Buffer.from('0.0.0')
})
]
}),
Expand All @@ -55,22 +55,22 @@ bleno.on('advertisingStart', function(error) {
new BlenoCharacteristic({
uuid: 'b0702881a295a8abf734031a98a512de',
properties: ['read'],
value: new Buffer('e2c56db5dffb48d2b060d0f5a71096e0', 'hex')
value: Buffer.from('e2c56db5dffb48d2b060d0f5a71096e0', 'hex')
}),
new BlenoCharacteristic({
uuid: 'b0702882a295a8abf734031a98a512de',
properties: ['read'],
value: new Buffer('0001', 'hex')
value: Buffer.from('0001', 'hex')
}),
new BlenoCharacteristic({
uuid: 'b0702883a295a8abf734031a98a512de',
properties: ['read'],
value: new Buffer('0002', 'hex')
value: Buffer.from('0002', 'hex')
}),
new BlenoCharacteristic({
uuid: 'b0702884a295a8abf734031a98a512de',
properties: ['read'],
value: new Buffer('c4', 'hex')
value: Buffer.from('c4', 'hex')
})
]
}),
Expand All @@ -94,7 +94,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('c8f21a07078a42df86600946ffd109be onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('e2c56db5dffb48d2b060d0f5a71096e0', 'hex'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('e2c56db5dffb48d2b060d0f5a71096e0', 'hex'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('c8f21a07078a42df86600946ffd109be onWriteRequest ' + data.toString('hex'));
Expand All @@ -108,7 +108,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('677ec16a743d42fcafe1d9f4a02a726f onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('0001', 'hex'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('0001', 'hex'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('677ec16a743d42fcafe1d9f4a02a726f onWriteRequest ' + data.toString('hex'));
Expand All @@ -122,7 +122,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('7722712a07f4433f8e305a6dc26356ba onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('0002', 'hex'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('0002', 'hex'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('7722712a07f4433f8e305a6dc26356ba onWriteRequest ' + data.toString('hex'));
Expand All @@ -136,7 +136,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('8aa2414e8e614d9cae14508ee3192dee onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('0f', 'hex'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('0f', 'hex'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('8aa2414e8e614d9cae14508ee3192dee onWriteRequest ' + data.toString('hex'));
Expand All @@ -150,7 +150,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('0b4700c35c5346519601b7e1e06b1bbf onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('c4', 'hex'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('c4', 'hex'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('0b4700c35c5346519601b7e1e06b1bbf onWriteRequest ' + data.toString('hex'));
Expand All @@ -164,7 +164,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('980ac81e94fd43f48b9a260a65dd3adc onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('TC000000'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('TC000000'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('980ac81e94fd43f48b9a260a65dd3adc onWriteRequest ' + data.toString('hex'));
Expand All @@ -178,7 +178,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('12d8cca8b1cc4e48abf7767b5e0f3ff6 onReadRequest');

callback(BlenoCharacteristic.RESULT_SUCCESS, new Buffer('', 'hex'));
callback(BlenoCharacteristic.RESULT_SUCCESS, Buffer.from('', 'hex'));
},
onWriteRequest: function(data, offset, withoutResponse, callback) {
console.log('12d8cca8b1cc4e48abf7767b5e0f3ff6 onWriteRequest ' + data.toString('hex'));
Expand All @@ -197,7 +197,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('fffc3dbb92d148f1aa5289a3d9517d79 onReadRequest');

var data = new Buffer(8);
var data = Buffer.alloc(8);
data.writeDoubleLE(123.456789, 0);

callback(BlenoCharacteristic.RESULT_SUCCESS, data);
Expand All @@ -214,7 +214,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('9e5f3adf337f4acfb54d929da486f512 onReadRequest');

var data = new Buffer(8);
var data = Buffer.alloc(8);
data.writeDoubleLE(999.123456, 0);

callback(BlenoCharacteristic.RESULT_SUCCESS, data);
Expand All @@ -231,7 +231,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('676e5ff15cd7484ab98f97f3c96e6361 onReadRequest');

var data = new Buffer([1]);
var data = Buffer.from([1]);

callback(BlenoCharacteristic.RESULT_SUCCESS, data);
},
Expand All @@ -252,7 +252,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('98a5a965efd34d16924718fd88bb8a30 onReadRequest');

var data = new Buffer('/https://twocanoes.com/bleu/config/default.plist');
var data = Buffer.from('/https://twocanoes.com/bleu/config/default.plist');

callback(BlenoCharacteristic.RESULT_SUCCESS, data);
},
Expand All @@ -268,7 +268,7 @@ bleno.on('advertisingStart', function(error) {
onReadRequest: function(offset, callback) {
console.log('3e8501d8aa3943368908b6e79d81a050 onReadRequest');

var data = new Buffer('');
var data = Buffer.from('');

callback(BlenoCharacteristic.RESULT_SUCCESS, data);
},
Expand Down
14 changes: 7 additions & 7 deletions estimote-sticker/pseudo.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ bleno.on('stateChange', function(state) {

if (state === 'poweredOn') {
var advertisement = Buffer.concat([
new Buffer('03030f18', 'hex'),
new Buffer('17ff', 'hex'),
new Buffer('5d0101', 'hex'),
new Buffer('0398290ef72bcff9', 'hex'),
Buffer.from('03030f18', 'hex'),
Buffer.from('17ff', 'hex'),
Buffer.from('5d0101', 'hex'),
Buffer.from('0398290ef72bcff9', 'hex'),

new Buffer('0401', 'hex') ,
new Buffer('000000000000000000', 'hex')
Buffer.from('0401', 'hex') ,
Buffer.from('000000000000000000', 'hex')
]);

if (platform === 'darwin') {
bleno.startAdvertisingWithEIRData(advertisement);
} else if (platform === 'linux') {
var scan = new Buffer(0);
var scan = Buffer.alloc(0);
bleno.startAdvertisingWithEIRData(advertisement, scan);
}
} else {
Expand Down
18 changes: 9 additions & 9 deletions estimote/estimote.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ var Estimote = function(peripheral) {
var serviceData = peripheral.advertisement.serviceData[0].data;

this.address = serviceData.slice(0, 6).toString('hex').match(/.{1,2}/g).reverse().join(':');
this.addressData = new Buffer(this.address.split(':').join(''), 'hex');
this.addressData = Buffer.from(this.address.split(':').join(''), 'hex');

this.measuredPower = serviceData.readInt8(6);
this.major = serviceData.readUInt16LE(7);
Expand Down Expand Up @@ -96,7 +96,7 @@ Estimote.prototype.pair = function(callback) {

sec = bignum(authService1Value).powm(exp, mod);

var authService2Data = new Buffer(16);
var authService2Data = Buffer.alloc(16);

// fill in authService2Data with address
authService2Data[0] = this.addressData[5];
Expand All @@ -122,16 +122,16 @@ Estimote.prototype.pair = function(callback) {
'c54fc29163e4457b8a9ac9868e1b3a9a' : // "new" fixed key (v3)
'ff8af207013625c2d810097f20d3050f'; // original fixed key

var key = new Buffer(fixedKeyHexString, 'hex');
var iv = new Buffer('00000000000000000000000000000000', 'hex');
var key = Buffer.from(fixedKeyHexString, 'hex');
var iv = Buffer.from('00000000000000000000000000000000', 'hex');

var cipher = crypto.createCipheriv('aes128', key, iv);

cipher.setAutoPadding(false);
authService2Data = cipher.update(authService2Data);

// fill in key with sec
var secData = new Buffer(4);
var secData = Buffer.alloc(4);
secData.writeUInt32BE(sec, 0);

key[0] = secData[3];
Expand Down Expand Up @@ -196,7 +196,7 @@ Estimote.prototype.readUuid1 = function(callback) {
};

Estimote.prototype.writeUuid1 = function(uuid1, callback) {
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, UUID_1_UUID, new Buffer(uuid1, 'hex'), callback);
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, UUID_1_UUID, Buffer.from(uuid1, 'hex'), callback);
};

Estimote.prototype.readUuid2 = function(callback) {
Expand All @@ -210,7 +210,7 @@ Estimote.prototype.readUuid2 = function(callback) {
};

Estimote.prototype.writeUuid2 = function(uuid2, callback) {
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, UUID_2_UUID, new Buffer(uuid2, 'hex'), callback);
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, UUID_2_UUID, Buffer.from(uuid2, 'hex'), callback);
};

Estimote.prototype.readPowerLevel = function(callback) {
Expand Down Expand Up @@ -361,7 +361,7 @@ Estimote.prototype.readEddystoneUidNamespace = function(callback) {
};

Estimote.prototype.writeEddystoneUidNamespace = function(uidNamespace, callback) {
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, EDDYSTONE_UID_NAMESPACE_UUID, new Buffer(uidNamespace, 'hex'), callback);
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, EDDYSTONE_UID_NAMESPACE_UUID, Buffer.from(uidNamespace, 'hex'), callback);
};

Estimote.prototype.readEddystoneUidInstance = function(callback) {
Expand All @@ -375,7 +375,7 @@ Estimote.prototype.readEddystoneUidInstance = function(callback) {
};

Estimote.prototype.writeEddystoneUidInstance = function(uidInstance, callback) {
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, EDDYSTONE_UID_INSTANCE_UUID, new Buffer(uidInstance, 'hex'), callback);
this.writeDataCharacteristic(ESTIMOTE_SERVICE_UUID, EDDYSTONE_UID_INSTANCE_UUID, Buffer.from(uidInstance, 'hex'), callback);
};

Estimote.prototype.readEddystoneUrl = function(callback) {
Expand Down
Loading