MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / addUniqueVendorSpecificUUID

Method addUniqueVendorSpecificUUID

tools/bles2gatt.js:1599–1620  ·  view source on GitHub ↗
(uuid, index, prefix)

Source from the content-addressed store, hash-verified

1597 file.line(`static const uint16_t ${prefix}_handle${index};`);
1598 }
1599 addUniqueVendorSpecificUUID(uuid, index, prefix) {
1600 if (36 !== uuid.length) return;
1601 let vendorSpecificUUIDs = this.vendorSpecificUUIDs;
1602 let buffer = new Uint8Array(uuid128toBuffer(uuid));
1603 let match;
1604 if ("service" == prefix) {
1605 match = vendorSpecificUUIDs.find(entry => { entry.buffer[12] == buffer[12] && entry.buffer[13] == buffer[13] });
1606 }
1607 else {
1608 match = vendorSpecificUUIDs.find(entry => {
1609 let equal = true;
1610 for (let i = 0; equal && (i < 16); ++i) {
1611 if (12 == i || 13 == i)
1612 continue;
1613 equal = entry.buffer[i] == buffer[i];
1614 }
1615 return equal;
1616 });
1617 }
1618 if (!match)
1619 vendorSpecificUUIDs.push({ index, prefix, buffer });
1620 }
1621};
1622
1623export default class extends TOOL {

Callers 1

generateMethod · 0.95

Calls 3

uuid128toBufferFunction · 0.85
findMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected