diff --git a/cjson/Makefile b/cjson/Makefile new file mode 100644 index 0000000..ff5f5ab --- /dev/null +++ b/cjson/Makefile @@ -0,0 +1,12 @@ +CC ?= gcc +CFLAGS ?= -Wall -O2 -lcjson + +TARGET = main.elf +SRC = main.c + +$(TARGET): $(SRC) + @echo CC $@ + @$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) + +clean: + rm -f $(TARGET) diff --git a/cjson/cjson.c b/cjson/main.c similarity index 70% rename from cjson/cjson.c rename to cjson/main.c index cd5f205..30c5d87 100644 --- a/cjson/cjson.c +++ b/cjson/main.c @@ -6,9 +6,10 @@ char *build_set_level_command(int level) { cJSON_AddStringToObject(root, "cmd", "set_level"); cJSON_AddNumberToObject(root, "level", level); - char *message = cJSON_PrintUnformatted(root); + // char *message = cJSON_PrintUnformatted(root); + char *msg2 = cJSON_Print(root); cJSON_Delete(root); - return message; // Remember to free this when done! + return msg2; // Remember to free this when done! } int main(void) {