• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Commit MetaInfo

Revisionfb1963284ac1e29034dd58db957318f192637a66 (tree)
Zeit2018-11-21 23:02:55
Autorkazuhiro_kondow <simauma.circus@gmai...>
Commiterkazuhiro_kondow

Log Message

The event that the Curl command could not be issued from LG 01 to the server via Bridge resolved

Ändern Zusammenfassung

Diff

--- a/LoRa_farme/server_lg01/server_lg01.ino
+++ b/LoRa_farme/server_lg01/server_lg01.ino
@@ -6,18 +6,15 @@
66 Then send the value to Database Server
77 */
88
9-#include <SPI.h>
109 #include <RH_RF95.h>
11-#include <Bridge.h>
12-#include <RTClib.h>
13-#include <String.h>
1410 #include <Process.h>
1511
1612 // Objects
1713 RH_RF95 rf95;
1814
1915 #define BAUDRATE 115200
20-const char* const PostUrl = "http://shimauma-circus.sakura.ne.jp/webapp/iot/dataentry -X POST -d \"data=";
16+#define MAX_DATA_SIZE 50
17+const char* const PostUrl = "http://shimauma-circus.sakura.ne.jp/webapp/iot/dataentry";
2118 uint16_t crcdata = 0;
2219 uint16_t recCRCData = 0;
2320 float frequency = 920.0;
@@ -31,19 +28,12 @@ void runCurl(const char*param);
3128
3229 void setup()
3330 {
34- // Bridge takes about two seconds to start up
35- // it can be helpful to use the on-board LED
36- // as an indicator for when it has initialized
37- pinMode(A2, OUTPUT);
38- digitalWrite(A2, LOW);
39- Bridge.begin(BAUDRATE);
40- digitalWrite(A2, HIGH);
4131
32+ Bridge.begin(BAUDRATE);
4233 Console.begin();
4334
4435 // wait for a serial connection
45- while (!Console)
46- ;
36+ while (!Console);
4737
4838 // Setup rf95
4939 if (!rf95.init())
@@ -61,11 +51,11 @@ void setup()
6151 void loop()
6252 {
6353 //receive data buffer
64- uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
54+ uint8_t buf[MAX_DATA_SIZE];
6555 //data buffer length
6656 uint8_t len = sizeof(buf);
6757 //post data buffer
68- char postdata[RH_RF95_MAX_MESSAGE_LEN] = {'\0'};
58+ char postdata[MAX_DATA_SIZE] = {'\0'};
6959
7060 // Listen Data from LoRa Node
7161 if (rf95.waitAvailableTimeout(2000))
@@ -87,12 +77,10 @@ void loop()
8777 }
8878 Console.println("");
8979
90- snprintf(postdata,RH_RF95_MAX_MESSAGE_LEN,"%s",PostUrl);
9180 for (int i = 0; i < len; i++)
9281 {
9382 snprintf(postdata,RH_RF95_MAX_MESSAGE_LEN,"%s%02x",postdata,buf[i]);
9483 }
95- snprintf(postdata,RH_RF95_MAX_MESSAGE_LEN,"%s%s",postdata,"\"");
9684 Console.println(postdata);
9785 runCurl(postdata);
9886
@@ -184,17 +172,26 @@ boolean rcvSensorData(uint8_t *buf,uint8_t *len)
184172 }
185173
186174 void runCurl(const char*param) {
187- Process p;
188- p.begin("curl");
189- p.addParameter(param);
190- p.run();
191-
192- while (p.available() > 0) {
193- char c = p.read();
194- Console.print(c);
195- }
196- Console.println("");
197- Console.println("Process is not available!");
198-
199- Console.flush();
175+ Process process;
176+ char mbuffer[100] = {'\0'};
177+ snprintf(mbuffer,100,"data=%s",param);
178+ Console.print(mbuffer);
179+
180+ process.begin("curl");
181+ process.addParameter(PostUrl);
182+ process.addParameter("-i");
183+ process.addParameter("-X");
184+ process.addParameter("POST");
185+ process.addParameter("-d");
186+ process.addParameter(mbuffer);
187+ process.run();
188+
189+ while (process.available() > 0) {
190+ char c = process.read();
191+ Console.print(c);
192+ }
193+ Console.println("");
194+ Console.println("Process is not available!");
195+
196+ Console.flush();
200197 }
--- a/Yun/Sketch_jun01a_bridge/sketch_jun01a_bridge.ino
+++ b/Yun/Sketch_jun01a_bridge/sketch_jun01a_bridge.ino
@@ -1,8 +1,18 @@
1-#include<Process.h>
1+#include <Process.h>
2+
23 #define BAUDRATE 115200
4+
5+// Objects
6+Process process;
7+
8+const char* const PostUrl = "http://shimauma-circus.sakura.ne.jp/webapp/iot/dataentry";
9+
10+// ProtType
11+void runCurl(const char*param);
12+
313 void setup() {
4- // put your setup code here, to run once:
514
15+ // put your setup code here, to run once:
616 // Bridge startup
717 pinMode(A2, OUTPUT);
818 digitalWrite(A2, LOW);
@@ -17,23 +27,34 @@ void setup() {
1727 }
1828
1929 void loop() {
20- // put your main code here, to run repeatedly:
21- runCurl("http://10.130.1.209:80/pythontest.py");
30+ runCurl("sendTestData");
2231 while(1);
32+
2333 }
2434
2535 void runCurl(const char*param) {
26- Process p;
27- p.begin("curl");
28- p.addParameter(param);
29- p.run();
36+ char mbuffer[100] = {'\0'};
37+ snprintf(mbuffer,100,"data=%s",param);
38+ Console.print(mbuffer);
39+
40+ process.begin("curl");
41+ process.addParameter(PostUrl);
42+ process.addParameter("-i");
43+ process.addParameter("-X");
44+ process.addParameter("POST");
45+ process.addParameter("-d");
46+ process.addParameter(mbuffer);
47+ process.run();
3048
31- while (p.available() > 0) {
32- char c = p.read();
49+ while (process.available() > 0) {
50+ char c = process.read();
3351 Console.print(c);
34- }
35- Console.println("");
36- Console.println("Process is not available!");
37-
38- Console.flush();
39-}
52+ }
53+ Console.println("");
54+ Console.println("Process is not available!");
55+
56+ Console.flush();
57+}
58+
59+
60+
Binary files "a/\351\226\213\347\231\272\343\203\255\343\202\260Book1.xlsx" and "b/\351\226\213\347\231\272\343\203\255\343\202\260Book1.xlsx" differ