mirror of
https://github.com/CovidBraceletPrj/CovidBracelet.git
synced 2024-12-05 00:55:43 +01:00
Rename sequence number functions to fit pattern
This commit is contained in:
parent
e74b58aab5
commit
09ac58c30b
@ -37,11 +37,11 @@ record_t* ens_records_iterator_next(record_iterator_t* iter) {
|
||||
// TODO lome: timestamp?
|
||||
}
|
||||
|
||||
if (sequence_number_eq(iter->sn_next, iter->sn_end)) {
|
||||
if (sn_equal(iter->sn_next, iter->sn_end)) {
|
||||
iter->finished = true; // this iterator will finish after this execution
|
||||
} else {
|
||||
// increase the current sn
|
||||
iter->sn_next = sequence_number_increment(iter->sn_next);
|
||||
iter->sn_next = sn_increment(iter->sn_next);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,10 +4,10 @@ record_sequence_number_t sn_mask(record_sequence_number_t sn) {
|
||||
return (sn & SN_MASK);
|
||||
}
|
||||
|
||||
int sequence_number_eq(record_sequence_number_t a, record_sequence_number_t b) {
|
||||
int sn_equal(record_sequence_number_t a, record_sequence_number_t b) {
|
||||
return sn_mask(a) == sn_mask(b);
|
||||
}
|
||||
|
||||
record_sequence_number_t sequence_number_increment(record_sequence_number_t sn) {
|
||||
record_sequence_number_t sn_increment(record_sequence_number_t sn) {
|
||||
return sn_mask(++sn);
|
||||
}
|
@ -24,7 +24,7 @@ record_sequence_number_t sn_mask(record_sequence_number_t sn);
|
||||
* @param b second sequence number
|
||||
* @return 1, if sequence numbers are equal, 0 otherwise.
|
||||
*/
|
||||
int sequence_number_eq(record_sequence_number_t a, record_sequence_number_t b);
|
||||
int sn_equal(record_sequence_number_t a, record_sequence_number_t b);
|
||||
|
||||
/**
|
||||
* Increment the given sequence number. Wraps around, if 2^24 is reached.
|
||||
@ -32,5 +32,5 @@ int sequence_number_eq(record_sequence_number_t a, record_sequence_number_t b);
|
||||
* @param sn sequence number to increment
|
||||
* @return the incremented sequenced number
|
||||
*/
|
||||
record_sequence_number_t sequence_number_increment(record_sequence_number_t sn);
|
||||
record_sequence_number_t sn_increment(record_sequence_number_t sn);
|
||||
#endif
|
@ -60,7 +60,7 @@ int save_storage_information() {
|
||||
|
||||
void increment_stored_contact_counter() {
|
||||
if (contact_information.count >= MAX_CONTACTS) {
|
||||
contact_information.oldest_contact = sequence_number_increment(contact_information.oldest_contact);
|
||||
contact_information.oldest_contact = sn_increment(contact_information.oldest_contact);
|
||||
} else {
|
||||
contact_information.count++;
|
||||
}
|
||||
@ -105,7 +105,7 @@ int load_contact(contact_t* dest, record_sequence_number_t sn) {
|
||||
}
|
||||
|
||||
int add_contact(contact_t* src) {
|
||||
record_sequence_number_t curr_sn = sequence_number_increment(get_latest_sequence_number());
|
||||
record_sequence_number_t curr_sn = sn_increment(get_latest_sequence_number());
|
||||
storage_id_t id = convert_sn_to_storage_id(curr_sn);
|
||||
|
||||
int rc = nvs_write(&fs, id, src, sizeof(*src));
|
||||
|
Loading…
Reference in New Issue
Block a user