ZotBins Core
Loading...
Searching...
No Matches
Serialize.hpp
1#ifndef CLIENT_SERIALIZE_HPP
2#define CLIENT_SERIALIZE_HPP
3
4#include <cJSON.h>
5#include <stdint.h>
6
7#define SENSOR 1
8#define CAMERA 2
9
10// Set the MCU type here
11#define MCU_TYPE SENSOR // Change to SENSOR if needed
12
13#if MCU_TYPE == CAMERA
14namespace Client
15{
16 /*
17 * @brief Serialize data from the camera MCU for API interaction.
18 *
19 * JSON object format:
20 * {
21 * "bin_id": 18838586676582,
22 * "mcu_type": "Camera",
23 * "message": string,
24 * "img_str": Image base64 string
25 * }
26 *
27 * @return cJSON* root of a JSON object containing camera data.
28 * Make sure to free this after use.
29 */
30 cJSON *serialize(char* message, const void* img_str, size_t buffer_length);
31}
32
33#elif MCU_TYPE == SENSOR
34namespace Client
35{
36 /*
37 * @brief Serialize data from the sensor MCU for API interaction.
38 *
39 * JSON object format:
40 * {
41 * "bin_id": 18838586676582,
42 * "mcu_type": "Sensor",
43 * "message": string,
44 * "fullness": 0.5,
45 * "overflow": false,
46 * "weight": 50
47 * }
48 *
49 * @return cJSON* root of a JSON object containing sensor data.
50 * Make sure to free this after use.
51 */
52 cJSON *serialize(char* message, float fullness, bool overflow, int32_t weight);
53}
54
55#endif // MCU_TYPE
56
57#endif // CLIENT_SERIALIZE_HPP