OTA Update Mode

Console commands still to do
Wifi tidied - commented stuff needs deleting
This commit is contained in:
M0WID 2020-10-18 22:51:31 +01:00
parent 5490709654
commit 7fe1a17a2d
10 changed files with 338 additions and 252 deletions

View File

@ -497,7 +497,7 @@ static uint16_t chunkIndex;
} }
myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation // myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
if ( autoSweepStep >= sweepPoints ) // If we have got to the end of the sweep if ( autoSweepStep >= sweepPoints ) // If we have got to the end of the sweep
@ -513,7 +513,7 @@ static uint16_t chunkIndex;
{ {
myActual[setting.BandscopePoints-1] = rxRSSI; // Yes, save it myActual[setting.BandscopePoints-1] = rxRSSI; // Yes, save it
myGain[setting.BandscopePoints-1] = gainReading; myGain[setting.BandscopePoints-1] = gainReading;
myFreq[setting.BandscopePoints-1] = oldSweepFreq; // myFreq[setting.BandscopePoints-1] = oldSweepFreq;
} }
if ( showRSSI == 1 ) // Only show it once? if ( showRSSI == 1 ) // Only show it once?

View File

@ -449,7 +449,7 @@ static uint16_t chunkIndex;
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img) if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin ); img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin );
myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation // myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
} // End of "if ( autoSweepFreq >= nextPointFreq )" } // End of "if ( autoSweepFreq >= nextPointFreq )"
@ -467,7 +467,7 @@ static uint16_t chunkIndex;
{ {
myActual[displayPoints-1] = rxRSSI; // Yes, save it myActual[displayPoints-1] = rxRSSI; // Yes, save it
myGain[displayPoints-1] = gainReading; myGain[displayPoints-1] = gainReading;
myFreq[displayPoints-1] = oldSweepFreq; // myFreq[displayPoints-1] = oldSweepFreq;
} }
if ( showRSSI == 1 ) // Only show it once? if ( showRSSI == 1 ) // Only show it once?

View File

@ -496,7 +496,7 @@ static uint16_t bpfCalFirstSweepDone;
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img) if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin ); img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin );
myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation // myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
} // End of "if ( autoSweepFreq >= nextPointFreq )" } // End of "if ( autoSweepFreq >= nextPointFreq )"
@ -514,7 +514,7 @@ static uint16_t bpfCalFirstSweepDone;
{ {
myActual[displayPoints-1] = rxRSSI; // Yes, save it myActual[displayPoints-1] = rxRSSI; // Yes, save it
myGain[displayPoints-1] = gainReading; myGain[displayPoints-1] = gainReading;
myFreq[displayPoints-1] = oldSweepFreq; // myFreq[displayPoints-1] = oldSweepFreq;
} }
if ( showRSSI == 1 ) // Only show it once? if ( showRSSI == 1 ) // Only show it once?

View File

@ -198,6 +198,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
case 2: // generator mode case 2: // generator mode
tg_lo.TxMode ( trackGenSetting.LO_Drive ); // Set tracking generator LO on tg_lo.TxMode ( trackGenSetting.LO_Drive ); // Set tracking generator LO on
tg_if.TxMode ( trackGenSetting.IF_Drive ); // Set tracking generator IF on tg_if.TxMode ( trackGenSetting.IF_Drive ); // Set tracking generator IF on
delayMicroseconds(300);
tg_lo.SetFrequency ( setting.IF_Freq + trackGenSetting.Offset + trackGenSetting.Frequency ); tg_lo.SetFrequency ( setting.IF_Freq + trackGenSetting.Offset + trackGenSetting.Frequency );
break; break;
@ -451,6 +452,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
JsonObject dataPoint = Points.createNestedObject (); // Add an object to the Json array to be pushed to the client JsonObject dataPoint = Points.createNestedObject (); // Add an object to the Json array to be pushed to the client
dataPoint["x"] = oldSweepFreq/1000000.0; // Set the x(frequency) value dataPoint["x"] = oldSweepFreq/1000000.0; // Set the x(frequency) value
dataPoint["y"] = rxRSSI; // Set the y (RSSI) value dataPoint["y"] = rxRSSI; // Set the y (RSSI) value
dataPoint["g"] = gainReading; // Set the y (gain) value
// Serial.printf ( "Add point chunkIndex %u, sweepStep %u of %u \n", chunkIndex, sweepStep, sweepPoints); // Serial.printf ( "Add point chunkIndex %u, sweepStep %u of %u \n", chunkIndex, sweepStep, sweepPoints);
chunkIndex++; // increment no of data points in current WiFi chunk chunkIndex++; // increment no of data points in current WiFi chunk
@ -463,6 +465,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
// Serial.print("D"); // Serial.print("D");
serializeJson ( jsonDocument, wsBuffer ); serializeJson ( jsonDocument, wsBuffer );
// Serial.printf("J%u", wsBuffer.length() ); // Serial.printf("J%u", wsBuffer.length() );
// Serial.println(wsBuffer);
unsigned long s = millis(); unsigned long s = millis();
webSocket.broadcastTXT ( wsBuffer ); // Send to all connected websocket clients webSocket.broadcastTXT ( wsBuffer ); // Send to all connected websocket clients
if (millis() - s > 1000) if (millis() - s > 1000)
@ -681,7 +684,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img) if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin ); img.pushSprite ( xOrigin+oldSweepStep-1, yOrigin );
myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation // myFreq[oldSweepStep] = oldSweepFreq; // Store the frequency for XML file creation
} // End of "if ( autoSweepFreq >= nextPointFreq )" } // End of "if ( autoSweepFreq >= nextPointFreq )"
@ -702,7 +705,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
{ {
myActual[displayPoints-1] = rxRSSI; // Yes, save it myActual[displayPoints-1] = rxRSSI; // Yes, save it
myGain[displayPoints-1] = gainReading; myGain[displayPoints-1] = gainReading;
myFreq[displayPoints-1] = oldSweepFreq; // myFreq[displayPoints-1] = oldSweepFreq;
} }
if ( showRSSI == 1 ) // Only show it once? if ( showRSSI == 1 ) // Only show it once?

