diff options
| author | Your Name <you@example.com> | 2026-05-18 22:49:34 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-18 22:49:34 +0530 |
| commit | eb2ae72d91a4b2ec0333a2e6d18eeeeee6b60464 (patch) | |
| tree | eff643bcd00ed44b5d7fd93084be1391970d6bd4 | |
| parent | 910fe47b2ed1284d93ff4d274f5c2341cb0d2d0b (diff) | |
feat: add WiFi setup state machine + config_add_wifi with unit tests
| -rw-r--r-- | main/config.c | 57 | ||||
| -rw-r--r-- | main/config.h | 1 | ||||
| -rw-r--r-- | main/wifi_setup.c | 89 | ||||
| -rw-r--r-- | main/wifi_setup.h | 51 | ||||
| -rw-r--r-- | tests/unit/Makefile | 5 | ||||
| -rw-r--r-- | tests/unit/test_wifi_setup.c | 121 |
6 files changed, 323 insertions, 1 deletions
diff --git a/main/config.c b/main/config.c index 6753f40..32ae30e 100644 --- a/main/config.c +++ b/main/config.c | |||
| @@ -320,3 +320,60 @@ void tollgate_config_derive_unique(tollgate_config_t *cfg) | |||
| 320 | ESP_LOGI(TAG, "Unique config derived from nsec: SSID='%s', AP_IP=%s", | 320 | ESP_LOGI(TAG, "Unique config derived from nsec: SSID='%s', AP_IP=%s", |
| 321 | cfg->ap_ssid, cfg->ap_ip_str); | 321 | cfg->ap_ssid, cfg->ap_ip_str); |
| 322 | } | 322 | } |
| 323 | |||
| 324 | esp_err_t tollgate_config_add_wifi(const char *ssid, const char *password) { | ||
| 325 | if (!ssid || !password) return ESP_ERR_INVALID_ARG; | ||
| 326 | if (g_config.network_count >= TOLLGATE_MAX_WIFI_NETWORKS) return ESP_ERR_NO_MEM; | ||
| 327 | |||
| 328 | strncpy(g_config.networks[g_config.network_count].ssid, ssid, | ||
| 329 | sizeof(g_config.networks[g_config.network_count].ssid) - 1); | ||
| 330 | strncpy(g_config.networks[g_config.network_count].password, password, | ||
| 331 | sizeof(g_config.networks[g_config.network_count].password) - 1); | ||
| 332 | g_config.network_count++; | ||
| 333 | |||
| 334 | cJSON *root = cJSON_CreateObject(); | ||
| 335 | cJSON *nsec = cJSON_CreateString(g_config.nsec); | ||
| 336 | cJSON_AddItemToObject(root, "nsec", nsec); | ||
| 337 | |||
| 338 | cJSON *networks = cJSON_CreateArray(); | ||
| 339 | for (int i = 0; i < g_config.network_count; i++) { | ||
| 340 | cJSON *net = cJSON_CreateObject(); | ||
| 341 | cJSON_AddStringToObject(net, "ssid", g_config.networks[i].ssid); | ||
| 342 | cJSON_AddStringToObject(net, "password", g_config.networks[i].password); | ||
| 343 | cJSON_AddItemToArray(networks, net); | ||
| 344 | } | ||
| 345 | cJSON_AddItemToObject(root, "wifi_networks", networks); | ||
| 346 | |||
| 347 | if (g_config.ap_password[0]) | ||
| 348 | cJSON_AddStringToObject(root, "ap_password", g_config.ap_password); | ||
| 349 | cJSON_AddStringToObject(root, "mint_url", g_config.mint_url); | ||
| 350 | cJSON_AddNumberToObject(root, "price_per_step", g_config.price_per_step); | ||
| 351 | cJSON_AddNumberToObject(root, "step_size_ms", g_config.step_size_ms); | ||
| 352 | |||
| 353 | if (g_config.metric[0]) | ||
| 354 | cJSON_AddStringToObject(root, "metric", g_config.metric); | ||
| 355 | |||
| 356 | cJSON_AddStringToObject(root, "nostr_geohash", g_config.nostr_geohash); | ||
| 357 | |||
| 358 | cJSON *relays = cJSON_CreateArray(); | ||
| 359 | for (int i = 0; i < g_config.nostr_relay_count; i++) { | ||
| 360 | cJSON_AddItemToArray(relays, cJSON_CreateString(g_config.nostr_relays[i])); | ||
| 361 | } | ||
| 362 | cJSON_AddItemToObject(root, "nostr_relays", relays); | ||
| 363 | cJSON_AddNumberToObject(root, "nostr_publish_interval_s", g_config.nostr_publish_interval_s); | ||
| 364 | |||
| 365 | char *json_str = cJSON_Print(root); | ||
| 366 | cJSON_Delete(root); | ||
| 367 | |||
| 368 | FILE *f = fopen("/spiffs/config.json", "w"); | ||
| 369 | if (!f) { | ||
| 370 | free(json_str); | ||
| 371 | return ESP_FAIL; | ||
| 372 | } | ||
| 373 | fputs(json_str, f); | ||
| 374 | fclose(f); | ||
| 375 | free(json_str); | ||
| 376 | |||
| 377 | ESP_LOGI(TAG, "Added WiFi network '%s' to config (total: %d)", ssid, g_config.network_count); | ||
| 378 | return ESP_OK; | ||
| 379 | } | ||
diff --git a/main/config.h b/main/config.h index fa4d95c..dad0ef0 100644 --- a/main/config.h +++ b/main/config.h | |||
| @@ -71,5 +71,6 @@ esp_err_t tollgate_config_init(void); | |||
| 71 | const tollgate_config_t *tollgate_config_get(void); | 71 | const tollgate_config_t *tollgate_config_get(void); |
| 72 | esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config); | 72 | esp_err_t tollgate_config_get_wifi(wifi_config_t *wifi_config); |
| 73 | esp_err_t tollgate_config_get_next_wifi(wifi_config_t *wifi_config); | 73 | esp_err_t tollgate_config_get_next_wifi(wifi_config_t *wifi_config); |
| 74 | esp_err_t tollgate_config_add_wifi(const char *ssid, const char *password); | ||
| 74 | 75 | ||
| 75 | #endif | 76 | #endif |
diff --git a/main/wifi_setup.c b/main/wifi_setup.c new file mode 100644 index 0000000..b2669e9 --- /dev/null +++ b/main/wifi_setup.c | |||
| @@ -0,0 +1,89 @@ | |||
| 1 | #include "wifi_setup.h" | ||
| 2 | #include <string.h> | ||
| 3 | |||
| 4 | void wifi_setup_init(wifi_setup_t *setup) { | ||
| 5 | if (!setup) return; | ||
| 6 | memset(setup, 0, sizeof(*setup)); | ||
| 7 | setup->state = SETUP_SCAN; | ||
| 8 | setup->selected_ap = -1; | ||
| 9 | } | ||
| 10 | |||
| 11 | void wifi_setup_set_aps(wifi_setup_t *setup, const wifi_ap_info_t *aps, int count) { | ||
| 12 | if (!setup || !aps) return; | ||
| 13 | if (count > WIFI_SETUP_MAX_APS) count = WIFI_SETUP_MAX_APS; | ||
| 14 | memcpy(setup->aps, aps, count * sizeof(wifi_ap_info_t)); | ||
| 15 | setup->ap_count = count; | ||
| 16 | setup->list_scroll = 0; | ||
| 17 | setup->state = SETUP_LIST; | ||
| 18 | } | ||
| 19 | |||
| 20 | int wifi_setup_visible_count(const wifi_setup_t *setup) { | ||
| 21 | if (!setup) return 0; | ||
| 22 | int remaining = setup->ap_count - setup->list_scroll; | ||
| 23 | if (remaining > WIFI_SETUP_MAX_VISIBLE) remaining = WIFI_SETUP_MAX_VISIBLE; | ||
| 24 | return remaining < 0 ? 0 : remaining; | ||
| 25 | } | ||
| 26 | |||
| 27 | const wifi_ap_info_t *wifi_setup_get_visible(const wifi_setup_t *setup, int idx) { | ||
| 28 | if (!setup || idx < 0 || idx >= wifi_setup_visible_count(setup)) return NULL; | ||
| 29 | return &setup->aps[setup->list_scroll + idx]; | ||
| 30 | } | ||
| 31 | |||
| 32 | setup_state_t wifi_setup_handle_select(wifi_setup_t *setup, int list_idx) { | ||
| 33 | if (!setup || setup->state != SETUP_LIST) return setup ? setup->state : SETUP_CANCELLED; | ||
| 34 | if (list_idx < 0 || list_idx >= wifi_setup_visible_count(setup)) return setup->state; | ||
| 35 | |||
| 36 | int real_idx = setup->list_scroll + list_idx; | ||
| 37 | setup->selected_ap = real_idx; | ||
| 38 | strncpy(setup->selected_ssid, setup->aps[real_idx].ssid, WIFI_SETUP_SSID_LEN - 1); | ||
| 39 | setup->selected_ssid[WIFI_SETUP_SSID_LEN - 1] = '\0'; | ||
| 40 | setup->state = SETUP_PASSWORD; | ||
| 41 | return setup->state; | ||
| 42 | } | ||
| 43 | |||
| 44 | setup_state_t wifi_setup_handle_connect(wifi_setup_t *setup) { | ||
| 45 | if (!setup || setup->state != SETUP_PASSWORD) return setup ? setup->state : SETUP_CANCELLED; | ||
| 46 | setup->state = SETUP_CONNECTING; | ||
| 47 | return setup->state; | ||
| 48 | } | ||
| 49 | |||
| 50 | setup_state_t wifi_setup_handle_connect_result(wifi_setup_t *setup, bool success, const char *ip) { | ||
| 51 | if (!setup) return SETUP_CANCELLED; | ||
| 52 | if (setup->state != SETUP_CONNECTING) return setup->state; | ||
| 53 | |||
| 54 | if (success) { | ||
| 55 | setup->state = SETUP_SUCCESS; | ||
| 56 | if (ip) { | ||
| 57 | strncpy(setup->connect_ip, ip, sizeof(setup->connect_ip) - 1); | ||
| 58 | setup->connect_ip[sizeof(setup->connect_ip) - 1] = '\0'; | ||
| 59 | } | ||
| 60 | setup->connect_failed_auth = false; | ||
| 61 | } else { | ||
| 62 | setup->state = SETUP_FAILED; | ||
| 63 | setup->connect_failed_auth = true; | ||
| 64 | setup->connect_ip[0] = '\0'; | ||
| 65 | } | ||
| 66 | return setup->state; | ||
| 67 | } | ||
| 68 | |||
| 69 | setup_state_t wifi_setup_handle_cancel(wifi_setup_t *setup) { | ||
| 70 | if (!setup) return SETUP_CANCELLED; | ||
| 71 | setup->state = SETUP_CANCELLED; | ||
| 72 | return setup->state; | ||
| 73 | } | ||
| 74 | |||
| 75 | setup_state_t wifi_setup_handle_retry(wifi_setup_t *setup) { | ||
| 76 | if (!setup) return SETUP_CANCELLED; | ||
| 77 | if (setup->state != SETUP_FAILED) return setup->state; | ||
| 78 | setup->state = SETUP_PASSWORD; | ||
| 79 | setup->connect_failed_auth = false; | ||
| 80 | return setup->state; | ||
| 81 | } | ||
| 82 | |||
| 83 | setup_state_t wifi_setup_handle_change_network(wifi_setup_t *setup) { | ||
| 84 | if (!setup) return SETUP_CANCELLED; | ||
| 85 | if (setup->state != SETUP_FAILED) return setup->state; | ||
| 86 | setup->state = SETUP_LIST; | ||
| 87 | setup->connect_failed_auth = false; | ||
| 88 | return setup->state; | ||
| 89 | } | ||
diff --git a/main/wifi_setup.h b/main/wifi_setup.h new file mode 100644 index 0000000..17712d5 --- /dev/null +++ b/main/wifi_setup.h | |||
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef WIFI_SETUP_H | ||
| 2 | #define WIFI_SETUP_H | ||
| 3 | |||
| 4 | #include "esp_err.h" | ||
| 5 | #include <stdint.h> | ||
| 6 | #include <stdbool.h> | ||
| 7 | |||
| 8 | #define WIFI_SETUP_MAX_APS 20 | ||
| 9 | #define WIFI_SETUP_MAX_VISIBLE 8 | ||
| 10 | #define WIFI_SETUP_SSID_LEN 33 | ||
| 11 | #define WIFI_SETUP_PASS_LEN 64 | ||
| 12 | |||
| 13 | typedef enum { | ||
| 14 | SETUP_SCAN, | ||
| 15 | SETUP_LIST, | ||
| 16 | SETUP_PASSWORD, | ||
| 17 | SETUP_CONNECTING, | ||
| 18 | SETUP_SUCCESS, | ||
| 19 | SETUP_FAILED, | ||
| 20 | SETUP_CANCELLED | ||
| 21 | } setup_state_t; | ||
| 22 | |||
| 23 | typedef struct { | ||
| 24 | char ssid[WIFI_SETUP_SSID_LEN]; | ||
| 25 | int rssi; | ||
| 26 | bool secured; | ||
| 27 | } wifi_ap_info_t; | ||
| 28 | |||
| 29 | typedef struct { | ||
| 30 | setup_state_t state; | ||
| 31 | wifi_ap_info_t aps[WIFI_SETUP_MAX_APS]; | ||
| 32 | int ap_count; | ||
| 33 | int list_scroll; | ||
| 34 | int selected_ap; | ||
| 35 | char selected_ssid[WIFI_SETUP_SSID_LEN]; | ||
| 36 | char connect_ip[16]; | ||
| 37 | bool connect_failed_auth; | ||
| 38 | } wifi_setup_t; | ||
| 39 | |||
| 40 | void wifi_setup_init(wifi_setup_t *setup); | ||
| 41 | void wifi_setup_set_aps(wifi_setup_t *setup, const wifi_ap_info_t *aps, int count); | ||
| 42 | int wifi_setup_visible_count(const wifi_setup_t *setup); | ||
| 43 | const wifi_ap_info_t *wifi_setup_get_visible(const wifi_setup_t *setup, int idx); | ||
| 44 | setup_state_t wifi_setup_handle_select(wifi_setup_t *setup, int list_idx); | ||
| 45 | setup_state_t wifi_setup_handle_connect(wifi_setup_t *setup); | ||
| 46 | setup_state_t wifi_setup_handle_connect_result(wifi_setup_t *setup, bool success, const char *ip); | ||
| 47 | setup_state_t wifi_setup_handle_cancel(wifi_setup_t *setup); | ||
| 48 | setup_state_t wifi_setup_handle_retry(wifi_setup_t *setup); | ||
| 49 | setup_state_t wifi_setup_handle_change_network(wifi_setup_t *setup); | ||
| 50 | |||
| 51 | #endif | ||
diff --git a/tests/unit/Makefile b/tests/unit/Makefile index b978891..0faf47e 100644 --- a/tests/unit/Makefile +++ b/tests/unit/Makefile | |||
| @@ -22,7 +22,7 @@ LDFLAGS := -lmbedcrypto -lcjson -lm | |||
| 22 | 22 | ||
| 23 | SECP256K1_OBJ := secp256k1.o precomputed_ecmult.o precomputed_ecmult_gen.o | 23 | SECP256K1_OBJ := secp256k1.o precomputed_ecmult.o precomputed_ecmult_gen.o |
| 24 | 24 | ||
| 25 | TESTS := test_geohash test_identity test_nostr_event test_cashu test_session test_tollgate_client test_lnurl_pay test_lightning_payout test_mcp_handler test_nip04 test_cvm_server test_touch test_keyboard | 25 | TESTS := test_geohash test_identity test_nostr_event test_cashu test_session test_tollgate_client test_lnurl_pay test_lightning_payout test_mcp_handler test_nip04 test_cvm_server test_touch test_keyboard test_wifi_setup |
| 26 | 26 | ||
| 27 | .PHONY: all test clean $(TESTS) | 27 | .PHONY: all test clean $(TESTS) |
| 28 | 28 | ||
| @@ -87,5 +87,8 @@ test_touch: test_touch.c $(REPO_ROOT)/main/touch.c | |||
| 87 | test_keyboard: test_keyboard.c $(REPO_ROOT)/main/keyboard.c | 87 | test_keyboard: test_keyboard.c $(REPO_ROOT)/main/keyboard.c |
| 88 | $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/keyboard.c -o $@ $(LDFLAGS) | 88 | $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/keyboard.c -o $@ $(LDFLAGS) |
| 89 | 89 | ||
| 90 | test_wifi_setup: test_wifi_setup.c $(REPO_ROOT)/main/wifi_setup.c | ||
| 91 | $(CC) $(CFLAGS) $< $(REPO_ROOT)/main/wifi_setup.c -o $@ $(LDFLAGS) | ||
| 92 | |||
| 90 | clean: | 93 | clean: |
| 91 | rm -f $(TESTS) $(SECP256K1_OBJ) | 94 | rm -f $(TESTS) $(SECP256K1_OBJ) |
diff --git a/tests/unit/test_wifi_setup.c b/tests/unit/test_wifi_setup.c new file mode 100644 index 0000000..5f1b8f0 --- /dev/null +++ b/tests/unit/test_wifi_setup.c | |||
| @@ -0,0 +1,121 @@ | |||
| 1 | #include "test_framework.h" | ||
| 2 | #include "../../main/wifi_setup.h" | ||
| 3 | #include <string.h> | ||
| 4 | |||
| 5 | int main(void) | ||
| 6 | { | ||
| 7 | printf("=== test_wifi_setup ===\n"); | ||
| 8 | |||
| 9 | wifi_setup_t setup; | ||
| 10 | wifi_setup_init(&setup); | ||
| 11 | |||
| 12 | ASSERT_EQ_INT(SETUP_SCAN, (int)setup.state, "Init state = SCAN"); | ||
| 13 | ASSERT_EQ_INT(0, setup.ap_count, "Init ap_count = 0"); | ||
| 14 | ASSERT_EQ_INT(-1, setup.selected_ap, "Init selected_ap = -1"); | ||
| 15 | |||
| 16 | wifi_ap_info_t test_aps[3] = { | ||
| 17 | {"FastNet", -30, true}, | ||
| 18 | {"SlowNet", -70, true}, | ||
| 19 | {"OpenNet", -50, false}, | ||
| 20 | }; | ||
| 21 | wifi_setup_set_aps(&setup, test_aps, 3); | ||
| 22 | |||
| 23 | ASSERT_EQ_INT(SETUP_LIST, (int)setup.state, "After set_aps: state = LIST"); | ||
| 24 | ASSERT_EQ_INT(3, setup.ap_count, "After set_aps: ap_count = 3"); | ||
| 25 | ASSERT_EQ_INT(3, wifi_setup_visible_count(&setup), "Visible count = 3"); | ||
| 26 | |||
| 27 | { | ||
| 28 | const wifi_ap_info_t *ap = wifi_setup_get_visible(&setup, 0); | ||
| 29 | ASSERT(ap != NULL, "Visible AP 0 is not NULL"); | ||
| 30 | ASSERT_EQ_STR("FastNet", ap->ssid, "AP 0 = FastNet"); | ||
| 31 | ASSERT_EQ_INT(-30, ap->rssi, "AP 0 RSSI = -30"); | ||
| 32 | ASSERT(ap->secured, "AP 0 is secured"); | ||
| 33 | } | ||
| 34 | |||
| 35 | { | ||
| 36 | const wifi_ap_info_t *ap = wifi_setup_get_visible(&setup, 2); | ||
| 37 | ASSERT(ap != NULL, "Visible AP 2 is not NULL"); | ||
| 38 | ASSERT_EQ_STR("OpenNet", ap->ssid, "AP 2 = OpenNet"); | ||
| 39 | ASSERT(!ap->secured, "AP 2 is open"); | ||
| 40 | } | ||
| 41 | |||
| 42 | { | ||
| 43 | const wifi_ap_info_t *ap = wifi_setup_get_visible(&setup, 3); | ||
| 44 | ASSERT(ap == NULL, "Out of range returns NULL"); | ||
| 45 | } | ||
| 46 | |||
| 47 | setup_state_t s = wifi_setup_handle_select(&setup, 0); | ||
| 48 | ASSERT_EQ_INT(SETUP_PASSWORD, (int)s, "Select AP 0: state = PASSWORD"); | ||
| 49 | ASSERT_EQ_INT(0, setup.selected_ap, "Selected AP index = 0"); | ||
| 50 | ASSERT_EQ_STR("FastNet", setup.selected_ssid, "Selected SSID = FastNet"); | ||
| 51 | |||
| 52 | wifi_setup_handle_connect(&setup); | ||
| 53 | ASSERT_EQ_INT(SETUP_CONNECTING, (int)setup.state, "Connect: state = CONNECTING"); | ||
| 54 | |||
| 55 | s = wifi_setup_handle_connect_result(&setup, true, "192.168.1.42"); | ||
| 56 | ASSERT_EQ_INT(SETUP_SUCCESS, (int)s, "Connect success: state = SUCCESS"); | ||
| 57 | ASSERT_EQ_STR("192.168.1.42", setup.connect_ip, "Connect IP stored"); | ||
| 58 | |||
| 59 | wifi_setup_init(&setup); | ||
| 60 | wifi_setup_set_aps(&setup, test_aps, 3); | ||
| 61 | wifi_setup_handle_select(&setup, 1); | ||
| 62 | wifi_setup_handle_connect(&setup); | ||
| 63 | |||
| 64 | s = wifi_setup_handle_connect_result(&setup, false, NULL); | ||
| 65 | ASSERT_EQ_INT(SETUP_FAILED, (int)s, "Connect fail: state = FAILED"); | ||
| 66 | ASSERT(setup.connect_failed_auth, "Failed auth flag set"); | ||
| 67 | |||
| 68 | s = wifi_setup_handle_retry(&setup); | ||
| 69 | ASSERT_EQ_INT(SETUP_PASSWORD, (int)s, "Retry: state = PASSWORD"); | ||
| 70 | ASSERT(!setup.connect_failed_auth, "Retry clears auth flag"); | ||
| 71 | |||
| 72 | wifi_setup_init(&setup); | ||
| 73 | wifi_setup_set_aps(&setup, test_aps, 3); | ||
| 74 | wifi_setup_handle_select(&setup, 0); | ||
| 75 | wifi_setup_handle_connect(&setup); | ||
| 76 | wifi_setup_handle_connect_result(&setup, false, NULL); | ||
| 77 | |||
| 78 | s = wifi_setup_handle_change_network(&setup); | ||
| 79 | ASSERT_EQ_INT(SETUP_LIST, (int)s, "Change network: state = LIST"); | ||
| 80 | |||
| 81 | wifi_setup_init(&setup); | ||
| 82 | s = wifi_setup_handle_cancel(&setup); | ||
| 83 | ASSERT_EQ_INT(SETUP_CANCELLED, (int)s, "Cancel: state = CANCELLED"); | ||
| 84 | |||
| 85 | wifi_setup_init(&setup); | ||
| 86 | wifi_ap_info_t many_aps[12]; | ||
| 87 | for (int i = 0; i < 12; i++) { | ||
| 88 | snprintf(many_aps[i].ssid, sizeof(many_aps[i].ssid), "Net%d", i); | ||
| 89 | many_aps[i].rssi = -30 - i * 5; | ||
| 90 | many_aps[i].secured = true; | ||
| 91 | } | ||
| 92 | wifi_setup_set_aps(&setup, many_aps, 12); | ||
| 93 | ASSERT_EQ_INT(12, setup.ap_count, "12 APs stored"); | ||
| 94 | ASSERT_EQ_INT(8, wifi_setup_visible_count(&setup), "Only 8 visible"); | ||
| 95 | |||
| 96 | { | ||
| 97 | const wifi_ap_info_t *ap = wifi_setup_get_visible(&setup, 7); | ||
| 98 | ASSERT(ap != NULL, "8th visible AP exists"); | ||
| 99 | ASSERT_EQ_STR("Net7", ap->ssid, "8th visible = Net7"); | ||
| 100 | } | ||
| 101 | |||
| 102 | wifi_setup_init(&setup); | ||
| 103 | s = wifi_setup_handle_select(&setup, 0); | ||
| 104 | ASSERT_EQ_INT(SETUP_SCAN, (int)s, "Select in SCAN state = no change"); | ||
| 105 | |||
| 106 | s = wifi_setup_handle_select(&setup, -1); | ||
| 107 | ASSERT_EQ_INT(SETUP_SCAN, (int)s, "Select invalid idx = no change"); | ||
| 108 | |||
| 109 | wifi_setup_init(&setup); | ||
| 110 | wifi_setup_set_aps(&setup, test_aps, 3); | ||
| 111 | s = wifi_setup_handle_retry(&setup); | ||
| 112 | ASSERT_EQ_INT(SETUP_LIST, (int)s, "Retry in LIST state = no change"); | ||
| 113 | |||
| 114 | s = wifi_setup_handle_change_network(&setup); | ||
| 115 | ASSERT_EQ_INT(SETUP_LIST, (int)s, "Change network in LIST state = no change"); | ||
| 116 | |||
| 117 | ASSERT_EQ_INT(0, wifi_setup_visible_count(NULL), "NULL setup returns 0"); | ||
| 118 | ASSERT(NULL == wifi_setup_get_visible(NULL, 0), "NULL setup returns NULL AP"); | ||
| 119 | |||
| 120 | TEST_SUMMARY(); | ||
| 121 | } | ||