Skip to content

Commit

Permalink
chore: linter fix
Browse files Browse the repository at this point in the history
  • Loading branch information
stoprocent committed Dec 22, 2024
1 parent 644fcd0 commit c3db116
Showing 1 changed file with 30 additions and 20 deletions.
50 changes: 30 additions & 20 deletions lib/hci-socket/gap.js
Original file line number Diff line number Diff line change
Expand Up @@ -373,26 +373,36 @@ Gap.prototype.parseServices = function (
case 0x16: // 16-bit Service Data
case 0x20: // 32-bit Service Data
case 0x21: // 128-bit Service Data
const uuidLength = eirType === 0x16 ? 2 : (eirType === 0x20 ? 4 : 16);
const serviceUuid = bytes
.slice(0, uuidLength)
.toString('hex')
.match(/.{1,2}/g)
.reverse()
.join('');

// Find existing service data index
const existingIndex = advertisement.serviceData.findIndex(s => s.uuid === serviceUuid);
const serviceData = {
uuid: serviceUuid,
data: bytes.slice(uuidLength, bytes.length)
};

// Update or append service data
if (existingIndex >= 0) {
advertisement.serviceData[existingIndex] = serviceData;
} else {
advertisement.serviceData.push(serviceData);
{
let uuidLength;
if (eirType === 0x16) {
uuidLength = 2;
} else if (eirType === 0x20) {
uuidLength = 4;
} else {
uuidLength = 16;
}

const serviceUuid = bytes
.slice(0, uuidLength)
.toString('hex')
.match(/.{1,2}/g)
.reverse()
.join('');

// Find existing service data index
const existingIndex = advertisement.serviceData.findIndex(s => s.uuid === serviceUuid);
const serviceData = {
uuid: serviceUuid,
data: bytes.slice(uuidLength, bytes.length)
};

// Update or append service data
if (existingIndex >= 0) {
advertisement.serviceData[existingIndex] = serviceData;
} else {
advertisement.serviceData.push(serviceData);
}
}
break;

Expand Down

0 comments on commit c3db116

Please sign in to comment.