add printChipInfo()
This commit is contained in:
@@ -82,6 +82,8 @@ void app_main() {
|
||||
ret = nvs_flash_init();
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
printChipInfo();
|
||||
|
||||
s_wifi_event_group = xEventGroupCreate();
|
||||
|
||||
@@ -144,6 +146,12 @@ void app_main() {
|
||||
ESP_LOGE(TAG, "UNEXPECTED EVENT");
|
||||
}
|
||||
|
||||
while(true)
|
||||
{
|
||||
ESP_LOGI(TAG, ":3");
|
||||
|
||||
}
|
||||
|
||||
// running = true;
|
||||
|
||||
// cmdList = getCMDList();
|
||||
|
||||
@@ -3,10 +3,15 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include "esp_system.h"
|
||||
#include "esp_chip_info.h"
|
||||
#include "esp_flash.h"
|
||||
|
||||
char* getNextArg(char* args)
|
||||
{
|
||||
uint8_t step = 0;
|
||||
int end = 0;
|
||||
uint8_t end = 0;
|
||||
// find next argument separator
|
||||
while (end == 0)
|
||||
{
|
||||
if (step < 255)
|
||||
@@ -15,10 +20,12 @@ char* getNextArg(char* args)
|
||||
{
|
||||
case ';':
|
||||
end = 1; // found
|
||||
break;
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\0':
|
||||
end = 2; // end of line
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -28,12 +35,73 @@ char* getNextArg(char* args)
|
||||
step++;
|
||||
}
|
||||
|
||||
if (end != 3)
|
||||
{
|
||||
return args + step;
|
||||
if (end == 1)
|
||||
{ // argument separator found
|
||||
end = 0;
|
||||
// find first char of argument
|
||||
while (end == 0)
|
||||
{
|
||||
step++;
|
||||
if (step < 255)
|
||||
{
|
||||
switch (*(args + step))
|
||||
{
|
||||
case ';':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\0':
|
||||
break;
|
||||
default:
|
||||
end = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
end = 3; // line to long
|
||||
}
|
||||
}
|
||||
|
||||
if (end == 1)
|
||||
{ // start of next argument found
|
||||
return args + step;
|
||||
}
|
||||
else
|
||||
{ // no new argument found
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
{ // is was the last argument (or the arguments is longer then 254 bytes)
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void printChipInfo()
|
||||
{
|
||||
esp_chip_info_t chip_info;
|
||||
uint32_t flash_size;
|
||||
esp_chip_info(&chip_info);
|
||||
printf("This is %s chip with %d CPU core(s), %s%s%s%s, ",
|
||||
CONFIG_IDF_TARGET,
|
||||
chip_info.cores,
|
||||
(chip_info.features & CHIP_FEATURE_WIFI_BGN) ? "WiFi/" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BT) ? "BT" : "",
|
||||
(chip_info.features & CHIP_FEATURE_BLE) ? "BLE" : "",
|
||||
(chip_info.features & CHIP_FEATURE_IEEE802154) ? ", 802.15.4 (Zigbee/Thread)" : ""
|
||||
);
|
||||
|
||||
unsigned major_rev = chip_info.revision / 100;
|
||||
unsigned minor_rev = chip_info.revision % 100;
|
||||
printf("silicon revision v%d.%d, ", major_rev, minor_rev);
|
||||
if(esp_flash_get_size(NULL, &flash_size) != ESP_OK) {
|
||||
printf("Get flash size failed");
|
||||
return;
|
||||
}
|
||||
|
||||
printf("%" PRIu32 "MB %s flash\n", flash_size / (uint32_t)(1024 * 1024),
|
||||
(chip_info.features & CHIP_FEATURE_EMB_FLASH) ? "embedded" : "external"
|
||||
);
|
||||
|
||||
printf("Minimum free heap size: %" PRIu32 " bytes\n", esp_get_minimum_free_heap_size());
|
||||
}
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
#define UTILS_H
|
||||
|
||||
char* getNextArg(char* args);
|
||||
void printChipInfo();
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user