#ifndef JSON_HELPERS_H
#define JSON_HELPERS_H
+#include <stdio.h>
+#include <stdint.h>
+
// really simple JSON helpers
#define JSON_START() dprintf(fd,"{")
#define JSON_NUM(NAME) dprintf(fd,"\"" #NAME "\":%d", NAME) //see the int?
#define JSON_CHAR(NAME) dprintf(fd,"\"" #NAME "\":\"%c\"", NAME)
#define JSON_END() dprintf(fd,"}\n")
+static inline void
+keys_json_print(int fd, char key)
+{
+ static const char *type = "keys";
+
+ JSON_START();
+ JSON_STR(type);
+ JSON_NEXT();
+ JSON_CHAR(key);
+ JSON_END();
+}
+
+static inline void
+rfid_json_print(int fd,
+ uint8_t card_type,
+ uint8_t sak, //select acknowledge
+ char *uid,
+ uint8_t size)
+{
+ static const char *type = "rfid";
+
+ JSON_START();
+ JSON_STR(type);
+ JSON_NEXT();
+ JSON_NUM(card_type);
+ JSON_NEXT();
+ JSON_NUM(sak);
+ JSON_NEXT();
+ JSON_NUM(size);
+ JSON_NEXT();
+ JSON_STR(uid);
+ JSON_END();
+}
+
#endif