barback32/main/main.c

62 lines
1.5 KiB
C
Raw Normal View History

2020-02-26 00:31:55 -05:00
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/uart.h"
2020-10-13 00:38:23 -04:00
#include "driver/gpio.h"
2020-02-26 00:31:55 -05:00
#include "esp_log.h"
#include "esp_debug_helpers.h"
2020-04-23 01:43:27 -04:00
#include "nvs_flash.h"
#include "esp_vfs_dev.h"
2020-02-26 00:31:55 -05:00
#include "main.h"
2020-02-26 10:11:57 -05:00
#include "console.h"
#include "ble.h"
#include "user_button.h"
2020-02-26 00:31:55 -05:00
2020-10-13 00:38:23 -04:00
static const char *TAG = "BARBACK";
2020-02-26 00:31:55 -05:00
uint8_t mac[6];
2020-02-26 00:31:55 -05:00
void app_main(void) {
2020-04-23 01:43:27 -04:00
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK( err );
nvs_handle_t nvs_handle;
err = nvs_open("config", NVS_READWRITE, &nvs_handle);
if (err != ESP_OK) {
printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err));
} else {
2020-04-24 15:56:14 -04:00
ESP_LOGI(TAG, "nvs_handle: %d", nvs_handle);
2020-04-23 01:43:27 -04:00
}
2020-02-26 00:31:55 -05:00
esp_efuse_mac_get_default((uint8_t*)&mac);
ESP_LOGI(TAG, "MAC: [%02X:%02X:%02X:%02X:%02X:%02X]", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
2020-10-13 00:38:23 -04:00
xTaskCreate(console_task, "console", 4048, NULL, tskIDLE_PRIORITY + 3, NULL);
2020-02-26 00:31:55 -05:00
2020-10-13 00:38:23 -04:00
ble_init();
2020-02-29 18:43:15 -05:00
#ifdef CONFIG_LORCOMM_BUTTON_ACTION_ENABLED
2020-10-13 00:38:23 -04:00
//user_button_init();
#endif
2020-10-13 00:38:23 -04:00
gpio_config_t io_conf;
io_conf.intr_type = GPIO_PIN_INTR_DISABLE;
io_conf.mode = GPIO_MODE_OUTPUT;
io_conf.pin_bit_mask = GPIO_PUMP_PIN_SEL;
io_conf.pull_down_en = 1;
io_conf.pull_up_en = 0;
gpio_config(&io_conf);
2020-02-26 00:31:55 -05:00
while(1) {
vTaskDelay(1000 / portTICK_PERIOD_MS);
2020-02-26 00:31:55 -05:00
}
}