First Ethernet activation
This commit is contained in:
@ -1,46 +1,57 @@
|
||||
#include <stdio.h>
|
||||
#include "esp_system.h"
|
||||
#include "esp_log.h"
|
||||
|
||||
#include "dev_name.h"
|
||||
#include "storage.h"
|
||||
#include "system.h"
|
||||
#include "crypto.h"
|
||||
#include "unsecure_api.h"
|
||||
#include "ethernet.h"
|
||||
|
||||
static const char *TAG = "main";
|
||||
|
||||
void app_main(void)
|
||||
{
|
||||
printf("\n");
|
||||
esp_log_level_set("*", ESP_LOG_VERBOSE);
|
||||
|
||||
ESP_LOGI(TAG, "SolarEnergy WT32-ETH01 device");
|
||||
|
||||
if (storage_init() == false)
|
||||
{
|
||||
printf("Failed to init storage!\n");
|
||||
ESP_LOGE(TAG, "Failed to init storage!\n");
|
||||
reboot();
|
||||
}
|
||||
|
||||
if (dev_generate_name())
|
||||
{
|
||||
printf("Generated a new device name\n");
|
||||
ESP_LOGI(TAG, "Generated a new device name\n");
|
||||
}
|
||||
|
||||
char *name = dev_name();
|
||||
printf("Dev name: %s\n", name);
|
||||
ESP_LOGI(TAG, "Dev name: %s\n", name);
|
||||
free(name);
|
||||
|
||||
if (crypto_gen_priv_key())
|
||||
{
|
||||
printf("Generated device private key!\n");
|
||||
ESP_LOGI(TAG, "Generated device private key!\n");
|
||||
}
|
||||
printf("Device private key:\n");
|
||||
ESP_LOGI(TAG, "Device private key:\n");
|
||||
crypto_print_priv_key();
|
||||
|
||||
char *csr = crypto_get_csr();
|
||||
printf("Current CSR:\n%s\n", csr);
|
||||
ESP_LOGI(TAG, "Current CSR:\n%s\n", csr);
|
||||
free(csr);
|
||||
|
||||
printf("Check secure origin\n");
|
||||
ESP_LOGI(TAG, "Initialize network\n");
|
||||
ethernet_init();
|
||||
|
||||
ESP_LOGI(TAG, "Check secure origin\n");
|
||||
char *sec_orig = unsecure_api_get_secure_origin();
|
||||
assert(sec_orig != NULL);
|
||||
printf("Res = %s\n", sec_orig);
|
||||
|
||||
system_sleep(20);
|
||||
|
||||
reboot();
|
||||
}
|
||||
|
Reference in New Issue
Block a user