()
| 41 | |
| 42 | class BluedroidGATTFile extends ESP32GATTFile { |
| 43 | generate() { |
| 44 | let tool = this.tool; |
| 45 | let file = this.file; |
| 46 | let services = this.services; |
| 47 | file.line('/* WARNING: This file is automatically generated. Do not edit. */'); |
| 48 | file.line(""); |
| 49 | file.line("typedef struct {"); |
| 50 | file.line("\tuint8_t service_index;"); |
| 51 | file.line("\tuint8_t att_index;"); |
| 52 | file.line("\tconst char *name;"); |
| 53 | file.line("\tconst char *type;"); |
| 54 | file.line("} char_name_table;"); |
| 55 | file.line(""); |
| 56 | if (0 == services.length) { |
| 57 | file.line("#define service_count 0"); |
| 58 | file.line("#define char_name_count 0"); |
| 59 | file.line("#define max_attribute_count 0"); |
| 60 | file.line(""); |
| 61 | file.line("static const uint8_t attribute_counts[0] = {};"); |
| 62 | file.line("static const esp_gatts_attr_db_t gatt_db[0][0] = {};"); |
| 63 | file.line("static const char_name_table char_names[0] = {};"); |
| 64 | return; |
| 65 | } |
| 66 | var attributeIndex = 0; |
| 67 | var char_names = []; |
| 68 | file.line("#define CHAR_DECLARATION_SIZE (sizeof(uint8_t))"); |
| 69 | file.line(""); |
| 70 | file.line("static const uint16_t primary_service_uuid = 0x2800;"); |
| 71 | file.line("static const uint16_t character_declaration_uuid = 0x2803;"); |
| 72 | file.line("static const uint16_t character_client_config_uuid = 0x2902;"); |
| 73 | file.line(""); |
| 74 | |
| 75 | var maxAttributeCount = 0; |
| 76 | var attributeCounts = new Array(services.length); |
| 77 | var characteristicIndex = 0; |
| 78 | var descriptorIndex = 0; |
| 79 | services.forEach((service, index) => { |
| 80 | let attributeCount = 1; |
| 81 | let characteristics = service.characteristics; |
| 82 | attributeCount += (Object.keys(characteristics).length * 2); |
| 83 | for (let key in characteristics) { |
| 84 | let characteristic = characteristics[key]; |
| 85 | if ((undefined === characteristic.permissions) && this.client) |
| 86 | characteristic.permissions = "read"; |
| 87 | if ((undefined === characteristic.properties) && this.client) |
| 88 | characteristic.properties = "read"; |
| 89 | let properties = characteristic.properties; |
| 90 | if (properties.includes("notify") || properties.includes("indicate")) { |
| 91 | ++attributeCount; |
| 92 | characteristic._notify = true; |
| 93 | } |
| 94 | if ("descriptors" in characteristic) { |
| 95 | attributeCount += Object.keys(characteristic.descriptors).length; |
| 96 | characteristic._descriptors = true; |
| 97 | } |
| 98 | } |
| 99 | if (attributeCount > maxAttributeCount) |
| 100 | maxAttributeCount = attributeCount; |
nothing calls this directly
no test coverage detected