11
11
#include " src/PiCode.h"
12
12
#include < stdio.h>
13
13
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
+
14
31
int main (){
15
32
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
+
16
38
/* Decode from pilight string */
17
39
18
40
char * pilight_string = (char *) " c:011010100101011010100110101001100110010101100110101010101010101012;p:1400,600,6800@" ;
19
41
20
42
char * decoded_string = PiCode.decodeString (pilight_string);
21
43
44
+ printf (" String to decode: \" %s\"\n " ,pilight_string);
45
+
22
46
if (decoded_string){
23
47
24
48
printf (" Decode string successful:\n " );
@@ -27,7 +51,8 @@ int main(){
27
51
free (decoded_string);
28
52
29
53
}else {
30
- printf (" Unable to decode string\n " );
54
+ printf (" ERROR: Unable to decode string.\n " );
55
+ result--;
31
56
}
32
57
33
58
/* Encode to pilight string from json */
@@ -37,6 +62,8 @@ int main(){
37
62
38
63
char * encoded_json_string = PiCode.encodeJson (json,repeats);
39
64
65
+ printf (" \n JSON to encode: \" %s\"\n " ,json);
66
+
40
67
if (encoded_json_string){
41
68
42
69
printf (" Encode successful:\n " );
@@ -45,8 +72,9 @@ int main(){
45
72
free (encoded_json_string);
46
73
47
74
}else {
48
- printf (" Unable to encode\n " );
75
+ printf (" ERROR: Unable to encode JSON.\n " );
76
+ result--;
49
77
}
50
78
51
- return 0 ;
79
+ return result ;
52
80
}
0 commit comments