-
Notifications
You must be signed in to change notification settings - Fork 7.1k
/
ble_mesh_console_system.c
74 lines (61 loc) · 1.57 KB
/
ble_mesh_console_system.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* Console example - various system commands
*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <inttypes.h>
#include "esp_log.h"
#include "esp_console.h"
#include "esp_system.h"
#include "esp_sleep.h"
#include "driver/rtc_io.h"
#include "soc/rtc_cntl_reg.h"
#include "argtable3/argtable3.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "ble_mesh_console_decl.h"
#define CONFIG_ESPTOOLPY_PORT "Which is choosen by Users for CMake"
static void register_free(void);
static void register_restart(void);
void register_system(void)
{
register_free();
register_restart();
}
/** 'restart' command restarts the program */
static int restart(int argc, char **argv)
{
printf("%s, %s", __func__, "Restarting");
esp_restart();
}
static void register_restart(void)
{
const esp_console_cmd_t cmd = {
.command = "restart",
.help = "Restart the program",
.hint = NULL,
.func = &restart,
};
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}
/** 'free' command prints available heap memory */
static int free_mem(int argc, char **argv)
{
printf("freeheap:%" PRIu32 "\n", esp_get_free_heap_size());
return 0;
}
static void register_free(void)
{
const esp_console_cmd_t cmd = {
.command = "free",
.help = "Get the total size of heap memory available",
.hint = NULL,
.func = &free_mem,
};
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
}