Skip to content

Commit

Permalink
Issue #36: Add support for ota/tag in config
Browse files Browse the repository at this point in the history
Issue #37: Add support for ota/server in config
Issue #38: ota status should show available server version for modem as
well as wifi
  • Loading branch information
markwj committed Apr 16, 2018
1 parent 9fabbea commit 29e3334
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
31 changes: 19 additions & 12 deletions vehicle/OVMS.V3/components/ovms_ota/src/ovms_ota.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,14 +192,18 @@ void ota_flash_http(int verbosity, OvmsWriter* writer, OvmsCommand* cmd, int arg
if (argc == 0)
{
// Automatically build the URL based on firmware
url = "api.openvehicles.com/firmware/ota/";
std::string tag = MyConfig.GetParamValue("ota","tag");
url = MyConfig.GetParamValue("ota","server","api.openvehicles.com/firmware/ota");
#ifdef CONFIG_OVMS_HW_BASE_3_0
url.append("v3.0/");
url.append("/v3.0/");
#endif //#ifdef CONFIG_OVMS_HW_BASE_3_0
#ifdef CONFIG_OVMS_HW_BASE_3_1
url.append("v3.1/");
url.append("/v3.1/");
#endif //#ifdef CONFIG_OVMS_HW_BASE_3_1
url.append(CONFIG_OVMS_VERSION_TAG);
if (tag.empty())
url.append(CONFIG_OVMS_VERSION_TAG);
else
url.append(tag);
url.append("/ovms3.bin");
}
else
Expand Down Expand Up @@ -439,7 +443,7 @@ void OvmsOTA::AutoFlashSD(std::string event, void* data)
OvmsOTA::OvmsOTA()
{
ESP_LOGI(TAG, "Initialising OTA (4400)");

MyConfig.RegisterParam("ota", "OTA setup and status", true, true);

#ifdef CONFIG_OVMS_COMP_SDCARD
Expand Down Expand Up @@ -474,24 +478,27 @@ void OvmsOTA::GetStatus(ota_info& info, bool check_update /*=true*/)
info.version_server = "";
info.partition_running = "";
info.partition_boot = "";

OvmsMetricString* m = StandardMetrics.ms_m_version;
if (m != NULL)
{
info.version_firmware = m->AsString();

if (check_update && MyNetManager.m_connected_wifi)
if (check_update && MyNetManager.m_connected_any)
{
// We have a wifi connection, so let's try to find out the version the server has
std::string url;
url = "api.openvehicles.com/firmware/ota/";
std::string tag = MyConfig.GetParamValue("ota","tag");
std::string url = MyConfig.GetParamValue("ota","server","api.openvehicles.com/firmware/ota");
#ifdef CONFIG_OVMS_HW_BASE_3_0
url.append("v3.0/");
url.append("/v3.0/");
#endif //#ifdef CONFIG_OVMS_HW_BASE_3_0
#ifdef CONFIG_OVMS_HW_BASE_3_1
url.append("v3.1/");
url.append("/v3.1/");
#endif //#ifdef CONFIG_OVMS_HW_BASE_3_1
url.append(CONFIG_OVMS_VERSION_TAG);
if (tag.empty())
url.append(CONFIG_OVMS_VERSION_TAG);
else
url.append(tag);
url.append("/ovms3.ver");

OvmsHttpClient http(url);
Expand Down
8 changes: 7 additions & 1 deletion vehicle/OVMS.V3/main/ovms_version.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static const char *TAG = "version";
#include <esp_ota_ops.h>
#include "ovms.h"
#include "ovms_version.h"
#include "ovms_config.h"
#include "ovms_metrics.h"
#include "metrics_standard.h"
#include "ovms_events.h"
Expand All @@ -46,15 +47,20 @@ std::string GetOVMSVersion()
{
std::string searchversion(OVMS_VERSION_PREFIX OVMS_VERSION OVMS_VERSION_POSTFIX);
std::string version(OVMS_VERSION);
std::string tag = MyConfig.GetParamValue("ota","tag");

const esp_partition_t *p = esp_ota_get_running_partition();
if (p != NULL)
{
version.append("/");
version.append(p->label);
}

version.append("/");
version.append(CONFIG_OVMS_VERSION_TAG);
if (tag.empty())
version.append(CONFIG_OVMS_VERSION_TAG);
else
version.append(tag);

return version;
}
Expand Down

0 comments on commit 29e3334

Please sign in to comment.