From 639d7f9e80b8f7438342a48b5677431a5db830a7 Mon Sep 17 00:00:00 2001 From: "Morgan 'ARR\\!' Allen" Date: Mon, 12 Oct 2020 21:38:23 -0700 Subject: [PATCH] itsa barback now --- main/main.c | 64 +++++++++++------------------------------------------ 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/main/main.c b/main/main.c index cc5b86e..38a202c 100644 --- a/main/main.c +++ b/main/main.c @@ -4,39 +4,21 @@ #include "freertos/task.h" #include "freertos/queue.h" #include "driver/uart.h" +#include "driver/gpio.h" #include "esp_log.h" #include "esp_debug_helpers.h" #include "nvs_flash.h" #include "esp_vfs_dev.h" #include "main.h" -#include "lorcomm.h" -#include "esp32-lora.h" #include "console.h" #include "ble.h" #include "user_button.h" -static const char *TAG = "loracom-main"; +static const char *TAG = "BARBACK"; -lora32_cfg_t lora; uint8_t mac[6]; -static void handle_lora_txdone() { - lora32_enable_continuous_rx(&lora); -} - -void handle_lora_caddone(bool detected) { - //ESP_LOGI(TAG, "CAD done: detected? %s", detected ? "true" : "false"); - - if(detected) { - lora32_enable_cad(&lora); - } else { - ESP_LOGI(TAG, "candone (no channel activity): enabling continuous RX"); - - lora32_enable_continuous_rx(&lora); - } -} - void app_main(void) { esp_err_t err = nvs_flash_init(); if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) { @@ -50,7 +32,6 @@ void app_main(void) { if (err != ESP_OK) { printf("Error (%s) opening NVS handle!\n", esp_err_to_name(err)); } else { - lorcomm_cfg.nvs_handle = nvs_handle; ESP_LOGI(TAG, "nvs_handle: %d", nvs_handle); } @@ -58,41 +39,22 @@ void app_main(void) { ESP_LOGI(TAG, "MAC: [%02X:%02X:%02X:%02X:%02X:%02X]", mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]); - lora.bandwidth = B125; - lora.codingRate = 5; - lora.frequency = 915000000; - lora.spreadingFactor = 11; - lora.preamble = DEFAULT_PREAMBLE; - lora.dio0 = CONFIG_LORA32_DIO0_PIN; - lora.implicitHeader = false; - lora.nss = CONFIG_LORA32_NSS_PIN; - lora.reset = CONFIG_LORA32_RESET_PIN; - lora.useCRC = false; - lora.fifoIdx = 0; - lora.receive = &lorcomm_handle_receive; - lora.tx_done = &handle_lora_txdone; - //lora.cad_done = &handle_lora_caddone; - //lora.cad_detected = &handle_lora_caddetected; + xTaskCreate(console_task, "console", 4048, NULL, tskIDLE_PRIORITY + 3, NULL); - lora32_init(&lora); - - //double dr = lora32_calc_datarate(&lora); - //ESP_LOGI(TAG, "data rate: %fbps", dr); - - lora32_dump_regs(&lora); - - lorcomm_cfg.lora = &lora; - - xTaskCreate(console_task, "console", 4048, &lorcomm_cfg, tskIDLE_PRIORITY + 3, NULL); - - //ble_init(); - - lora32_enable_continuous_rx(&lora); + ble_init(); #ifdef CONFIG_LORCOMM_BUTTON_ACTION_ENABLED - user_button_init(); + //user_button_init(); #endif + 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); + while(1) { vTaskDelay(1000 / portTICK_PERIOD_MS); }