Commit 8e09bee1 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Revert "ralphs test branch. I think it should be working" I committed to master like a retard.

This reverts commit 349c3c84
parent f8c4f74e
......@@ -26,21 +26,54 @@
#include "app/status.h"
static const char* TAG = "MAIN_MODULE";
static volatile bool door_request_done;
static volatile bool door_access_accepted;
static void code_check_done(int32_t status_code)
{
door_request_done = true;
door_access_accepted = status_code == HTTP_SUCCESS;
}
static void check_code_task(void* pvParameters)
{
(void)pvParameters;
// door_rtos_wait_forever_for_event(WIFI_CONNECTED_EVENT);
ESP_LOGI(TAG, "Started test thread. Opening door...");
door_lock_open();
ESP_LOGI(TAG, "Door unlock request sent to the door lock module");
door_rtos_wait_forever_for_event(WIFI_CONNECTED_EVENT);
ESP_LOGI(TAG, "Connected to AP, begin connecting to DoorCode API");
door_api_verify_code("123866", code_check_done);
while (!door_request_done)
door_rtos_task_delay(100);
if (door_access_accepted)
{
ESP_LOGI(TAG, "We are allowed in the first door!");
door_lock_open();
}
else
ESP_LOGI(TAG, "REJECTED from first door");
door_request_done = false;
door_rtos_task_delay(5000);
ESP_LOGI(TAG, "Putting controller in open mode.");
door_rtos_event_set(DOOR_OPEN_MODE_EVENT);
ESP_LOGI(TAG, "Door is now in open mode. Any registered keypad presses will open door.");
ESP_LOGI(TAG, "Making second request");
door_api_verify_code("123867", code_check_done);
while (!door_request_done)
door_rtos_task_delay(100);
ESP_LOGI(TAG, "Done with second request");
if (door_access_accepted)
{
ESP_LOGI(TAG, "We are allowed in the second door!");
door_lock_open();
}
else
ESP_LOGI(TAG, "REJECTED from second door");
ESP_LOGI(TAG, "Stopping test thread... Other threads are still running meaning that any keypress will still be"
" registered and handled");
// door_api_stop();
// door_wifi_destroy();
ESP_LOGI(TAG, "Finished Requests shutting down the scrublord thread");
door_rtos_task_current_kill();
}
......@@ -49,35 +82,35 @@ void initialize(void)
// Setup non volatile storage
door_nvs_initialize();
// Setup API token (This uses NVS)
// door_token_initialize(API_TOKEN);
door_token_initialize(API_TOKEN);
// Setup the RTOS interfaces such as events
door_rtos_initialize();
// Needs RTOS
door_keypad_initialize();
// Start up WiFi (WiFi uses tokens and the RTOS events)
// door_wifi_initialize();
door_wifi_initialize();
// Setup SNTP time syncing (Uses WiFi and the RTOS events)
// door_sntp_initialize();
door_sntp_initialize();
// Needs RTOS and token, possibly WiFi? but not for initialization I don't think.
// door_api_initialize();
door_api_initialize();
// Needs the API
// door_status_initialize();
door_status_initialize();
}
void start(void)
{
// xTaskCreate(door_api_handle_requests_task, "api_task", 4096, NULL, 5, NULL);
xTaskCreate(door_api_handle_requests_task, "api_task", 4096, NULL, 5, NULL);
xTaskCreate(door_lock_task, "lock_task", 4096, NULL, 6, NULL);
xTaskCreate(door_keypad_scan_task, "keypad_task", 4096, NULL, 6, NULL);
xTaskCreate(door_state_task, "state_task", 4096, NULL, 5, NULL);
// xTaskCreate(update_task, "update_task", 4096, NULL, 2, NULL);
// xTaskCreate(check_code_task, "http_task", 4096, NULL, 3, NULL);
// xTaskCreate(door_status_refresh_task, "refresh_task", 4096, NULL, 5, NULL);
// xTaskCreate(door_status_sync_status_task, "sync_task", 10240, NULL, 4, NULL);
xTaskCreate(update_task, "update_task", 4096, NULL, 2, NULL);
xTaskCreate(check_code_task, "http_task", 4096, NULL, 3, NULL);
xTaskCreate(door_status_refresh_task, "refresh_task", 4096, NULL, 5, NULL);
xTaskCreate(door_status_sync_status_task, "sync_task", 10240, NULL, 4, NULL);
}
void app_main()
......
......@@ -13,6 +13,14 @@
bool door_diagnostic_self_test(void)
{
// For the test branch we won't worry about verifying API connectivity.
return true;
door_http_client_handle_t client = door_http_create_client(door_token_get());
if (!door_rtos_event_wait_ms(WIFI_CONNECTED_EVENT, DOOR_DIAGNOSTIC_CONNECT_TIME_MS) || !client)
return false;
int status = door_http_get(client, API_BASE_PATH DOOR_DIAGNOSTIC_TEST_URL, NULL);
door_http_destroy_client_handle(client);
return status == 200;
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment