Yodiwo / Mbed 2 deprecated YoPlegma

Dependencies:   EthernetInterface FXOS8700Q HTTPClient HTTPD MQTTS SDFileSystem YodiwoPlegma mbed-rpc mbed-rtos mbed wolfSSL

Revision:
1:c5abc450140c
Parent:
0:00797f1ebe04
Child:
2:b7489c070d1f
--- a/pairing_backend.cpp	Tue Sep 01 10:23:13 2015 +0000
+++ b/pairing_backend.cpp	Tue Sep 01 12:01:50 2015 +0000
@@ -2,11 +2,13 @@
 #include "HTTPClient.h"
 #include "mbed.h"
 #include "rtos.h"
+#include "yodiwo_helpers.h"
+#include "jsmn.h"
 
 HTTPClient http;
 char recvBuff[1024*20];
 int __get_tokens(pairing_context *ctx);
- 
+
 int pairing_context_init_with_defaults(pairing_context *ctx, onPaired_callback callback)
 {
     ctx->postUrl = "http://10.30.254.199:3334/pairing/";
@@ -47,8 +49,8 @@
 
     strcpy(url, ctx->postUrl);
     strcat(url, "/gettokens");
-//    http.dumpReqHeader(true);
-//    http.dumpResHeader(true);
+    http.dumpReqHeader(true);
+    http.dumpResHeader(true);
     int ret;
     
     //GET data
@@ -71,10 +73,21 @@
     map.put("uuid", ctx->uuid);
     printf("\nTrying to post data...\n");
     ret = http.post(url, map, &inText);
+    Yodiwo_Plegma_PairingServerTokensResponse_t tokens;
     if (!ret)
     {
-      printf("Executed POST successfully - read %d characters\n", strlen(str));
-      printf("Result: %s\n", str);
+        printf("Executed POST successfully - read %d characters\n", strlen(str));
+        printf("Result: %s\n", str);
+        int jret = Yodiwo_Plegma_PairingServerTokensResponse_FromJson(str, strlen(str), &tokens);
+        if (jret == Yodiwo_JsonSuccessParse) {
+            ctx->token1 = tokens.token1;
+            ctx->token2 = tokens.token2;
+            return 0;
+        } else {
+            printf("error parsing response");
+            return -2;
+        }
+      
       
     }
     else
@@ -84,3 +97,4 @@
     return ret;
     
 }
+