2020-07-14 20:54:14 +02:00
|
|
|
// Copyright 2020 Lukas Haubaum
|
|
|
|
//
|
|
|
|
// Licensed under the GNU Affero General Public License, Version 3;
|
|
|
|
// you may not use this file except in compliance with the License.
|
|
|
|
// You may obtain a copy of the License at
|
2020-07-11 12:11:34 +02:00
|
|
|
|
2020-07-14 20:54:14 +02:00
|
|
|
// https://www.gnu.org/licenses/agpl-3.0.html
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
// See the License for the specific language governing permissions and
|
|
|
|
// limitations under the License.
|
|
|
|
#include <string.h>
|
2020-07-11 12:11:34 +02:00
|
|
|
#include "freertos/FreeRTOS.h"
|
|
|
|
#include "freertos/task.h"
|
|
|
|
#include <time.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include "esp_system.h"
|
|
|
|
#include "esp_log.h"
|
|
|
|
|
|
|
|
#include "ena.h"
|
|
|
|
#include "ena-storage.h"
|
2020-07-22 21:44:17 +02:00
|
|
|
#include "ena-beacons.h"
|
|
|
|
#include "ena-exposure.h"
|
2020-07-25 13:33:03 +02:00
|
|
|
#include "ena-bluetooth-advertise.h"
|
|
|
|
#include "ena-bluetooth-scan.h"
|
|
|
|
#include "ena-cwa.h"
|
2020-07-22 21:44:17 +02:00
|
|
|
#include "ds3231.h"
|
2020-08-16 16:40:05 +02:00
|
|
|
#include "ssd1306.h"
|
2020-09-29 19:58:01 +02:00
|
|
|
#include "interface.h"
|
|
|
|
#include "button-input.h"
|
|
|
|
#include "rtc.h"
|
2020-08-16 16:40:05 +02:00
|
|
|
#include "wifi-controller.h"
|
2020-07-11 12:11:34 +02:00
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
|
2020-07-11 12:11:34 +02:00
|
|
|
#include "sdkconfig.h"
|
|
|
|
|
|
|
|
void app_main(void)
|
|
|
|
{
|
2020-08-16 16:40:05 +02:00
|
|
|
|
2020-07-25 13:33:03 +02:00
|
|
|
// debug only own LOG TAGs
|
|
|
|
esp_log_level_set("*", ESP_LOG_WARN);
|
|
|
|
esp_log_level_set(ENA_LOG, ESP_LOG_DEBUG);
|
|
|
|
esp_log_level_set(ENA_BEACON_LOG, ESP_LOG_DEBUG);
|
|
|
|
esp_log_level_set(ENA_ADVERTISE_LOG, ESP_LOG_DEBUG);
|
|
|
|
esp_log_level_set(ENA_SCAN_LOG, ESP_LOG_DEBUG);
|
|
|
|
esp_log_level_set(ENA_EXPOSURE_LOG, ESP_LOG_DEBUG);
|
|
|
|
esp_log_level_set(ENA_STORAGE_LOG, ESP_LOG_INFO);
|
|
|
|
esp_log_level_set(ENA_CWA_LOG, ESP_LOG_DEBUG);
|
2020-07-27 16:54:51 +02:00
|
|
|
esp_log_level_set(INTERFACE_LOG, ESP_LOG_DEBUG);
|
2020-07-25 13:33:03 +02:00
|
|
|
esp_log_level_set(WIFI_LOG, ESP_LOG_DEBUG);
|
|
|
|
|
2020-08-16 16:40:05 +02:00
|
|
|
// start interface
|
|
|
|
interface_start();
|
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
// set system time from RTC
|
2020-07-22 21:44:17 +02:00
|
|
|
struct tm rtc_time;
|
2020-09-29 19:58:01 +02:00
|
|
|
rtc_get_time(&rtc_time);
|
2020-07-25 13:33:03 +02:00
|
|
|
|
|
|
|
time_t curtime = mktime(&rtc_time);
|
2020-07-22 21:44:17 +02:00
|
|
|
struct timeval tv = {0};
|
|
|
|
tv.tv_sec = curtime;
|
2020-07-11 12:11:34 +02:00
|
|
|
settimeofday(&tv, NULL);
|
2020-07-15 22:22:54 +02:00
|
|
|
|
2020-07-27 16:54:51 +02:00
|
|
|
// Hardcoded timezone of UTC+2 for now (consider POSIX notation!)
|
2020-07-22 21:44:17 +02:00
|
|
|
setenv("TZ", "UTC-2", 1);
|
|
|
|
tzset();
|
|
|
|
|
2020-07-12 14:14:06 +02:00
|
|
|
ena_start();
|
2020-07-22 21:44:17 +02:00
|
|
|
|
2020-08-16 16:40:05 +02:00
|
|
|
// start with main interface
|
|
|
|
interface_main_start();
|
|
|
|
|
2020-09-29 19:58:01 +02:00
|
|
|
// start button input
|
|
|
|
button_input_start();
|
|
|
|
|
2020-07-25 13:33:03 +02:00
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
ena_run();
|
2020-08-16 16:40:05 +02:00
|
|
|
ena_cwa_run();
|
2020-07-25 13:33:03 +02:00
|
|
|
vTaskDelay(1000 / portTICK_PERIOD_MS);
|
|
|
|
}
|
2020-07-11 12:11:34 +02:00
|
|
|
}
|