Training Class with ROHM Sensor Board and LoRa mDot

Dependencies:   MbedJSONValue libmDot mbed-rtos mbed

Revision:
1:3ef353c7f925
Parent:
0:7f1c7e1755bc
--- a/main.cpp	Fri Feb 26 23:07:36 2016 +0000
+++ b/main.cpp	Sun Feb 28 23:06:53 2016 +0000
@@ -59,7 +59,6 @@
 
 #include "mbed.h"
 #include "MbedJSONValue.h"
-// #include "HTTPJson.h"
 #include <string>
 
 //  added the following help files for a mDot not required for Dragonfly.
@@ -73,20 +72,6 @@
 // Debug serial port
 static Serial debug(USBTX, USBRX);
 
-// see https://m2x.att.com/developer/documentation/v2/overview for M2X API documentation
-// M2X device ID
-static const std::string m2x_device_id = "";
-
-// M2X primary API key
-static const std::string m2x_api_key = "";
-
-// set to true if you want to post to the cloud
-// you need to have you M2X account set up properly for this to work?
-bool do_cloud_post = false;
-//bool do_cloud_post = true;
-
-std::string url = "http://api-m2x.att.com/v2/devices/" + m2x_device_id + "/update";
-
 
 // variables for sensor data
 float temp_celsius;
@@ -104,7 +89,6 @@
 static int motion_interval_ms = 5000;
 static int print_interval_ms = 5000;
 static int sms_interval_ms = 5000;
-// static int post_interval_ms = 30000;   // based on the web stuff that I want to delete.
 int debug_baud = 115200;
 
 
@@ -473,11 +457,11 @@
             printf("  In sms routine \r\n");
             
             char send_msg[20];
-            sprintf(send_msg, "Dilbert,%0.0f", RPR0521_ALS[0]);
+            sprintf(send_msg, "Dilbert,%0.0f", RPR0521_ALS[0]);     //***************************************probably note worthy
             std::string send_msg_str(send_msg);
             std::vector<uint8_t> data(send_msg_str.begin(), send_msg_str.end());
 
-            // Added the mdot send code here vs that the sms fuction was doing.  seemed reasonable.
+            // Added the mdot send code here vs that the sms fuction was doing. 
             // send the data to the gateway
             if ((ret = dot->send(data)) != mDot::MDOT_OK) {
                 logError("failed to send", ret, mDot::getReturnCodeString(ret).c_str());
@@ -485,85 +469,13 @@
                 logInfo("successfully sent data to gateway");
             }
 
-            //  End of send LoRa radio code.
-
-//            if (radio_ok) {
-//                MbedJSONValue sms_json;
-//                string sms_str;
-//
-//                sms_json["temp_C"] = BDE0600_output;
-//                sms_json["UV"] = ML8511_output;
-//                sms_json["Ambient Light"] = RPR0521_ALS[0];
-//                sms_json["Prox"]      = RPR0521_ALS[1];
-//                sms_json["pressure_hPa"] = BM1383[1];
-//                sms_json["mag_mgauss"]["x"] = MEMS_Mag[0];
-//                sms_json["mag_mgauss"]["y"] = MEMS_Mag[1];
-//                sms_json["mag_mgauss"]["z"] = MEMS_Mag[2];
-//                sms_json["acc_mg"]["x"] = MEMS_Accel[0];
-//                sms_json["acc_mg"]["y"] = MEMS_Accel[1];
-//                sms_json["acc_mg"]["z"] = MEMS_Accel[2];
-//                sms_json["Red"]   = BH1745[0];
-//                sms_json["Green"] = BH1745[1];
-//                sms_json["Blue"]  = BH1745[2];
-//
-//                sms_str = "SENSOR DATA:\n";
-//                sms_str += sms_json.serialize();
-//
-//                logDebug("sending SMS to %s:\r\n%s", phone_number.c_str(), sms_str.c_str());
-//                Code ret = radio->sendSMS(phone_number, sms_str);
-//                if (ret != MTS_SUCCESS)
-//                    logError("sending SMS failed");
-//            }
         }
 #endif
