-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #464 from atsign-foundation/arduino-atlogger
feat: Arduino atlogger
- Loading branch information
Showing
29 changed files
with
256 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,8 @@ lib/**/lib*.a | |
|
||
sdkconfig | ||
|
||
Testing/ | ||
|
||
__pycache__/ | ||
|
||
.pio/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
* | ||
!.gitignore | ||
!c_cpp_properties.json | ||
!settings.json | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
CompileFlags: | ||
Add: [-xc++, -std=c++11] |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
generators/arduino/atsdk/atsdk.htemplate → generators/arduino/atsdk/lib/atsdk.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// For both development and compile time | ||
#include "atsdk.h" | ||
#include <cstdarg> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
#ifdef __clang__ // For development to supress irrelevant errors | ||
#include "../../../../packages/atlogger/include/atlogger/atlogger.h" | ||
class DummySerial { | ||
public: | ||
void print(const char *); | ||
void println(const char *); | ||
}; | ||
extern DummySerial Serial; | ||
|
||
#else // Actual compile time includes | ||
#include <Arduino.h> | ||
#endif | ||
|
||
void atsdk_arduino_setup() {} | ||
|
||
extern "C" { | ||
void atlogger_log(const char *tag, const enum atlogger_logging_level level, const char *format, ...) { | ||
atlogger_logging_level allowed_level = atlogger_get_logging_level(); | ||
if (level > allowed_level) { | ||
return; | ||
} | ||
|
||
va_list args; | ||
va_start(args, format); | ||
if (tag != nullptr) { | ||
Serial.print(tag); | ||
Serial.print(" | "); | ||
} | ||
int len = vsnprintf(NULL, 0, format, args); | ||
char *buf = new char[len + 1]; | ||
vsnprintf(buf, len, format, args); | ||
Serial.print(buf); | ||
delete[] buf; | ||
|
||
va_end(args); | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,22 @@ | ||
option(FIRST_ATSIGN "First atSign used for all functional tests") | ||
if(${FIRST_ATSIGN}) | ||
add_compile_definitions(FIRST_ATSIGN) | ||
endif() | ||
|
||
option(SECOND_ATSIGN "Second atSign for two-way atSign functional tests") | ||
if(${SECOND_ATSIGN}) | ||
add_compile_definitions(SECOND_ATSIGN) | ||
endif() | ||
|
||
# loop through every .c file in this directory | ||
file(GLOB_RECURSE files ${CMAKE_CURRENT_LIST_DIR}/test_*.c) | ||
|
||
foreach(file ${files}) | ||
# ${filename} - without `.c` | ||
get_filename_component(filename ${file} NAME) | ||
string(REPLACE ".c" "" filename ${filename}) | ||
# ${filename} - without `.c` | ||
get_filename_component(filename ${file} NAME) | ||
string(REPLACE ".c" "" filename ${filename}) | ||
|
||
add_executable(${filename} ${file}) | ||
target_link_libraries(${filename} PRIVATE atchops atlogger) | ||
add_test(NAME ${filename} COMMAND $<TARGET_FILE:${filename}>) | ||
add_executable(${filename} ${file}) | ||
target_link_libraries(${filename} PRIVATE atchops atlogger) | ||
add_test(NAME ${filename} COMMAND $<TARGET_FILE:${filename}>) | ||
endforeach() |
Oops, something went wrong.