View File

@ -50,11 +50,11 @@
<button id="aboutButton" onclick="window.location.href='about.html';">About</button> <button id="aboutButton" onclick="window.location.href='about.html';">About</button>
</div> </div>
<div class ="Grid"> <div class ="Grid">
<div class = "Grid-cell" id="chartSA" style="display:none"> <div class = "Grid-cell" id="chartSA" style="display:block">
<!-- container for chart --> <!-- container for chart -->
</div> </div>
<div class = "Grid-cell" id="sigGen" style="display:block"> <div class = "Grid-cell" id="sigGen" style="display:none">
<!-- container for sig gen controls --> <!-- container for sig gen controls -->
<br /> <br />
<div class="sigTitle">Signal Generator</div> <div class="sigTitle">Signal Generator</div>
@ -107,6 +107,7 @@
<!-- <option class="sweep-option" value="6">Zero Span High</option> --> <!-- <option class="sweep-option" value="6">Zero Span High</option> -->
<option class="sweep-option" value="7">Bandscope</option> <option class="sweep-option" value="7">Bandscope</option>
<option class="sweep-option" value="8">RBW Test</option> <option class="sweep-option" value="8">RBW Test</option>
<option class="sweep-option" value="9">OTA Update</option>
</select> </select>
<img src="refresh.png" id="refresh" name = "refresh" height = "18"> <img src="refresh.png" id="refresh" name = "refresh" height = "18">
</div> </div>
@ -1055,7 +1056,8 @@ connect(hostName.value);
$(document).ready(function () { $(document).ready(function () {
update(); // update();
sendValue("r", 0); // get settings
var chartUpdateVar; var chartUpdateVar;
// chartUpdateVar = setInterval(renderChart, 500); // chartUpdateVar = setInterval(renderChart, 500);
}); });
@ -1382,15 +1384,22 @@ function handleChunkData (data)
data.Points.forEach (function (point, index) { // copy data into the chart data series data.Points.forEach (function (point, index) { // copy data into the chart data series
var p = {}; var p = {};
p = point; // create a copy not a reference ?? p = point.y; // create a copy not a reference ??
var f = {}; var f = {};
f = point.x; f = point.x;
chartSA.options.data[1].dataPoints[dataStart + index] = p; // RSSI var g = {};
g = point.g;
chartSA.options.data[0].dataPoints[dataStart + index].x = f * 1; chartSA.options.data[1].dataPoints[dataStart + index].x = f * 1; // RSSI
var dB = p.y/2+b; chartSA.options.data[1].dataPoints[dataStart + index].y = p * 1;
chartSA.options.data[0].dataPoints[dataStart + index].x = f * 1; // dBm
var dB = p/2+b;
chartSA.options.data[0].dataPoints[dataStart + index].y = dB * 1; chartSA.options.data[0].dataPoints[dataStart + index].y = dB * 1;
chartSA.options.data[2].dataPoints[dataStart + index].x = f * 1; // gain
chartSA.options.data[2].dataPoints[dataStart + index].y = g * 1;
//chartSA.options.data[3].dataPoints[dataStart + index] = point; //chartSA.options.data[3].dataPoints[dataStart + index] = point;
//try { //try {
@ -1440,14 +1449,14 @@ function handleChunkData (data)
}) })
} }
if (chartSA.options.data[2].visible) { // if (chartSA.options.data[2].visible) {
$.getJSON( "getGainSweep") // proper line // $.getJSON( "getGainSweep") // proper line
// $.getJSON( "getGainSweep.json") // for local test // $.getJSON( "getGainSweep.json") // for local test
.done(function (data) { // .done(function (data) {
// We have the data, process it. // We have the data, process it.
chartSA.options.data[2].dataPoints = data.gainPoints; // Gain trace // chartSA.options.data[2].dataPoints = data.gainPoints; // Gain trace
}); // });
} // }
} }

View File

