Skip to content

Commit 8c57c10

Browse files
author
Juha Heiskanen
committed
Code clean and Keep time update at 16-bit.
Change-Id: Ica2efa76f1beb9106695eb2c1776b1b1c3979e31
1 parent 9ff35ab commit 8c57c10

File tree

1 file changed

+8
-15
lines changed
  • source/Service_Libs/etx

1 file changed

+8
-15
lines changed

source/Service_Libs/etx/etx.c

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ static void etx_cache_entry_init(uint8_t attribute_index)
121121
storage->sample_count = 0;
122122
}
123123

124-
static bool etx_update_possible(etx_sample_storage_t *storage, etx_storage_t *entry, uint8_t time)
124+
static bool etx_update_possible(etx_sample_storage_t *storage, etx_storage_t *entry, uint16_t time_update)
125125
{
126-
if (storage->etx_timer && time) {
127-
if (time >= storage->etx_timer) {
126+
if (storage->etx_timer && time_update) {
127+
if (time_update >= storage->etx_timer) {
128128
storage->etx_timer = 0;
129129
} else {
130-
storage->etx_timer -= time;
130+
storage->etx_timer -= time_update;
131131
}
132132
}
133133

@@ -797,19 +797,12 @@ void etx_cache_timer(int8_t interface_id, uint16_t seconds_update)
797797
return;
798798
}
799799

800-
mac_neighbor_table_t *table_class = mac_neighbor_info(interface);
801-
if (!table_class) {
802-
return;
803-
}
804800

805-
uint8_t update_seconds;
806-
if (seconds_update > 255) {
807-
update_seconds = 255;
808-
} else {
809-
update_seconds = seconds_update;
801+
if (!mac_neighbor_info(interface)) {
802+
return;
810803
}
811804

812-
ns_list_foreach(mac_neighbor_table_entry_t, neighbour, &table_class->neighbour_list) {
805+
ns_list_foreach(mac_neighbor_table_entry_t, neighbour, &mac_neighbor_info(interface)->neighbour_list) {
813806

814807
etx_storage_t *etx_entry = etx_storage_entry_get(interface_id, neighbour->index);
815808

@@ -818,7 +811,7 @@ void etx_cache_timer(int8_t interface_id, uint16_t seconds_update)
818811
}
819812
etx_sample_storage_t *storage = etx_info.etx_cache_storage_list + neighbour->index;
820813

821-
if (etx_update_possible(storage, etx_entry, update_seconds)) {
814+
if (etx_update_possible(storage, etx_entry, seconds_update)) {
822815
etx_calculation(etx_entry, storage->attempts_count, storage->received_acks, neighbour->index);
823816
}
824817
}

0 commit comments

Comments
 (0)