Hi, from what I've understood you're making this way too complicated. A database would need an index to be able to find the item you want to mark as is_logged. However you are always logging and saving the data in a certain order, so i BTree is just a waste of space (and code).
My proposal would be: 1 struct representing a data point struct datapoint { uint64_t timestamp; uint8_t sensor_id; uint8_t value; } And two pointer to keep track of your data on the flash: uint8_t * next_insert_ptr uint8_t * next_to_log_ptr When you get a new datapoint, create it (pseudo code): struct datapoint * dp = new_datapoint(time, sensor, value); save_to_flash_at_address(dp, next_insert_ptr); next_insert_ptr = increase_ptr(next_insert_ptr); And when you're logging over bluetooth: struct datapoint * dp = read_datapoint_from_flash(next_to_log_ptr); log_to_phone_over_bluetooth(dp); next_to_log_ptr = increase_ptr(next_to_log_ptr); The details I haven't bothered with here is for example: * don't log value that is ahead of next_insert_ptr * cycle memory, when 8 gb is full, start again at 0 (or some address above your code) -- Fredrik Gustafsson phone: +46 733-608274 e-mail: iv...@iveqy.com website: http://www.iveqy.com _______________________________________________ sqlite-users mailing list sqlite-users@mailinglists.sqlite.org http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users