OTA with HTTP GET

  1. My goal is:

I would like to do OTA with HTTP GET. (https://mongoose-os.com/docs/mongoose-os/api/net/ota-http-client.md).

  1. My actions are:

I include the following in the mos.yml file:

    # ota-http-client
    - ["update.url", "s", {title : "Fetch updates from here"}]
    - ["update.interval", "i", {title : "Check for updates this often"}]
    - ["update.extra_http_headers", "s", {title : "Extra HTTP request headers"}]
    - ["update.ssl_ca_file", "s", "ca.pem", {title : "TLS CA file"}]
    - ["update.ssl_client_cert_file", "s", {title: "TLS client cert file"}]
    - ["update.ssl_server_name", "s", {title : "TLS Server Name"}]

    # ota-common
    - ["update", "o", {title: "Firmware updater"}]
    - ["update.timeout", "i", 600, {title : "Update will be aborted if it does not finish within this time"}]
    - ["update.commit_timeout", "i", {title : "After applying update, wait for commit up to this long"}]


    - origin: https://github.com/mongoose-os-libs/ota-http-client

I send a JSON file as a Google Cloud Platform config built-in MQTT message that the the following function handles:

mqtt::set_config_handler([](std::string topic, std::string msg) {
        (void)topic;

        bool if_ota;
        char *ota_url_c = NULL;
        char *ota_name_c = NULL;
        auto scanned_elements = json_scanf(msg.c_str(), strlen(msg.c_str()),
                                           "{if_ota: %B, ota_name: %Q, ota_url: %Q}",
                                           &if_ota, &ota_name_c, &ota_url_c);
        if (scanned_elements)
        {
            //std::string if_ota{if_ota_c};
            std::string ota_url{ota_url_c};
            std::string ota_name{ota_name_c};
            //free(if_ota_c);
            free(ota_url_c);
            free(ota_name_c);
            LOG(LL_INFO, ("if_ota true: %d", if_ota));
            LOG(LL_INFO, ("ota_name: %s", ota_name.c_str()));
            LOG(LL_INFO, ("ota_url: %s", ota_url.c_str()));
            if (if_ota == true)
            {
                LOG(LL_INFO, ("if_ota true, url: %s", ota_url.c_str()));
                ota->update(ota_url);
            }
        }
    });

which points to

void ota::update(const std::string& url) {
        //https:/github.com/mongoose-os-libs/ota-http-client
        mgos_ota_http_start(url.c_str(), &options);
    }

I also set the following in struct mgos_ota_opts options;

        options.timeout = 0;
        options.commit_timeout = 0;
        options.ignore_same_version = true;
  1. The result I see is:
[Mar 10 14:13:28.382] mgos_mqtt.c:141         MQTT TCP connect ok (0)
[Mar 10 14:13:30.838] mgos_mqtt.c:182         MQTT CONNACK 0
[Mar 10 14:13:30.838] mgos_mqtt.c:125         Subscribing to 'my/topic' (QoS 1)
[Mar 10 14:13:30.838] mgos_mqtt.c:125         Subscribing to '/devices/esp8266_5A44A7/config' (QoS 1)
[Mar 10 14:13:30.838] mgos_mqtt.c:125         Subscribing to '/devices/esp8266_5A44A7/commands/#' (QoS 1)
[Mar 10 14:13:30.838] mgos_mqtt.c:125         Subscribing to '/devices/esp8266_5A44A7/commands/#' (QoS 1)
[Mar 10 14:13:30.886] main.cpp:71             AFTER OTA BUILD (brighter is less intense)
[Mar 10 14:13:30.931] main.cpp:73             MQTT config topic: /devices/esp8266_5A44A7/config
[Mar 10 14:13:30.931] main.cpp:74             MQTT config message: {"if_ota": true, "ota_name": "recorded_ota_test_4", "ota_url": "https://somegcpstoragebucketname.storage.googleapis.com/fw.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=..."}
[Mar 10 14:13:31.021] main.cpp:91             if_ota true: 1
[Mar 10 14:13:31.021] main.cpp:92             ota_name: recorded_ota_test_4
[Mar 10 14:13:31.021] main.cpp:93             ota_url: https://somegcpstoragebucketname.storage.googleapis.com/fw.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=...
[Mar 10 14:13:31.108] main.cpp:96             if_ota true, url: https://somegcpstoragebucketname.storage.googleapis.com/fw.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=...
[Mar 10 14:13:31.152] mgos_ota_http_clien:270 Update URL: https://somegcpstoragebucketname.storage.googleapis.com/fw.zip?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=...
[Mar 10 14:13:31.349] mg_ssl_if_mbedtls.c:35  0x3fff4ddc ciphersuite: TLS-ECDHE-ECDSA-WITH-AES-128-GCM-SHA256
[Mar 10 14:13:31.907] SW ECDSA verify curve 3 hash_len 32 sig_len 72
[Mar 10 14:13:37.117] SW ECDH curve 3
[Mar 10 14:13:42.151] mgos_mongoose.c:66      New heap free LWM: 7560

  1. My expectation & question is:

I expect the OTA to work, as it already did work a couple weeks back. I suspect that something is on with my credentials either for GCP or with the CA file etc. I am really confused as to what could cause this. I do not get any error, and just simply do not know where to look. My question is if anyone has had experience with this and could help me out here. I would appreciate your kind help.

Best,
Mark