提交 409c75da 编写于 作者: M me-no-dev

Implement ESP_LOGx override option

Usable for library developers who write code not dependent on Arduino.
Adding 3 lines to the includes will permit their debug messages to be
visible in Arduino IDE or when enabled under IDF
上级 c8ffcacd
...@@ -66,6 +66,16 @@ config ARDUHAL_LOG_COLORS ...@@ -66,6 +66,16 @@ config ARDUHAL_LOG_COLORS
Enable ANSI terminal color codes in bootloader output. Enable ANSI terminal color codes in bootloader output.
In order to view these, your terminal program must support ANSI color codes. In order to view these, your terminal program must support ANSI color codes.
config ARDUHAL_ESP_LOG
bool "Forward ESP_LOGx to Arduino log output"
default "n"
help
This option will redefine the ESP_LOGx macros to Arduino's log_x macros.
To enable for your application, add the follwing after your includes:
#ifdef ARDUINO_ARCH_ESP32
#include "esp32-hal-log.h"
#endif
endmenu endmenu
config AUTOCONNECT_WIFI config AUTOCONNECT_WIFI
......
...@@ -107,6 +107,22 @@ int log_printf(const char *fmt, ...); ...@@ -107,6 +107,22 @@ int log_printf(const char *fmt, ...);
#define log_e(format, ...) #define log_e(format, ...)
#endif #endif
#ifdef CONFIG_ARDUHAL_ESP_LOG
#include "esp_log.h"
#undef ESP_LOGE
#undef ESP_LOGW
#undef ESP_LOGI
#undef ESP_LOGD
#undef ESP_LOGV
#define ESP_LOGE(tag, ...) log_e(__VA_ARGS__)
#define ESP_LOGW(tag, ...) log_w(__VA_ARGS__)
#define ESP_LOGI(tag, ...) log_i(__VA_ARGS__)
#define ESP_LOGD(tag, ...) log_d(__VA_ARGS__)
#define ESP_LOGV(tag, ...) log_v(__VA_ARGS__)
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif
......
To use as a component of ESP-IDF To use as a component of ESP-IDF
================================================= =================================================
## Installation
- Download and install [esp-idf](https://github.com/espressif/esp-idf) - Download and install [esp-idf](https://github.com/espressif/esp-idf)
- Create blank idf project (from one of the examples) - Create blank idf project (from one of the examples)
- in the project folder, create a folder called components and clone this repository inside - in the project folder, create a folder called components and clone this repository inside
...@@ -55,3 +57,14 @@ To use as a component of ESP-IDF ...@@ -55,3 +57,14 @@ To use as a component of ESP-IDF
- If enabled, WiFi will start with the last known configuration - If enabled, WiFi will start with the last known configuration
- Else it will wait for WiFi.begin - Else it will wait for WiFi.begin
- ```make flash monitor``` will build, upload and open serial monitor to your board - ```make flash monitor``` will build, upload and open serial monitor to your board
## Logging To Serial
If you are writing code that does not require Arduino to compile and you want your `ESP_LOGx` macros to work in Arduino IDE, you can enable the compatibility by adding the following lines after your includes:
```cpp
#ifdef ARDUINO_ARCH_ESP32
#include "esp32-hal-log.h"
#endif
```
...@@ -134,6 +134,7 @@ ...@@ -134,6 +134,7 @@
#define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1 #define CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA 1
#define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32 #define CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM 32
#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1 #define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1
#define CONFIG_ARDUHAL_ESP_LOG 1
#define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1 #define CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED 1
#define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240 #define CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ 240
#define CONFIG_MBEDTLS_HARDWARE_AES 1 #define CONFIG_MBEDTLS_HARDWARE_AES 1
......
...@@ -126,6 +126,7 @@ CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_DEBUG= ...@@ -126,6 +126,7 @@ CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_DEBUG=
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE= CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL_VERBOSE=
CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=1 CONFIG_ARDUHAL_LOG_DEFAULT_LEVEL=1
CONFIG_ARDUHAL_LOG_COLORS= CONFIG_ARDUHAL_LOG_COLORS=
CONFIG_ARDUHAL_ESP_LOG=y
CONFIG_AUTOCONNECT_WIFI= CONFIG_AUTOCONNECT_WIFI=
CONFIG_AWS_IOT_SDK= CONFIG_AWS_IOT_SDK=
CONFIG_BT_ENABLED=y CONFIG_BT_ENABLED=y
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册