Simple receiver application for SX127x radio.

Dependencies:   MbedJSONValue SX127x sx12xx_hal

Revision:
3:cfbb4ffd0cbd
Parent:
2:fef452211079
Child:
4:fed69c9a3bbf
--- a/main.cpp	Fri Sep 06 22:59:55 2019 +0000
+++ b/main.cpp	Fri Sep 06 23:18:09 2019 +0000
@@ -38,20 +38,25 @@
         printf("JSON Format!\r\n");
         // Display payload packet information
         char* json = (char*)Radio::radio.rx_buf;
-        printf("Message: %s\r\n", json);
-        
+        printf("Message: %s\r\n", json);       
         parse(message, (char*)json);
-        
-        int btn_count = message["btn_count"].get<int>();
-        int btn_timer = message["btn_timer"].get<int>();
-        string my_str = message["my_str"].get<string>(); 
-        bool my_bool = message["my_boolean"].get<bool>();
-        
         printf("\r\n\n");
-        printf("btn_count: %d\r\n", message["btn_count"].get<int>());
-        printf("btn_timer: %f\r\n", message["btn_timer"].get<double>());
-        printf("my_str: %s\r\n", message["my_str"].get<string>().c_str());
-        printf("my_bool: %s\r\n", message["my_boolean"].get<bool>() ? "true" : "false");
+        if(message.hasMember("btn_count"))
+        {
+            printf("btn_count: %d\r\n", message["btn_count"].get<int>());
+        }
+        if(message.hasMember("btn_timer"))
+        {
+            printf("btn_timer: %f\r\n", message["btn_timer"].get<double>());
+        }
+        if(message.hasMember("my_str"))
+        {
+            printf("my_str: %s\r\n", message["my_str"].get<string>().c_str());
+        }
+        if(message.hasMember("my_boolean"))
+        {
+            printf("my_bool: %s\r\n", message["my_boolean"].get<bool>() ? "true" : "false");
+        }       
         printf("\r\n\n");
     }
     else