diff options
Diffstat (limited to 'main/tollgate_main.c')
| -rw-r--r-- | main/tollgate_main.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c index 6adb0ec..2670f05 100644 --- a/main/tollgate_main.c +++ b/main/tollgate_main.c | |||
| @@ -79,6 +79,12 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base, | |||
| 79 | } | 79 | } |
| 80 | } | 80 | } |
| 81 | 81 | ||
| 82 | static void services_start_task(void *pvParameters) | ||
| 83 | { | ||
| 84 | start_services(); | ||
| 85 | vTaskDelete(NULL); | ||
| 86 | } | ||
| 87 | |||
| 82 | static void ip_event_handler(void *arg, esp_event_base_t event_base, | 88 | static void ip_event_handler(void *arg, esp_event_base_t event_base, |
| 83 | int32_t event_id, void *event_data) | 89 | int32_t event_id, void *event_data) |
| 84 | { | 90 | { |
| @@ -88,16 +94,11 @@ static void ip_event_handler(void *arg, esp_event_base_t event_base, | |||
| 88 | s_retry_count = 0; | 94 | s_retry_count = 0; |
| 89 | xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); | 95 | xEventGroupSetBits(s_wifi_event_group, WIFI_CONNECTED_BIT); |
| 90 | 96 | ||
| 91 | const tollgate_config_t *cfg = tollgate_config_get(); | ||
| 92 | nucula_wallet_init(cfg->mint_url); | ||
| 93 | |||
| 94 | lightning_payout_init(&cfg->payout); | ||
| 95 | |||
| 96 | char gw_ip_str[16]; | 97 | char gw_ip_str[16]; |
| 97 | snprintf(gw_ip_str, sizeof(gw_ip_str), IPSTR, IP2STR(&event->ip_info.gw)); | 98 | snprintf(gw_ip_str, sizeof(gw_ip_str), IPSTR, IP2STR(&event->ip_info.gw)); |
| 98 | tollgate_client_on_sta_connected(gw_ip_str); | 99 | tollgate_client_on_sta_connected(gw_ip_str); |
| 99 | 100 | ||
| 100 | start_services(); | 101 | xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL); |
| 101 | } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { | 102 | } else if (event_base == IP_EVENT && event_id == IP_EVENT_STA_LOST_IP) { |
| 102 | ESP_LOGW(TAG, "Lost IP address"); | 103 | ESP_LOGW(TAG, "Lost IP address"); |
| 103 | xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT); | 104 | xEventGroupClearBits(s_wifi_event_group, WIFI_CONNECTED_BIT); |
| @@ -141,6 +142,9 @@ static void start_services(void) | |||
| 141 | session_manager_init(); | 142 | session_manager_init(); |
| 142 | 143 | ||
| 143 | const tollgate_config_t *cfg = tollgate_config_get(); | 144 | const tollgate_config_t *cfg = tollgate_config_get(); |
| 145 | nucula_wallet_init(cfg->mint_url); | ||
| 146 | lightning_payout_init(&cfg->payout); | ||
| 147 | |||
| 144 | dns_server_start(ap_ip_info.ip, upstream_dns); | 148 | dns_server_start(ap_ip_info.ip, upstream_dns); |
| 145 | captive_portal_start(cfg->ap_ip_str); | 149 | captive_portal_start(cfg->ap_ip_str); |
| 146 | tollgate_api_start(); | 150 | tollgate_api_start(); |