Skip to content

Commit

Permalink
Merge branch 'new_versions' into new_tools
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Jun 12, 2021
2 parents af69b5d + b37eb24 commit 24c42b1
Show file tree
Hide file tree
Showing 23 changed files with 219 additions and 63 deletions.
2 changes: 1 addition & 1 deletion data/about.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ function loadThisVersion() { // Get current parameters
})
.done(function (thisVersion) {
try {
$('#thisVersion').text("v" + thisVersion.version);
$('#thisVersion').text("v" + thisVersion.fw_version);
$('#thisBranch').text(thisVersion.branch);
$('#thisBuild').text(thisVersion.build);
}
Expand Down
2 changes: 1 addition & 1 deletion data/help.htm
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ <h4 class="card-title">Brew Bubbles Support</h4>
other users on the <a href="http://support.brewbubbles.com/">HomeBrewTalk Thread</a>
</li>
<li><span class="fa-li"><i class="fas fa-chalkboard-teacher"></i></span>Discuss on
<a href="http://support.brewbubbles.com/">GitHub Discussions</a>
<a href="http://discuss.brewbubbles.com/">GitHub Discussions</a>
</li>
</ul>
</p>
Expand Down
28 changes: 20 additions & 8 deletions data/settings.htm
Original file line number Diff line number Diff line change
Expand Up @@ -545,24 +545,36 @@ <h4 class="card-title">Reset Controller</h4>
<h4 class="card-title">Update Firmware: Confirmation</h4>
</div>
<div class="card-body">
<p>
<table class="table table-hover">
<thead>
<tr>
<th scope="col"></th>
<th scope="col">Current</th>
<th scope="col">Available</th>
</tr>
</thead>
<tbody>
<tr class="table-success">
<th scope="row">Current Version:</th>
<tr class="table-firmware table-success">
<th scope="row">Firmware</th>
<td>
<div id="thisFWVersion">... loading</div>
</td>
<td>
<div id="thisVersion">... loading</div>
<div id="thatFWVersion">... loading</div>
</td>
</tr>
<tr class="table-info">
<th scope="row">Available version:</th>
<tr class="table-firmware table-info">
<th scope="row">Filesystem</th>
<td>
<div id="thatVersion">... loading</div>
<div id="thisFSVersion">... loading</div>
</td>
<td>
<div id="thatFSVersion">... loading</div>
</td>
</tr>
</tbody>
</table>
</p>

<p>
If you are sure you want to update firmware, click the button below.
</p>
Expand Down
18 changes: 12 additions & 6 deletions data/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,17 +99,20 @@ function loadThisVersion() { // Get current parameters
})
.done(function (thisVersion) {
try {
$('#thisVersion').text(thisVersion.version);
$('#thisFWVersion').text(thisVersion.fw_version);
$('#thisFSVersion').text(thisVersion.fs_version);
}
catch {
if (!unloadingState) {
$('#thisVersion').text("Error parsing.");
$('#thisFWVersion').text("Error parsing.");
$('#thisFSVersion').text("Error parsing.");
}
}
})
.fail(function () {
if (!unloadingState) {
$('#thisVersion').text("Error loading.");
$('#thisFWVersion').text("Error loading.");
$('#thisFSVersion').text("Error loading.");
}
})
.always(function () {
Expand All @@ -129,18 +132,21 @@ function loadThatVersion() { // Get current parameters
})
.done(function (thatVersion) {
try {
$('#thatVersion').text(thatVersion.version);
$('#thatFWVersion').text(thatVersion.fw_version);
$('#thatFSVersion').text(thatVersion.fs_version);
document.getElementById("proceed").disabled = false;
}
catch {
if (!unloadingState) {
$('#thatVersion').text("Error parsing.");
$('#thatFWVersion').text("Error parsing.");
$('#thatFSVersion').text("Error parsing.");
}
}
})
.fail(function () {
if (!unloadingState) {
$('#thatVersion').text("Error loading.");
$('#thatFWVersion').text("Error loading.");
$('#thatFSVersion').text("Error loading.");
}
})
.always(function () {
Expand Down
5 changes: 5 additions & 0 deletions data/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"version": "2.2.3",
"fs_version": "2.2.3",
"fw_version": "2.2.3"
}
18 changes: 16 additions & 2 deletions firmware/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,34 @@

## Brew Bubbles Firmware

This directory contains the firmware files and scripts to prepare the controller. Instructions to program the controller are contained in [the documentaiton](https://docs.brewbubbles.com).
This directory contains the firmware files to prepare the controller. Instructions to program the controller are contained in [the documentation](https://docs.brewbubbles.com).

## Flashing Manually

If you have ``esptool.py`` on yor system, you may use the following command line:

```
esptool.py --chip esp8266 --before default_reset --after hard_reset write_flash 0x00000000 firmware.bin 0x00300000 spiffs.bin
esptool.py --chip esp8266 --before default_reset --after hard_reset write_flash 0x00000000 firmware.bin 0x00300000 littlefs.bin
```

## Files in this Directory

### Versions <= 2.2.3

These files exist for legacy (version <= 2.2.3) Brew Bubbles users.

**File Name**|**Description**
-----|-----
`firmware.bin`| Main firmware file containing the Brew Bubbles application.
`littlefs.bin`| Controller filesystem image containing the web pages used by Brew Bubbles.
`version.json` | File used for version control.

### Versions > 2.2.3

These files exist for updated (version > 2.2.3) Brew Bubbles users.

**File Name**|**Description**
-----|-----
`{board_type}_firmware.bin`| Main firmware file containing the Brew Bubbles application.
`{board_type}_littlefs.bin`| Controller filesystem image containing the web pages used by Brew Bubbles.
`version.json` | File used for version control.
Binary file added firmware/d1_mini_firmware.bin
Binary file not shown.
Binary file added firmware/d1_mini_littlefs.bin
Binary file not shown.
Binary file modified firmware/firmware.bin
Binary file not shown.
Binary file modified firmware/littlefs.bin
Binary file not shown.
6 changes: 5 additions & 1 deletion firmware/version.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
{"version": "2.2.3"}
{
"version": "2.2.4-Alpha",
"fs_version": "2.2.4-Alpha",
"fw_version": "2.2.4-Alpha"
}
23 changes: 14 additions & 9 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,30 +224,35 @@ SOFTWARE. */

//////////////////////////////////////////////////////////////////////////
//
// Set Version JSON location
// File name for configuration JSON
//
#ifndef VERSIONJSONLOC
#define VERSIONJSONLOC "http://www.brewbubbles.com/firmware/version.json"
#ifndef CONFIGJSON
#define CONFIGJSON "/config.json"
#endif
//
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
//
// Firmware URL
// File name for version JSON
//
#ifndef FIRMWAREURL
#define FIRMWAREURL "http://www.brewbubbles.com/firmware/firmware.bin"
#ifndef VERSIONJSON
#define VERSIONJSON "/version.json"
#endif
//
//////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////
//
// LittleFS URL
// Upgrade URL
//
#ifndef LITTLEFSURL
#define LITTLEFSURL "http://www.brewbubbles.com/firmware/littlefs.bin"
#ifndef UPGRADEURL
// #define DOBETA // Comment out for prod code
#ifdef DOBETA
#define UPGRADEURL "http://firmware.brewbubbles.com/testing"
#else
#define UPGRADEURL "http://firmware.brewbubbles.com"
#endif
#endif
//
//////////////////////////////////////////////////////////////////////////
Expand Down
23 changes: 18 additions & 5 deletions src/execota.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,20 @@ void execfw()
saveConfig();

ESPhttpUpdate.setLedPin(LED, LOW);
// "http://www.brewbubbles.com/firmware/firmware.bin"
WiFiClient _client;
Log.verbose(F("Pulling Firmware from: %s" CR), F(FIRMWAREURL));
char url[128];
#ifdef DOBETA
strcpy(url, UPGRADEURL);
#else
strcpy(url, UPGRADEURL);
#endif
strcat(url, "/");
strcat(url, board());
strcat(url, "_firmware.bin");
Log.verbose(F("Pulling Firmware from: %s" CR), url);
config.nodrd = true;
saveConfig();
t_httpUpdate_return ret = ESPhttpUpdate.update(_client, F(FIRMWAREURL), "0");
t_httpUpdate_return ret = ESPhttpUpdate.update(_client, url, "0");

switch (ret)
{
Expand Down Expand Up @@ -108,8 +116,13 @@ void execspiffs()
ESPhttpUpdate.setLedPin(LED, LOW);
// "http://www.brewbubbles.com/firmware/spiffs.bin"
WiFiClient client;
Log.verbose(F("Pulling Filesystem from: %s" CR), F(LITTLEFSURL));
t_httpUpdate_return ret = ESPhttpUpdate.updateFS(client, F(LITTLEFSURL), "");
char url[128];
strcpy(url, UPGRADEURL);
strcat(url, "/");
strcat(url, board());
strcat(url, "_littlefs.bin");
Log.verbose(F("Pulling Filesystem from: %s" CR), url);
t_httpUpdate_return ret = ESPhttpUpdate.updateFS(client, url, "");

switch (ret)
{
Expand Down
1 change: 1 addition & 0 deletions src/execota.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ SOFTWARE. */
#include "tools.h"
#include "jsonconfig.h"
#include "webserver.h"
#include "version.h"
#include <ESP8266WiFi.h>
#include <ESP8266httpUpdate.h>
#include <ArduinoLog.h>
Expand Down
2 changes: 1 addition & 1 deletion src/jsonconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SOFTWARE. */

#include "jsonconfig.h"

const char *filename = "/config.json";
const char *filename = CONFIGJSON;
Config config;

extern const size_t capacitySerial = 1536;
Expand Down
2 changes: 1 addition & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void setup()
if (bubbles.start()) // Initialize bubble counter
Log.notice(F("Bubble counter initialized." CR));

Log.notice(F("Started %s version %s (%s) [%s]." CR), API_KEY, version(), branch(), build());
Log.notice(F("Started %s version %s/%s (%s) [%s]." CR), API_KEY, fw_version(), fs_version(), branch(), build());
}

void loop()
Expand Down
41 changes: 31 additions & 10 deletions src/thatVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ void sendRequest()
{
if (request.readyState() == 0 || request.readyState() == 4)
{
request.open("GET", VERSIONJSONLOC);
char url[128];
#ifdef DOBETA
strcpy(url, UPGRADEURL);
#else
strcpy(url, UPGRADEURL);
#endif
strcat(url, VERSIONJSON);
request.open("GET", url);
request.send();
}
}
Expand All @@ -51,8 +58,7 @@ void requestHandler(void *optParm, asyncHTTPrequest *request, int readyState)
bool serializeVersion(const ThatVersion &thatVersion, Print &dst)
{
// Serialize version
const size_t capacity = JSON_OBJECT_SIZE(1);
DynamicJsonDocument doc(capacity);
StaticJsonDocument<96> doc;

// Create an object at the root
JsonObject root = doc.to<JsonObject>();
Expand All @@ -67,8 +73,7 @@ bool serializeVersion(const ThatVersion &thatVersion, Print &dst)
bool deserializeVersion(const char *&src, ThatVersion &thatVersion)
{
// Deserialize version
const size_t capacity = JSON_OBJECT_SIZE(1) + 50;
DynamicJsonDocument doc(capacity);
StaticJsonDocument<128> doc;

// Parse the JSON object in the file
DeserializationError err = deserializeJson(doc, src);
Expand All @@ -92,14 +97,30 @@ void doPoll()

void ThatVersion::save(JsonObject obj) const
{
obj["version"] = version;
obj["fw_version"] = fw_version;
obj["fs_version"] = fs_version;
}

void ThatVersion::load(JsonObjectConst obj)
{
const char *v = obj["version"];
if (v)
strlcpy(version, v, sizeof(version));
const char *fw = obj["fw_version"];
if (fw)
strlcpy(fw_version, fw, sizeof(fw_version));
else
strlcpy(version, "0.0.0", sizeof(version)); // Default
{
const char *_fw = obj["version"];
if (_fw)
{
Log.notice(F("Deprecated version format detected." CR));
strlcpy(fw_version, _fw, sizeof(fw_version)); // Default
}
else
strlcpy(fw_version, "0.0.0", sizeof(fw_version)); // Default
}

const char *fs = obj["fs_version"];
if (fs)
strlcpy(fs_version, fs, sizeof(fs_version));
else
strlcpy(fs_version, "0.0.0", sizeof(fs_version)); // Default
}
3 changes: 2 additions & 1 deletion src/thatVersion.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ SOFTWARE. */

struct ThatVersion
{
char version[32] = {'0', '.', '0', '.', '0'};
char fw_version[32] = {'0', '.', '0', '.', '0'};
char fs_version[32] = {'0', '.', '0', '.', '0'};

void load(JsonObjectConst);
void save(JsonObject) const;
Expand Down

0 comments on commit 24c42b1

Please sign in to comment.