@ -32,7 +32,7 @@
#define PROGRAM_NAME "simpleSA" // These are for the WiFi interface #define PROGRAM_NAME "simpleSA" // These are for the WiFi interface
#define PROGRAM_VERSION "Version 0.1" // Current version - beta! #define PROGRAM_VERSION "Version 0.11" // Current version - beta!
/* /*
@ -190,7 +190,7 @@
*/ */
enum { SA_LOW_RANGE, SA_HIGH_RANGE, SIG_GEN_LOW_RANGE, SIG_GEN_HIGH_RANGE, enum { SA_LOW_RANGE, SA_HIGH_RANGE, SIG_GEN_LOW_RANGE, SIG_GEN_HIGH_RANGE,
IF_SWEEP, ZERO_SPAN_LOW_RANGE, ZERO_SPAN_HIGH_RANGE, BANDSCOPE, RX_SWEEP }; IF_SWEEP, ZERO_SPAN_LOW_RANGE, ZERO_SPAN_HIGH_RANGE, BANDSCOPE, RX_SWEEP, OTA_UPDATE };
/* /*

View File

@ -372,9 +372,9 @@ uint16_t websocketFailCount;
#ifdef USE_WIFI #ifdef USE_WIFI
// Json document buffers // Json document buffers
//size_t capacity = JSON_ARRAY_SIZE ( MAX_WIFI_POINTS + 1 ) //size_t capacity = JSON_ARRAY_SIZE ( MAX_WIFI_POINTS + 1 )
// + ( MAX_WIFI_POINTS + 1 ) * JSON_OBJECT_SIZE ( 2 ) + JSON_OBJECT_SIZE( 5 ); // + ( MAX_WIFI_POINTS + 1 ) * JSON_OBJECT_SIZE ( 3 ) + JSON_OBJECT_SIZE( 5 );
static DynamicJsonDocument jsonDocument ( 4000 ); // Buffer for json data to be pushed to the web clients static DynamicJsonDocument jsonDocument ( 5000 ); // Buffer for json data to be pushed to the web clients
static JsonArray Points = jsonDocument.createNestedArray ( "Points" ); // add Points array static JsonArray Points = jsonDocument.createNestedArray ( "Points" ); // add Points array
#endif #endif
@ -502,7 +502,7 @@ uint8_t myData[SCREEN_WIDTH+1];
uint8_t myStorage[SCREEN_WIDTH+1]; uint8_t myStorage[SCREEN_WIDTH+1];
uint8_t myActual[SCREEN_WIDTH+1]; uint8_t myActual[SCREEN_WIDTH+1];
uint8_t myGain[SCREEN_WIDTH+1]; // Preamp gain uint8_t myGain[SCREEN_WIDTH+1]; // Preamp gain
uint32_t myFreq[SCREEN_WIDTH+1]; // Frequency for XML file //uint32_t myFreq[SCREEN_WIDTH+1]; // Frequency for XML file
uint16_t peakLevel; // Current maximum signal level uint16_t peakLevel; // Current maximum signal level
uint16_t oldPeakLevel; // Old maximum signal level uint16_t oldPeakLevel; // Old maximum signal level
@ -843,6 +843,14 @@ bool fsStatus = false; // True if SPIFFS loads ok
}) })
.onProgress([](unsigned int progress, unsigned int total) { .onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100))); Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
tft.setCursor ( 20, 200);
tft.setTextColor(WHITE);
tft.setFreeFont ( &FreeSansBold9pt7b ); // Select Free Serif 9 point font
tft.print( "Progress:");
tft.fillRect(120, 180, 100, 20, SIG_BACKGROUND_COLOR); // x, y, w, h, color
tft.setCursor (120, 200);
tft.printf("%u%%", (progress / (total / 100)));
}) })
.onError([](ota_error_t error) { .onError([](ota_error_t error) {
Serial.printf("Error[%u]: ", error); Serial.printf("Error[%u]: ", error);
@ -928,12 +936,12 @@ loopStartMicros = micros();
lastWebsocketMicros = loopStartMicros; lastWebsocketMicros = loopStartMicros;
} }
ArduinoOTA.handle(); // check if OTA programming requested
#endif #endif
CheckCommand (); // Anything from the serial input? CheckCommand (); // Anything from the serial input?
if ( ( setting.Mode != SIG_GEN_LOW_RANGE ) || (ui_mode != UI_NORMAL ) ) if ( ( ( tinySA_mode != SIG_GEN_LOW_RANGE ) && ( tinySA_mode != OTA_UPDATE ) )
|| ( ui_mode != UI_NORMAL ) )
{ {
UiProcessTouch (); // Handle the touch screen UiProcessTouch (); // Handle the touch screen
if ( ui_mode != UI_NORMAL ) if ( ui_mode != UI_NORMAL )
@ -947,7 +955,7 @@ loopStartMicros = micros();
* Not fully implemented yet. * Not fully implemented yet.
*/ */
switch ( setting.Mode ) switch ( tinySA_mode )
{ {
case SA_LOW_RANGE: case SA_LOW_RANGE:
doSweepLow(); // Spectrum Analyser Low Frequency range doSweepLow(); // Spectrum Analyser Low Frequency range
@ -977,6 +985,10 @@ loopStartMicros = micros();
doBandscope(); // Bandscope Sweep doBandscope(); // Bandscope Sweep
break; break;
case OTA_UPDATE: // Over the air (wifi) update
doOTA();
break;
default: default:
DisplayError ( ERR_WARN, DisplayError ( ERR_WARN,
"Invalid Mode!", "Invalid Mode!",
@ -1024,6 +1036,9 @@ void setMode ( uint16_t newMode )
initRX_Sweep(); initRX_Sweep();
break; break;
case OTA_UPDATE:
initOTA();
break;
default: default:
DisplayError ( ERR_WARN, DisplayError ( ERR_WARN,
@ -1084,6 +1099,10 @@ void menuExit()
initBandscope(); initBandscope();
break; break;
case OTA_UPDATE:
initOTA();
break;
default: default:
// add handler here // add handler here
break; break;
@ -1272,9 +1291,61 @@ void doSigGenHigh ()
} }
/*
* Over The Air (OTA) update allows the ESP32 to be programmed over wifi
* This is handled as a separte mode as it has a hit on scan times
* The Init function just draws a simple page indicating it is in OTA Mode
*/
void initOTA()
{
boolean pressed;
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
tft.fillScreen(SIG_BACKGROUND_COLOR);
tft.setTextColor(WHITE);
tft.setFreeFont ( &FreeSansBold9pt7b ); // Select Free Serif 9 point font
tft.setTextDatum ( TC_DATUM ); // Top center text position datum
tft.drawString ( "simpleSA", 160, 20 );
tft.drawString ( "OTA Mode", 160, 60 );
tft.drawString ( "Press to Exit", 160, 100 );
tft.setTextDatum ( TL_DATUM ); // Back to default top left
tft.setFreeFont ( NULL ); // Select default font
// Make sure touch is not pressed when leaving
do {
pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed
} while ( pressed );
tinySA_mode = OTA_UPDATE; // don't set the setting.Mode as we may want to return to previous mode
}
/*
* Here we just call the OTA monitor and check if the user has pessed the screen to exit
* This is called once every main loop scan
*/
void doOTA()
{
uint16_t t_x = 0, t_y = 0; // To store the touch coordinates
static boolean lastPress = true;
ArduinoOTA.handle(); // check if OTA programming requested
// Get current touch state and coordinates
boolean pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed
if ( pressed && !lastPress )
{
// go back to previous mode
// wait for press to be released
do {
pressed = tft.getTouch(&t_x, &t_y); // Just uses standard TFT_eSPI function as not bothered about speed
} while ( pressed );
setMode(setting.Mode);
}
lastPress = pressed;
}
/* /*
* "SetRX" - Mode 3 is sig gen, 0 is normal (RX as receive, LO on), 1 is both * "SetRX" - Mode 3 is sig gen, 0 is normal (RX as receive, LO on), 1 is both

View File

@ -511,23 +511,23 @@ void addTagNameValue ( char *b, char *_name, char *value )
* or perhaps just create the xml at the end of each scan - investigate later * or perhaps just create the xml at the end of each scan - investigate later
*/ */
void onGetScan ( AsyncWebServerRequest *request ) //void onGetScan ( AsyncWebServerRequest *request )
{ //{
response = request->beginResponseStream ( "text/xml" ); // response = request->beginResponseStream ( "text/xml" );
// Serial.println ( "onGetScan" ); //// Serial.println ( "onGetScan" );
//
response->print ( "<?xml version=\"1.0\" encoding=\"utf-16\"?>" ); // response->print ( "<?xml version=\"1.0\" encoding=\"utf-16\"?>" );
response->println ( "<Points>" ); // response->println ( "<Points>" );
//
for( int i = 0; i < displayPoints-1; i++ ) // For each data point // for( int i = 0; i < displayPoints-1; i++ ) // For each data point
{ // {
// Serial.printf ( "<Point F=\"%i\" RSSI=\"%i\"/> %i\n",myFreq[i], myData[i], i ); //// Serial.printf ( "<Point F=\"%i\" RSSI=\"%i\"/> %i\n",myFreq[i], myData[i], i );
response->printf ( "<P F=\"%i\" R=\"%i\"/>\n", myFreq[i], myData[i] ); // response->printf ( "<P F=\"%i\" R=\"%i\"/>\n", myFreq[i], myData[i] );
} // }
//
response->print ( "</Points>" ); // response->print ( "</Points>" );
request->send ( response ); // request->send ( response );
} //}
/* /*
@ -535,31 +535,31 @@ void onGetScan ( AsyncWebServerRequest *request )
* Ideally we would push the data to the web page at the end of a scan, * Ideally we would push the data to the web page at the end of a scan,
*/ */
void onGetGainSweep ( AsyncWebServerRequest *request ) //void onGetGainSweep ( AsyncWebServerRequest *request )
{ //{
size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH ) // size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
+ JSON_OBJECT_SIZE ( 1 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 ); // + JSON_OBJECT_SIZE ( 1 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 );
//
AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize ); // AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize );
// response->addHeader ( "Server","ESP Async Web Server" ); //// response->addHeader ( "Server","ESP Async Web Server" );
//
JsonObject root = response->getRoot(); // JsonObject root = response->getRoot();
JsonArray gainPoints = root.createNestedArray ( "gainPoints" ); // Add gainPoints array // JsonArray gainPoints = root.createNestedArray ( "gainPoints" ); // Add gainPoints array
//
/* ///*
* Add the objects to the array // * Add the objects to the array
*/ // */
//
for ( int i = 0; i < displayPoints; i++ ) // For each data point // for ( int i = 0; i < displayPoints; i++ ) // For each data point
{ // {
JsonObject dataPoint = gainPoints.createNestedObject(); // Add an object to the array // JsonObject dataPoint = gainPoints.createNestedObject(); // Add an object to the array
dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value // dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value
dataPoint["y"] = myGain[i]; // set the y (gain) value // dataPoint["y"] = myGain[i]; // set the y (gain) value
} // }
//
response->setLength(); // response->setLength();
request->send ( response ); // request->send ( response );
} //}
/* /*
@ -567,101 +567,101 @@ void onGetGainSweep ( AsyncWebServerRequest *request )
* Ideally we would push the data to the web page at the end of a scan. * Ideally we would push the data to the web page at the end of a scan.
*/ */
void onGetSweep ( AsyncWebServerRequest *request ) //void onGetSweep ( AsyncWebServerRequest *request )
{ //{
size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH ) // size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
+ JSON_OBJECT_SIZE ( 14 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 ); // + JSON_OBJECT_SIZE ( 14 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 );
//
AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize ); // AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize );
//
JsonObject root = response->getRoot(); // JsonObject root = response->getRoot();
//
root["dispPoints"] = displayPoints; // root["dispPoints"] = displayPoints;
root["start"] = setting.ScanStart / 1000.0; // root["start"] = setting.ScanStart / 1000.0;
root["stop"] = setting.ScanStop / 1000.0; // root["stop"] = setting.ScanStop / 1000.0;
root["IF"] = setting.IF_Freq / 1000000.0; // root["IF"] = setting.IF_Freq / 1000000.0;
root["attenuation"] = setting.Attenuate; // root["attenuation"] = setting.Attenuate;
root["extGain"] = setting.ExternalGain; // root["extGain"] = setting.ExternalGain;
root["levelOffset"] = setting.LevelOffset; // root["levelOffset"] = setting.LevelOffset;
root["filterCal"] = bpfCalibrations[bpfIndex]; // root["filterCal"] = bpfCalibrations[bpfIndex];
root["setRBW"] = setting.Bandwidth10; // root["setRBW"] = setting.Bandwidth10;
root["bandwidth"] = bandwidth; // root["bandwidth"] = bandwidth;
root["RefOut"] = setting.ReferenceOut; // root["RefOut"] = setting.ReferenceOut;
root["Drive"] = setting.Drive; // root["Drive"] = setting.Drive;
root["sweepPoints"] = sweepPoints; // root["sweepPoints"] = sweepPoints;
//
if ( AGC_On ) // if ( AGC_On )
root["PreAmp"] = 0x60; // Auto // root["PreAmp"] = 0x60; // Auto
//
else // else
root["PreAmp"] = setting.PreampGain; // Fixed gain // root["PreAmp"] = setting.PreampGain; // Fixed gain
//
JsonArray Points = root.createNestedArray ( "Points" ); // Add Points array // JsonArray Points = root.createNestedArray ( "Points" ); // Add Points array
//
//
for ( int i = 0; i < displayPoints; i++ ) //For each data point // for ( int i = 0; i < displayPoints; i++ ) //For each data point
{ // {
JsonObject dataPoint = Points.createNestedObject(); // add an object to the array // JsonObject dataPoint = Points.createNestedObject(); // add an object to the array
dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value // dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value
dataPoint["y"] = myData[i]; // set the y (RSSI) value // dataPoint["y"] = myData[i]; // set the y (RSSI) value
} // }
//
//
response->setLength(); // response->setLength();
request->send ( response ); // request->send ( response );
} //}
/* /*
* On request from web page send the settings as JSON * On request from web page send the settings as JSON
*/ */
void onGetSettings (AsyncWebServerRequest *request) //void onGetSettings (AsyncWebServerRequest *request)
{ //{
AsyncJsonResponse * response = new AsyncJsonResponse(false) ; // AsyncJsonResponse * response = new AsyncJsonResponse(false) ;
//
JsonObject root = response->getRoot(); // JsonObject root = response->getRoot();
//
root["mType"] = "Settings"; // root["mType"] = "Settings";
root["mode"] = setting.Mode; // root["mode"] = setting.Mode;
root["dispPoints"] = displayPoints; // root["dispPoints"] = displayPoints;
root["start"] = setting.ScanStart / 1000.0; // root["start"] = setting.ScanStart / 1000.0;
root["stop"] = setting.ScanStop / 1000.0; // root["stop"] = setting.ScanStop / 1000.0;
root["IF"] = setting.IF_Freq / 1000000.0; // root["IF"] = setting.IF_Freq / 1000000.0;
root["attenuation"] = setting.Attenuate; // root["attenuation"] = setting.Attenuate;
root["extGain"] = setting.ExternalGain; // root["extGain"] = setting.ExternalGain;
root["levelOffset"] = setting.LevelOffset; // root["levelOffset"] = setting.LevelOffset;
root["filterCal"] = bpfCalibrations[bpfIndex]; // root["filterCal"] = bpfCalibrations[bpfIndex];
root["setRBW"] = setting.Bandwidth10; // root["setRBW"] = setting.Bandwidth10;
root["bandwidth"] = bandwidth; // root["bandwidth"] = bandwidth;
root["RefOut"] = setting.ReferenceOut; // root["RefOut"] = setting.ReferenceOut;
root["Drive"] = setting.Drive; // root["Drive"] = setting.Drive;
root["sweepPoints"] = sweepPoints; // root["sweepPoints"] = sweepPoints;
root["spur"] = setting.Spur; // root["spur"] = setting.Spur;
root["tg"] = trackGenSetting.Mode; // root["tg"] = trackGenSetting.Mode;
root["tgPower"] = trackGenSetting.Power; // root["tgPower"] = trackGenSetting.Power;
root["tgFreq"] = trackGenSetting.Frequency; // root["tgFreq"] = trackGenSetting.Frequency;
root["tgMod"] = trackGenSetting.ModulationType; // root["tgMod"] = trackGenSetting.ModulationType;
root["tgModFreq"] = trackGenSetting.ModFrequency; // root["tgModFreq"] = trackGenSetting.ModFrequency;
root["sg"] = sigGenOutputOn; // // root["sg"] = sigGenOutputOn; //
root["sgPower"] = sigGenSetting.Power; // root["sgPower"] = sigGenSetting.Power;
root["sgMod"] = sigGenSetting.ModulationType; // root["sgMod"] = sigGenSetting.ModulationType;
root["sgModFreq"] = sigGenSetting.ModFrequency; // root["sgModFreq"] = sigGenSetting.ModFrequency;
root["sgFreq"] = sigGenSetting.Frequency; // root["sgFreq"] = sigGenSetting.Frequency;
root["sgCal"] = sigGenSetting.Calibration; // root["sgCal"] = sigGenSetting.Calibration;
root["sgRange"] = ATTENUATOR_RANGE + 11; // SI4432 output can be adjusted over 21dBm but max to SAW filter is 10dBm // root["sgRange"] = ATTENUATOR_RANGE + 11; // SI4432 output can be adjusted over 21dBm but max to SAW filter is 10dBm
root["tgCal"] = trackGenSetting.Calibration; // root["tgCal"] = trackGenSetting.Calibration;
root["tgRange"] = ATTENUATOR_RANGE + 21; // no SAW filter so 20dBm output is possible. // root["tgRange"] = ATTENUATOR_RANGE + 21; // no SAW filter so 20dBm output is possible.
//
if ( AGC_On ) // if ( AGC_On )
root["PreAmp"] = 0x60; // Auto // root["PreAmp"] = 0x60; // Auto
//
else // else
root["PreAmp"] = setting.PreampGain; // Fixed gain // root["PreAmp"] = setting.PreampGain; // Fixed gain
//
response->setLength(); // response->setLength();
request->send ( response ); // request->send ( response );
// Serial.printf ( "Get Settings sweepPoints %u\n", sweepPoints ); //// Serial.printf ( "Get Settings sweepPoints %u\n", sweepPoints );
} //}
/* /*
@ -1034,85 +1034,85 @@ void onDoReboot ( AsyncWebServerRequest *request )
// doSetSweep ? setStart = 10 & setStop = 20 & setExtGain = 0 & setRBW = 26 // doSetSweep ? setStart = 10 & setStop = 20 & setExtGain = 0 & setRBW = 26
void onSetSweep ( AsyncWebServerRequest *request ) //void onSetSweep ( AsyncWebServerRequest *request )
{ //{
//
Serial.print ( request->url ()); // Get the paramaters passed from the // Serial.print ( request->url ()); // Get the paramaters passed from the
Serial.print ( ":-" ); // web page, checking they exist // Serial.print ( ":-" ); // web page, checking they exist
//
if ( request->hasParam ( "setStart" )) // if ( request->hasParam ( "setStart" ))
{ // {
Serial.print ( "setStart;" ); // Serial.print ( "setStart;" );
AsyncWebParameter* startInput = request->getParam ( "setStart" ); // AsyncWebParameter* startInput = request->getParam ( "setStart" );
SetSweepStart ( atof ( startInput->value().c_str()) * 1000000.0 ); // SetSweepStart ( atof ( startInput->value().c_str()) * 1000000.0 );
} // }
//
if ( request->hasParam ( "setStop" )) // if ( request->hasParam ( "setStop" ))
{ // {
Serial.print ( "setStop;" ); // Serial.print ( "setStop;" );
AsyncWebParameter* stopInput = request->getParam ( "setStop" ); // AsyncWebParameter* stopInput = request->getParam ( "setStop" );
SetSweepStop( atof ( stopInput->value().c_str()) * 1000000.0 ); // SetSweepStop( atof ( stopInput->value().c_str()) * 1000000.0 );
} // }
//
if ( request->hasParam ( "setExtGain" )) // if ( request->hasParam ( "setExtGain" ))
{ // {
Serial.print ( "setExtGain;" ); // Serial.print ( "setExtGain;" );
AsyncWebParameter* extGainInput = request->getParam ( "setExtGain" ); // AsyncWebParameter* extGainInput = request->getParam ( "setExtGain" );
// Need to add function later //// Need to add function later
} // }
//
if ( request->hasParam ( "refOut" )) // if ( request->hasParam ( "refOut" ))
{ // {
Serial.print ( "refOut;" ); // Serial.print ( "refOut;" );
AsyncWebParameter* setRefOut = request->getParam ( "setRefOut" ); // AsyncWebParameter* setRefOut = request->getParam ( "setRefOut" );
setting.ReferenceOut = atoi ( setRefOut->value().c_str() ); // setting.ReferenceOut = atoi ( setRefOut->value().c_str() );
xmit.SetPowerReference ( setting.ReferenceOut ); // xmit.SetPowerReference ( setting.ReferenceOut );
} // }
//
if ( request->hasParam ( "setAtten" )) // if ( request->hasParam ( "setAtten" ))
{ // {
Serial.print ( "setAtten:" ); // Serial.print ( "setAtten:" );
AsyncWebParameter* setAtten = request->getParam ( "setAtten"); // AsyncWebParameter* setAtten = request->getParam ( "setAtten");
SetAttenuation ( atoi ( setAtten->value().c_str() )); // SetAttenuation ( atoi ( setAtten->value().c_str() ));
Serial.print ( atoi ( setAtten->value().c_str() )); // Serial.print ( atoi ( setAtten->value().c_str() ));
Serial.print ( "; " ); // Serial.print ( "; " );
} // }
//
if ( request->hasParam ( "setRBW" )) // if ( request->hasParam ( "setRBW" ))
{ // {
Serial.print ( "setRBW "); // Serial.print ( "setRBW ");
AsyncWebParameter* rbwInput = request->getParam ( "setRBW" ); // AsyncWebParameter* rbwInput = request->getParam ( "setRBW" );
SetRBW ( atoi ( rbwInput->value().c_str() )); // SetRBW ( atoi ( rbwInput->value().c_str() ));
Serial.printf ( "setting.bandwidth = %i, input = %i;", setting.Bandwidth10, atoi ( rbwInput->value().c_str() )); // Serial.printf ( "setting.bandwidth = %i, input = %i;", setting.Bandwidth10, atoi ( rbwInput->value().c_str() ));
} // }
//
Serial.println (); // Serial.println ();
request->redirect ( "index.html" ); // redirect to the index page // request->redirect ( "index.html" ); // redirect to the index page
} //}
//
//
/* ///*
* Function sets the sweep parameters based on the data in the form posted by the web page // * Function sets the sweep parameters based on the data in the form posted by the web page
* No longer used // * No longer used
*/ // */
//
// doSetSweep ? setStart = 10 &setStop = 20 & setExtGain = 0 & setRBW = 26 //// doSetSweep ? setStart = 10 &setStop = 20 & setExtGain = 0 & setRBW = 26
//
void onSettings ( AsyncWebServerRequest *request ) //void onSettings ( AsyncWebServerRequest *request )
{ //{
Serial.print ( request->url() ); // Get the paramaters passed from the web // Serial.print ( request->url() ); // Get the paramaters passed from the web
Serial.print ( ":-" ); // page, checking they exist // Serial.print ( ":-" ); // page, checking they exist
//
if ( request->hasParam ( "setActPower" )) // if ( request->hasParam ( "setActPower" ))
{ // {
Serial.print ( "setActPower;" ); // Serial.print ( "setActPower;" );
AsyncWebParameter* setLevelInput = request->getParam ( "setActPower" ); // AsyncWebParameter* setLevelInput = request->getParam ( "setActPower" );
SetPowerLevel ( atof ( setLevelInput->value().c_str()) ); // SetPowerLevel ( atof ( setLevelInput->value().c_str()) );
} // }
//
Serial.println(); // Serial.println();
request->redirect ( "index.html"); // Redirect to the index page // request->redirect ( "index.html"); // Redirect to the index page
} //}
void onGetNameVersion ( AsyncWebServerRequest *request ) void onGetNameVersion ( AsyncWebServerRequest *request )
@ -1176,17 +1176,17 @@ void buildServer () // We can now configure and start the server
{ {
Serial.println ( "Building Server.." ); Serial.println ( "Building Server.." );
server.reset (); // Clear any existing settings and events server.reset (); // Clear any existing settings and events
server.on ( "/getSweep", HTTP_GET, onGetSweep ); // Set event to return sweep data as JSON array // server.on ( "/getSweep", HTTP_GET, onGetSweep ); // Set event to return sweep data as JSON array
server.on ( "/getGainSweep", HTTP_GET, onGetGainSweep ); // Set event to return sweep gain data as JSON array // server.on ( "/getGainSweep", HTTP_GET, onGetGainSweep ); // Set event to return sweep gain data as JSON array
server.on ( "/getSettings", HTTP_GET, onGetSettings ); // Set event to return settings data as JSON array // server.on ( "/getSettings", HTTP_GET, onGetSettings ); // Set event to return settings data as JSON array
server.on ( "/doSetSweep", HTTP_POST, onSetSweep ); // Set event to set sweep values received from client // server.on ( "/doSetSweep", HTTP_POST, onSetSweep ); // Set event to set sweep values received from client
server.on ( "/doReboot", HTTP_GET, onDoReboot ); // Set event to reboot the ESP32 server.on ( "/doReboot", HTTP_GET, onDoReboot ); // Set event to reboot the ESP32
server.on ( "/getNameVersion", HTTP_GET, onGetNameVersion );// Set event to return name and version server.on ( "/getNameVersion", HTTP_GET, onGetNameVersion );// Set event to return name and version
server.on ( "/getScan", HTTP_GET, onGetScan ); // Set event to return sweep data as XML // server.on ( "/getScan", HTTP_GET, onGetScan ); // Set event to return sweep data as XML
server.on ( "/getRbwList", HTTP_GET, onGetRbwList ); // Set event to return RBW options as JSON array server.on ( "/getRbwList", HTTP_GET, onGetRbwList ); // Set event to return RBW options as JSON array
server.on ( "/getAttenList", HTTP_GET, onGetAttenList ); // Set event to return attenuator options as JSON array server.on ( "/getAttenList", HTTP_GET, onGetAttenList ); // Set event to return attenuator options as JSON array
server.on ( "/getSSIDs", HTTP_GET, onGetSIDDs ); // Set event to return list of SSID as XML server.on ( "/getSSIDs", HTTP_GET, onGetSIDDs ); // Set event to return list of SSID as XML
server.on ( "/doSettings", HTTP_POST, onSettings ); // Set event to set setting values received from client // server.on ( "/doSettings", HTTP_POST, onSettings ); // Set event to set setting values received from client
server.serveStatic ( "/", SPIFFS, "/" ).setDefaultFile ( "index.html" ); server.serveStatic ( "/", SPIFFS, "/" ).setDefaultFile ( "index.html" );

View File

@ -81,7 +81,7 @@
extern uint8_t myStorage[SCREEN_WIDTH+1]; extern uint8_t myStorage[SCREEN_WIDTH+1];
extern uint8_t myActual[SCREEN_WIDTH+1]; extern uint8_t myActual[SCREEN_WIDTH+1];
extern uint8_t myGain[SCREEN_WIDTH+1]; // M0WID addition to record preamp gain extern uint8_t myGain[SCREEN_WIDTH+1]; // M0WID addition to record preamp gain
extern uint32_t myFreq[SCREEN_WIDTH+1]; // M0WID addition to store frequency for XML file // extern uint32_t myFreq[SCREEN_WIDTH+1]; // M0WID addition to store frequency for XML file
extern WebSocketsServer webSocket; // Initiated in TinySA.ino extern WebSocketsServer webSocket; // Initiated in TinySA.ino

9
ui.cpp
View File

@ -451,6 +451,7 @@ static Menuitem menu_mode[] = // Select mode menu
Menuitem ( MT_FUNC, "\2BAND\0SCOPE",menu_mode_cb ), Menuitem ( MT_FUNC, "\2BAND\0SCOPE",menu_mode_cb ),
Menuitem ( MT_FUNC, "\2IF\0SWEEP", menu_mode_cb ), Menuitem ( MT_FUNC, "\2IF\0SWEEP", menu_mode_cb ),
Menuitem ( MT_FUNC, "\2RX\0SWEEP", menu_mode_cb ), Menuitem ( MT_FUNC, "\2RX\0SWEEP", menu_mode_cb ),
Menuitem ( MT_FUNC, "\2OTA\0UPDATE",menu_mode_cb ),
Menuitem ( MT_BACK, "<-BACK" ), // Next level up Menuitem ( MT_BACK, "<-BACK" ), // Next level up
Menuitem ( MT_END ) // End marker Menuitem ( MT_END ) // End marker
}; };
@ -1181,9 +1182,6 @@ void ShowSplash ( void )
} }
void enter_dfu(void) {} // Do nothing function
void request_to_redraw_grid() // Clear the display and update void request_to_redraw_grid() // Clear the display and update
{ {
ClearDisplay (); ClearDisplay ();
@ -1230,6 +1228,11 @@ void menu_mode_cb ( int item )
ui_mode_normal (); // No menu displayed ui_mode_normal (); // No menu displayed
break; break;
case 5:
setMode(OTA_UPDATE); // Set OTA mode
ui_mode_normal();
break;
} }
changedSetting = true; changedSetting = true;