2022-09-27 05:22:34 -04:00
|
|
|
/*
|
|
|
|
* SPDX-FileCopyrightText: 2022 Espressif Systems (Shanghai) CO LTD
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Unlicense OR CC0-1.0
|
|
|
|
*/
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2023-10-11 07:41:20 -04:00
|
|
|
#include "ieee802154_cmd.h"
|
2022-09-27 05:22:34 -04:00
|
|
|
#include "esp_system.h"
|
|
|
|
#include "esp_log.h"
|
|
|
|
#include "esp_console.h"
|
|
|
|
#include "esp_vfs_dev.h"
|
|
|
|
#include "esp_vfs_fat.h"
|
|
|
|
#include "nvs.h"
|
|
|
|
#include "nvs_flash.h"
|
|
|
|
#include "esp_ieee802154.h"
|
|
|
|
#include "esp_phy_init.h"
|
2023-10-11 07:41:20 -04:00
|
|
|
#include "cmd_system.h"
|
2022-09-27 05:22:34 -04:00
|
|
|
|
|
|
|
#define PROMPT_STR "ieee802154"
|
|
|
|
|
|
|
|
static void initialize_nvs(void)
|
|
|
|
{
|
|
|
|
esp_err_t err = nvs_flash_init();
|
|
|
|
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
2023-10-11 07:41:20 -04:00
|
|
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
2022-09-27 05:22:34 -04:00
|
|
|
err = nvs_flash_init();
|
|
|
|
}
|
|
|
|
ESP_ERROR_CHECK(err);
|
|
|
|
}
|
|
|
|
|
|
|
|
void app_main(void)
|
|
|
|
{
|
|
|
|
esp_ieee802154_enable();
|
|
|
|
esp_console_repl_t *repl = NULL;
|
|
|
|
esp_console_repl_config_t repl_config = ESP_CONSOLE_REPL_CONFIG_DEFAULT();
|
|
|
|
/* Prompt to be printed before each line.
|
|
|
|
* This can be customized, made dynamic, etc.
|
|
|
|
*/
|
|
|
|
repl_config.prompt = PROMPT_STR ">";
|
|
|
|
repl_config.max_cmdline_length = 256;
|
|
|
|
|
|
|
|
initialize_nvs();
|
|
|
|
|
|
|
|
/* Register commands */
|
|
|
|
esp_console_register_help_command();
|
|
|
|
register_ieee802154_cmd();
|
2023-10-11 07:41:20 -04:00
|
|
|
register_system_common();
|
2022-09-27 05:22:34 -04:00
|
|
|
|
|
|
|
esp_console_dev_uart_config_t hw_config = ESP_CONSOLE_DEV_UART_CONFIG_DEFAULT();
|
|
|
|
ESP_ERROR_CHECK(esp_console_new_repl_uart(&hw_config, &repl_config, &repl));
|
|
|
|
|
|
|
|
ESP_ERROR_CHECK(esp_console_start_repl(repl));
|
|
|
|
}
|