Skip to content

Commit

Permalink
fix: log_ fix
Browse files Browse the repository at this point in the history
  • Loading branch information
RobertByrnes committed Jul 16, 2024
1 parent bfbbc5e commit eaee121
Show file tree
Hide file tree
Showing 4 changed files with 83 additions and 15 deletions.
32 changes: 17 additions & 15 deletions .github/workflows/scripts/compile_arduino_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ compile_example() {

# Compile the example using arduino-cli
# arduino-cli compile --build-property "compiler.cpp.extra_flags=-E -H" --clean --fqbn "$board" . || {
arduino-cli compile --clean --fqbn "$board" . || {
arduino-cli compile --build-property "compiler.cpp.extra_flags=-E -H" --clean --fqbn "$board" . || {
echo "Compilation failed for $example_dir for board: $board" >> "$ROOT_DIR/compile_errors.log"
RESULTS["$example_name,$board"]="Failed"
return 1
Expand Down Expand Up @@ -71,21 +71,23 @@ clean_example() {
# Remove previous log file
rm -f "$ROOT_DIR/compile_errors.log"

compile_example "$ROOT_DIR"/examples/Esp32-Arduino-IDE/https_gsm_SIM800/ "esp32:esp32:esp32doit-devkit-v1"

# Iterate over each example directory
for example_dir in "$ROOT_DIR"/examples/Esp32-Arduino-IDE/*/; do
echo "$example_dir"
# Check if the directory contains a .ino file
if [ -f "$example_dir"/*.ino ]; then
for board in "${BOARDS[@]}"; do
compile_example "$example_dir" "$board"
done

# Clean the example after all board-specific compilations are complete
clean_example "$example_dir"
else
echo "Skipping directory $example_dir (no .ino file found)"
fi
done
# for example_dir in "$ROOT_DIR"/examples/Esp32-Arduino-IDE/*/; do
# echo "$example_dir"
# # Check if the directory contains a .ino file
# if [ -f "$example_dir"/*.ino ]; then
# for board in "${BOARDS[@]}"; do
# compile_example "$example_dir" "$board"
# done

# # Clean the example after all board-specific compilations are complete
# clean_example "$example_dir"
# else
# echo "Skipping directory $example_dir (no .ino file found)"
# fi
# done

# Generate summary
echo "Compilation Summary:"
Expand Down
3 changes: 3 additions & 0 deletions src/SSLClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@

#ifndef SSLCLIENT_H
#define SSLCLIENT_H

#include "log_.h"

#ifdef PLATFORMIO
#include <Arduino.h>
#endif
Expand Down
2 changes: 2 additions & 0 deletions src/certBundle.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#ifndef CERT_BUNDLE_H
#define CERT_BUNDLE_H

#include "log_.h"

#ifndef SSL_CLIENT_TEST_ENVIRONMENT
#include "mbedtls/ssl.h"
#else
Expand Down
61 changes: 61 additions & 0 deletions src/log_.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
* @file log_.h
* @brief Log levels and macros
* @details This file contains the log levels and macros for logging.
* These exist to enable the library to used in different environments,
* namely the ESP-IDF and the Arduino framework.
*/
#ifndef LOG__H_
#define LOG__H_

#include <Arduino.h>

#ifndef LOG_LEVEL_NONE
#define LOG_LEVEL_NONE 0
#endif

#ifndef LOG_LEVEL_ERROR
#define LOG_LEVEL_ERROR 1
#endif

#ifndef LOG_LEVEL_WARN
#define LOG_LEVEL_WARN 2
#endif

#ifndef LOG_LEVEL_INFO
#define LOG_LEVEL_INFO 3
#endif

#ifndef LOG_LEVEL_DEBUG
#define LOG_LEVEL_DEBUG 4
#endif

#ifndef LOG_LEVEL_VERBOSE
#define LOG_LEVEL_VERBOSE 5
#endif

#ifndef LOG_LEVEL
#define LOG_LEVEL LOG_LEVEL_VERBOSE // Change this to set the log level
#endif

#ifndef log_e
#define log_e(...) if (LOG_LEVEL >= LOG_LEVEL_ERROR) { Serial.printf("E ("); Serial.printf(__VA_ARGS__); Serial.println(")"); }
#endif

#ifndef log_w
#define log_w(...) if (LOG_LEVEL >= LOG_LEVEL_WARN) { Serial.printf("W ("); Serial.printf(__VA_ARGS__); Serial.println(")"); }
#endif

#ifndef log_i
#define log_i(...) if (LOG_LEVEL >= LOG_LEVEL_INFO) { Serial.printf("I ("); Serial.printf(__VA_ARGS__); Serial.println(")"); }
#endif

#ifndef log_d
#define log_d(...) if (LOG_LEVEL >= LOG_LEVEL_DEBUG) { Serial.printf("D ("); Serial.printf(__VA_ARGS__); Serial.println(")"); }
#endif

#ifndef log_v
#define log_v(...) if (LOG_LEVEL >= LOG_LEVEL_VERBOSE) { Serial.printf("V ("); Serial.printf(__VA_ARGS__); Serial.println(")"); }
#endif

#endif // LOG__H_

0 comments on commit eaee121

Please sign in to comment.