-
-#ifdef Web
-        if (post_timer.read_ms() > post_interval_ms && do_cloud_post) {
-            printf("in web\n\r");
-//            if (radio->connect()) {
-//                logDebug("posting sensor data");
-//
-//                HTTPClient http;
-//                MbedJSONValue http_json_data;
-//                std::string http_json_str;
-//                std::string m2x_header = "X-M2X-KEY: " + m2x_api_key + "\r\n";
-//                int ret;
-//                char http_response_buf[256];
-//                HTTPText http_response(http_response_buf, sizeof(http_response_buf));
-//
-//                // temp_c, temp_f, humidity, pressure, and moisture are all stream IDs for my device in M2X
-//                // modify these to match your streams or give your streams the same name
-//                http_json_data["values"]["temp_c"] = BDE0600_output;
-//                http_json_data["values"]["UV"] = ML8511_output;
-//                http_json_data["values"]["Ambient Light"] = RPR0521_ALS[0];
-//                http_json_data["values"]["Prox"] = RPR0521_ALS[1];
-//                http_json_str = http_json_data.serialize();
-//
-//                // add extra header with M2X API key
-//                http.setHeader(m2x_header.c_str());
-//
-//                HTTPJson http_json((char*)  http_json_str.c_str());
-//                ret = http.post(url.c_str(), http_json, &http_response);
-//                if (ret != HTTP_OK)
-//                    logError("posting data to cloud failed: [%d][%s]", ret, http_response_buf);
-//                else
-//                    logDebug("post result [%d][%s]", http.getHTTPResponseCode(), http_response_buf);
-//
-//                radio->disconnect();
-//            } else {
-//                logError("establishing PPP link failed");
-//            }
-
-            post_timer.reset();
-        }
-#endif
-
         wait_ms(10);
     }
 }
 
-
-
+/************************************************************************************************/
 // Sensor data acquisition functions
 /************************************************************************************************/
 #ifdef AnalogTemp
@@ -766,38 +678,3 @@
 
 }
 #endif
-
-
-/************************************************************************************
-//  reference only to remember what the names and fuctions are without finding them above.
- ************************************************************************************
-    (" Temp = %.2f C\r\n", BDE0600_output);
-    printf(" UV = %.1f mW/cm2\r\n", ML8511_output);
-
-    printf("BH1745 COLOR Sensor Data:\r\n");
-    printf(" Red   = %d ADC Counts\r\n",BH1745[0]);
-    printf(" Green = %d ADC Counts\r\n",BH1745[1]);
-    printf(" Blue  = %d ADC Counts\r\n",BH1745[2]);
-
-    printf(" ALS = %0.2f lx\r\n", RPR0521_ALS[0]);
-    printf(" PROX= %u ADC Counts\r\n", RPR0521_ALS[1]);     //defined as a float but is an unsigned, bad coding on my part.
-
-    printf("KMX62 Accel+Mag Sensor Data:\r\n");
-    printf(" AccX= %0.2f g\r\n", MEMS_Accel[0]);
-    printf(" AccY= %0.2f g\r\n", MEMS_Accel[1]);
-    printf(" AccZ= %0.2f g\r\n", MEMS_Accel[2]);
-
-    printf(" MagX= %0.2f uT\r\n", MEMS_Mag[0]);
-    printf(" MagY= %0.2f uT\r\n", MEMS_Mag[1]);
-    printf(" MagZ= %0.2f uT\r\n", MEMS_Mag[2]);
-
-    printf("KX022 Accelerometer Sensor Data: \r\n");
-    printf(" AccX= %0.2f g\r\n", KX022_Accel[0]);
-    printf(" AccY= %0.2f g\r\n", KX022_Accel[1]);
-    printf(" AccZ= %0.2f g\r\n", KX022_Accel[2]);
-
-    printf("BM1383 Pressure Sensor Data:\r\n");
-    printf(" Temperature= %0.2f C\r\n", BM1383[0]);
-    printf(" Pressure   = %0.2f hPa\r\n", BM1383[1]);
-
- **********************************************************************************/