Skip to content

Commit

Permalink
Init variables not properly intialized
Browse files Browse the repository at this point in the history
  • Loading branch information
diegoparrilla committed Nov 13, 2023
1 parent cd1daf1 commit 0d71ac1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 25 deletions.
3 changes: 2 additions & 1 deletion configurator/src/include/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion configurator/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ? "!" : " ");
Expand Down
52 changes: 29 additions & 23 deletions configurator/src/network.c
Original file line number Diff line number Diff line change
@@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 0d71ac1

Please sign in to comment.