added BTN
This commit is contained in:
parent
b63f965866
commit
73b9891e26
@ -14,8 +14,8 @@
|
||||
#include "esp_ota_ops.h"
|
||||
#include "esp_http_client.h"
|
||||
#include "esp_https_ota.h"
|
||||
#include "protocol_examples_common.h"
|
||||
#include "string.h"
|
||||
#include "driver/gpio.h"
|
||||
|
||||
#include "nvs.h"
|
||||
#include "nvs_flash.h"
|
||||
@ -25,14 +25,14 @@
|
||||
#include "esp_wifi.h"
|
||||
#endif
|
||||
|
||||
#include "LCD.h"
|
||||
|
||||
static const char *TAG = "simple_ota_example";
|
||||
extern const uint8_t server_cert_pem_start[] asm("_binary_ca_cert_pem_start");
|
||||
extern const uint8_t server_cert_pem_end[] asm("_binary_ca_cert_pem_end");
|
||||
|
||||
#define OTA_URL_SIZE 256
|
||||
|
||||
#define GPIO_BTN 0
|
||||
|
||||
esp_err_t _http_event_handler(esp_http_client_event_t *evt)
|
||||
{
|
||||
switch (evt->event_id) {
|
||||
@ -63,8 +63,17 @@ esp_err_t _http_event_handler(esp_http_client_event_t *evt)
|
||||
|
||||
void simple_ota_example_task(void *pvParameter)
|
||||
{
|
||||
ESP_LOGI(TAG, "Starting OTA example");
|
||||
ESP_LOGI(TAG, "Starting OTA example\n");
|
||||
ESP_LOGI(TAG, "Press BOOT BTN to start");
|
||||
|
||||
|
||||
for(;;) {
|
||||
if(gpio_get_level(0) == 0){
|
||||
break;
|
||||
}
|
||||
vTaskDelay(100 / portTICK_PERIOD_MS);
|
||||
}
|
||||
|
||||
esp_http_client_config_t config = {
|
||||
.url = CONFIG_EXAMPLE_FIRMWARE_UPGRADE_URL,
|
||||
.cert_pem = (char *)server_cert_pem_start,
|
||||
@ -103,6 +112,13 @@ void simple_ota_example_task(void *pvParameter)
|
||||
void app_main(void)
|
||||
{
|
||||
|
||||
gpio_config_t io_conf;
|
||||
io_conf.pin_bit_mask = (1ULL<<GPIO_BTN);
|
||||
io_conf.mode = GPIO_MODE_INPUT;
|
||||
io_conf.intr_type = GPIO_INTR_DISABLE;
|
||||
io_conf.pull_down_en = 1;
|
||||
gpio_config(&io_conf);
|
||||
|
||||
// Initialize NVS.
|
||||
esp_err_t err = nvs_flash_init();
|
||||
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
|
||||
@ -128,23 +144,8 @@ void app_main(void)
|
||||
/* Ensure to disable any WiFi power save mode, this allows best throughput
|
||||
* and hence timings for overall OTA operation.
|
||||
*/
|
||||
esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
//esp_wifi_set_ps(WIFI_PS_NONE);
|
||||
#endif // CONFIG_EXAMPLE_CONNECT_WIFI
|
||||
|
||||
|
||||
/*
|
||||
iLCD_init(); //init lcd screen
|
||||
|
||||
iLCD_clearFramebuffer(COLOR_BLACK); //set complete screen to desired color
|
||||
|
||||
vTaskDelay(1000 / portTICK_RATE_MS); //wait one sec
|
||||
|
||||
iLCD_writeString(42,42,"Hello World!",COLOR_WHITE,COLOR_BLACK); //Write text to screen
|
||||
|
||||
iLCD_writeString(42,50,"ESP32",COLOR_WHITE,COLOR_GREEN); //Write text to screen
|
||||
*/
|
||||
|
||||
|
||||
|
||||
xTaskCreate(&simple_ota_example_task, "ota_example_task", 8192, NULL, 5, NULL);
|
||||
}
|
||||
|
@ -75,13 +75,13 @@ CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0
|
||||
# Serial flasher config
|
||||
#
|
||||
CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB1"
|
||||
CONFIG_ESPTOOLPY_BAUD_115200B=y
|
||||
# CONFIG_ESPTOOLPY_BAUD_115200B is not set
|
||||
# CONFIG_ESPTOOLPY_BAUD_230400B is not set
|
||||
# CONFIG_ESPTOOLPY_BAUD_921600B is not set
|
||||
CONFIG_ESPTOOLPY_BAUD_921600B=y
|
||||
# CONFIG_ESPTOOLPY_BAUD_2MB is not set
|
||||
# CONFIG_ESPTOOLPY_BAUD_OTHER is not set
|
||||
CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200
|
||||
CONFIG_ESPTOOLPY_BAUD=115200
|
||||
CONFIG_ESPTOOLPY_BAUD=921600
|
||||
CONFIG_ESPTOOLPY_COMPRESSED=y
|
||||
# CONFIG_ESPTOOLPY_NO_STUB is not set
|
||||
# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set
|
||||
|
1107
sdkconfig.old
Normal file
1107
sdkconfig.old
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user