1111#include " src/PiCode.h"
1212#include < stdio.h>
1313
14+ #define STRINGIFY2 (X ) #X
15+ #define STRINGIFY (X ) STRINGIFY2(X)
16+
17+ #ifndef BUILD_VERSION
18+ #define BUILD_VERSION no git info
19+ #endif
20+
21+ #ifndef BUILD_COMPILER
22+ #define BUILD_COMPILER no compiler info
23+ #endif
24+
25+ #ifdef DEBUG
26+ #define BUILD_TYPE " Debug"
27+ #else
28+ #define BUILD_TYPE " Release"
29+ #endif
30+
1431int main (){
1532
33+ printf (" picode_example (%s)\n " , STRINGIFY (BUILD_VERSION));
34+ printf (" Compiled at " __DATE__ " " __TIME__ " %s (%s)\n\n " ,STRINGIFY (BUILD_COMPILER), BUILD_TYPE );
35+
36+ int result = 0 ;
37+
1638 /* Decode from pilight string */
1739
1840 char * pilight_string = (char *) " c:011010100101011010100110101001100110010101100110101010101010101012;p:1400,600,6800@" ;
1941
2042 char * decoded_string = PiCode.decodeString (pilight_string);
2143
44+ printf (" String to decode: \" %s\"\n " ,pilight_string);
45+
2246 if (decoded_string){
2347
2448 printf (" Decode string successful:\n " );
@@ -27,7 +51,8 @@ int main(){
2751 free (decoded_string);
2852
2953 }else {
30- printf (" Unable to decode string\n " );
54+ printf (" ERROR: Unable to decode string.\n " );
55+ result--;
3156 }
3257
3358 /* Encode to pilight string from json */
@@ -37,6 +62,8 @@ int main(){
3762
3863 char * encoded_json_string = PiCode.encodeJson (json,repeats);
3964
65+ printf (" \n JSON to encode: \" %s\"\n " ,json);
66+
4067 if (encoded_json_string){
4168
4269 printf (" Encode successful:\n " );
@@ -45,8 +72,9 @@ int main(){
4572 free (encoded_json_string);
4673
4774 }else {
48- printf (" Unable to encode\n " );
75+ printf (" ERROR: Unable to encode JSON.\n " );
76+ result--;
4977 }
5078
51- return 0 ;
79+ return result ;
5280}
0 commit comments