Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mp-se committed Mar 12, 2024
2 parents b4b5ebf + cf712e4 commit d61d83e
Show file tree
Hide file tree
Showing 15 changed files with 71 additions and 57 deletions.
Binary file modified bin/firmware.bin
Binary file not shown.
Binary file modified bin/firmware32.bin
Binary file not shown.
Binary file modified bin/firmware32c3.bin
Binary file not shown.
Binary file modified bin/firmware32c3v1.bin
Binary file not shown.
Binary file modified bin/firmware32lite.bin
Binary file not shown.
Binary file modified bin/firmware32s2.bin
Binary file not shown.
Binary file modified bin/firmware32s3.bin
Binary file not shown.
2 changes: 1 addition & 1 deletion bin/version.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "project":"gravmon", "version":"1.4.0", "html": [ ] }
{ "project":"gravmon", "version":"1.4.1", "html": [ ] }
51 changes: 21 additions & 30 deletions html/index.htm
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
iSpindel configuration file has been detected, do you want to copy formula and gyro calibration ?
</div>
<div class="col-md-2">
<button class="btn btn-primary btn-sm" type="button" id="migrate-btn" data-bs-toggle="collapse" data-bs-target="#collapseSupport" aria-expanded="false" aria-controls="collapseSupport" data-bs-toggle="tooltip" name="support-btn" id="support-btn" title="Collect data relevant for a support case">
<button class="btn btn-primary btn-sm" type="button" id="migrate-btn" data-bs-toggle="tooltip" name="migrate-btn" title="Migrate ispindel config">
Migrate
</button>
</div>
Expand All @@ -124,25 +124,22 @@
// var url = "/test/migrate.json";
$.getJSON(url, function (cfg) {
console.log( cfg );

gyro = {}
gyro["ax"] = cfg["Offset"][0];
gyro["ay"] = cfg["Offset"][1];
gyro["az"] = cfg["Offset"][2];
gyro["gx"] = cfg["Offset"][3];
gyro["gy"] = cfg["Offset"][4];
gyro["gz"] = cfg["Offset"][5];

data = {}
data["gyro-calibration-data"] = gyro;
data["ax"] = cfg["Offset"][0];
data["ay"] = cfg["Offset"][1];
data["az"] = cfg["Offset"][2];
data["gx"] = cfg["Offset"][3];
data["gy"] = cfg["Offset"][4];
data["gz"] = cfg["Offset"][5];
data["gravity-formula"] = cfg["POLY"];

$.ajax( "/api/migrate", {
type: "POST",
data: JSON.stringify(data),
statusCode: {
200: function(response) {
showSuccess("Migration completed!");
showSuccess("Migration completed! Please restart device for changes to be applied to gyro.");
hideMigration();
$('#spinner').hide();
},
Expand Down Expand Up @@ -269,15 +266,15 @@ <h2 class="accordion-header" id="headingSoftware">
};
</script>

<button class="btn btn-primary btn-sm" id="log-btn" type="button" data-bs-toggle="collapse" data-bs-target="#collapseLog" aria-expanded="false" aria-controls="collapseLog" data-bs-toggle="tooltip" title="Load and show the last 10 errors that has occured on the device">
<button class="btn btn-primary btn-sm" id="log-btn" type="button" data-bs-toggle="collapse" data-bs-target="#collapseLog" aria-expanded="false" aria-controls="collapseLog">
View error log
</button>

<button class="btn btn-secondary btn-sm" id="issue-btn" type="button" data-bs-toggle="tooltip" name="github-btn" id="github-btn" title="Go to github and place a issue">
<button class="btn btn-secondary btn-sm" type="button" data-bs-toggle="tooltip" name="github-btn" id="github-btn" title="Go to github and place a issue">
Submit a issue on github
</button>

<button class="btn btn-secondary btn-sm" id="support-btn" type="button" data-bs-toggle="collapse" data-bs-target="#collapseSupport" aria-expanded="false" aria-controls="collapseSupport" data-bs-toggle="tooltip" name="support-btn" id="support-btn" title="Collect data relevant for a support case">
<button class="btn btn-secondary btn-sm" type="button" data-bs-toggle="collapse" data-bs-target="#collapseSupport" aria-expanded="false" aria-controls="collapseSupport" data-bs-toggle="tooltip" name="support-btn" id="support-btn" title="Collect data relevant for a support case">
Gather support information
</button>

Expand Down Expand Up @@ -361,23 +358,17 @@ <h2 class="accordion-header" id="headingSoftware">
//var url = "/test/adv.json";
$.getJSON(url, function (cfg) {
debug["advanced"] = cfg;

var url = "/api/upload";
//var url = "/test/upload.json";
$.getJSON(url, function (cfg) {
debug["files"] = cfg;

var url = "/log";
//var url = "/test/log";
$.ajax({url: url, method: 'get', success: function (data) {
debug["log"] = data.split("\n");
var s = JSON.stringify(debug, null, 2);
$("#supportContent").text( s );
$('#spinner').hide();
//navigator.clipboard.writeText(s);
//alert("Support information copied to clipboard");
}
});
var url = "/log";
//var url = "/test/log";
$.ajax({url: url, method: 'get', success: function (data) {
debug["log"] = data.split("\n");
var s = JSON.stringify(debug, null, 2);
$("#supportContent").text( s );
$('#spinner').hide();
//navigator.clipboard.writeText(s);
//alert("Support information copied to clipboard");
}
});
});
});
Expand Down
28 changes: 11 additions & 17 deletions html/index.min.htm

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ build_flags =
-D WEB_DISABLE_LOGGING
-D MAIN_DISABLE_LOGGING
-D USE_LITTLEFS=true
-D CFG_APPVER="\"1.4.0\""
-D CFG_APPVER="\"1.4.1\""
#-D CFG_GITREV=\""beta-3\""
!python script/git_rev.py
lib_deps =
Expand Down
34 changes: 27 additions & 7 deletions src/webserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ void WebServerHandler::webHandleMigrate(AsyncWebServerRequest *request) {

#if defined(ESP8266)
DynamicJsonDocument doc(500);
DeserializationError err = deserializeJson(doc, request->arg("plain"));
DeserializationError err = deserializeJson(doc, request->arg("body"));

if (err) {
writeErrorLog("CFG : Failed to parse migration data (json)");
Expand All @@ -1199,16 +1199,19 @@ void WebServerHandler::webHandleMigrate(AsyncWebServerRequest *request) {
myConfig.setGravityFormula(doc[PARAM_GRAVITY_FORMULA]);

RawGyroData gyro = {0, 0, 0, 0, 0, 0};
gyro.ax = doc[PARAM_GYRO_CALIBRATION]["ax"];
gyro.ay = doc[PARAM_GYRO_CALIBRATION]["ay"];
gyro.az = doc[PARAM_GYRO_CALIBRATION]["az"];
gyro.gx = doc[PARAM_GYRO_CALIBRATION]["gx"];
gyro.gy = doc[PARAM_GYRO_CALIBRATION]["gy"];
gyro.gz = doc[PARAM_GYRO_CALIBRATION]["gz"];
gyro.ax = doc["ax"];
gyro.ay = doc["ay"];
gyro.az = doc["az"];
gyro.gx = doc["gx"];
gyro.gy = doc["gy"];
gyro.gz = doc["gz"];

myConfig.setGyroCalibration(gyro);
myConfig.saveFile();

Log.notice(F("WEB : %s." CR), myConfig.getGravityFormula());
Log.notice(F("WEB : %d." CR), myConfig.getGyroCalibration().ax);

LittleFS.rename("/config.json", "/ispindel.json");
request->send(200, "text/plain", F("Data migrated"));
#else
Expand All @@ -1218,6 +1221,20 @@ void WebServerHandler::webHandleMigrate(AsyncWebServerRequest *request) {
LOG_PERF_STOP("webserver-api-migrate");
}

void WebServerHandler::webHandleMigrateUndo(AsyncWebServerRequest *request) {
LOG_PERF_START("webserver-api-migrate-undo");
Log.notice(F("WEB : webServer callback for /api/migrate/undo." CR));

#if defined(ESP8266)
LittleFS.rename("/ispindel.json", "/config.json");
request->send(200, "text/plain", F("ispindel config restored"));
#else
request->send(404, "text/plain", F("Not implemented"));
#endif

LOG_PERF_STOP("webserver-api-migrate-undo");
}

void WebServerHandler::webHandlePageNotFound(AsyncWebServerRequest *request) {
Log.error(F("WEB : URL not found %s received." CR), request->url().c_str());
request->send(404, "text/plain", F("URL not found"));
Expand Down Expand Up @@ -1350,6 +1367,9 @@ bool WebServerHandler::setupWebServer() {
_server->on("/api/restart", HTTP_GET,
std::bind(&WebServerHandler::webHandleRestart, this,
std::placeholders::_1));
_server->on("/api/migrate/undo", HTTP_GET,
std::bind(&WebServerHandler::webHandleMigrateUndo, this,
std::placeholders::_1));
_server->on("/api/migrate", HTTP_POST,
std::bind(&WebServerHandler::webHandleMigrate, this,
std::placeholders::_1));
Expand Down
1 change: 1 addition & 0 deletions src/webserver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ class WebServerHandler {
void webHandlePageNotFound(AsyncWebServerRequest *request);
void webHandleRestart(AsyncWebServerRequest *request);
void webHandleMigrate(AsyncWebServerRequest *request);
void webHandleMigrateUndo(AsyncWebServerRequest *request);

String readFile(String fname);
bool writeFile(String fname, String data);
Expand Down
8 changes: 8 additions & 0 deletions src_docs/source/releases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
Releases
########

v1.4.1
======

Issues adressed
++++++++++++++++
* Fixed broken iSpindel configuration migration for the esp8266.
* Fixed broken gather support button.

v1.4.0
======

Expand Down
2 changes: 1 addition & 1 deletion src_docs/source/services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ Finally add the following format template to HTTP POST 1
{
"apikey": "${token}",
"type":"ispindel",
"type":"gravitymon",
"brand":"wemos_d1_mini",
"version":"${app-ver}",
"chipid":"${id}",
Expand Down

0 comments on commit d61d83e

Please sign in to comment.