JSON file in mbed.

Dependencies:   MbedJSONValue SDFileSystem mbed

Fork of City_Game_JSON by Alex Vancoillie

Revision:
5:eedf89829452
Parent:
3:0ace19f0cc2b
diff -r 54fdacd71dc9 -r eedf89829452 main.cpp
--- a/main.cpp	Wed Mar 29 07:27:01 2017 +0000
+++ b/main.cpp	Mon Nov 27 05:22:40 2017 +0000
@@ -1,13 +1,14 @@
 #include "mbed.h"
 #include "MbedJSONValue.h"
-#include "SDFileSystem.h"
+//#include "SDFileSystem.h"
 #include "mission.h"
 #include <iostream>
 #include <vector>
+Serial pc(USBTX,USBRX);
 
 using namespace VivesCityGame;
 
-SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // mosi, miso, sclk, cs
+//SDFileSystem sd(PTE3, PTE1, PTE2, PTE4, "sd"); // mosi, miso, sclk, cs
 
 #define charlimit 100
 char words[charlimit];
@@ -16,7 +17,7 @@
 int main() {
     MbedJSONValue demo;
 
-    FILE * fp1
+   /* FILE * fp1
     = fopen("/sd/test.json", "r");
     if(fp1 == NULL)
     {
@@ -33,10 +34,12 @@
 
     printf("Read from SD card: %s\r\n", words);
 
-    fclose(fp1);
+    fclose(fp1);*/
+     printf("Starting the program");
 
     //const char * json = "{\"gameMode\":\"LocationGame\",\"gameModeId\":1,\"version\":\"1.235\",\"creationDate\":\"11-02-2017\",\"missions\":[{\"type\":\"gotoLocation\",\"id\":1,\"message\":\"Go to the big roundabout in Oostende.\",\"deadline\":true,\"deadlineTime\":30,\"latitude\":51.21543,\"longitude\":2.928656,\"radius\":200},{\"type\":\"puzzle\",\"id\":2,\"message\":\"Find the key A\",\"hint\":\"Look in a tree\",\"deadline\":false}]}";
-    const char * json = words;
+    const char * json = "{\"gameMode\":\"LocationGame\",\"gameModeId\":1,\"message\":\"Go to the big roundabout in Oostende.\"}";
+    //const char * json = words;
     //const  char * json = "{\"my_array\": [\"demo_string\", 10], \"my_boolean\": true}";
 
     // parse the previous string and fill the object demo
@@ -54,20 +57,22 @@
     }
 
     cout << "Missions: " << endl;
+    while(1)
+    {
 
-    for(std::size_t i = 0; i < missions.size(); i++)
+    for(int i = 0; i < missions.size(); i++)
     {
-        printf("Type: %s\r\n", missions[i].get_type().c_str());
-        printf("Id: %d\r\n", missions[i].get_id());
-        printf("Message: %s\r\n", missions[i].get_message().c_str());
-        printf("Hint: %s\r\n", missions[i].get_hint().c_str());
+        pc.printf("Type: %s\r\n", missions[i].get_type().c_str());
+        pc.printf("Id: %d\r\n", missions[i].get_id());
+        pc.printf("Message: %s\r\n", missions[i].get_message().c_str());
+        /*printf("Hint: %s\r\n", missions[i].get_hint().c_str());
         printf("Deadline: %s\r\n", missions[i].get_deadline() ? "true" : "false");
         printf("DeadlineTime: %d\r\n", missions[i].get_deadlineTime());
         printf("Latitude: %f\r\n", missions[i].get_latitude());
         printf("Longitude: %f\r\n", missions[i].get_longitude());
-        printf("Radius: %d\r\n", missions[i].get_radius());
+        printf("Radius: %d\r\n", missions[i].get_radius());*/
     }
-    
+    }
     /*
     for(std::size_t i = 0; i < missions.size(); i++)
     {