()
| 977 | |
| 978 | class GeckoGATTFile extends GATTFile { |
| 979 | generate() { |
| 980 | let file = this.file; |
| 981 | let services = this.services; |
| 982 | let clientOnly = (this.client && !this.server); |
| 983 | file.line('/* WARNING: This file is automatically generated. Do not edit. */'); |
| 984 | file.line(''); |
| 985 | if (!clientOnly) { |
| 986 | file.line('#include "bg_gattdb_def.h"'); |
| 987 | file.line(''); |
| 988 | file.line('#ifdef __GNUC__'); |
| 989 | file.line('\t#define GATT_HEADER(F) F __attribute__ ((section (".gatt_header")))'); |
| 990 | file.line('\t#define GATT_DATA(F) F __attribute__ ((section (".gatt_data")))'); |
| 991 | file.line('#else'); |
| 992 | file.line('\t#ifdef __ICCARM__'); |
| 993 | file.line('\t\t#define GATT_HEADER(F) _Pragma("location=\\".gatt_header\\"") F'); |
| 994 | file.line('\t\t#define GATT_DATA(F) _Pragma("location=\\".gatt_data\\"") F'); |
| 995 | file.line('\t#else'); |
| 996 | file.line('\t\t#define GATT_HEADER(F) F'); |
| 997 | file.line('\t\t#define GATT_DATA(F) F'); |
| 998 | file.line('\t#endif'); |
| 999 | file.line('#endif'); |
| 1000 | file.line(''); |
| 1001 | } |
| 1002 | file.line("typedef struct {"); |
| 1003 | file.line("\tuint16_t handle;"); |
| 1004 | file.line("\tuint8_t uuid[16];"); |
| 1005 | file.line("\tuint16_t uuid_length;"); |
| 1006 | file.line("\tconst char *name;"); |
| 1007 | file.line("\tconst char *type;"); |
| 1008 | file.line("} char_name_table;"); |
| 1009 | file.line(""); |
| 1010 | let char_names = []; |
| 1011 | let uuidtable_16_map = ["0x2800","0x2801","0x2803"]; |
| 1012 | let uuidtable_128_map = []; |
| 1013 | let dynamic_mapping_map = []; |
| 1014 | let attributes_max = services.length; |
| 1015 | let attributes_dynamic_max = 0; |
| 1016 | let needs_cccd = true; |
| 1017 | services.forEach((service, index) => { |
| 1018 | if (4 != service.uuid.length) |
| 1019 | throw new Error("128-bit UUIDs not supported"); |
| 1020 | uuidtable_16_map.push('0x' + service.uuid); |
| 1021 | let characteristics = service.characteristics; |
| 1022 | let length = Object.keys(characteristics).length; |
| 1023 | attributes_max += (length * 2); |
| 1024 | for (let key in characteristics) { |
| 1025 | let characteristic = characteristics[key]; |
| 1026 | if ((undefined === characteristic.permissions) && this.client) |
| 1027 | characteristic.permissions = "read"; |
| 1028 | if ((undefined === characteristic.properties) && this.client) |
| 1029 | characteristic.properties = "read"; |
| 1030 | if (!characteristic.hasOwnProperty("value")) |
| 1031 | attributes_dynamic_max += 1; |
| 1032 | if (4 != characteristic.uuid.length) |
| 1033 | throw new Error("128-bit UUIDs not supported"); |
| 1034 | uuidtable_16_map.push('0x' + characteristic.uuid); |
| 1035 | let properties = characteristic.properties; |
| 1036 | if (properties.includes("notify") || properties.includes("indicate")) { |
nothing calls this directly
no test coverage detected