fp

Dependencies:   libmDot-mbed5 ISL29011

Files at this revision

API Documentation at this revision

Comitter:
harryyyy
Date:
Mon Jan 06 08:17:12 2020 +0000
Parent:
39:1f8558902454
Commit message:
fp

Changed in this revision

examples/src/ota_example.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 1f8558902454 -r 71d8df33ef7d examples/src/ota_example.cpp
--- a/examples/src/ota_example.cpp	Fri Jan 03 07:18:09 2020 +0000
+++ b/examples/src/ota_example.cpp	Mon Jan 06 08:17:12 2020 +0000
@@ -96,7 +96,7 @@
     
     // set network
     config(dot,plan);    
-
+    
     while (true) {
         int tmp,ret;
         std::vector<uint8_t> data;
@@ -104,24 +104,44 @@
         std::string data_str ;
         
         tmp = in.read_u16();
-        printf("%d\r\n",tmp);
-        
-        // format data for sending to the gateway
-        ss << tmp;
-        ss << "@105502522/105502511/105502512/105502531/105502546/105502528";
-        ss >> data_str;
-        for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
-            data.push_back((uint8_t) *it);
+        //printf("%d\r\n",tmp);
         
-        // send the data to the gateway
-        if ((ret = dot->send(data)) != mDot::MDOT_OK) {
-            logError("failed to send\r\n", ret, mDot::getReturnCodeString(ret).c_str());
-        } else {
-            logInfo("successfully sent data to gateway\r\n");
+        if(tmp < 37000 ){
+            // format data for sending to the gateway
+            ss << "yes";
+            ss >> data_str;
+            for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
+                data.push_back((uint8_t) *it);
+            
+            // send the data to the gateway
+            if ((ret = dot->send(data)) != mDot::MDOT_OK) {
+                logError("failed to send\r\n", ret, mDot::getReturnCodeString(ret).c_str());
+            } else {
+                logInfo("successfully sent data to gateway\r\n");
+            }
+    
+            // we use US but in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
+            osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs()));
+            
+        } 
+        else if (tmp > 40000 ){
+            // format data for sending to the gateway
+            ss << "no";
+            ss >> data_str;
+            for (std::string::iterator it = data_str.begin(); it != data_str.end(); it++)
+                data.push_back((uint8_t) *it);
+            
+            // send the data to the gateway
+            if ((ret = dot->send(data)) != mDot::MDOT_OK) {
+                logError("failed to send\r\n", ret, mDot::getReturnCodeString(ret).c_str());
+            } else {
+                logInfo("successfully sent data to gateway\r\n");
+            }
+    
+            // we use US but in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
+            osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs()));
+
         }
-
-        // we use US but in the 868 (EU) frequency band, we need to wait until another channel is available before transmitting again
-        osDelay(std::max((uint32_t)5000, (uint32_t)dot->getNextTxMs()));
     }
 
     return 0;