Library for Yodiwo's Plegma API

Revision:
2:855390040d43
Parent:
0:384a04dc912e
Child:
3:96b08b5f998f
--- a/yodiwo_api.c	Fri Sep 04 08:19:58 2015 +0000
+++ b/yodiwo_api.c	Tue Sep 08 11:08:03 2015 +0000
@@ -1,5 +1,5 @@
 /**
-* Created by ApiGenerator Tool (C) on 28/8/2015 1:51:58 πμ.
+* Created by ApiGenerator Tool (C) on 8/9/2015 1:25:00 μμ.
 */
 
 // This is only for windows testing
@@ -281,6 +281,31 @@
 }
 
 // -----------------------------------------------------------------------------------------------------------------------
+int Yodiwo_Plegma_TimelineDescriptorKey_ToJson(char* jsonStart, size_t jsonSize, Yodiwo_Plegma_TimelineDescriptorKey_t *value)
+{
+	char *json = jsonStart, *jsonEnd = json + jsonSize;
+	int len;
+	json += snprintf(json, jsonEnd - json, "%s", "{ UserKey : ");
+	if ((len = Yodiwo_Plegma_UserKey_ToJson(json, jsonEnd - json, &value->UserKey) - 1) < 0) return -1; else json += len;
+	json += snprintf(json, jsonEnd - json, ", Id : \"%s\"", value->Id); if (json >= jsonEnd) return -1;
+	*json = '}'; json++;
+	*json = '\0'; json++;
+	return json - jsonStart;
+}
+
+// -----------------------------------------------------------------------------------------------------------------------
+int Yodiwo_Plegma_MqttAPIMessage_ToJson(char* jsonStart, size_t jsonSize, Yodiwo_Plegma_MqttAPIMessage_t *value)
+{
+	char *json = jsonStart, *jsonEnd = json + jsonSize;
+	int len;
+	json += snprintf(json, jsonEnd - json, "{ ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
+	json += snprintf(json, jsonEnd - json, ", Payload : \"%s\"", value->Payload); if (json >= jsonEnd) return -1;
+	*json = '}'; json++;
+	*json = '\0'; json++;
+	return json - jsonStart;
+}
+
+// -----------------------------------------------------------------------------------------------------------------------
 int Yodiwo_Plegma_Port_ToJson(char* jsonStart, size_t jsonSize, Yodiwo_Plegma_Port_t *value)
 {
 	char *json = jsonStart, *jsonEnd = json + jsonSize;
@@ -347,10 +372,7 @@
 {
 	char *json = jsonStart, *jsonEnd = json + jsonSize;
 	int len;
-	json += snprintf(json, jsonEnd - json, "{ Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
+	json += snprintf(json, jsonEnd - json, "{ SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -363,10 +385,7 @@
 	int len;
 	json += snprintf(json, jsonEnd - json, "{ NodeKey : \"%s\"", value->NodeKey); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SecretKey : \"%s\"", value->SecretKey); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -462,10 +481,7 @@
 	int len;
 	json += snprintf(json, jsonEnd - json, "%s", "{ RequestedThingType : ");
 	if ((len = Yodiwo_Plegma_NodeThingType_ToJson(json, jsonEnd - json, &value->RequestedThingType) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -481,10 +497,7 @@
 	json += snprintf(json, jsonEnd - json, ", Capabilities : %d", value->Capabilities); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, "%s", ", ThingTypes : ");
 	if ((len = Array_Yodiwo_Plegma_NodeThingType_ToJson(json, jsonEnd - json, &value->ThingTypes) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -499,10 +512,7 @@
 	json += snprintf(json, jsonEnd - json, ", ThingKey : \"%s\"", value->ThingKey); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, "%s", ", Data : ");
 	if ((len = Array_Yodiwo_Plegma_Thing_ToJson(json, jsonEnd - json, &value->Data) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -517,10 +527,7 @@
 	json += snprintf(json, jsonEnd - json, ", Status : %s", (value->Status) ? "true" : "false"); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, "%s", ", Data : ");
 	if ((len = Array_Yodiwo_Plegma_Thing_ToJson(json, jsonEnd - json, &value->Data) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -546,10 +553,7 @@
 	int len;
 	json += snprintf(json, jsonEnd - json, "%s", "{ PortEvents : ");
 	if ((len = Array_Yodiwo_Plegma_PortEvent_ToJson(json, jsonEnd - json, &value->PortEvents) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -563,10 +567,7 @@
 	json += snprintf(json, jsonEnd - json, "{ Operation : %d", value->Operation); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, "%s", ", PortKeys : ");
 	if ((len = Array_string_ToJson(json, jsonEnd - json, &value->PortKeys) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -594,10 +595,7 @@
 	json += snprintf(json, jsonEnd - json, "{ Operation : %d", value->Operation); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, "%s", ", PortStates : ");
 	if ((len = Array_Yodiwo_Plegma_PortState_ToJson(json, jsonEnd - json, &value->PortStates) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -610,10 +608,7 @@
 	int len;
 	json += snprintf(json, jsonEnd - json, "%s", "{ ActivePortKeys : ");
 	if ((len = Array_string_ToJson(json, jsonEnd - json, &value->ActivePortKeys) - 1) < 0) return -1; else json += len;
-	json += snprintf(json, jsonEnd - json, ", Id : %d", value->Id); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", Version : %d", value->Version); if (json >= jsonEnd) return -1;
 	json += snprintf(json, jsonEnd - json, ", SeqNo : %d", value->SeqNo); if (json >= jsonEnd) return -1;
-	json += snprintf(json, jsonEnd - json, ", ResponseToSeqNo : %d", value->ResponseToSeqNo); if (json >= jsonEnd) return -1;
 	*json = '}'; json++;
 	*json = '\0'; json++;
 	return json - jsonStart;
@@ -686,7 +681,7 @@
 /* ======================================================================================================================= */
 /* FromJson Functions                                                                                                      */
 /* ======================================================================================================================= */
-		// -----------------------------------------------------------------------------------------------------------------------
+// -----------------------------------------------------------------------------------------------------------------------
 Yodiwo_Plegma_Json_e Array_Yodiwo_Plegma_ConfigParameter_FromJson(char* json, size_t jsonSize, Array_Yodiwo_Plegma_ConfigParameter_t *array)
 {
 	int i = 0, r;
@@ -946,6 +941,28 @@
 }
 
 // -----------------------------------------------------------------------------------------------------------------------
+Yodiwo_Plegma_Json_e Yodiwo_Plegma_TimelineDescriptorKey_FromJson(char* json, size_t jsonSize, Yodiwo_Plegma_TimelineDescriptorKey_t *value)
+{
+	memset(value, 0, sizeof(Yodiwo_Plegma_TimelineDescriptorKey_t));
+	ParseTable table[] = {
+		{ "UserKey", 7, NULL, Yodiwo_Plegma_UserKey_FromJson, &value->UserKey },
+		{ "Id", 2, Parse_String, NULL, &value->Id },
+	};
+	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
+}
+
+// -----------------------------------------------------------------------------------------------------------------------
+Yodiwo_Plegma_Json_e Yodiwo_Plegma_MqttAPIMessage_FromJson(char* json, size_t jsonSize, Yodiwo_Plegma_MqttAPIMessage_t *value)
+{
+	memset(value, 0, sizeof(Yodiwo_Plegma_MqttAPIMessage_t));
+	ParseTable table[] = {
+		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
+		{ "Payload", 7, Parse_String, NULL, &value->Payload },
+	};
+	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
+}
+
+// -----------------------------------------------------------------------------------------------------------------------
 Yodiwo_Plegma_Json_e Yodiwo_Plegma_Port_FromJson(char* json, size_t jsonSize, Yodiwo_Plegma_Port_t *value)
 {
 	memset(value, 0, sizeof(Yodiwo_Plegma_Port_t));
@@ -1005,10 +1022,7 @@
 {
 	memset(value, 0, sizeof(Yodiwo_Plegma_LoginReq_t));
 	ParseTable table[] = {
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1020,10 +1034,7 @@
 	ParseTable table[] = {
 		{ "NodeKey", 7, Parse_String, NULL, &value->NodeKey },
 		{ "SecretKey", 9, Parse_String, NULL, &value->SecretKey },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1108,10 +1119,7 @@
 	memset(value, 0, sizeof(Yodiwo_Plegma_NodeInfoReq_t));
 	ParseTable table[] = {
 		{ "RequestedThingType", 18, NULL, Yodiwo_Plegma_NodeThingType_FromJson, &value->RequestedThingType },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1125,10 +1133,7 @@
 		{ "Type", 4, Parse_Int, NULL, &value->Type },
 		{ "Capabilities", 12, Parse_Int, NULL, &value->Capabilities },
 		{ "ThingTypes", 10, NULL, Array_Yodiwo_Plegma_NodeThingType_FromJson, &value->ThingTypes },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1141,10 +1146,7 @@
 		{ "Operation", 9, Parse_Int, NULL, &value->Operation },
 		{ "ThingKey", 8, Parse_String, NULL, &value->ThingKey },
 		{ "Data", 4, NULL, Array_Yodiwo_Plegma_Thing_FromJson, &value->Data },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1157,10 +1159,7 @@
 		{ "Operation", 9, Parse_Int, NULL, &value->Operation },
 		{ "Status", 6, Parse_Bool, NULL, &value->Status },
 		{ "Data", 4, NULL, Array_Yodiwo_Plegma_Thing_FromJson, &value->Data },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1183,10 +1182,7 @@
 	memset(value, 0, sizeof(Yodiwo_Plegma_PortEventMsg_t));
 	ParseTable table[] = {
 		{ "PortEvents", 10, NULL, Array_Yodiwo_Plegma_PortEvent_FromJson, &value->PortEvents },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1198,10 +1194,7 @@
 	ParseTable table[] = {
 		{ "Operation", 9, Parse_Int, NULL, &value->Operation },
 		{ "PortKeys", 8, NULL, Array_string_FromJson, &value->PortKeys },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1226,10 +1219,7 @@
 	ParseTable table[] = {
 		{ "Operation", 9, Parse_Int, NULL, &value->Operation },
 		{ "PortStates", 10, NULL, Array_Yodiwo_Plegma_PortState_FromJson, &value->PortStates },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1240,10 +1230,7 @@
 	memset(value, 0, sizeof(Yodiwo_Plegma_ActivePortKeysMsg_t));
 	ParseTable table[] = {
 		{ "ActivePortKeys", 14, NULL, Array_string_FromJson, &value->ActivePortKeys },
-		{ "Id", 2, Parse_Int, NULL, &value->Id },
-		{ "Version", 7, Parse_Int, NULL, &value->Version },
 		{ "SeqNo", 5, Parse_Int, NULL, &value->SeqNo },
-		{ "ResponseToSeqNo", 15, Parse_Int, NULL, &value->ResponseToSeqNo },
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
@@ -1302,9 +1289,3 @@
 	};
 	return HelperJsonParseExec(json, jsonSize, table, sizeof(table) / sizeof(table[0]));
 }
-
-
-
-
-
-