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 6b2d614
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
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
}
};
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 6b2d614

Please sign in to comment.