Commit aefd2303 authored by Jacob Priddy's avatar Jacob Priddy 👌

add some extra debugging statements in needed places

parent 1f946b66
Pipeline #17957 passed with stages
in 1 minute and 19 seconds
......@@ -23,6 +23,8 @@ extern "C" {
void door_state_task(void* parameters);
void door_state_quit(void);
//
//void new_key_hook(unsigned char);
#ifdef __cplusplus
}
......
......@@ -69,6 +69,28 @@ static const char* TAG = "MAIN_MODULE";
// ESP_LOGI(TAG, "Finished Requests shutting down the scrublord thread");
// door_rtos_task_current_kill();
//}
//
//static void debug_task(void* pvParameters)
//{
// door_rtos_wait_forever_for_event(TIME_SYNCED_EVENT);
// door_rtos_task_delay(60000);
// new_key_hook('0');
// door_rtos_task_delay(1000);
// new_key_hook('1');
// door_rtos_task_delay(1000);
// new_key_hook('2');
// door_rtos_task_delay(1000);
// new_key_hook('3');
// door_rtos_task_delay(1000);
// new_key_hook('4');
// door_rtos_task_delay(1000);
// new_key_hook('5');
// door_rtos_task_delay(1000);
// new_key_hook('6');
// door_rtos_task_delay(1000);
// new_key_hook('7');
// door_rtos_task_current_kill();
//}
void initialize(void)
{
......@@ -109,6 +131,7 @@ void start(void)
// 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(debug_task, "debug_task", 4096, NULL, 3, NULL);
}
void app_main()
......@@ -117,16 +140,21 @@ void app_main()
initialize();
// Do application rollback process
const esp_partition_t *running = esp_ota_get_running_partition();
const esp_partition_t* running = esp_ota_get_running_partition();
esp_ota_img_states_t ota_state;
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK) {
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY) {
if (esp_ota_get_state_partition(running, &ota_state) == ESP_OK)
{
if (ota_state == ESP_OTA_IMG_PENDING_VERIFY)
{
// run diagnostic function ...
bool diagnostic_is_ok = door_diagnostic_self_test();
if (diagnostic_is_ok) {
if (diagnostic_is_ok)
{
ESP_LOGI(TAG, "Diagnostics completed successfully! Continuing execution ...");
esp_ota_mark_app_valid_cancel_rollback();
} else {
}
else
{
ESP_LOGE(TAG, "Diagnostics failed! Start rollback to the previous version ...");
esp_ota_mark_app_invalid_rollback_and_reboot();
}
......
......@@ -6,6 +6,11 @@
#include "connectors/rtos.h"
#include "connectors/gpio.h"
#ifdef DEBUG_LOGGING
#include <esp_log.h>
#endif
#define DOOR_UNLOCK_LEVEL DOOR_GPIO_HIGH
#define DOOR_LOCK_LEVEL DOOR_GPIO_LOW
......@@ -32,6 +37,9 @@ void door_lock_task(void* pvParameters)
notify_value = door_rtos_notify_wait_forever();
if (notify_value & UNLOCK_DOOR && !door_rtos_event_get(DOOR_LATCH_EVENT))
{
#ifdef DEBUG_LOGGING
ESP_LOGI("LOCK", "Unlocking door.");
#endif
door_gpio_set_output_pin(DOOR_LOCK_PIN, DOOR_UNLOCK_LEVEL);
// Stop it early if the door opens.
door_rtos_event_wait_ms(DOOR_LATCH_EVENT, DOOR_OPEN_LENGTH_MS);
......
......@@ -7,6 +7,10 @@
#include "app/lock.h"
#include "app/event.h"
#ifdef DEBUG_LOGGING
#include <esp_log.h>
#endif
#define KEYS_LOCK_WAIT_TIME_MS 40
#define KEY_QUEUE_BUFFER_SIZE 20
......@@ -45,14 +49,22 @@ void door_state_task(void* parameters)
{
if (door_rtos_queue_receive(key_queue, &c, KEYPAD_CLEAR_TIME_MS))
{
#ifdef DEBUG_LOGGING
ESP_LOGI("STATE", "New keypress of '%c'", c);
#endif
// If we are in unlocked mode, just open the door and carry on.
if (door_rtos_event_get(DOOR_OPEN_MODE_EVENT) && !door_rtos_event_get(DOOR_LATCH_EVENT))
{
#ifdef DEBUG_LOGGING
ESP_LOGI("STATE", "Door is in open mode. Sending unlock command.");
#endif
door_lock_open();
total_keys = 0;
continue;
}
if (total_keys == KEYPAD_KEY_PRESS_MEMORY_SIZE)
if (total_keys >= KEYPAD_KEY_PRESS_MEMORY_SIZE)
total_keys = 0;
keys[total_keys++] = c;
if (c == KEYPAD_SUBMIT_CODE_KEY)
......
......@@ -95,25 +95,25 @@ void door_status_refresh_task(void* pvParameters)
schedule_data_p schedule_data = (schedule_data_p)curr->data;
time_t start = schedule_data->start;
time_t end = schedule_data->end;
#ifdef DEBUG_LOGGING
char buffer[80];
struct tm s;
s = (const struct tm) { 0 };
s.tm_isdst = -1;
localtime_r(&current_time, &s);
strftime(buffer,80,"Current time: %x - %I:%M%p", &s);
ESP_LOGI("Status", "%s", buffer);
s = (const struct tm) { 0 };
s.tm_isdst = -1;
localtime_r(&start, &s);
strftime(buffer,80,"Start time: %x - %I:%M%p", &s);
ESP_LOGI("Status", "%s", buffer);
s = (const struct tm) { 0 };
s.tm_isdst = -1;
localtime_r(&end, &s);
strftime(buffer,80,"End time: %x - %I:%M%p", &s);
ESP_LOGI("Status", "%s", buffer);
#endif
//#ifdef DEBUG_LOGGING
// char buffer[80];
// struct tm s;
// s = (const struct tm) { 0 };
// s.tm_isdst = -1;
// localtime_r(&current_time, &s);
// strftime(buffer,80,"Current time: %x - %I:%M%p", &s);
// ESP_LOGI("Status", "%s", buffer);
// s = (const struct tm) { 0 };
// s.tm_isdst = -1;
// localtime_r(&start, &s);
// strftime(buffer,80,"Start time: %x - %I:%M%p", &s);
// ESP_LOGI("Status", "%s", buffer);
// s = (const struct tm) { 0 };
// s.tm_isdst = -1;
// localtime_r(&end, &s);
// strftime(buffer,80,"End time: %x - %I:%M%p", &s);
// ESP_LOGI("Status", "%s", buffer);
//#endif
/*
* We are guaranteed to have them in sorted order by begin date by the API specification.
......@@ -156,9 +156,19 @@ void door_status_refresh_task(void* pvParameters)
END_PROTECT_RESOURCE(schedule_list_guard);
if (found)
{
door_rtos_event_set(DOOR_OPEN_MODE_EVENT);
//#ifdef DEBUG_LOGGING
// ESP_LOGI("Status", "Found open mode event for now. Putting in open mode.");
//#endif
}
else
{
//#ifdef DEBUG_LOGGING
// ESP_LOGI("Status", "No open mode for current time. Turning off open mode.");
//#endif
door_rtos_event_clear(DOOR_OPEN_MODE_EVENT);
}
} while (!done);
door_rtos_task_current_kill();
}
......
Markdown is supported
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