Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions stm32/Src/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,9 @@ bool Esp32Init(void);
void WiFiInit(void) {
APP_LOG(TS_OFF, VLEVEL_M, "WiFi app starting\r\n");

// Mark WiFi controller as initialized so assert guards pass
ControllerWiFiSetInitialized();

// loop until sucessful connection
while (!Esp32Init()) {
Disconnect();
Expand Down
8 changes: 8 additions & 0 deletions stm32/lib/controller/include/controller/wifi.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,14 @@ typedef struct {
size_t size;
} ControllerWiFiResponse;

/**
* @brief Mark the WiFi controller as initialized
*
* Must be called before any other ControllerWiFi* functions. Subsequent calls
* to ControllerWiFi* functions without calling this will trigger an assert.
*/
void ControllerWiFiSetInitialized(void);

/**
* @brief Initialize WiFi settings on the esp32
*
Expand Down
9 changes: 9 additions & 0 deletions stm32/lib/controller/src/wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,17 @@
/** Timeout for i2c communication with esp32, in communication.h */
extern unsigned int g_controller_i2c_timeout;

/** Flag to track if the WiFi controller has been initialized */
static bool wifi_initialized = false;

void ControllerWiFiSetInitialized(void) { wifi_initialized = true; }

ControllerStatus WiFiCommandTransaction(const WiFiCommand *input,
Comment thread
pm-ju marked this conversation as resolved.
WiFiCommand *output) {
if (!wifi_initialized) {
return CONTROLLER_ERROR;
}

// get reference to tx and rx buffers
Buffer *tx = ControllerTx();
Buffer *rx = ControllerRx();
Expand Down
Loading