added https_client and menuconfig

This commit is contained in:
2021-01-05 12:15:26 +01:00
parent d570ce8cc7
commit 91edfa0c63
8 changed files with 644 additions and 58 deletions

View File

@ -124,22 +124,17 @@ menu "Mesh OTA Configuration"
help
Authentication mode.
config WIFI_AUTH_OPEN
bool "WIFI_AUTH_OPEN"
config WIFI_AUTH_WPA_PSK
bool "WIFI_AUTH_WPA_PSK"
config WIFI_AUTH_WPA2_PSK
bool "WIFI_AUTH_WPA2_PSK"
config WIFI_AUTH_WPA_WPA2_PSK
bool "WIFI_AUTH_WPA_WPA2_PSK"
config WIFI_AUTH_WPA2_ENTERPRISE
bool "WIFI_AUTH_WPA2_ENTERPRISE"
endchoice
config MESH_AP_AUTHMODE
int
default 0 if WIFI_AUTH_OPEN
default 2 if WIFI_AUTH_WPA_PSK
default 3 if WIFI_AUTH_WPA2_PSK
default 4 if WIFI_AUTH_WPA_WPA2_PSK
default 5 if WIFI_AUTH_WPA2_ENTERPRISE
help
Mesh AP authentication mode.
@ -162,4 +157,29 @@ menu "Mesh OTA Configuration"
default 50
help
The number of devices over the network(max: 300).
config OTA_HTTPS_SERVER_COMMON_NAME
string "Common name OTA server"
default "exmaple.com"
help
Fully Qualified Domain Name used in the certificate.
config OTA_HTTPS_SERVER_PORT
string "Server port"
default "443"
help
HTTPS webserver port
config OTA_HTTPS_URL
string "URL to ota image"
default "https://exmaple.com/theImage.bin"
help
Uniform Resource Locator to the image file
config OTA_HTTPS_AUTH
string "HTTPS authentication"
default "base64(user:password)"
help
HTTPS basic auth using base64 decoded "user:password"
endmenu

View File

@ -17,8 +17,6 @@
#define RX_SIZE (1234)
#define TX_SIZE (1234)
static const char *MESH_TAG = "mesh_main";
static const uint8_t MESH_ID[6] = { 0x77, 0x77, 0x77, 0x77, 0x77, 0x77};
static uint8_t tx_buf[TX_SIZE] = { 0, };
@ -477,6 +475,54 @@ void ip_event_handler(void *arg, esp_event_base_t event_base,
}
static void test(void *pvParameters)
{
esp_err_t err;
ESP_LOGI(MESH_TAG, "Hello World");
const esp_partition_t * currentPartition = esp_ota_get_boot_partition();
ESP_LOGI(MESH_TAG, "Type: %d", (*currentPartition).subtype);
ESP_LOGI(MESH_TAG, "Start address: %d", (*currentPartition).address);
ESP_LOGI(MESH_TAG, "Size: %d", (*currentPartition).size);
ESP_LOGI(MESH_TAG, "Encrypted: %d", (*currentPartition).encrypted);
esp_app_desc_t curPartitionDesc;
err = esp_ota_get_partition_description(currentPartition, &curPartitionDesc);
ESP_ERROR_CHECK(err);
ESP_LOGI(MESH_TAG, "currentPartition project_name: %s", (curPartitionDesc).project_name);
ESP_LOGI(MESH_TAG, "currentPartition version: %s", (curPartitionDesc).version);
ESP_LOGI(MESH_TAG, "currentPartition Timestamp: %s %s", (curPartitionDesc).date, (curPartitionDesc).time);
https_clientInitialize();
uint32_t u32BufferLenght = 1024U;
unsigned char buffer[1024U];
uint32_t u32BytesRead = 0;
https_clientRetrieveData(buffer, &u32BufferLenght, &u32BytesRead);
// Print response directly to stdout as it is read
for(uint32_t i = 0; i < u32BytesRead; i++) {
putchar(buffer[i]);
// printf("%x ", buffer[i]);
}
printf("\n END \n");
https_clientDeinitialize();
char test[] = "1.2.3";
if(bNewerVersion((curPartitionDesc).version, test)){
ESP_LOGI(MESH_TAG, "Newer Version available");
}
while(1)
{
}
}
void app_main(void)
@ -485,10 +531,7 @@ void app_main(void)
esp_err_t err;
/*
err = nvs_flash_erase();
if(err != ESP_OK){
ESP_LOGI(MESH_TAG, "Error: %x", err);
while(1){
@ -499,31 +542,6 @@ void app_main(void)
ESP_ERROR_CHECK(nvs_flash_init());
ESP_LOGI(MESH_TAG, "Hello World");
const esp_partition_t * currentPartition = esp_ota_get_boot_partition();
ESP_LOGI(MESH_TAG, "Type: %d", (*currentPartition).subtype);
ESP_LOGI(MESH_TAG, "Start address: %d", (*currentPartition).address);
ESP_LOGI(MESH_TAG, "Size: %d", (*currentPartition).size); //passt
ESP_LOGI(MESH_TAG, "Encrypted: %d", (*currentPartition).encrypted);
esp_app_desc_t curPartitionDesc;
err = esp_ota_get_partition_description(currentPartition, &curPartitionDesc);
ESP_ERROR_CHECK(err);
ESP_LOGI(MESH_TAG, "currentPartition project_name: %s", (curPartitionDesc).project_name);
ESP_LOGI(MESH_TAG, "currentPartition version: %s", (curPartitionDesc).version);
ESP_LOGI(MESH_TAG, "currentPartition Timestamp: %s %s", (curPartitionDesc).date, (curPartitionDesc).time);
char test[] = "1.2.3";
if(bNewerVersion((curPartitionDesc).version, test)){
ESP_LOGI(MESH_TAG, "Newer Version available");
}
/* tcpip initialization */
ESP_ERROR_CHECK(esp_netif_init());
@ -587,12 +605,14 @@ void app_main(void)
esp_mesh_get_topology(), esp_mesh_get_topology() ? "(chain)":"(tree)", esp_mesh_is_ps_enabled());
for(;;) {
if(gpio_get_level(0) == 0){
break;
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
}
xTaskCreate(&test, "test_task", 8192, NULL, 5, NULL);
}