update example for lora
This commit is contained in:
parent
fa4ceb6173
commit
efecb90233
2 changed files with 8 additions and 13 deletions
|
@ -2,5 +2,7 @@
|
||||||
# in this exact order for cmake to work correctly
|
# in this exact order for cmake to work correctly
|
||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
|
add_compile_options(-fdiagnostics-color=always)
|
||||||
|
|
||||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||||
project(coatt)
|
project(coatt)
|
||||||
|
|
19
main/main.c
19
main/main.c
|
@ -1,28 +1,21 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include "esp_log.h"
|
||||||
#include "esp_mac.h"
|
#include "esp_mac.h"
|
||||||
#include "esp_wifi.h"
|
#include "esp_wifi.h"
|
||||||
|
|
||||||
#include "nvs_flash.h"
|
#include "nvs_flash.h"
|
||||||
|
|
||||||
#include "esp_netif_now.h"
|
#include "esp_netif_lora.h"
|
||||||
|
|
||||||
void app_main() {
|
void app_main() {
|
||||||
esp_netif_now_config_t config;
|
esp_netif_lora_config_t config;
|
||||||
|
|
||||||
esp_efuse_mac_get_default((uint8_t*)&config.mac);
|
esp_efuse_mac_get_default((uint8_t*)&config.mac);
|
||||||
|
|
||||||
ESP_ERROR_CHECK(nvs_flash_init());
|
|
||||||
ESP_ERROR_CHECK(esp_netif_init());
|
|
||||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
|
||||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_start());
|
|
||||||
ESP_ERROR_CHECK(esp_wifi_set_channel(1, WIFI_SECOND_CHAN_NONE));
|
|
||||||
|
|
||||||
esp_netif_set_ip4_addr(&config.ip_info.ip, 10, 10 , 0, config.mac[5]);
|
esp_netif_set_ip4_addr(&config.ip_info.ip, 10, 10 , 0, config.mac[5]);
|
||||||
esp_netif_set_ip4_addr(&config.ip_info.gw, 10, 10 , 0, 1);
|
esp_netif_set_ip4_addr(&config.ip_info.gw, 10, 10 , 0, 1);
|
||||||
esp_netif_set_ip4_addr(&config.ip_info.netmask, 255, 255 , 255, 0);
|
esp_netif_set_ip4_addr(&config.ip_info.netmask, 255, 255 , 255, 0);
|
||||||
|
|
||||||
esp_netif_now_init(&config);
|
esp_log_level_set("LoRa32", ESP_LOG_INFO);
|
||||||
|
esp_netif_lora_init(&config);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue