Skip to content

Commit 710307a

Browse files
committed
fix bug
1 parent 656be9c commit 710307a

File tree

2 files changed

+16
-77
lines changed

2 files changed

+16
-77
lines changed

libraries/Dragino/examples/IoTServer/Cayenne and TTN/cayenne and ttn example/GPS_shield examples/GPS_shield_cayenne_and_ttn-abpClient/GPS_shield_cayenne_and_ttn-abpClient.ino

Lines changed: 9 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ unsigned int count = 0; //For times count
4343

4444
float longitude,latitude;
4545
float flat,flon,falt;
46-
float mgLon,mgLat; // World Geodetic System ==> Mars Geodetic System
4746

4847
static uint8_t mydata[11] ={0x03,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4948

@@ -85,27 +84,12 @@ void onEvent (ev_t ev) {
8584
Serial.print(os_getTime());
8685
Serial.print(": ");
8786
switch(ev) {
88-
case EV_SCAN_TIMEOUT:
89-
Serial.println(F("EV_SCAN_TIMEOUT"));
90-
break;
91-
case EV_BEACON_FOUND:
92-
Serial.println(F("EV_BEACON_FOUND"));
93-
break;
94-
case EV_BEACON_MISSED:
95-
Serial.println(F("EV_BEACON_MISSED"));
96-
break;
97-
case EV_BEACON_TRACKED:
98-
Serial.println(F("EV_BEACON_TRACKED"));
99-
break;
10087
case EV_JOINING:
10188
Serial.println(F("EV_JOINING"));
10289
break;
10390
case EV_JOINED:
10491
Serial.println(F("EV_JOINED"));
10592
break;
106-
case EV_RFU1:
107-
Serial.println(F("EV_RFU1"));
108-
break;
10993
case EV_JOIN_FAILED:
11094
Serial.println(F("EV_JOIN_FAILED"));
11195
break;
@@ -124,22 +108,10 @@ void onEvent (ev_t ev) {
124108
// Schedule next transmission
125109
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
126110
break;
127-
case EV_LOST_TSYNC:
128-
Serial.println(F("EV_LOST_TSYNC"));
129-
break;
130-
case EV_RESET:
131-
Serial.println(F("EV_RESET"));
132-
break;
133111
case EV_RXCOMPLETE:
134112
// data received in ping slot
135113
Serial.println(F("EV_RXCOMPLETE"));
136114
break;
137-
case EV_LINK_DEAD:
138-
Serial.println(F("EV_LINK_DEAD"));
139-
break;
140-
case EV_LINK_ALIVE:
141-
Serial.println(F("EV_LINK_ALIVE"));
142-
break;
143115
default:
144116
Serial.println(F("Unknown event"));
145117
break;
@@ -193,19 +165,17 @@ void GPSRead()
193165
flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;//save six decimal places
194166
flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
195167
falt == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : falt, 2;//save two decimal places
196-
if((flon < 72.004 || flon > 137.8347)&&(flat < 0.8293 || flat >55.8271)) //out of China
197-
{
168+
// if((flon < 72.004 || flon > 137.8347)&&(flat < 0.8293 || flat >55.8271)) //out of China
169+
// {
198170
longitude=flon;
199171
latitude=flat;
200172
// Serial.println("Out of China");
201-
}
202-
else
203-
{
204-
WGS2GCJTransform(flon,flat,mgLon,mgLat);
205-
longitude=mgLon;
206-
latitude=mgLat;
207-
//Serial.println("In China");
208-
}
173+
// }
174+
// else
175+
// {
176+
// WGS2GCJTransform(flon,flat,longitude,latitude);
177+
// //Serial.println("In China");
178+
// }
209179
int32_t lat = latitude * 10000;
210180
int32_t lon = longitude * 10000;
211181
int32_t alt = falt * 100;
@@ -241,7 +211,7 @@ void printdata(){
241211
}
242212
else
243213
{
244-
Serial.println(F("Unsuccessfully positioning"));
214+
Serial.println(F("Fail positioning"));
245215
}
246216
}
247217

libraries/Dragino/examples/IoTServer/Cayenne and TTN/cayenne and ttn example/GPS_shield examples/GPS_shield_cayenne_and_ttn-otaaClient/GPS_shield_cayenne_and_ttn-otaaClient.ino

Lines changed: 7 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ unsigned int count = 0; //For times count
4343

4444
float longitude,latitude;
4545
float flat,flon,falt;
46-
float mgLon,mgLat; // World Geodetic System ==> Mars Geodetic System
4746

4847
static uint8_t mydata[11] ={0x03,0x88,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
4948

@@ -83,31 +82,15 @@ void onEvent (ev_t ev) {
8382
Serial.print(os_getTime());
8483
Serial.print(": ");
8584
switch(ev) {
86-
case EV_SCAN_TIMEOUT:
87-
Serial.println(F("EV_SCAN_TIMEOUT"));
88-
break;
89-
case EV_BEACON_FOUND:
90-
Serial.println(F("EV_BEACON_FOUND"));
91-
break;
92-
case EV_BEACON_MISSED:
93-
Serial.println(F("EV_BEACON_MISSED"));
94-
break;
95-
case EV_BEACON_TRACKED:
96-
Serial.println(F("EV_BEACON_TRACKED"));
97-
break;
9885
case EV_JOINING:
9986
Serial.println(F("EV_JOINING"));
10087
break;
10188
case EV_JOINED:
10289
Serial.println(F("EV_JOINED"));
103-
10490
// Disable link check validation (automatically enabled
10591
// during join, but not supported by TTN at this time).
10692
LMIC_setLinkCheckMode(0);
10793
break;
108-
case EV_RFU1:
109-
Serial.println(F("EV_RFU1"));
110-
break;
11194
case EV_JOIN_FAILED:
11295
Serial.println(F("EV_JOIN_FAILED"));
11396
break;
@@ -127,22 +110,10 @@ void onEvent (ev_t ev) {
127110
// Schedule next transmission
128111
os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send);
129112
break;
130-
case EV_LOST_TSYNC:
131-
Serial.println(F("EV_LOST_TSYNC"));
132-
break;
133-
case EV_RESET:
134-
Serial.println(F("EV_RESET"));
135-
break;
136113
case EV_RXCOMPLETE:
137114
// data received in ping slot
138115
Serial.println(F("EV_RXCOMPLETE"));
139116
break;
140-
case EV_LINK_DEAD:
141-
Serial.println(F("EV_LINK_DEAD"));
142-
break;
143-
case EV_LINK_ALIVE:
144-
Serial.println(F("EV_LINK_ALIVE"));
145-
break;
146117
default:
147118
Serial.println(F("Unknown event"));
148119
break;
@@ -204,9 +175,7 @@ void GPSRead()
204175
}
205176
else
206177
{
207-
WGS2GCJTransform(flon,flat,mgLon,mgLat);
208-
longitude=mgLon;
209-
latitude=mgLat;
178+
WGS2GCJTransform(flon,flat,longitude,latitude);
210179
//Serial.println("In China");
211180
}
212181
int32_t lat = latitude * 10000;
@@ -233,18 +202,18 @@ void printdata(){
233202
{
234203
Serial.println(F("The longtitude and latitude and altitude are:"));
235204
Serial.print(F("["));
236-
Serial.print(mgLon,4);
205+
Serial.print(longitude,4);
237206
Serial.print(F(","));
238-
Serial.print(mgLat,4);
207+
Serial.print(latitude,4);
239208
Serial.print(F(","));
240-
Serial.print(falt);
209+
Serial.print(falt);
241210
Serial.print(F("]"));
242-
Serial.println(F(""));
211+
Serial.println(F(""));
243212
count++;
244213
}
245214
else
246215
{
247-
Serial.println(F("Unsuccessfully positioning"));
216+
Serial.println(F("Fail positioning"));
248217
}
249218
}
250219

@@ -280,7 +249,7 @@ void setup() {
280249
Serial.println(F("Starting"));
281250
ss.begin(9600);
282251
#ifdef VCC_ENABLE
283-
// For Pinoccio Scout boards
252+
//For Pinoccio Scout boards
284253
pinMode(VCC_ENABLE, OUTPUT);
285254
digitalWrite(VCC_ENABLE, HIGH);
286255
delay(1000);

0 commit comments

Comments
 (0)