Skip to content

Commit

Permalink
- put service UUID's in advertisement data and not scan
Browse files Browse the repository at this point in the history
  • Loading branch information
sandeepmistry committed Jan 8, 2014
1 parent 8ecda02 commit 67b9bf1
Showing 1 changed file with 22 additions and 22 deletions.
44 changes: 22 additions & 22 deletions lib/linux/hci-ble.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ HciBle.prototype.startAdvertising = function(name, serviceUuids) {
}

if (serviceUuids16bit.length) {
scanDataLength += 2 + 2 * serviceUuids16bit.length;
advertisementDataLength += 2 + 2 * serviceUuids16bit.length;
}

if (serviceUuids128bit.length) {
scanDataLength += 2 + 16 * serviceUuids128bit.length;
advertisementDataLength += 2 + 16 * serviceUuids128bit.length;
}

i = 0;
Expand All @@ -102,40 +102,40 @@ HciBle.prototype.startAdvertising = function(name, serviceUuids) {
advertisementData[i++] = 0x01;
advertisementData[i++] = 0x05;

i = 0;
var scanData = new Buffer(scanDataLength);

// name
if (name && name.length) {
var nameBuffer = new Buffer(name);

scanData[i++] = nameBuffer.length + 1;
scanData[i++] = 0x08;
for (j = 0; j < nameBuffer.length; j++) {
scanData[i++] = nameBuffer[j];
}
}

if (serviceUuids16bit.length) {
scanData[i++] = 1 + 2 * serviceUuids16bit.length;
scanData[i++] = 0x02;
advertisementData[i++] = 1 + 2 * serviceUuids16bit.length;
advertisementData[i++] = 0x03;
for (j = 0; j < serviceUuids16bit.length; j++) {
for (k = 0; k < serviceUuids16bit[j].length; k++) {
scanData[i++] = serviceUuids16bit[j][k];
advertisementData[i++] = serviceUuids16bit[j][k];
}
}
}

if (serviceUuids128bit.length) {
scanData[i++] = 1 + 16 * serviceUuids128bit.length;
scanData[i++] = 0x06;
advertisementData[i++] = 1 + 16 * serviceUuids128bit.length;
advertisementData[i++] = 0x06;
for (j = 0; j < serviceUuids128bit.length; j++) {
for (k = 0; k < serviceUuids128bit[j].length; k++) {
scanData[i++] = serviceUuids128bit[j][k];
advertisementData[i++] = serviceUuids128bit[j][k];
}
}
}

i = 0;
var scanData = new Buffer(scanDataLength);

// name
if (name && name.length) {
var nameBuffer = new Buffer(name);

scanData[i++] = nameBuffer.length + 1;
scanData[i++] = 0x08;
for (j = 0; j < nameBuffer.length; j++) {
scanData[i++] = nameBuffer[j];
}
}

this.startAdvertisingWithEIRData(advertisementData, scanData);
};

Expand Down

0 comments on commit 67b9bf1

Please sign in to comment.