fix styling,

fix http serv deinit
This commit is contained in:
Arthur Lu 2024-02-29 14:21:31 -08:00
parent 8cd68286df
commit bc52e60153
2 changed files with 12 additions and 8 deletions

View File

@ -16,7 +16,6 @@ typedef struct TCP_SERVER_T_ {
struct tcp_pcb * server_pcb;
bool complete;
ip_addr_t gw;
} TCP_SERVER_T;
typedef struct TCP_CONNECT_STATE_T_ {
@ -29,7 +28,7 @@ typedef struct TCP_CONNECT_STATE_T_ {
ip_addr_t * gw;
} TCP_CONNECT_STATE_T;
TCP_SERVER_T * state = NULL;
TCP_SERVER_T * http_serv_state = NULL;
static err_t tcp_close_client_connection(TCP_CONNECT_STATE_T * con_state, struct tcp_pcb * client_pcb, err_t close_err) {
if (client_pcb) {
@ -274,13 +273,13 @@ static bool tcp_server_open(void * arg) {
}
int http_serv_init () {
state = calloc(1, sizeof(TCP_SERVER_T));
if (!state) {
http_serv_state = calloc(1, sizeof(TCP_SERVER_T));
if (!http_serv_state) {
DEBUG_printf("[HTTP] [ERR] Failed to allocate state\n");
return 1;
}
if (!tcp_server_open(state)) {
if (!tcp_server_open(http_serv_state)) {
DEBUG_printf("[HTTP] [ERR] Failed to open server\n");
return 1;
}
@ -291,7 +290,9 @@ int http_serv_init () {
}
int http_serv_deinit () {
tcp_server_close(state);
tcp_server_close(http_serv_state);
free(http_serv_state);
http_serv_state = NULL;
return 0;
}

5
main.c
View File

@ -30,8 +30,11 @@ int main() {
// set LED to on to indicate it has connected and initialized
cyw43_arch_gpio_put(CYW43_WL_GPIO_LED_PIN, 1);
while(true);
while (!http_serv_state->complete) {
sleep_ms(1000);
}
bmc_handler_deinit();
http_serv_deinit();
cyw43_arch_deinit();
return 0;