mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-23 19:20:51 +00:00
att_db: add att db version as first byte, report error if version differs (also works for older db without version byte)
This commit is contained in:
parent
eeeae29572
commit
fd1be25d18
@ -200,6 +200,12 @@ static int att_copy_value(att_iterator_t *it, uint16_t offset, uint8_t * buffer,
|
||||
}
|
||||
|
||||
void att_set_db(uint8_t const * db){
|
||||
// validate db version
|
||||
if (db == NULL) return;
|
||||
if (*db++ != ATT_DB_VERSION){
|
||||
log_error("ATT DB version differs, please regenerate .h from .gatt file or update att_db_util.c");
|
||||
return;
|
||||
}
|
||||
att_db = db;
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,7 @@
|
||||
#ifdef MAX_ATT_DB_SIZE
|
||||
static uint8_t att_db_storage[MAX_ATT_DB_SIZE];
|
||||
#else
|
||||
#error Neither HAVE_MALLOC] nor MAX_ATT_DB_SIZE is defined.
|
||||
#error Neither HAVE_MALLOC nor MAX_ATT_DB_SIZE is defined.
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@ -75,7 +75,9 @@ void att_db_util_init(void){
|
||||
att_db = att_db_storage;
|
||||
att_db_max_size = sizeof(att_db_storage);
|
||||
#endif
|
||||
att_db_size = 0;
|
||||
// store att version
|
||||
att_db[0] = ATT_DB_VERSION;
|
||||
att_db_size = 1;
|
||||
att_db_next_handle = 1;
|
||||
att_db_util_set_end_tag();
|
||||
}
|
||||
|
@ -301,6 +301,7 @@ typedef uint8_t sm_key_t[16];
|
||||
|
||||
// ..
|
||||
// Internal properties reuse some GATT Characteristic Properties fields
|
||||
#define ATT_DB_VERSION 0x01
|
||||
|
||||
// EVENTS
|
||||
|
||||
|
@ -17,9 +17,10 @@ import sys
|
||||
|
||||
header = '''
|
||||
// {0} generated from {1} for BTstack
|
||||
// att db format version 1
|
||||
|
||||
// binary representation
|
||||
// attribute size in bytes (16), flags(16), handle (16), uuid (16/128), value(...)
|
||||
// binary attribute representation:
|
||||
// - size in bytes (16), flags(16), handle (16), uuid (16/128), value(...)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
@ -825,7 +826,12 @@ def parse(fname_in, fin, fname_out, fout):
|
||||
|
||||
fout.write(header.format(fname_out, fname_in))
|
||||
fout.write('{\n')
|
||||
|
||||
write_indent(fout)
|
||||
fout.write('// ATT DB Version\n')
|
||||
write_indent(fout)
|
||||
fout.write('1,\n')
|
||||
fout.write("\n")
|
||||
|
||||
parseLines(fname_in, fin, fout)
|
||||
|
||||
serviceDefinitionComplete(fout)
|
||||
|
Loading…
x
Reference in New Issue
Block a user