Revisión | c919edccde5350aeacbee1bff00e6911641fd2b6 (tree) |
---|---|
Tiempo | 2020-11-18 23:23:33 |
Autor | kazuhiro_kondow <simauma.circus@gmai...> |
Commiter | kazuhiro_kondow |
Merge branch 'master' of git.pf.osdn.net:/gitroot/k/ka/kazuhiro_kondow/LoRa_Farm_IOT
@@ -4,7 +4,7 @@ | ||
4 | 4 | "name": "Win32", |
5 | 5 | "browse": { |
6 | 6 | "path": [ |
7 | - "C:\\Users\\user1\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\avr\\1.6.21\\cores\\arduino", | |
7 | + "C:\\Users\\user1\\AppData\\Local\\Arduino15\\packages\\arduino\\hardware\\megaavr\\1.8.1\\cores\\arduino", | |
8 | 8 | "C:\\Program Files (x86)\\Arduino\\libraries", |
9 | 9 | "C:\\Program Files (x86)\\Arduino\\hardware\\arduino\\avr\\libraries", |
10 | 10 | "C:\\Users\\user1\\Documents\\Arduino\\libraries", |
@@ -18,7 +18,7 @@ | ||
18 | 18 | "${workspaceFolder}" |
19 | 19 | ], |
20 | 20 | "forcedInclude": [], |
21 | - "intelliSenseMode": "msvc-x64", | |
21 | + "intelliSenseMode": "${default}", | |
22 | 22 | "compilerPath": "C:\\MinGW\\bin\\gcc.exe", |
23 | 23 | "cStandard": "c11", |
24 | 24 | "cppStandard": "c++17" |
@@ -52,6 +52,7 @@ typedef struct _st_standby_data | ||
52 | 52 | { |
53 | 53 | unsigned char msg_type; |
54 | 54 | unsigned char unit_uuid[16]; |
55 | + unsigned char node_type; | |
55 | 56 | float lon; |
56 | 57 | float lat; |
57 | 58 | } st_standby_data; |
@@ -62,7 +63,7 @@ typedef struct _st_boiler_data | ||
62 | 63 | unsigned char unit_uuid[16]; |
63 | 64 | unsigned char node_type; |
64 | 65 | unsigned char node_status; |
65 | - float temperature_val[4]; | |
66 | + float temperature_val[5]; | |
66 | 67 | } st_boiler_data; |
67 | 68 | |
68 | 69 | typedef struct _st_environ_data |
@@ -1,3 +1,4 @@ | ||
1 | +// 20200813 Serial.printの後にdelayを入れてコンソールへの送信時間を調整する事、蓄積するとデバイス側でResetが発生する | |
1 | 2 | #ifndef UserLoRaInterface_h |
2 | 3 | #define UserLoRaInterface_h |
3 | 4 |
@@ -17,7 +18,8 @@ bool sendUnitMsg(uint8_t *pBuffer, uint32_t length, unsigned char *pUuid, unsign | ||
17 | 18 | // WAIT_RESPONSE_TIME unit:millis sec |
18 | 19 | { |
19 | 20 | //Send LoRa Data |
20 | - Serial.println("sendUnitMsg"); | |
21 | + // Serial.println(F("SRT sendUnitMsg")); | |
22 | + // delay(200); | |
21 | 23 | //Reply data array |
22 | 24 | uni_respons_data buf; |
23 | 25 | //reply data length |
@@ -27,22 +29,26 @@ bool sendUnitMsg(uint8_t *pBuffer, uint32_t length, unsigned char *pUuid, unsign | ||
27 | 29 | int retry_cnt= 0; |
28 | 30 | |
29 | 31 | // for debug |
30 | - Serial.println("Send LoRa Data : "); | |
31 | - delay(100); | |
32 | - for (int i = 0; i < length + 2; i++) | |
33 | - { | |
34 | - Serial.print(pBuffer[i], HEX); | |
35 | - Serial.print(","); | |
36 | - } | |
37 | - Serial.println(""); | |
32 | + // Serial.print(F("Data length : ")); | |
33 | + // Serial.println(length); | |
34 | + // Serial.println(F("Send LoRa Data : ")); | |
35 | + // delay(100); | |
36 | + // for (int i = 0; i < length + 2; i++) | |
37 | + // { | |
38 | + // Serial.print(pBuffer[i], HEX); | |
39 | + // Serial.print(","); | |
40 | + // } | |
41 | + // Serial.println(""); | |
42 | + // delay(100); | |
38 | 43 | |
39 | 44 | unsigned long send_time = millis(); |
40 | 45 | |
41 | 46 | do{ |
42 | 47 | if(bRetryFlag) |
43 | 48 | { |
44 | - Serial.println("do send message"); // for debug | |
45 | - delay(100); | |
49 | + // Serial.println(F("do send message")); // for debug | |
50 | + // delay(150); | |
51 | + | |
46 | 52 | rf95.send(pBuffer, length + 2); |
47 | 53 | // rf95 changing mode it idle |
48 | 54 | rf95.waitPacketSent(); |
@@ -59,49 +65,65 @@ bool sendUnitMsg(uint8_t *pBuffer, uint32_t length, unsigned char *pUuid, unsign | ||
59 | 65 | { |
60 | 66 | if(buf.val.msg_type != (uint8_t)MSG_TYPE_RESPONSE) |
61 | 67 | { |
62 | - Serial.println("Check MSG_TYPE_RESPONSE :continue"); // for debug | |
68 | + // Serial.println(F("Check MSG_TYPE_RESPONSE :continue")); // for debug | |
69 | + // delay(100); | |
63 | 70 | continue; |
64 | 71 | } |
72 | + | |
65 | 73 | // Check receved reply UUID |
66 | - if (memcmp(buf.val.unit_uuid, pUuid, (size_t)16) != 0) | |
74 | + if (memcmp(buf.val.unit_uuid, pUuid, sizeof(*pUuid)) != 0) | |
67 | 75 | { |
68 | - Serial.println("Check receved reply UUID :continue"); // for debug | |
76 | + // Serial.println(F("Check receved reply UUID :continue")); // for debug | |
77 | + // delay(100); | |
69 | 78 | continue; |
70 | 79 | } |
71 | 80 | else |
72 | 81 | { |
73 | 82 | if (buf.val.respons == 0x06) |
74 | 83 | { |
75 | - Serial.println("Replay ACK"); | |
84 | + // Serial.println(F("Replay ACK")); | |
85 | + // Serial.print("u time:"); | |
86 | + // Serial.println(buf.val.unix_time_stamp_val); | |
87 | + // delay(200); | |
76 | 88 | *rtime = buf.val.unix_time_stamp_val; |
77 | 89 | break; |
78 | 90 | } |
79 | 91 | else if (buf.val.respons == 0x21) |
80 | 92 | { |
81 | - Serial.println("Replay NAK"); | |
93 | + Serial.println(F("Replay NAK")); | |
94 | + delay(200); | |
82 | 95 | bRetryFlag = true; |
83 | 96 | } |
84 | 97 | else |
85 | 98 | { |
86 | - Serial.println("Replay Unkown"); | |
99 | + Serial.println(F("Replay Unkown")); | |
100 | + delay(200); | |
87 | 101 | bRetryFlag = true; |
88 | 102 | } |
89 | 103 | } |
90 | 104 | } |
91 | 105 | else |
92 | 106 | { |
93 | - Serial.println("recv failed"); | |
107 | + Serial.println(F("Recv failed")); | |
108 | + delay(100); | |
94 | 109 | bRetryFlag = true; |
95 | 110 | } |
96 | 111 | } |
97 | 112 | else |
98 | 113 | { |
99 | - Serial.println("No reply, is rf95_server running?"); //No signal reply | |
114 | + Serial.println(F("No Replay")); //No signal reply | |
115 | + delay(200); | |
100 | 116 | bRetryFlag = true; |
101 | 117 | } |
102 | - bResultFlag = (((millis() - send_time) < WAIT_RESPONSE_TIME ) && (retry_cnt < SEND_RETRY_MAX)); | |
118 | + | |
119 | + unsigned long send_time2 = millis(); | |
120 | + bResultFlag = (((send_time2 - send_time) < WAIT_RESPONSE_TIME ) && (retry_cnt < SEND_RETRY_MAX)); | |
121 | + | |
103 | 122 | }while(bResultFlag); |
104 | 123 | |
124 | + // Serial.println(F("END sendUnitMsg")); | |
125 | + // delay(200); | |
126 | + | |
105 | 127 | return bResultFlag; |
106 | 128 | } |
107 | 129 |