Skip to content

Commit

Permalink
Appearances are now exported, and we also added missing scripts
Browse files Browse the repository at this point in the history
We were missing a schema for GAP Appearance, as well as some form of node validation.
  • Loading branch information
dinesharjani committed Jan 15, 2024
1 parent 6b4d3c2 commit 2532f2d
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
4 changes: 4 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,24 @@ const companies = require(pathForJson('company_ids'));
const services = require(pathForJson('service_uuids'));
const characteristics = require(pathForJson('characteristic_uuids'));
const descriptors = require(pathForJson('descriptor_uuids'));
const appearances = require(pathForJson('gap_appearance'));

const companySchema = require(pathForJson('company_schema'));
const attributeSchema = require(pathForJson('attribute_schema'));
const appearanceSchema = require(pathForJson('appearance_schema'));

module.exports = {
version,
companies,
services,
characteristics,
descriptors,
appearances,
schemas: {
companies: companySchema,
services: attributeSchema,
characteristics: attributeSchema,
descriptors: attributeSchema,
appearances: appearanceSchema
}
};
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bluetooth-numbers-database",
"version": "1.0.3",
"version": "1.1",
"description": "The Nordic Bluetooth UUID Database provides a simple mechanism through which you can keep an up-to-date listing of all the various Bluetooth Specification-related elements that are defined by our industry, such as Company IDs, Service UUIDs, Characteristic UUIDs and Descriptor UUIDs.",
"main": "index.js",
"scripts": {
Expand Down
27 changes: 27 additions & 0 deletions v1/appearance_schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"type": "array",
"items": {
"type": "object",
"properties": {
"category": {
"type": "string",
"pattern": "^[0-9A-Fa-f]+$"
},
"name": {
"type": "string"
},
"subcategory": {
"type": "array",
"items": {
"type": "object",
"properties": {
"value": { "type": "string" },
"name": { "type": "string" }
},
"required": ["value", "name"]
}
}
},
"required": ["category", "name"]
}
}
8 changes: 8 additions & 0 deletions verify.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ const noDuplicates = Object.keys(db)
let companyCodes = db[list].map(company => company.code);
numberOfItems = companyCodes.length;
numberOfUniques = (new Set(companyCodes)).size;
} else if (list == 'appearances') {
let appearances = db[list].map(appearance => appearance.category);
numberOfItems = appearances.length;
numberOfUniques = (new Set(appearances)).size;
if (numberOfItems != numberOfUniques) {
console.error(`Failed to verify '${list}'. Found '${numberOfItems - numberOfUniques}' duplicate items.`);
return false;
}
} else {
// GATT Attributes
let uuids = db[list].map(gatt => gatt.uuid);
Expand Down

0 comments on commit 2532f2d

Please sign in to comment.