Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 30 additions & 6 deletions Example/LoRaWAN/examples/TrackerD/GPS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ bool GPS_DATA(void)
{
while (SerialGPS.available() > 0)
{
//Serial.println("Inside GPS_data and Serial.GPS > 0");
if (gps.encode(SerialGPS.read()))
{
// Every time anything is updated, print everything.
Expand Down Expand Up @@ -92,6 +93,7 @@ bool GPS_DATA(void)
if((sys.pdop_value>=sensor.pdop_gps)&&(sensor.pdop_gps!=0.0)&&(sensor.Fix_Status == 3))
// if((sys.pdop_value>=sensor.pdop_gps)&&(sensor.pdop_gps!=0.0))
{
// Valid GPS data, prepare uplink
String latitude_string , longitiude_string,year_string,month_string,day_string,hour_string,minute_string,second_string;
latitude = gps.location.lat();
sensor.latitude = (int)(latitude*1000000);
Expand Down Expand Up @@ -133,10 +135,10 @@ bool GPS_DATA(void)
sys.gps_data_buff[i++] = (sensor.bat) & 0xFF;
}

// sys.gps_data_Weite();
// Serial.printf("addr_gps_write:%d\r\n",sys.addr_gps_write);
// sys.read_gps_data_on_flash();
// Serial.printf("addr_gps_read:%d\r\n",sys.addr_gps_read);
// sys.gps_data_Weite();
// Serial.printf("addr_gps_write:%d\r\n",sys.addr_gps_write);
// sys.read_gps_data_on_flash();
// Serial.printf("addr_gps_read:%d\r\n",sys.addr_gps_read);
if(sys.lon == 1)
{
if(sys.sensor_type == 22)
Expand Down Expand Up @@ -172,7 +174,17 @@ bool GPS_DATA(void)
digitalWrite(LED_PIN_BLUE, LOW);
delay(100);
}
}
}
if(sys.fix == 1)
{
// placeholders for gps data will be empty
sensor.latitude = 0;
sensor.longitude = 0;

Serial.println("No GPS fix, sending placeholder data. 2nd if.");

return true;
}
if (millis() - last > 30000)
{
last = millis();
Expand All @@ -184,6 +196,7 @@ bool GPS_DATA(void)
}
else
{
//Serial.println("Entering else statement ---- GPS.cpp ----");
if(sys.lon == 1)
{
if(sys.sensor_type == 22)
Expand All @@ -200,7 +213,18 @@ bool GPS_DATA(void)
digitalWrite(LED_PIN_BLUE, LOW);
delay(100);
}
}
}
// This if statement will only activate when no fix has been found and when sys.fix = 1.
if(sys.fix == 1)
{
// placeholders for gps data will be empty
sensor.latitude = 0;
sensor.longitude = 0;

Serial.println("No GPS fix, sending placeholder data.");

return true;
}
if (millis() - last > 30000)
{
last = millis();
Expand Down
1 change: 1 addition & 0 deletions Example/LoRaWAN/examples/TrackerD/TrackerD.ino
Original file line number Diff line number Diff line change
Expand Up @@ -1587,6 +1587,7 @@ void gps_send(void)
{
if(GPS_DATA() == true )
{
// Serial.println("GPS_DATA = true ---- TrackerD.ino ----");
os_JOINED_flag = 0;
sys.gps_work_flag = false;
if(sys.Positioning_time != 0)
Expand Down
19 changes: 19 additions & 0 deletions Example/LoRaWAN/examples/TrackerD/at.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,25 @@ ATEerror_t at_lon_set(const char *param)
return AT_OK;
}

/************** AT_FIX **************/
ATEerror_t at_fix_get(const char *param)
{
if(keep)
Serial.print(AT FIX "=");
Serial.println(sys.fix);
return AT_OK;
}
ATEerror_t at_fix_set(const char *param)
{
uint32_t is_on = atoi(param);
if(is_on >=2) // Has to be 1 or 0
{
return AT_PARAM_ERROR;
}
sys.fix = is_on;
return AT_OK;
}

/************** AT_INTWK **************/
ATEerror_t at_intwk_get(const char *param)
{
Expand Down
15 changes: 15 additions & 0 deletions Example/LoRaWAN/examples/TrackerD/at.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#define DEVICE "+DEVICE"
#define PDTA "+PDTA"
#define BTDC "+BTDC"
#define FIX "+FIX"
typedef enum
{
AT_OK = 0,
Expand Down Expand Up @@ -129,6 +130,8 @@ ATEerror_t at_intwk_get(const char *param);
ATEerror_t at_intwk_set(const char *param);
ATEerror_t at_lon_get(const char *param);
ATEerror_t at_lon_set(const char *param);
ATEerror_t at_fix_get(const char *param);
ATEerror_t at_fix_set(const char *param);
ATEerror_t at_CHS_get(const char *param);
ATEerror_t at_CHS_set(const char *param);
ATEerror_t at_CHE_get(const char *param);
Expand Down Expand Up @@ -418,6 +421,18 @@ static const struct ATCommand_s ATCommand[] =
.set = at_lon_set,
.run = at_return_error,
},
/**************** AT+FIX ****************/
{
.string = AT FIX,
.size_string = sizeof(FIX) - 1,
#ifndef NO_HELP
.help_string = AT FIX " : Enable/Disable Uplink without GPS",
#endif
.get = at_fix_get,
.set = at_fix_set,
.run = at_return_error,
},

/**************** AT+CHE ****************/
{
.string = AT CHE,
Expand Down
Loading