2024-07-16 19:05:20 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "esp_system.h"
|
|
|
|
|
2024-07-27 13:31:17 +00:00
|
|
|
#include "dev_name.h"
|
|
|
|
#include "storage.h"
|
2024-07-27 14:15:35 +00:00
|
|
|
#include "system.h"
|
2024-07-27 14:34:41 +00:00
|
|
|
#include "crypto.h"
|
2024-07-27 13:31:17 +00:00
|
|
|
|
2024-07-16 19:05:20 +00:00
|
|
|
void app_main(void)
|
|
|
|
{
|
2024-07-27 13:31:17 +00:00
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
if (storage_init() == false)
|
|
|
|
{
|
|
|
|
printf("Failed to init storage!\n");
|
2024-07-27 14:15:35 +00:00
|
|
|
reboot();
|
2024-07-27 13:31:17 +00:00
|
|
|
}
|
|
|
|
|
2024-07-27 14:15:35 +00:00
|
|
|
if (dev_generate_name())
|
2024-07-27 13:31:17 +00:00
|
|
|
{
|
|
|
|
printf("Generated a new device name\n");
|
|
|
|
}
|
|
|
|
|
2024-07-27 14:34:41 +00:00
|
|
|
char *name = dev_name();
|
|
|
|
printf("Dev name: %s\n", name);
|
|
|
|
free(name);
|
|
|
|
|
2024-07-27 14:15:35 +00:00
|
|
|
if (crypto_gen_priv_key())
|
|
|
|
{
|
|
|
|
printf("Generated device private key!\n");
|
|
|
|
}
|
2024-08-15 11:32:01 +00:00
|
|
|
printf("Device private key:\n");
|
|
|
|
crypto_print_priv_key();
|
2024-07-27 14:15:35 +00:00
|
|
|
|
2024-08-16 09:51:33 +00:00
|
|
|
char *csr = crypto_get_csr();
|
|
|
|
printf("Current CSR:\n%s\n", csr);
|
|
|
|
free(csr);
|
|
|
|
|
2024-07-27 14:34:41 +00:00
|
|
|
reboot();
|
2024-07-16 19:05:20 +00:00
|
|
|
}
|