diff --git a/configurator/src/include/network.h b/configurator/src/include/network.h index 741e250..1714b6c 100644 --- a/configurator/src/include/network.h +++ b/configurator/src/include/network.h @@ -106,12 +106,13 @@ static ConnectionData connection_data_example = { .status = CONNECTED_WIFI_IP}; #endif -__uint16_t check_latest_release(); +__uint16_t get_latest_release(); __uint16_t wifi_menu(); __uint16_t force_connection_status(__uint16_t show_bar); __uint16_t get_connection_status(__uint16_t show_bar); __uint16_t roms_from_network_selector(); __uint16_t check_network_connection(); + void init_connection_status(); #endif // NETWORK_H diff --git a/configurator/src/main.c b/configurator/src/main.c index f76b17e..4af9e61 100644 --- a/configurator/src/main.c +++ b/configurator/src/main.c @@ -74,7 +74,7 @@ static __int8_t exit_option_index = (sizeof(menuItems) / sizeof(menuItems[0])) - // BLink if there is a new verson available static void blink_if_new_version_available(__uint16_t blink_toogle) { - if (check_latest_release()) + if (get_latest_release()) { locate(47, 0); printf("\033p%s\033q", blink_toogle ? "!" : " "); diff --git a/configurator/src/network.c b/configurator/src/network.c index 9c1f4ad..45b1fa9 100644 --- a/configurator/src/network.c +++ b/configurator/src/network.c @@ -1,10 +1,10 @@ #include "include/network.h" -static ConnectionData *connection_data = NULL; -static ConnectionStatus connection_status = DISCONNECTED; +static __uint16_t poll_latest_release; +static __uint16_t latest_release_available; -static __uint16_t poll_latest_release = TRUE; -static __uint16_t latest_release_available = FALSE; +static ConnectionStatus connection_status = DISCONNECTED; +static ConnectionData *connection_data = NULL; static void read_networks_from_memory(char *ssids, WifiNetworkInfo networks[], __uint16_t total_size) { @@ -92,10 +92,34 @@ char *get_status_str(ConnectionStatus status) return status_str; } +static void check_latest_release() +{ + // Check if the latest release is available + if (connection_data != NULL) + { + if (connection_data->status == CONNECTED_WIFI_IP) + { + if (poll_latest_release) + { + poll_latest_release = FALSE; + int err = send_sync_command(GET_LATEST_RELEASE, NULL, 0, 10, FALSE); + if (err == 0) + { + char *latest_release = (char *)(LATEST_RELEASE_START_ADDRESS + sizeof(__uint32_t)); + // The latest release is the same as the current version or not? + latest_release_available = strlen(latest_release) > 0; + } + } + } + } +} + void init_connection_status() { connection_data = malloc(sizeof(ConnectionData)); memset(connection_data, 0, sizeof(ConnectionData)); + poll_latest_release = TRUE; + latest_release_available = FALSE; } __uint16_t get_connection_status(__uint16_t show_bar) @@ -137,26 +161,8 @@ __uint16_t get_connection_status(__uint16_t show_bar) return err; } -__uint16_t check_latest_release() +__uint16_t get_latest_release() { - // Check if the latest release is available - if (connection_data != NULL) - { - if (connection_data->status == CONNECTED_WIFI_IP) - { - if (poll_latest_release) - { - poll_latest_release = FALSE; - int err = send_sync_command(GET_LATEST_RELEASE, NULL, 0, 10, FALSE); - if (err == 0) - { - char *latest_release = (char *)(LATEST_RELEASE_START_ADDRESS + sizeof(__uint32_t)); - // The latest release is the same as the current version or not? - latest_release_available = strlen(latest_release) > 0; - } - } - } - } return latest_release_available; }