Skip to content

Merge v3.1 #389

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Feb 3, 2023
Merged
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
31 changes: 23 additions & 8 deletions Firmware/RTK_Surveyor/AP-Config/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,8 @@ function useGeodeticCoordinates() {
ge("fixedLat").value = geodeticLat;
ge("fixedLong").value = geodeticLon;
ge("fixedAltitude").value = geodeticAlt;
var hae = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000
ge("fixedHAE_APC").value = hae.toFixed(3);
}

function startNewLog() {
Expand Down Expand Up @@ -1061,15 +1063,18 @@ document.addEventListener("DOMContentLoaded", (event) => {
});

ge("fixedAltitude").addEventListener("change", function () {
ge("fixedHAE_APC").value = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000;
var hae = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000;
ge("fixedHAE_APC").value = hae.toFixed(3);
});

ge("antennaHeight").addEventListener("change", function () {
ge("fixedHAE_APC").value = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000;
var hae = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000;
ge("fixedHAE_APC").value = hae.toFixed(3);
});

ge("antennaReferencePoint").addEventListener("change", function () {
ge("fixedHAE_APC").value = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000;
var hae = Number(ge("fixedAltitude").value) + Number(ge("antennaHeight").value) / 1000 + Number(ge("antennaReferencePoint").value) / 1000;
ge("fixedHAE_APC").value = hae.toFixed(3);
});
})

