Added client folder for the client side of the project
Made the network component shared between two firmawre
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
# The following five lines of boilerplate have to be in your project's
|
||||
# CMakeLists in this exact order for cmake to work correctly
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
|
||||
idf_build_set_property(MINIMAL_BUILD ON)
|
||||
project(Client)
|
||||
@@ -0,0 +1,133 @@
|
||||
dependencies:
|
||||
espressif/ethernet_init:
|
||||
component_hash: 9f7d29acf5fe32315579ddb6247388291cda555aa529409108c0ada0aa7cd99d
|
||||
dependencies:
|
||||
- matches:
|
||||
- if: $CONFIG{ETHERNET_SPI_USE_CH390} == 1
|
||||
name: espressif/ch390
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: $CONFIG{ETHERNET_SPI_USE_DM9051} == 1
|
||||
name: espressif/dm9051
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
name: espressif/dp83848
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32, esp32p4]
|
||||
- if: $CONFIG{ETHERNET_PHY_USE_DP83848} == 1
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: $CONFIG{ETHERNET_SPI_USE_ENC28J60} == 1
|
||||
name: espressif/enc28j60
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
name: espressif/ip101
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32, esp32p4]
|
||||
- if: $CONFIG{ETHERNET_PHY_USE_IP101} == 1
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
name: espressif/ksz80xx
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32, esp32p4]
|
||||
- if: $CONFIG{ETHERNET_PHY_USE_KSZ80XX} == 1
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: $CONFIG{ETHERNET_SPI_USE_KSZ8851SNL} == 1
|
||||
name: espressif/ksz8851snl
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: $CONFIG{ETHERNET_SPI_USE_LAN865X} == 1
|
||||
name: espressif/lan865x
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
version: ^0.1.1
|
||||
- name: espressif/lan867x
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32, esp32p4]
|
||||
- if: $CONFIG{ETHERNET_PHY_USE_LAN867X} == 1
|
||||
version: '>=2.0.0'
|
||||
- matches:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
name: espressif/lan87xx
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32, esp32p4]
|
||||
- if: $CONFIG{ETHERNET_PHY_USE_LAN87XX} == 1
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
name: espressif/rtl8201
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: target in [esp32, esp32p4]
|
||||
- if: $CONFIG{ETHERNET_PHY_USE_RTL8201} == 1
|
||||
version: '*'
|
||||
- matches:
|
||||
- if: $CONFIG{ETHERNET_SPI_USE_W5500} == 1
|
||||
name: espressif/w5500
|
||||
registry_url: https://components.espressif.com
|
||||
require: private
|
||||
rules:
|
||||
- if: idf_version >=6.0
|
||||
version: ^1.0.0
|
||||
version: '*'
|
||||
- name: idf
|
||||
require: private
|
||||
version: '>=5.4.3,!=5.5.0,!=5.5.1'
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
type: service
|
||||
version: 1.3.0
|
||||
idf:
|
||||
source:
|
||||
type: idf
|
||||
version: 5.5.3
|
||||
network:
|
||||
dependencies:
|
||||
- name: idf
|
||||
version: '>=4.1.0'
|
||||
- name: espressif/ethernet_init
|
||||
version: ^1.3.0
|
||||
source:
|
||||
path: C:\Dev\Classified\Calendink\components\network
|
||||
type: local
|
||||
version: 1.0.0
|
||||
direct_dependencies:
|
||||
- idf
|
||||
- network
|
||||
manifest_hash: 12f55da0a0684644c57ee6a400e8e98810d36140fad54f35a96e434eb9774b8c
|
||||
target: esp32
|
||||
version: 2.0.0
|
||||
@@ -0,0 +1,3 @@
|
||||
idf_component_register(SRCS "main.cpp"
|
||||
PRIV_REQUIRES esp_eth esp_wifi esp_netif driver network nvs_flash
|
||||
INCLUDE_DIRS ".")
|
||||
@@ -0,0 +1,6 @@
|
||||
## IDF Component Manager Manifest File
|
||||
dependencies:
|
||||
idf:
|
||||
version: '>=4.1.0'
|
||||
network:
|
||||
path: "../../components/network"
|
||||
@@ -0,0 +1,54 @@
|
||||
#include <stdio.h>
|
||||
#include "esp_log.h"
|
||||
#include "esp_system.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
#include "nvs_flash.h"
|
||||
#include "network.hpp"
|
||||
|
||||
static const char *TAG = "ClientMain";
|
||||
|
||||
extern "C" void app_main()
|
||||
{
|
||||
ESP_LOGI(TAG, "Hello, Calendink Client!");
|
||||
|
||||
// Initialize NVS (required for some Wi-Fi configurations and network features)
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
// Connect to WiFi
|
||||
ESP_LOGI(TAG, "Initializing WiFi connection");
|
||||
|
||||
// Attempting to connect, we don't necessarily need to block forever here
|
||||
// as network.cpp already handles some of the retries
|
||||
esp_err_t err = connect_wifi(CONFIG_CALENDINK_WIFI_SSID, CONFIG_CALENDINK_WIFI_PASSWORD, false);
|
||||
|
||||
if (err == ESP_OK) {
|
||||
uint8_t retries = 1;
|
||||
do {
|
||||
err = check_wifi_connection(retries);
|
||||
if (err != ESP_OK) {
|
||||
ESP_LOGW(TAG, "WiFi connection check timeout, retrying... (%d)", retries);
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
retries++;
|
||||
} while (err == ESP_ERR_TIMEOUT && retries <= CONFIG_CALENDINK_WIFI_RETRIES);
|
||||
}
|
||||
|
||||
if (err == ESP_OK) {
|
||||
ESP_LOGI(TAG, "Successfully connected to WiFi!");
|
||||
} else {
|
||||
ESP_LOGE(TAG, "Failed to connect to WiFi.");
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
vTaskDelay(pdMS_TO_TICKS(1000));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user