()
| 1281 | this.vendorSpecificUUIDs = []; |
| 1282 | } |
| 1283 | generate() { |
| 1284 | let tool = this.tool; |
| 1285 | let file = this.file; |
| 1286 | let services = this.services; |
| 1287 | file.line('/* WARNING: This file is automatically generated. Do not edit. */'); |
| 1288 | file.line(""); |
| 1289 | file.line("typedef struct {"); |
| 1290 | file.line("\tuint8_t service_index;"); |
| 1291 | file.line("\tuint8_t att_index;"); |
| 1292 | file.line("\tconst char *name;"); |
| 1293 | file.line("\tconst char *type;"); |
| 1294 | file.line("} char_name_table;"); |
| 1295 | file.line(""); |
| 1296 | file.line("typedef struct {"); |
| 1297 | file.line("\tuint8_t service_index;"); |
| 1298 | file.line("\tuint8_t att_index;"); |
| 1299 | file.line("\tble_gatts_char_handles_t handles;"); |
| 1300 | file.line("} gatts_handles_t;"); |
| 1301 | file.line(""); |
| 1302 | |
| 1303 | if (0 == services.length) { |
| 1304 | file.line("#define service_count 0"); |
| 1305 | file.line("#define char_name_count 0"); |
| 1306 | file.line("#define max_attribute_count 0"); |
| 1307 | file.line("#define vendor_specific_uuid_count 0"); |
| 1308 | file.line(""); |
| 1309 | file.line("static const uint8_t attribute_counts[0] = {};"); |
| 1310 | file.line("static const gatts_attr_db_t gatt_db[0][0] = {};"); |
| 1311 | file.line("static const char_name_table char_names[0] = {};"); |
| 1312 | file.line("static const vendor_specific_uuid_t vendor_uuids[0] = {};"); |
| 1313 | if (this.server) { |
| 1314 | file.line(""); |
| 1315 | file.line("#define handles_count 0"); |
| 1316 | file.line("static gatts_handles_t att_handles[0] = {};"); |
| 1317 | file.line("static uint16_t service_handles[0] = {};"); |
| 1318 | } |
| 1319 | return; |
| 1320 | } |
| 1321 | var attributeIndex = 0; |
| 1322 | var char_names = []; |
| 1323 | |
| 1324 | var maxAttributeCount = 0; |
| 1325 | var attributeCounts = new Array(services.length); |
| 1326 | var characteristicIndex = 0; |
| 1327 | var descriptorIndex = 0; |
| 1328 | |
| 1329 | services.forEach((service, index) => { |
| 1330 | let attributeCount = 1; |
| 1331 | let characteristics = service.characteristics; |
| 1332 | attributeCount += (Object.keys(characteristics).length * 2); |
| 1333 | for (let key in characteristics) { |
| 1334 | let characteristic = characteristics[key]; |
| 1335 | if ((undefined === characteristic.permissions) && this.client) |
| 1336 | characteristic.permissions = "read"; |
| 1337 | if ((undefined === characteristic.properties) && this.client) |
| 1338 | characteristic.properties = "read"; |
| 1339 | let properties = characteristic.properties; |
| 1340 | if (properties.includes("notify") || properties.includes("indicate")) { |
nothing calls this directly
no test coverage detected