ESP32のhttp OTA実用的な操作をアップグレード

ESP32のhttp OTA実用的な操作をアップグレード

説明

ESP32 OTA調査レコードは、コメント暗号化サーバ証明書の検証プロセスでは、あなたの参考のために、テスト太田HTTPを行いました。

HTTPサーバ

ソフトウェアのダウンロードリンク:HFS
のオープンソフトウェアのプレスファームウェアを追加するためのアイコン:
ここに画像を挿入説明

コーディング

my_ota.c

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "esp_log.h"
#include "esp_err.h"
#include "esp_system.h"
#include "esp_https_ota.h"
#include "my_ota.h"

#define TAG "my_ota"

void test_ota_start(void)
{
	const esp_http_client_config_t config = {
		.url = "http://192.168.1.101:8000/hello-world.bin",
	};
	esp_err_t err = esp_https_ota(&config);
	if(err != ESP_OK){
		ESP_LOGE(TAG, "test_ota fail err:0x%x", err);
	}else{
		ESP_LOGI(TAG, "test_ota success");
		esp_restart();
	}
}

my_ota.h

#ifndef _MY_OTA_H_
#define _MY_OTA_H_

void test_ota_start(void);

#endif

esp-idf\components\esp_https_ota\src\esp_https_ota.c証明書の検証プロセスコメントは、他の変更を必要としません

esp_err_t esp_https_ota(const esp_http_client_config_t *config)
{
   ...
   ...
#if 0
    if (!config->cert_pem && !config->use_global_ca_store) {
        ESP_LOGE(TAG, "Server certificate not found, either through configuration or global CA store");
        return ESP_ERR_INVALID_ARG;
    }
#endif
    ...
    ...
#if 0
    if (esp_http_client_get_transport_type(client) != HTTP_TRANSPORT_OVER_SSL) {
        ESP_LOGE(TAG, "Transport is not over HTTPS");
        return ESP_FAIL;
    }
#endif
	...
	...
}

make menuconfig
ここに画像を挿入説明

注:次のようにOTAは、あなたが無線LANに接続する必要がアップグレードする前に、おそらくログは次のようになります。
ここに画像を挿入説明

出版元の記事 ウォンの賞賛1 ビュー147

おすすめ

転載: blog.csdn.net/weixin_40299863/article/details/103903695