OTA Update Mode
Console commands still to do Wifi tidied - commented stuff needs deleting
This commit is contained in:
parent
5490709654
commit
7fe1a17a2d
@ -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
|
||||
@ -513,7 +513,7 @@ static uint16_t chunkIndex;
|
||||
{
|
||||
myActual[setting.BandscopePoints-1] = rxRSSI; // Yes, save it
|
||||
myGain[setting.BandscopePoints-1] = gainReading;
|
||||
myFreq[setting.BandscopePoints-1] = oldSweepFreq;
|
||||
// myFreq[setting.BandscopePoints-1] = oldSweepFreq;
|
||||
}
|
||||
|
||||
if ( showRSSI == 1 ) // Only show it once?
|
||||
|
@ -449,7 +449,7 @@ static uint16_t chunkIndex;
|
||||
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
|
||||
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 )"
|
||||
|
||||
@ -467,7 +467,7 @@ static uint16_t chunkIndex;
|
||||
{
|
||||
myActual[displayPoints-1] = rxRSSI; // Yes, save it
|
||||
myGain[displayPoints-1] = gainReading;
|
||||
myFreq[displayPoints-1] = oldSweepFreq;
|
||||
// myFreq[displayPoints-1] = oldSweepFreq;
|
||||
}
|
||||
|
||||
if ( showRSSI == 1 ) // Only show it once?
|
||||
|
@ -496,7 +496,7 @@ static uint16_t bpfCalFirstSweepDone;
|
||||
if ( oldSweepStep > 0 ) // Only push if not first point (two pixel wide img)
|
||||
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 )"
|
||||
|
||||
@ -514,7 +514,7 @@ static uint16_t bpfCalFirstSweepDone;
|
||||
{
|
||||
myActual[displayPoints-1] = rxRSSI; // Yes, save it
|
||||
myGain[displayPoints-1] = gainReading;
|
||||
myFreq[displayPoints-1] = oldSweepFreq;
|
||||
// myFreq[displayPoints-1] = oldSweepFreq;
|
||||
}
|
||||
|
||||
if ( showRSSI == 1 ) // Only show it once?
|
||||
|
@ -198,6 +198,7 @@ static uint32_t tgIF; // Track gen IF - SA IF plus any offset if both SI4432
|
||||
case 2: // generator mode
|
||||
tg_lo.TxMode ( trackGenSetting.LO_Drive ); // Set tracking generator LO on
|
||||
tg_if.TxMode ( trackGenSetting.IF_Drive ); // Set tracking generator IF on
|
||||
delayMicroseconds(300);
|
||||
tg_lo.SetFrequency ( setting.IF_Freq + trackGenSetting.Offset + trackGenSetting.Frequency );
|
||||
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
|
||||
dataPoint["x"] = oldSweepFreq/1000000.0; // Set the x(frequency) 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);
|
||||
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");
|
||||
serializeJson ( jsonDocument, wsBuffer );
|
||||
// Serial.printf("J%u", wsBuffer.length() );
|
||||
// Serial.println(wsBuffer);
|
||||
unsigned long s = millis();
|
||||
webSocket.broadcastTXT ( wsBuffer ); // Send to all connected websocket clients
|
||||
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)
|
||||
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 )"
|
||||
|
||||
@ -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
|
||||
myGain[displayPoints-1] = gainReading;
|
||||
myFreq[displayPoints-1] = oldSweepFreq;
|
||||
// myFreq[displayPoints-1] = oldSweepFreq;
|
||||
}
|
||||
|
||||
if ( showRSSI == 1 ) // Only show it once?
|
||||
|
@ -50,11 +50,11 @@
|
||||
<button id="aboutButton" onclick="window.location.href='about.html';">About</button>
|
||||
</div>
|
||||
<div class ="Grid">
|
||||
<div class = "Grid-cell" id="chartSA" style="display:none">
|
||||
<div class = "Grid-cell" id="chartSA" style="display:block">
|
||||
<!-- container for chart -->
|
||||
</div>
|
||||
|
||||
<div class = "Grid-cell" id="sigGen" style="display:block">
|
||||
<div class = "Grid-cell" id="sigGen" style="display:none">
|
||||
<!-- container for sig gen controls -->
|
||||
<br />
|
||||
<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="7">Bandscope</option>
|
||||
<option class="sweep-option" value="8">RBW Test</option>
|
||||
<option class="sweep-option" value="9">OTA Update</option>
|
||||
</select>
|
||||
<img src="refresh.png" id="refresh" name = "refresh" height = "18">
|
||||
</div>
|
||||
@ -1055,7 +1056,8 @@ connect(hostName.value);
|
||||
|
||||
$(document).ready(function () {
|
||||
|
||||
update();
|
||||
// update();
|
||||
sendValue("r", 0); // get settings
|
||||
var chartUpdateVar;
|
||||
// chartUpdateVar = setInterval(renderChart, 500);
|
||||
});
|
||||
@ -1382,15 +1384,22 @@ function handleChunkData (data)
|
||||
|
||||
data.Points.forEach (function (point, index) { // copy data into the chart data series
|
||||
var p = {};
|
||||
p = point; // create a copy not a reference ??
|
||||
p = point.y; // create a copy not a reference ??
|
||||
var f = {};
|
||||
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;
|
||||
var dB = p.y/2+b;
|
||||
chartSA.options.data[1].dataPoints[dataStart + index].x = f * 1; // RSSI
|
||||
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[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;
|
||||
//try {
|
||||
@ -1440,14 +1449,14 @@ function handleChunkData (data)
|
||||
})
|
||||
}
|
||||
|
||||
if (chartSA.options.data[2].visible) {
|
||||
$.getJSON( "getGainSweep") // proper line
|
||||
// if (chartSA.options.data[2].visible) {
|
||||
// $.getJSON( "getGainSweep") // proper line
|
||||
// $.getJSON( "getGainSweep.json") // for local test
|
||||
.done(function (data) {
|
||||
// .done(function (data) {
|
||||
// We have the data, process it.
|
||||
chartSA.options.data[2].dataPoints = data.gainPoints; // Gain trace
|
||||
});
|
||||
}
|
||||
// chartSA.options.data[2].dataPoints = data.gainPoints; // Gain trace
|
||||
// });
|
||||
// }
|
||||
|
||||
|
||||
}
|
||||
|
@ -32,7 +32,7 @@
|
||||
|
||||
|
||||
#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,
|
||||
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 };
|
||||
|
||||
|
||||
/*
|
||||
|
83
simpleSA.ino
83
simpleSA.ino
@ -372,9 +372,9 @@ uint16_t websocketFailCount;
|
||||
#ifdef USE_WIFI
|
||||
// Json document buffers
|
||||
//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
|
||||
#endif
|
||||
|
||||
@ -502,7 +502,7 @@ uint8_t myData[SCREEN_WIDTH+1];
|
||||
uint8_t myStorage[SCREEN_WIDTH+1];
|
||||
uint8_t myActual[SCREEN_WIDTH+1];
|
||||
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 oldPeakLevel; // Old maximum signal level
|
||||
@ -843,6 +843,14 @@ bool fsStatus = false; // True if SPIFFS loads ok
|
||||
})
|
||||
.onProgress([](unsigned int progress, unsigned int total) {
|
||||
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) {
|
||||
Serial.printf("Error[%u]: ", error);
|
||||
@ -928,12 +936,12 @@ loopStartMicros = micros();
|
||||
lastWebsocketMicros = loopStartMicros;
|
||||
}
|
||||
|
||||
ArduinoOTA.handle(); // check if OTA programming requested
|
||||
#endif
|
||||
|
||||
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
|
||||
if ( ui_mode != UI_NORMAL )
|
||||
@ -947,7 +955,7 @@ loopStartMicros = micros();
|
||||
* Not fully implemented yet.
|
||||
*/
|
||||
|
||||
switch ( setting.Mode )
|
||||
switch ( tinySA_mode )
|
||||
{
|
||||
case SA_LOW_RANGE:
|
||||
doSweepLow(); // Spectrum Analyser Low Frequency range
|
||||
@ -977,6 +985,10 @@ loopStartMicros = micros();
|
||||
doBandscope(); // Bandscope Sweep
|
||||
break;
|
||||
|
||||
case OTA_UPDATE: // Over the air (wifi) update
|
||||
doOTA();
|
||||
break;
|
||||
|
||||
default:
|
||||
DisplayError ( ERR_WARN,
|
||||
"Invalid Mode!",
|
||||
@ -1024,6 +1036,9 @@ void setMode ( uint16_t newMode )
|
||||
initRX_Sweep();
|
||||
break;
|
||||
|
||||
case OTA_UPDATE:
|
||||
initOTA();
|
||||
break;
|
||||
|
||||
default:
|
||||
DisplayError ( ERR_WARN,
|
||||
@ -1084,6 +1099,10 @@ void menuExit()
|
||||
initBandscope();
|
||||
break;
|
||||
|
||||
case OTA_UPDATE:
|
||||
initOTA();
|
||||
break;
|
||||
|
||||
default:
|
||||
// add handler here
|
||||
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
|
||||
|
@ -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
|
||||
*/
|
||||
|
||||
void onGetScan ( AsyncWebServerRequest *request )
|
||||
{
|
||||
response = request->beginResponseStream ( "text/xml" );
|
||||
// Serial.println ( "onGetScan" );
|
||||
|
||||
response->print ( "<?xml version=\"1.0\" encoding=\"utf-16\"?>" );
|
||||
response->println ( "<Points>" );
|
||||
|
||||
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 );
|
||||
response->printf ( "<P F=\"%i\" R=\"%i\"/>\n", myFreq[i], myData[i] );
|
||||
}
|
||||
|
||||
response->print ( "</Points>" );
|
||||
request->send ( response );
|
||||
}
|
||||
//void onGetScan ( AsyncWebServerRequest *request )
|
||||
//{
|
||||
// response = request->beginResponseStream ( "text/xml" );
|
||||
//// Serial.println ( "onGetScan" );
|
||||
//
|
||||
// response->print ( "<?xml version=\"1.0\" encoding=\"utf-16\"?>" );
|
||||
// response->println ( "<Points>" );
|
||||
//
|
||||
// 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 );
|
||||
// response->printf ( "<P F=\"%i\" R=\"%i\"/>\n", myFreq[i], myData[i] );
|
||||
// }
|
||||
//
|
||||
// response->print ( "</Points>" );
|
||||
// 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,
|
||||
*/
|
||||
|
||||
void onGetGainSweep ( AsyncWebServerRequest *request )
|
||||
{
|
||||
size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
|
||||
+ JSON_OBJECT_SIZE ( 1 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 );
|
||||
|
||||
AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize );
|
||||
// response->addHeader ( "Server","ESP Async Web Server" );
|
||||
|
||||
JsonObject root = response->getRoot();
|
||||
JsonArray gainPoints = root.createNestedArray ( "gainPoints" ); // Add gainPoints array
|
||||
|
||||
/*
|
||||
* Add the objects to the array
|
||||
*/
|
||||
|
||||
for ( int i = 0; i < displayPoints; i++ ) // For each data point
|
||||
{
|
||||
JsonObject dataPoint = gainPoints.createNestedObject(); // Add an object to the array
|
||||
dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value
|
||||
dataPoint["y"] = myGain[i]; // set the y (gain) value
|
||||
}
|
||||
|
||||
response->setLength();
|
||||
request->send ( response );
|
||||
}
|
||||
//void onGetGainSweep ( AsyncWebServerRequest *request )
|
||||
//{
|
||||
// size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
|
||||
// + JSON_OBJECT_SIZE ( 1 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 );
|
||||
//
|
||||
// AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize );
|
||||
//// response->addHeader ( "Server","ESP Async Web Server" );
|
||||
//
|
||||
// JsonObject root = response->getRoot();
|
||||
// JsonArray gainPoints = root.createNestedArray ( "gainPoints" ); // Add gainPoints array
|
||||
//
|
||||
///*
|
||||
// * Add the objects to the array
|
||||
// */
|
||||
//
|
||||
// for ( int i = 0; i < displayPoints; i++ ) // For each data point
|
||||
// {
|
||||
// JsonObject dataPoint = gainPoints.createNestedObject(); // Add an object to the array
|
||||
// dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value
|
||||
// dataPoint["y"] = myGain[i]; // set the y (gain) value
|
||||
// }
|
||||
//
|
||||
// response->setLength();
|
||||
// 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.
|
||||
*/
|
||||
|
||||
void onGetSweep ( AsyncWebServerRequest *request )
|
||||
{
|
||||
size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
|
||||
+ JSON_OBJECT_SIZE ( 14 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 );
|
||||
|
||||
AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize );
|
||||
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
root["dispPoints"] = displayPoints;
|
||||
root["start"] = setting.ScanStart / 1000.0;
|
||||
root["stop"] = setting.ScanStop / 1000.0;
|
||||
root["IF"] = setting.IF_Freq / 1000000.0;
|
||||
root["attenuation"] = setting.Attenuate;
|
||||
root["extGain"] = setting.ExternalGain;
|
||||
root["levelOffset"] = setting.LevelOffset;
|
||||
root["filterCal"] = bpfCalibrations[bpfIndex];
|
||||
root["setRBW"] = setting.Bandwidth10;
|
||||
root["bandwidth"] = bandwidth;
|
||||
root["RefOut"] = setting.ReferenceOut;
|
||||
root["Drive"] = setting.Drive;
|
||||
root["sweepPoints"] = sweepPoints;
|
||||
|
||||
if ( AGC_On )
|
||||
root["PreAmp"] = 0x60; // Auto
|
||||
|
||||
else
|
||||
root["PreAmp"] = setting.PreampGain; // Fixed gain
|
||||
|
||||
JsonArray Points = root.createNestedArray ( "Points" ); // Add Points array
|
||||
|
||||
|
||||
for ( int i = 0; i < displayPoints; i++ ) //For each data point
|
||||
{
|
||||
JsonObject dataPoint = Points.createNestedObject(); // add an object to the array
|
||||
dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value
|
||||
dataPoint["y"] = myData[i]; // set the y (RSSI) value
|
||||
}
|
||||
|
||||
|
||||
response->setLength();
|
||||
request->send ( response );
|
||||
}
|
||||
//void onGetSweep ( AsyncWebServerRequest *request )
|
||||
//{
|
||||
// size_t bufferSize = JSON_ARRAY_SIZE ( SCREEN_WIDTH )
|
||||
// + JSON_OBJECT_SIZE ( 14 ) + SCREEN_WIDTH * JSON_OBJECT_SIZE ( 2 );
|
||||
//
|
||||
// AsyncJsonResponse * response = new AsyncJsonResponse ( false, bufferSize );
|
||||
//
|
||||
// JsonObject root = response->getRoot();
|
||||
//
|
||||
// root["dispPoints"] = displayPoints;
|
||||
// root["start"] = setting.ScanStart / 1000.0;
|
||||
// root["stop"] = setting.ScanStop / 1000.0;
|
||||
// root["IF"] = setting.IF_Freq / 1000000.0;
|
||||
// root["attenuation"] = setting.Attenuate;
|
||||
// root["extGain"] = setting.ExternalGain;
|
||||
// root["levelOffset"] = setting.LevelOffset;
|
||||
// root["filterCal"] = bpfCalibrations[bpfIndex];
|
||||
// root["setRBW"] = setting.Bandwidth10;
|
||||
// root["bandwidth"] = bandwidth;
|
||||
// root["RefOut"] = setting.ReferenceOut;
|
||||
// root["Drive"] = setting.Drive;
|
||||
// root["sweepPoints"] = sweepPoints;
|
||||
//
|
||||
// if ( AGC_On )
|
||||
// root["PreAmp"] = 0x60; // Auto
|
||||
//
|
||||
// else
|
||||
// root["PreAmp"] = setting.PreampGain; // Fixed gain
|
||||
//
|
||||
// JsonArray Points = root.createNestedArray ( "Points" ); // Add Points array
|
||||
//
|
||||
//
|
||||
// for ( int i = 0; i < displayPoints; i++ ) //For each data point
|
||||
// {
|
||||
// JsonObject dataPoint = Points.createNestedObject(); // add an object to the array
|
||||
// dataPoint["x"] = myFreq[i]/1000000.0; // set the x(frequency) value
|
||||
// dataPoint["y"] = myData[i]; // set the y (RSSI) value
|
||||
// }
|
||||
//
|
||||
//
|
||||
// response->setLength();
|
||||
// request->send ( response );
|
||||
//}
|
||||
|
||||
|
||||
/*
|
||||
* On request from web page send the settings as JSON
|
||||
*/
|
||||
void onGetSettings (AsyncWebServerRequest *request)
|
||||
{
|
||||
AsyncJsonResponse * response = new AsyncJsonResponse(false) ;
|
||||
|
||||
JsonObject root = response->getRoot();
|
||||
|
||||
root["mType"] = "Settings";
|
||||
root["mode"] = setting.Mode;
|
||||
root["dispPoints"] = displayPoints;
|
||||
root["start"] = setting.ScanStart / 1000.0;
|
||||
root["stop"] = setting.ScanStop / 1000.0;
|
||||
root["IF"] = setting.IF_Freq / 1000000.0;
|
||||
root["attenuation"] = setting.Attenuate;
|
||||
root["extGain"] = setting.ExternalGain;
|
||||
root["levelOffset"] = setting.LevelOffset;
|
||||
root["filterCal"] = bpfCalibrations[bpfIndex];
|
||||
root["setRBW"] = setting.Bandwidth10;
|
||||
root["bandwidth"] = bandwidth;
|
||||
root["RefOut"] = setting.ReferenceOut;
|
||||
root["Drive"] = setting.Drive;
|
||||
root["sweepPoints"] = sweepPoints;
|
||||
root["spur"] = setting.Spur;
|
||||
root["tg"] = trackGenSetting.Mode;
|
||||
root["tgPower"] = trackGenSetting.Power;
|
||||
root["tgFreq"] = trackGenSetting.Frequency;
|
||||
root["tgMod"] = trackGenSetting.ModulationType;
|
||||
root["tgModFreq"] = trackGenSetting.ModFrequency;
|
||||
root["sg"] = sigGenOutputOn; //
|
||||
root["sgPower"] = sigGenSetting.Power;
|
||||
root["sgMod"] = sigGenSetting.ModulationType;
|
||||
root["sgModFreq"] = sigGenSetting.ModFrequency;
|
||||
root["sgFreq"] = sigGenSetting.Frequency;
|
||||
root["sgCal"] = sigGenSetting.Calibration;
|
||||
root["sgRange"] = ATTENUATOR_RANGE + 11; // SI4432 output can be adjusted over 21dBm but max to SAW filter is 10dBm
|
||||
root["tgCal"] = trackGenSetting.Calibration;
|
||||
root["tgRange"] = ATTENUATOR_RANGE + 21; // no SAW filter so 20dBm output is possible.
|
||||
|
||||
if ( AGC_On )
|
||||
root["PreAmp"] = 0x60; // Auto
|
||||
|
||||
else
|
||||
root["PreAmp"] = setting.PreampGain; // Fixed gain
|
||||
|
||||
response->setLength();
|
||||
request->send ( response );
|
||||
// Serial.printf ( "Get Settings sweepPoints %u\n", sweepPoints );
|
||||
}
|
||||
//void onGetSettings (AsyncWebServerRequest *request)
|
||||
//{
|
||||
// AsyncJsonResponse * response = new AsyncJsonResponse(false) ;
|
||||
//
|
||||
// JsonObject root = response->getRoot();
|
||||
//
|
||||
// root["mType"] = "Settings";
|
||||
// root["mode"] = setting.Mode;
|
||||
// root["dispPoints"] = displayPoints;
|
||||
// root["start"] = setting.ScanStart / 1000.0;
|
||||
// root["stop"] = setting.ScanStop / 1000.0;
|
||||
// root["IF"] = setting.IF_Freq / 1000000.0;
|
||||
// root["attenuation"] = setting.Attenuate;
|
||||
// root["extGain"] = setting.ExternalGain;
|
||||
// root["levelOffset"] = setting.LevelOffset;
|
||||
// root["filterCal"] = bpfCalibrations[bpfIndex];
|
||||
// root["setRBW"] = setting.Bandwidth10;
|
||||
// root["bandwidth"] = bandwidth;
|
||||
// root["RefOut"] = setting.ReferenceOut;
|
||||
// root["Drive"] = setting.Drive;
|
||||
// root["sweepPoints"] = sweepPoints;
|
||||
// root["spur"] = setting.Spur;
|
||||
// root["tg"] = trackGenSetting.Mode;
|
||||
// root["tgPower"] = trackGenSetting.Power;
|
||||
// root["tgFreq"] = trackGenSetting.Frequency;
|
||||
// root["tgMod"] = trackGenSetting.ModulationType;
|
||||
// root["tgModFreq"] = trackGenSetting.ModFrequency;
|
||||
// root["sg"] = sigGenOutputOn; //
|
||||
// root["sgPower"] = sigGenSetting.Power;
|
||||
// root["sgMod"] = sigGenSetting.ModulationType;
|
||||
// root["sgModFreq"] = sigGenSetting.ModFrequency;
|
||||
// root["sgFreq"] = sigGenSetting.Frequency;
|
||||
// root["sgCal"] = sigGenSetting.Calibration;
|
||||
// root["sgRange"] = ATTENUATOR_RANGE + 11; // SI4432 output can be adjusted over 21dBm but max to SAW filter is 10dBm
|
||||
// root["tgCal"] = trackGenSetting.Calibration;
|
||||
// root["tgRange"] = ATTENUATOR_RANGE + 21; // no SAW filter so 20dBm output is possible.
|
||||
//
|
||||
// if ( AGC_On )
|
||||
// root["PreAmp"] = 0x60; // Auto
|
||||
//
|
||||
// else
|
||||
// root["PreAmp"] = setting.PreampGain; // Fixed gain
|
||||
//
|
||||
// response->setLength();
|
||||
// request->send ( response );
|
||||
//// 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
|
||||
|
||||
void onSetSweep ( AsyncWebServerRequest *request )
|
||||
{
|
||||
|
||||
Serial.print ( request->url ()); // Get the paramaters passed from the
|
||||
Serial.print ( ":-" ); // web page, checking they exist
|
||||
|
||||
if ( request->hasParam ( "setStart" ))
|
||||
{
|
||||
Serial.print ( "setStart;" );
|
||||
AsyncWebParameter* startInput = request->getParam ( "setStart" );
|
||||
SetSweepStart ( atof ( startInput->value().c_str()) * 1000000.0 );
|
||||
}
|
||||
|
||||
if ( request->hasParam ( "setStop" ))
|
||||
{
|
||||
Serial.print ( "setStop;" );
|
||||
AsyncWebParameter* stopInput = request->getParam ( "setStop" );
|
||||
SetSweepStop( atof ( stopInput->value().c_str()) * 1000000.0 );
|
||||
}
|
||||
|
||||
if ( request->hasParam ( "setExtGain" ))
|
||||
{
|
||||
Serial.print ( "setExtGain;" );
|
||||
AsyncWebParameter* extGainInput = request->getParam ( "setExtGain" );
|
||||
// Need to add function later
|
||||
}
|
||||
|
||||
if ( request->hasParam ( "refOut" ))
|
||||
{
|
||||
Serial.print ( "refOut;" );
|
||||
AsyncWebParameter* setRefOut = request->getParam ( "setRefOut" );
|
||||
setting.ReferenceOut = atoi ( setRefOut->value().c_str() );
|
||||
xmit.SetPowerReference ( setting.ReferenceOut );
|
||||
}
|
||||
|
||||
if ( request->hasParam ( "setAtten" ))
|
||||
{
|
||||
Serial.print ( "setAtten:" );
|
||||
AsyncWebParameter* setAtten = request->getParam ( "setAtten");
|
||||
SetAttenuation ( atoi ( setAtten->value().c_str() ));
|
||||
Serial.print ( atoi ( setAtten->value().c_str() ));
|
||||
Serial.print ( "; " );
|
||||
}
|
||||
|
||||
if ( request->hasParam ( "setRBW" ))
|
||||
{
|
||||
Serial.print ( "setRBW ");
|
||||
AsyncWebParameter* rbwInput = request->getParam ( "setRBW" );
|
||||
SetRBW ( atoi ( rbwInput->value().c_str() ));
|
||||
Serial.printf ( "setting.bandwidth = %i, input = %i;", setting.Bandwidth10, atoi ( rbwInput->value().c_str() ));
|
||||
}
|
||||
|
||||
Serial.println ();
|
||||
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
|
||||
* No longer used
|
||||
*/
|
||||
|
||||
// doSetSweep ? setStart = 10 &setStop = 20 & setExtGain = 0 & setRBW = 26
|
||||
|
||||
void onSettings ( AsyncWebServerRequest *request )
|
||||
{
|
||||
Serial.print ( request->url() ); // Get the paramaters passed from the web
|
||||
Serial.print ( ":-" ); // page, checking they exist
|
||||
|
||||
if ( request->hasParam ( "setActPower" ))
|
||||
{
|
||||
Serial.print ( "setActPower;" );
|
||||
AsyncWebParameter* setLevelInput = request->getParam ( "setActPower" );
|
||||
SetPowerLevel ( atof ( setLevelInput->value().c_str()) );
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
request->redirect ( "index.html"); // Redirect to the index page
|
||||
}
|
||||
//void onSetSweep ( AsyncWebServerRequest *request )
|
||||
//{
|
||||
//
|
||||
// Serial.print ( request->url ()); // Get the paramaters passed from the
|
||||
// Serial.print ( ":-" ); // web page, checking they exist
|
||||
//
|
||||
// if ( request->hasParam ( "setStart" ))
|
||||
// {
|
||||
// Serial.print ( "setStart;" );
|
||||
// AsyncWebParameter* startInput = request->getParam ( "setStart" );
|
||||
// SetSweepStart ( atof ( startInput->value().c_str()) * 1000000.0 );
|
||||
// }
|
||||
//
|
||||
// if ( request->hasParam ( "setStop" ))
|
||||
// {
|
||||
// Serial.print ( "setStop;" );
|
||||
// AsyncWebParameter* stopInput = request->getParam ( "setStop" );
|
||||
// SetSweepStop( atof ( stopInput->value().c_str()) * 1000000.0 );
|
||||
// }
|
||||
//
|
||||
// if ( request->hasParam ( "setExtGain" ))
|
||||
// {
|
||||
// Serial.print ( "setExtGain;" );
|
||||
// AsyncWebParameter* extGainInput = request->getParam ( "setExtGain" );
|
||||
//// Need to add function later
|
||||
// }
|
||||
//
|
||||
// if ( request->hasParam ( "refOut" ))
|
||||
// {
|
||||
// Serial.print ( "refOut;" );
|
||||
// AsyncWebParameter* setRefOut = request->getParam ( "setRefOut" );
|
||||
// setting.ReferenceOut = atoi ( setRefOut->value().c_str() );
|
||||
// xmit.SetPowerReference ( setting.ReferenceOut );
|
||||
// }
|
||||
//
|
||||
// if ( request->hasParam ( "setAtten" ))
|
||||
// {
|
||||
// Serial.print ( "setAtten:" );
|
||||
// AsyncWebParameter* setAtten = request->getParam ( "setAtten");
|
||||
// SetAttenuation ( atoi ( setAtten->value().c_str() ));
|
||||
// Serial.print ( atoi ( setAtten->value().c_str() ));
|
||||
// Serial.print ( "; " );
|
||||
// }
|
||||
//
|
||||
// if ( request->hasParam ( "setRBW" ))
|
||||
// {
|
||||
// Serial.print ( "setRBW ");
|
||||
// AsyncWebParameter* rbwInput = request->getParam ( "setRBW" );
|
||||
// SetRBW ( atoi ( rbwInput->value().c_str() ));
|
||||
// Serial.printf ( "setting.bandwidth = %i, input = %i;", setting.Bandwidth10, atoi ( rbwInput->value().c_str() ));
|
||||
// }
|
||||
//
|
||||
// Serial.println ();
|
||||
// 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
|
||||
// * No longer used
|
||||
// */
|
||||
//
|
||||
//// doSetSweep ? setStart = 10 &setStop = 20 & setExtGain = 0 & setRBW = 26
|
||||
//
|
||||
//void onSettings ( AsyncWebServerRequest *request )
|
||||
//{
|
||||
// Serial.print ( request->url() ); // Get the paramaters passed from the web
|
||||
// Serial.print ( ":-" ); // page, checking they exist
|
||||
//
|
||||
// if ( request->hasParam ( "setActPower" ))
|
||||
// {
|
||||
// Serial.print ( "setActPower;" );
|
||||
// AsyncWebParameter* setLevelInput = request->getParam ( "setActPower" );
|
||||
// SetPowerLevel ( atof ( setLevelInput->value().c_str()) );
|
||||
// }
|
||||
//
|
||||
// Serial.println();
|
||||
// request->redirect ( "index.html"); // Redirect to the index page
|
||||
//}
|
||||
|
||||
|
||||
void onGetNameVersion ( AsyncWebServerRequest *request )
|
||||
@ -1176,17 +1176,17 @@ void buildServer () // We can now configure and start the server
|
||||
{
|
||||
Serial.println ( "Building Server.." );
|
||||
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 ( "/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 ( "/doSetSweep", HTTP_POST, onSetSweep ); // Set event to set sweep values received from client
|
||||
// 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 ( "/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 ( "/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 ( "/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 ( "/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 ( "/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" );
|
||||
|
||||
|
@ -81,7 +81,7 @@
|
||||
extern uint8_t myStorage[SCREEN_WIDTH+1];
|
||||
extern uint8_t myActual[SCREEN_WIDTH+1];
|
||||
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
|
||||
|
9
ui.cpp
9
ui.cpp
@ -451,6 +451,7 @@ static Menuitem menu_mode[] = // Select mode menu
|
||||
Menuitem ( MT_FUNC, "\2BAND\0SCOPE",menu_mode_cb ),
|
||||
Menuitem ( MT_FUNC, "\2IF\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_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
|
||||
{
|
||||
ClearDisplay ();
|
||||
@ -1230,6 +1228,11 @@ void menu_mode_cb ( int item )
|
||||
ui_mode_normal (); // No menu displayed
|
||||
break;
|
||||
|
||||
case 5:
|
||||
setMode(OTA_UPDATE); // Set OTA mode
|
||||
ui_mode_normal();
|
||||
break;
|
||||
|
||||
}
|
||||
changedSetting = true;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user