Expand Down Expand Up @@ -1160,19 +1165,21 @@ function addGeodetic() {
checkElementValue("fixedLat", -180, 180, "Must be -180 to 180", "collapseBaseConfig");
checkElementValue("fixedLong", -180, 180, "Must be -180 to 180", "collapseBaseConfig");
checkElementValue("fixedAltitude", -11034, 8849, "Must be -11034 to 8849", "collapseBaseConfig");
checkElementValue("antennaHeight", -15000, 15000, "Must be -15000 to 15000", "collapseBaseConfig");
checkElementValue("antennaReferencePoint", -200.0, 200.0, "Must be -200.0 to 200.0", "collapseBaseConfig");

if (errorCount == 0) {
//Check name against the list
var index = 0;
for (; index < recordsGeodetic.length; ++index) {
var parts = recordsGeodetic[index].split(' ');
if (ge("nicknameGeodetic").value == parts[0]) {
recordsGeodetic[index] = nicknameGeodetic.value + ' ' + fixedLat.value + ' ' + fixedLong.value + ' ' + fixedAltitude.value;
recordsGeodetic[index] = nicknameGeodetic.value + ' ' + fixedLat.value + ' ' + fixedLong.value + ' ' + fixedAltitude.value + ' ' + antennaHeight.value + ' ' + antennaReferencePoint.value;
break;
}
}
if (index == recordsGeodetic.length)
recordsGeodetic.push(nicknameGeodetic.value + ' ' + fixedLat.value + ' ' + fixedLong.value + ' ' + fixedAltitude.value);
recordsGeodetic.push(nicknameGeodetic.value + ' ' + fixedLat.value + ' ' + fixedLong.value + ' ' + fixedAltitude.value + ' ' + antennaHeight.value + ' ' + antennaReferencePoint.value);
}

updateGeodeticList();
Expand All @@ -1189,14 +1196,19 @@ function loadGeodetic() {
var val = ge("StationCoordinatesGeodetic").value;
if (val > "") {
var parts = recordsGeodetic[val].split(' ');
ge("nicknameGeodetic").value = parts[0];
ge("fixedLat").value = parts[1];
ge("fixedLong").value = parts[2];
ge("fixedAltitude").value = parts[3];
ge("nicknameGeodetic").value = parts[0];
ge("antennaHeight").value = parts[4];
ge("antennaReferencePoint").value = parts[5];

clearError("nicknameGeodetic");
clearError("fixedLat");
clearError("fixedLong");
clearError("fixedAltitude");
clearError("nicknameGeodetic");
clearError("antennaHeight");
clearError("antennaReferencePoint");
}
}

Expand All @@ -1216,7 +1228,6 @@ function updateGeodeticList() {
}

for (let index = 0; index < recordsGeodetic.length; ++index) {

var option = document.createElement('option');
option.text = recordsGeodetic[index];
option.value = index;
Expand Down Expand Up @@ -1284,6 +1295,10 @@ function fileManagerToggle() {
function fileManagerDelete() {
selectedFiles = document.querySelectorAll('input[name=fileID]:checked');

if (confirm("Delete " + selectedFiles.length + " files?") == false) {
return;
}

for (let x = 0; x < selectedFiles.length; x++) {
var urltocall = "/file?name=" + selectedFiles[x].id + "&action=delete";
xmlhttp = new XMLHttpRequest();
Expand Down
6 changes: 5 additions & 1 deletion Firmware/RTK_Surveyor/Bluetooth.ino
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ bool bluetoothRxDataAvailable()
int bluetoothWrite(const uint8_t *buffer, int length)
{
#ifdef COMPILE_BT
return bluetoothSerial->write(buffer, length);
//BLE write does not handle 0 length requests correctly
if(length > 0)
return bluetoothSerial->write(buffer, length);
else
return 0;
#else //COMPILE_BT
return 0;
#endif //COMPILE_BT
Expand Down
15 changes: 7 additions & 8 deletions Firmware/RTK_Surveyor/Form.ino
Original file line number Diff line number Diff line change
Expand Up @@ -165,21 +165,18 @@ void stopWebServer()

if (websocket != NULL)
{
Serial.println("Free websocket");
delete websocket;
websocket = NULL;
}

if (settingsCSV != NULL)
{
Serial.println("Freeing settingsCSV");
free(settingsCSV);
settingsCSV = NULL;
}

if (incomingSettings != NULL)
{
Serial.println("Freeing incomingSettings");
free(incomingSettings);
incomingSettings = NULL;
}
Expand Down Expand Up @@ -504,11 +501,13 @@ void createSettingsString(char* newSettings)
stringRecord(newSettings, "maxLogTime_minutes", settings.maxLogTime_minutes);
stringRecord(newSettings, "maxLogLength_minutes", settings.maxLogLength_minutes);

char sdSpace[30];
sprintf(sdSpace, "%s", stringHumanReadableSize(sdFreeSpace));
stringRecord(newSettings, "sdFreeSpace", sdSpace);
sprintf(sdSpace, "%s", stringHumanReadableSize(sdCardSize));
stringRecord(newSettings, "sdSize", sdSpace);
char sdCardSizeChar[20];
stringHumanReadableSize(sdCardSize).toCharArray(sdCardSizeChar, sizeof(sdCardSizeChar));
char sdFreeSpaceChar[20];
stringHumanReadableSize(sdFreeSpace).toCharArray(sdFreeSpaceChar, sizeof(sdFreeSpaceChar));

stringRecord(newSettings, "sdFreeSpace", sdCardSizeChar);
stringRecord(newSettings, "sdSize", sdFreeSpaceChar);

stringRecord(newSettings, "enableResetDisplay", settings.enableResetDisplay);

Expand Down
23 changes: 18 additions & 5 deletions Firmware/RTK_Surveyor/NtripClient.ino
Original file line number Diff line number Diff line change
Expand Up @@ -306,19 +306,32 @@ void ntripClientStop(bool wifiClientAllocated)
#endif //COMPILE_WIFI
}

//Check for the arrival of any correction data. Push it to the GNSS.
//Stop task if the connection has dropped or if we receive no data for maxTimeBeforeHangup_ms
void ntripClientUpdate()
//Determine if NTRIP Client is needed
bool ntripClientIsNeeded()
{
if (settings.enableNtripClient == false)
{
//If user turns off NTRIP Client via settings, stop server
if (ntripClientState > NTRIP_CLIENT_OFF)
ntripClientStop(true); //Don't allocate new wifiClient
return;
return(false);
}

if (wifiInConfigMode()) return; //Do not service NTRIP during WiFi config
if (wifiInConfigMode()) return(false); //Do not service NTRIP during WiFi config

//Allow NTRIP Client to run during Survey-In,
//but do not allow NTRIP Client to run during Base
if (systemState == STATE_BASE_TEMP_TRANSMITTING)
return(false);

return(true);
}

//Check for the arrival of any correction data. Push it to the GNSS.
//Stop task if the connection has dropped or if we receive no data for maxTimeBeforeHangup_ms
void ntripClientUpdate()
{
if(ntripClientIsNeeded() == false) return;

#ifdef COMPILE_WIFI
//Periodically display the NTRIP client state
Expand Down
4 changes: 2 additions & 2 deletions Firmware/RTK_Surveyor/RTK_Surveyor.ino
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

const int FIRMWARE_VERSION_MAJOR = 3;
const int FIRMWARE_VERSION_MINOR = 0;
const int FIRMWARE_VERSION_MINOR = 1;

#define COMPILE_WIFI //Comment out to remove WiFi functionality
#define COMPILE_AP //Requires WiFi. Comment out to remove Access Point functionality
Expand Down Expand Up @@ -300,7 +300,7 @@ const int readTaskStackSize = 2000;

TaskHandle_t handleGNSSDataTaskHandle = NULL;
const uint8_t handleGNSSDataTaskPriority = 1; //3 being the highest, and 0 being the lowest
const int handleGNSSDataTaskStackSize = 2000;
const int handleGNSSDataTaskStackSize = 3000;

TaskHandle_t pinUART2TaskHandle = NULL; //Dummy task to start UART2 on core 0.
volatile bool uart2pinned = false; //This variable is touched by core 0 but checked by core 1. Must be volatile.
Expand Down
6 changes: 4 additions & 2 deletions Firmware/RTK_Surveyor/States.ino
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,9 @@ void updateSystemState()

displayBaseStart(0); //Show 'Base'

wifiStop(); //Stop WiFi. Re-enable in each specific base start state.
//Allow WiFi to continue running if NTRIP Client is needed for assisted survey in
if(wifiIsNeeded() == false)
wifiStop();

bluetoothStop();
bluetoothStart(); //Restart Bluetooth with 'Base' identifier
Expand Down Expand Up @@ -328,7 +330,7 @@ void updateSystemState()
systemPrint("Time elapsed: ");
systemPrint(svinObservationTime);
systemPrint(" Accuracy: ");
systemPrint(svinMeanAccuracy);
systemPrint(svinMeanAccuracy, 3);
systemPrint(" SIV: ");
systemPrint(numSV);
systemPrintln();
Expand Down
17 changes: 3 additions & 14 deletions Firmware/RTK_Surveyor/Tasks.ino
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ void F9PSerialReadTask(void *e)
{
static PARSE_STATE parse = {waitForPreamble, processUart1Message, "Log"};

bool newDataLost = false; //Goes true at the first instance of 0 bytes available
uint8_t incomingData = 0;

availableHandlerSpace = settings.gnssHandlerBufferSize;
Expand All @@ -131,10 +130,6 @@ void F9PSerialReadTask(void *e)
//Read the data from UART1
incomingData = serialGNSS.read();

//For testing: Inject bad data once in awhile
//if(random(0,10000) == 1) //0.01% failure rate
// incomingData = 0xAA; //Bogus data

//Save the data byte
parse.buffer[parse.length++] = incomingData;
parse.length %= PARSE_BUFFER_LENGTH;
Expand All @@ -147,8 +142,6 @@ void F9PSerialReadTask(void *e)
parse.state(&parse, incomingData);
}

//emptyRingBuffer(true); //Empty and record to SD

delay(1);
taskYIELD();
}
Expand Down Expand Up @@ -223,9 +216,6 @@ void processUart1Message(PARSE_STATE * parse, uint8_t type)
//Display the dataHead offset
if (settings.enablePrintRingBufferOffsets && (!inMainMenu))
systemPrintf("%4d\r\n", dataHead);

//Start emptying the ring buffer
//emptyRingBuffer(false);
}

//If new data is in the ringBuffer, dole it out to appropriate interface
Expand Down Expand Up @@ -281,7 +271,6 @@ void handleGNSSDataTask(void *e)
//Send data over Bluetooth
//----------------------------------------------------------------------

//If we are actively survey-in then do not pass NMEA data from ZED to phone
if (!btConnected)
//Discard the data
btTail = dataHead;
Expand Down Expand Up @@ -361,7 +350,7 @@ void handleGNSSDataTask(void *e)
if (settings.enablePrintSDBuffers && !inMainMenu)
{
int availableUARTSpace = settings.uartReceiveBufferSize - serialGNSS.available();
systemPrintf("SD Incoming Serial: %04d\tToRead: %04d\tMovedToBuffer: %04d\tavailableUARTSpace: %04d\tavailableHandlerSpace: %04d\tToRecord: %04d\tRecorded: %04d\tBO: %d\n\r", serialGNSS.available(), 0, 0, availableUARTSpace, availableHandlerSpace, sliceToRecord, 0, bufferOverruns);
systemPrintf("SD Incoming Serial: %04d\tToRead: %04d\tMovedToBuffer: %04d\tavailableUARTSpace: %04d\tavailableHandlerSpace: %04d\tToRecord: %04d\tRecorded: %04d\tBO: %d\r\n", serialGNSS.available(), 0, 0, availableUARTSpace, availableHandlerSpace, sliceToRecord, 0, bufferOverruns);
}

//Write the data to the file
Expand Down Expand Up @@ -390,7 +379,7 @@ void handleGNSSDataTask(void *e)
if (settings.enablePrintBufferOverrun)
{
if (endTime - startTime > 150)
systemPrintf("Long Write! Time: %ld ms / Location: %ld / Recorded %d bytes / spaceRemaining %d bytes\n\r", endTime - startTime, fileSize, sdBytesToRecord, combinedSpaceRemaining);
systemPrintf("Long Write! Time: %ld ms / Location: %ld / Recorded %d bytes / spaceRemaining %d bytes\r\n", endTime - startTime, fileSize, sdBytesToRecord, combinedSpaceRemaining);
}

xSemaphoreGive(sdCardSemaphore);
Expand Down Expand Up @@ -949,7 +938,7 @@ void sdSizeCheckTask(void *e)

xSemaphoreGive(sdCardSemaphore);

uint64_t sdUsedSpace = sdCardSize - sdFreeSpace; //Don't think of it as used, think of it as unusable
//uint64_t sdUsedSpace = sdCardSize - sdFreeSpace; //Don't think of it as used, think of it as unusable

systemPrintf("SD card size: %s / Free space: %s\r\n",
stringHumanReadableSize(sdCardSize),
Expand Down
10 changes: 9 additions & 1 deletion Firmware/RTK_Surveyor/WiFi.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ static const int MAX_WIFI_CONNECTION_ATTEMPTS = 500;
//ms - Max of 4,294,967,295 or 4.3M seconds or 71,000 minutes or 1193 hours or 49 days between attempts
static int wifiConnectionAttempts = 0; //Count the number of connection attempts between restarts
static uint32_t wifiConnectionAttemptsTotal; //Count the number of connection attempts absolutely
static uint32_t wifiLastConnectionAttempt = 0;
static uint32_t wifiConnectionAttemptTimeout = 0;

//----------------------------------------
Expand All @@ -55,6 +54,8 @@ static uint32_t wifiConnectionAttemptTimeout = 0;

#ifdef COMPILE_WIFI

static uint32_t wifiLastConnectionAttempt = 0;

//WiFi Timer usage:
// * Measure interval to display IP address
static unsigned long wifiDisplayTimer = 0;
Expand Down Expand Up @@ -460,6 +461,13 @@ bool wifiIsNeeded()
)
needed = true;

//If the user has enabled NTRIP Client for an Assisted Survey-In, and Survey-In is running, keep WiFi on.
if (systemState >= STATE_BASE_NOT_STARTED && systemState <= STATE_BASE_TEMP_SURVEY_STARTED
&& settings.enableNtripClient == true
&& settings.fixedBase == false
)
needed = true;

//If WiFi is on while we are in the following states, allow WiFi to continue to operate
if (systemState >= STATE_BUBBLE_LEVEL && systemState <= STATE_PROFILE)
{
Expand Down
Loading