show binary file, generated by server
All checks were successful
Build and Push Multi-Arch Docker Image / build-and-push (push) Successful in 15m48s
All checks were successful
Build and Push Multi-Arch Docker Image / build-and-push (push) Successful in 15m48s
Signed-off-by: Peter Siegmund <developer@mars3142.org>
This commit is contained in:
@@ -170,13 +170,12 @@ lv_fs_res_t fs_seek(lv_fs_drv_t *drv, void *file_p, uint32_t pos, lv_fs_whence_t
|
||||
case LV_FS_SEEK_CUR:
|
||||
f_lseek((FIL *)file_p, f_tell((FIL *)file_p) + pos);
|
||||
break;
|
||||
case LV_FS_SEEK_END:
|
||||
{
|
||||
FSIZE_t fsize = f_size((FIL *)file_p);
|
||||
ESP_LOGI(TAG, "fs_seek to end, file size: %lu", (unsigned long)fsize);
|
||||
f_lseek((FIL *)file_p, fsize + pos);
|
||||
}
|
||||
break;
|
||||
case LV_FS_SEEK_END: {
|
||||
FSIZE_t fsize = f_size((FIL *)file_p);
|
||||
ESP_LOGI(TAG, "fs_seek to end, file size: %lu", (unsigned long)fsize);
|
||||
f_lseek((FIL *)file_p, fsize + pos);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
dependencies:
|
||||
espressif/esp_lvgl_port:
|
||||
component_hash: bb938deffba7d80b2ce582a796c053681b0439e0a7033666688e0f1f5b921125
|
||||
component_hash:
|
||||
bb938deffba7d80b2ce582a796c053681b0439e0a7033666688e0f1f5b921125
|
||||
dependencies:
|
||||
- name: idf
|
||||
require: private
|
||||
@@ -18,7 +19,8 @@ dependencies:
|
||||
type: idf
|
||||
version: 5.5.1
|
||||
lovyan03/LovyanGFX:
|
||||
component_hash: a2345b5bcee38d6348e3d893bfd45ced564a542c30d17d3f91fde8e5cace02fd
|
||||
component_hash:
|
||||
a2345b5bcee38d6348e3d893bfd45ced564a542c30d17d3f91fde8e5cace02fd
|
||||
dependencies: []
|
||||
source:
|
||||
git: https://github.com/lovyan03/LovyanGFX.git
|
||||
@@ -26,7 +28,8 @@ dependencies:
|
||||
type: git
|
||||
version: 55a0f66d9278faa596c8d51a8e8a3e537dd8f44f
|
||||
lvgl/lvgl:
|
||||
component_hash: b702d642e03e95928046d5c6726558e6444e112420c77efa5fdb6650b0a13c5d
|
||||
component_hash:
|
||||
b702d642e03e95928046d5c6726558e6444e112420c77efa5fdb6650b0a13c5d
|
||||
dependencies: []
|
||||
source:
|
||||
registry_url: https://components.espressif.com/
|
||||
|
||||
16186
firmware/main/image.h
16186
firmware/main/image.h
File diff suppressed because it is too large
Load Diff
@@ -2,88 +2,93 @@
|
||||
|
||||
LGFX::LGFX(void)
|
||||
{
|
||||
{ // バス制御の設定を行います。
|
||||
auto cfg = _bus_instance.config(); // バス設定用の構造体を取得します。
|
||||
// 8ビットパラレルバスの設定
|
||||
// cfg.i2s_port = I2S_NUM_0; // 使用するI2Sポートを選択 (I2S_NUM_0 or I2S_NUM_1) (ESP32のI2S LCDモードを使用します)
|
||||
cfg.freq_write = 20000000; // 送信クロック (最大20MHz, 80MHzを整数で割った値に丸められます)
|
||||
cfg.pin_wr = 47; // WR を接続しているピン番号
|
||||
cfg.pin_rd = -1; // RD を接続しているピン番号
|
||||
cfg.pin_rs = 0; // RS(D/C)を接続しているピン番号
|
||||
cfg.pin_d0 = 9; // D0を接続しているピン番号
|
||||
cfg.pin_d1 = 46; // D1を接続しているピン番号
|
||||
cfg.pin_d2 = 3; // D2を接続しているピン番号
|
||||
cfg.pin_d3 = 8; // D3を接続しているピン番号
|
||||
cfg.pin_d4 = 18; // D4を接続しているピン番号
|
||||
cfg.pin_d5 = 17; // D5を接続しているピン番号
|
||||
cfg.pin_d6 = 16; // D6を接続しているピン番号
|
||||
cfg.pin_d7 = 15; // D7を接続しているピン番号
|
||||
_bus_instance.config(cfg); // 設定値をバスに反映します。
|
||||
_panel_instance.setBus(&_bus_instance); // バスをパネルにセットします。
|
||||
{ // Configure bus control settings
|
||||
auto cfg = _bus_instance.config(); // Get structure for bus configuration
|
||||
// 8-bit parallel bus configuration
|
||||
// cfg.i2s_port = I2S_NUM_0; // Select I2S port to use (I2S_NUM_0 or I2S_NUM_1) (ESP32 I2S
|
||||
// LCD mode is used)
|
||||
cfg.freq_write = 20000000; // Transmission clock (max 20MHz, rounded to integer division of 80MHz)
|
||||
cfg.pin_wr = 47; // Pin number connected to WR
|
||||
cfg.pin_rd = -1; // Pin number connected to RD
|
||||
cfg.pin_rs = 0; // Pin number connected to RS(D/C)
|
||||
cfg.pin_d0 = 9; // Pin number connected to D0
|
||||
cfg.pin_d1 = 46; // Pin number connected to D1
|
||||
cfg.pin_d2 = 3; // Pin number connected to D2
|
||||
cfg.pin_d3 = 8; // Pin number connected to D3
|
||||
cfg.pin_d4 = 18; // Pin number connected to D4
|
||||
cfg.pin_d5 = 17; // Pin number connected to D5
|
||||
cfg.pin_d6 = 16; // Pin number connected to D6
|
||||
cfg.pin_d7 = 15; // Pin number connected to D7
|
||||
_bus_instance.config(cfg); // Apply configuration values to bus
|
||||
_panel_instance.setBus(&_bus_instance); // Set bus to panel
|
||||
}
|
||||
|
||||
{ // 表示パネル制御の設定を行います。
|
||||
auto cfg = _panel_instance.config(); // 表示パネル設定用の構造体を取得します。
|
||||
{ // Configure display panel control settings
|
||||
auto cfg = _panel_instance.config(); // Get structure for display panel configuration
|
||||
|
||||
cfg.pin_cs = -1; // CSが接続されているピン番号 (-1 = disable)
|
||||
cfg.pin_rst = 4; // RSTが接続されているピン番号 (-1 = disable)
|
||||
cfg.pin_busy = -1; // BUSYが接続されているピン番号 (-1 = disable)
|
||||
cfg.pin_cs = -1; // Pin number connected to CS (-1 = disable)
|
||||
cfg.pin_rst = 4; // Pin number connected to RST (-1 = disable)
|
||||
cfg.pin_busy = -1; // Pin number connected to BUSY (-1 = disable)
|
||||
|
||||
// ※ 以下の設定値はパネル毎に一般的な初期値が設定されていますので、不明な項目はコメントアウトして試してみてください。
|
||||
// Note:
|
||||
// The following configuration values have common default values set for each panel, so please comment out
|
||||
// unknown items and try them.
|
||||
|
||||
cfg.panel_width = 320; // 実際に表示可能な幅
|
||||
cfg.panel_height = 480; // 実際に表示可能な高さ
|
||||
cfg.offset_x = 0; // パネルのX方向オフセット量
|
||||
cfg.offset_y = 0; // パネルのY方向オフセット量
|
||||
cfg.offset_rotation = 0; // 回転方向の値のオフセット 0~7 (4~7は上下反転)
|
||||
cfg.dummy_read_pixel = 8; // ピクセル読出し前のダミーリードのビット数
|
||||
cfg.dummy_read_bits = 1; // ピクセル以外のデータ読出し前のダミーリードのビット数
|
||||
cfg.readable = true; // データ読出しが可能な場合 trueに設定
|
||||
cfg.invert = true; // パネルの明暗が反転してしまう場合 trueに設定
|
||||
cfg.rgb_order = false; // パネルの赤と青が入れ替わってしまう場合 trueに設定
|
||||
cfg.dlen_16bit = false; // 16bitパラレルやSPIでデータ長を16bit単位で送信するパネルの場合 trueに設定
|
||||
cfg.bus_shared = true; // SDカードとバスを共有している場合 trueに設定(drawJpgFile等でバス制御を行います)
|
||||
cfg.panel_width = 320; // Actual displayable width
|
||||
cfg.panel_height = 480; // Actual displayable height
|
||||
cfg.offset_x = 0; // Panel X direction offset amount
|
||||
cfg.offset_y = 0; // Panel Y direction offset amount
|
||||
cfg.offset_rotation = 0; // Rotation direction value offset 0~7 (4~7 are upside down)
|
||||
cfg.dummy_read_pixel = 8; // Number of dummy read bits before pixel reading
|
||||
cfg.dummy_read_bits = 1; // Number of dummy read bits before reading data other than pixels
|
||||
cfg.readable = true; // Set to true if data reading is possible
|
||||
cfg.invert = true; // Set to true if panel brightness is inverted
|
||||
cfg.rgb_order = false; // Set to true if panel red and blue are swapped
|
||||
cfg.dlen_16bit =
|
||||
false; // Set to true for panels that send data length in 16-bit units via 16-bit parallel or SPI
|
||||
cfg.bus_shared = true; // Set to true if sharing bus with SD card (bus control is performed by drawJpgFile etc.)
|
||||
|
||||
// 以下はST7735やILI9163のようにピクセル数が可変のドライバで表示がずれる場合にのみ設定してください。
|
||||
// cfg.memory_width = 240; // ドライバICがサポートしている最大の幅
|
||||
// cfg.memory_height = 320; // ドライバICがサポートしている最大の高さ
|
||||
// The following should only be set if the display is misaligned on drivers with variable pixel counts like
|
||||
// ST7735 or ILI9163.
|
||||
// cfg.memory_width = 240; // Maximum width supported by driver IC
|
||||
// cfg.memory_height = 320; // Maximum height supported by driver IC
|
||||
|
||||
_panel_instance.config(cfg);
|
||||
}
|
||||
|
||||
//*
|
||||
{ // バックライト制御の設定を行います。(必要なければ削除)
|
||||
auto cfg = _light_instance.config(); // バックライト設定用の構造体を取得します。
|
||||
{ // Configure backlight control settings (delete if not needed)
|
||||
auto cfg = _light_instance.config(); // Get structure for backlight configuration
|
||||
|
||||
cfg.pin_bl = 45; // バックライトが接続されているピン番号
|
||||
cfg.invert = false; // バックライトの輝度を反転させる場合 true
|
||||
cfg.freq = 44100; // バックライトのPWM周波数
|
||||
cfg.pwm_channel = 7; // 使用するPWMのチャンネル番号
|
||||
cfg.pin_bl = 45; // Pin number connected to backlight
|
||||
cfg.invert = false; // Set to true to invert backlight brightness
|
||||
cfg.freq = 44100; // Backlight PWM frequency
|
||||
cfg.pwm_channel = 7; // PWM channel number to use
|
||||
|
||||
_light_instance.config(cfg);
|
||||
_panel_instance.setLight(&_light_instance); // バックライトをパネルにセットします。
|
||||
_panel_instance.setLight(&_light_instance); // Set backlight to panel
|
||||
}
|
||||
|
||||
{ // タッチスクリーン制御の設定を行います。(必要なければ削除)
|
||||
{ // Configure touch screen control settings (delete if not needed)
|
||||
auto cfg = _touch_instance.config();
|
||||
|
||||
cfg.x_min = 0; // タッチスクリーンから得られる最小のX値(生の値)
|
||||
cfg.x_max = 319; // タッチスクリーンから得られる最大のX値(生の値)
|
||||
cfg.y_min = 0; // タッチスクリーンから得られる最小のY値(生の値)
|
||||
cfg.y_max = 479; // タッチスクリーンから得られる最大のY値(生の値)
|
||||
cfg.pin_int = 7; // INTが接続されているピン番号
|
||||
cfg.bus_shared = true; // 画面と共通のバスを使用している場合 trueを設定
|
||||
cfg.offset_rotation = 0; // 表示とタッチの向きのが一致しない場合の調整 0~7の値で設定
|
||||
// I2C接続の場合
|
||||
cfg.i2c_port = 1; // 使用するI2Cを選択 (0 or 1)
|
||||
cfg.i2c_addr = 0x38; // I2Cデバイスアドレス番号
|
||||
cfg.pin_sda = 6; // SDAが接続されているピン番号
|
||||
cfg.pin_scl = 5; // SCLが接続されているピン番号
|
||||
cfg.freq = 400000; // I2Cクロックを設定
|
||||
cfg.x_min = 0; // Minimum X value obtained from touch screen (raw value)
|
||||
cfg.x_max = 319; // Maximum X value obtained from touch screen (raw value)
|
||||
cfg.y_min = 0; // Minimum Y value obtained from touch screen (raw value)
|
||||
cfg.y_max = 479; // Maximum Y value obtained from touch screen (raw value)
|
||||
cfg.pin_int = 7; // Pin number connected to INT
|
||||
cfg.bus_shared = true; // Set to true if using common bus with screen
|
||||
cfg.offset_rotation = 0; // Adjustment when display and touch orientation don't match, set value 0~7
|
||||
// For I2C connection
|
||||
cfg.i2c_port = 1; // Select I2C to use (0 or 1)
|
||||
cfg.i2c_addr = 0x38; // I2C device address number
|
||||
cfg.pin_sda = 6; // Pin number connected to SDA
|
||||
cfg.pin_scl = 5; // Pin number connected to SCL
|
||||
cfg.freq = 400000; // Set I2C clock
|
||||
|
||||
_touch_instance.config(cfg);
|
||||
_panel_instance.setTouch(&_touch_instance); // タッチスクリーンをパネルにセットします。
|
||||
_panel_instance.setTouch(&_touch_instance); // Set touch screen to panel
|
||||
}
|
||||
//*/
|
||||
setPanel(&_panel_instance); // 使用するパネルをセットします。
|
||||
setPanel(&_panel_instance); // Set panel to use
|
||||
};
|
||||
|
||||
@@ -2,23 +2,31 @@
|
||||
#include <lvgl.h>
|
||||
|
||||
#include "esp_err.h"
|
||||
#include "esp_heap_caps.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_task_wdt.h"
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/task.h"
|
||||
|
||||
#include "ff.h"
|
||||
#include "image.h"
|
||||
#include "storage.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
#define screenWidth (480)
|
||||
#define screenHeight (320)
|
||||
#define DISPLAY_WIDTH (480)
|
||||
#define DISPLAY_HEIGHT (320)
|
||||
|
||||
const unsigned int lvBufferSize = screenWidth * screenHeight / 10 * (LV_COLOR_DEPTH / 8);
|
||||
const unsigned int lvBufferSize = DISPLAY_WIDTH * DISPLAY_HEIGHT / 10 * (LV_COLOR_DEPTH / 8);
|
||||
uint8_t lvBuffer1[lvBufferSize];
|
||||
uint8_t lvBuffer2[lvBufferSize];
|
||||
|
||||
static const char *TAG = "main";
|
||||
|
||||
LGFX tft;
|
||||
static FATFS fs;
|
||||
|
||||
// Image cache variables
|
||||
static uint8_t *image_cache = NULL;
|
||||
static size_t image_cache_size = 0;
|
||||
static lv_image_dsc_t cached_image_dsc;
|
||||
|
||||
void setup_tft(void)
|
||||
{
|
||||
@@ -52,25 +60,86 @@ void my_touch_read(lv_indev_t *indev_driver, lv_indev_data_t *data)
|
||||
}
|
||||
}
|
||||
|
||||
void fatfs_lvgl_init(void)
|
||||
bool load_image_to_cache(const char *filename)
|
||||
{
|
||||
// 1. Das Dateisystem "mounten" (einmalig für FatFS)
|
||||
f_mount(&fs, "S:", 1); // "S:" ist der Laufwerksbuchstabe
|
||||
FIL file;
|
||||
FRESULT result = f_open(&file, filename, FA_READ);
|
||||
if (result != FR_OK)
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to open %s: %d", filename, result);
|
||||
return false;
|
||||
}
|
||||
|
||||
// 2. Eine Treiber-Variable deklarieren
|
||||
static lv_fs_drv_t drv;
|
||||
lv_fs_drv_init(&drv); // Treiberstruktur initialisieren
|
||||
// Determine file size
|
||||
FSIZE_t file_size = f_size(&file);
|
||||
ESP_LOGI(TAG, "Image file size: %d bytes", (int)file_size);
|
||||
|
||||
// 3. Unsere Bridge-Funktionen zuweisen
|
||||
drv.letter = 'S'; // WICHTIG: Muss mit dem Buchstaben in f_mount übereinstimmen
|
||||
drv.open_cb = fs_open;
|
||||
drv.close_cb = fs_close;
|
||||
drv.read_cb = fs_read;
|
||||
drv.seek_cb = fs_seek;
|
||||
drv.tell_cb = fs_tell;
|
||||
// Allocate memory for entire image (prefer PSRAM)
|
||||
image_cache = (uint8_t *)heap_caps_malloc(file_size, MALLOC_CAP_SPIRAM | MALLOC_CAP_8BIT);
|
||||
if (image_cache == NULL)
|
||||
{
|
||||
ESP_LOGW(TAG, "Failed to allocate PSRAM, trying internal RAM");
|
||||
// Fallback to internal RAM
|
||||
image_cache = (uint8_t *)malloc(file_size);
|
||||
}
|
||||
|
||||
// 4. Den Treiber bei LVGL registrieren
|
||||
lv_fs_drv_register(&drv);
|
||||
if (image_cache == NULL)
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to allocate memory for image cache");
|
||||
f_close(&file);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check which memory type is used
|
||||
bool is_psram = esp_ptr_external_ram(image_cache);
|
||||
ESP_LOGI(TAG, "Image cache allocated in %s: %d bytes", is_psram ? "PSRAM" : "internal RAM", (int)file_size);
|
||||
|
||||
// Read entire image in one go
|
||||
UINT bytes_read;
|
||||
result = f_read(&file, image_cache, file_size, &bytes_read);
|
||||
f_close(&file);
|
||||
|
||||
if (result != FR_OK || bytes_read != file_size)
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to read image file completely");
|
||||
free(image_cache);
|
||||
image_cache = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
image_cache_size = file_size;
|
||||
|
||||
// Read image header from first bytes (LVGL BIN format)
|
||||
if (image_cache_size >= 4)
|
||||
{
|
||||
// Parse LVGL BIN header
|
||||
lv_image_header_t *header = (lv_image_header_t *)image_cache;
|
||||
|
||||
// Set up image descriptor for LVGL with correct header data
|
||||
cached_image_dsc.header.w = header->w;
|
||||
cached_image_dsc.header.h = header->h;
|
||||
cached_image_dsc.header.cf = header->cf;
|
||||
cached_image_dsc.header.flags = header->flags;
|
||||
cached_image_dsc.header.stride = header->stride;
|
||||
cached_image_dsc.data_size = image_cache_size;
|
||||
cached_image_dsc.data = image_cache;
|
||||
|
||||
ESP_LOGI(TAG, "Image header: %dx%d, format: %d", header->w, header->h, header->cf);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Fallback for unknown format
|
||||
cached_image_dsc.header.w = 0;
|
||||
cached_image_dsc.header.h = 0;
|
||||
cached_image_dsc.header.cf = LV_COLOR_FORMAT_UNKNOWN;
|
||||
cached_image_dsc.header.flags = 0;
|
||||
cached_image_dsc.header.stride = 0;
|
||||
cached_image_dsc.data_size = image_cache_size;
|
||||
cached_image_dsc.data = image_cache;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Image successfully loaded to cache (%d bytes)", (int)image_cache_size);
|
||||
return true;
|
||||
}
|
||||
|
||||
void esp_lv_log_print(lv_log_level_t level, const char *buf)
|
||||
@@ -106,9 +175,8 @@ void setup()
|
||||
lv_log_register_print_cb(esp_lv_log_print);
|
||||
|
||||
fs_mount();
|
||||
fatfs_lvgl_init();
|
||||
|
||||
static auto *display = lv_display_create(screenWidth, screenHeight);
|
||||
static auto *display = lv_display_create(DISPLAY_WIDTH, DISPLAY_HEIGHT);
|
||||
lv_display_set_color_format(display, LV_COLOR_FORMAT_RGB565);
|
||||
lv_display_set_flush_cb(display, flush);
|
||||
lv_display_set_buffers(display, lvBuffer1, lvBuffer2, lvBufferSize, LV_DISPLAY_RENDER_MODE_PARTIAL);
|
||||
@@ -118,15 +186,19 @@ void setup()
|
||||
lv_indev_set_read_cb(lvInput, my_touch_read);
|
||||
|
||||
ESP_LOGI(TAG, "create image");
|
||||
#ifndef LOCAL
|
||||
static auto *image = lv_image_create(lv_scr_act());
|
||||
lv_image_set_src(image, &image_data);
|
||||
lv_obj_align(image, LV_ALIGN_TOP_LEFT, 0, 0);
|
||||
#else
|
||||
lv_obj_t *img = lv_image_create(lv_screen_active());
|
||||
lv_image_set_src(img, "S:/response.png"); // Pfad beginnt mit "S:"
|
||||
lv_obj_center(img);
|
||||
#endif
|
||||
|
||||
// Load image once into cache
|
||||
if (load_image_to_cache("/poster.bin"))
|
||||
{
|
||||
lv_obj_t *img = lv_image_create(lv_screen_active());
|
||||
lv_image_set_src(img, &cached_image_dsc); // Use cached image data
|
||||
lv_obj_center(img);
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to load image from cache");
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "image created");
|
||||
}
|
||||
|
||||
@@ -137,6 +209,26 @@ void loop()
|
||||
vTaskDelay(pdMS_TO_TICKS(10));
|
||||
}
|
||||
|
||||
void cleanup_image_cache(void)
|
||||
{
|
||||
if (image_cache != NULL)
|
||||
{
|
||||
// Use heap_caps_free since we used heap_caps_malloc
|
||||
if (esp_ptr_external_ram(image_cache))
|
||||
{
|
||||
ESP_LOGI(TAG, "Freeing PSRAM image cache");
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGI(TAG, "Freeing internal RAM image cache");
|
||||
}
|
||||
heap_caps_free(image_cache);
|
||||
image_cache = NULL;
|
||||
image_cache_size = 0;
|
||||
ESP_LOGI(TAG, "Image cache cleaned up");
|
||||
}
|
||||
}
|
||||
|
||||
void lvgl_task(void *pvParameter)
|
||||
{
|
||||
setup();
|
||||
@@ -144,6 +236,8 @@ void lvgl_task(void *pvParameter)
|
||||
{
|
||||
loop();
|
||||
}
|
||||
|
||||
cleanup_image_cache();
|
||||
fs_unmount();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#include "esp_wifi.h"
|
||||
#include "esp_event.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_wifi.h"
|
||||
#include "nvs_flash.h"
|
||||
|
||||
static const char *TAG = "WPS_EXAMPLE";
|
||||
|
||||
// Funktion, um WPS zu starten (z.B. durch Button-Interrupt aufgerufen)
|
||||
// Function to start WPS (e.g., called by button interrupt)
|
||||
void start_wps_process()
|
||||
{
|
||||
ESP_LOGI(TAG, "Starting WPS...");
|
||||
@@ -14,8 +14,7 @@ void start_wps_process()
|
||||
// ESP_ERROR_CHECK(esp_wifi_wps_start(0)); // Start WPS indefinitely (handle timeout via event)
|
||||
}
|
||||
|
||||
static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
static void wifi_event_handler(void *arg, esp_event_base_t event_base, int32_t event_id, void *event_data)
|
||||
{
|
||||
if (event_base == WIFI_EVENT)
|
||||
{
|
||||
@@ -23,51 +22,51 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
||||
{
|
||||
case WIFI_EVENT_STA_START:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_START: Wi-Fi station started.");
|
||||
// Option 1: Start WPS direkt hier
|
||||
// Option 1: Start WPS directly here
|
||||
// start_wps_process();
|
||||
// Option 2: Warten auf externen Trigger (z.B. Button), siehe start_wps_process()
|
||||
// Optional: Versuchen, sich normal zu verbinden, falls Zugangsdaten gespeichert sind
|
||||
// Option 2: Wait for external trigger (e.g., button), see start_wps_process()
|
||||
// Optional: Try to connect normally if credentials are stored
|
||||
// esp_wifi_connect();
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_CONNECTED:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_CONNECTED");
|
||||
// Falls verbunden (z.B. aus Flash), WPS deaktivieren, falls es noch lief
|
||||
// If connected (e.g., from flash), disable WPS if it was still running
|
||||
// esp_wifi_wps_disable();
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_DISCONNECTED:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_DISCONNECTED");
|
||||
// Eventuell normalen Verbindungsversuch starten oder auf WPS-Trigger warten
|
||||
// esp_wifi_connect(); // Oder: Warte auf Button für WPS
|
||||
// Possibly start normal connection attempt or wait for WPS trigger
|
||||
// esp_wifi_connect(); // Or: Wait for button for WPS
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_WPS_ER_SUCCESS:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_WPS_ER_SUCCESS");
|
||||
// WPS erfolgreich, Zugangsdaten wurden empfangen.
|
||||
// Der Wi-Fi Stack versucht nun automatisch, sich zu verbinden.
|
||||
// WPS deaktivieren.
|
||||
// WPS successful, credentials were received.
|
||||
// The Wi-Fi stack now automatically tries to connect.
|
||||
// Disable WPS.
|
||||
ESP_ERROR_CHECK(esp_wifi_wps_disable());
|
||||
// Optional: Zugangsdaten auslesen und speichern, falls nötig (normalerweise nicht erforderlich, da der Stack sie intern nutzt)
|
||||
// Optional: Read and save credentials if needed (usually not required as the stack uses them internally)
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_WPS_ER_FAILED:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_WPS_ER_FAILED");
|
||||
ESP_ERROR_CHECK(esp_wifi_wps_disable());
|
||||
// Hier Fehlerbehandlung: Info an User, evtl. erneuten Start ermöglichen
|
||||
// Here error handling: Info to user, possibly allow restart
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_WPS_ER_TIMEOUT:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_WPS_ER_TIMEOUT");
|
||||
ESP_ERROR_CHECK(esp_wifi_wps_disable());
|
||||
// Hier Fehlerbehandlung: Info an User, evtl. erneuten Start ermöglichen
|
||||
// Here error handling: Info to user, possibly allow restart
|
||||
break;
|
||||
|
||||
case WIFI_EVENT_STA_WPS_ER_PIN:
|
||||
ESP_LOGI(TAG, "WIFI_EVENT_STA_WPS_ER_PIN");
|
||||
// Relevant für PIN-Modus
|
||||
// Relevant for PIN mode
|
||||
// wifi_event_sta_wps_er_pin_t* event = (wifi_event_sta_wps_er_pin_t*) event_data;
|
||||
// ESP_LOGI(TAG, "WPS PIN: %.*s", event->pin_code_len, event->pin_code); // Beispiel: ESP32 generiert PIN
|
||||
// ESP_LOGI(TAG, "WPS PIN: %.*s", event->pin_code_len, event->pin_code); // Example: ESP32 generates PIN
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -78,13 +77,13 @@ static void wifi_event_handler(void *arg, esp_event_base_t event_base,
|
||||
{
|
||||
ip_event_got_ip_t *event = (ip_event_got_ip_t *)event_data;
|
||||
ESP_LOGI(TAG, "Got IP address: " IPSTR, IP2STR(&event->ip_info.ip));
|
||||
// Verbindung erfolgreich hergestellt
|
||||
// Connection successfully established
|
||||
}
|
||||
}
|
||||
|
||||
void wifi_init_sta_wps(void)
|
||||
{
|
||||
// 1. NVS initialisieren
|
||||
// 1. Initialize NVS
|
||||
esp_err_t ret = nvs_flash_init();
|
||||
if (ret == ESP_ERR_NVS_NO_FREE_PAGES || ret == ESP_ERR_NVS_NEW_VERSION_FOUND)
|
||||
{
|
||||
@@ -93,29 +92,29 @@ void wifi_init_sta_wps(void)
|
||||
}
|
||||
ESP_ERROR_CHECK(ret);
|
||||
|
||||
// 2. TCP/IP Stack initialisieren
|
||||
// 2. Initialize TCP/IP stack
|
||||
ESP_ERROR_CHECK(esp_netif_init());
|
||||
|
||||
// 3. Event Loop erstellen
|
||||
// 3. Create event loop
|
||||
ESP_ERROR_CHECK(esp_event_loop_create_default());
|
||||
|
||||
// 4. Default Wi-Fi Station Netif erstellen
|
||||
// 4. Create default Wi-Fi Station Netif
|
||||
esp_netif_create_default_wifi_sta();
|
||||
|
||||
// 5. Wi-Fi Treiber initialisieren
|
||||
// 5. Initialize Wi-Fi driver
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK(esp_wifi_init(&cfg));
|
||||
|
||||
// 6. Event Handler registrieren
|
||||
// 6. Register event handler
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &wifi_event_handler, NULL));
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &wifi_event_handler, NULL));
|
||||
|
||||
// 7. Wi-Fi Modus auf Station setzen
|
||||
// 7. Set Wi-Fi mode to station
|
||||
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
|
||||
|
||||
// 8. Wi-Fi starten (löst WIFI_EVENT_STA_START aus)
|
||||
// 8. Start Wi-Fi (triggers WIFI_EVENT_STA_START)
|
||||
ESP_ERROR_CHECK(esp_wifi_start());
|
||||
|
||||
ESP_LOGI(TAG, "Wi-Fi Initialisierung abgeschlossen.");
|
||||
ESP_LOGI(TAG, "Bereit für WPS Trigger (z.B. Button-Druck oder automatischen Start in STA_START).");
|
||||
ESP_LOGI(TAG, "Wi-Fi initialization completed.");
|
||||
ESP_LOGI(TAG, "Ready for WPS trigger (e.g., button press or automatic start in STA_START).");
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
# Name , Type , SubType , Offset , Size , Flags
|
||||
nvs , data , nvs , 0x9000 , 24k ,
|
||||
phy_init , data , phy , , 4k ,
|
||||
factory , app , factory , 0x10000 , 4M ,
|
||||
storage , data , fat , , 11M ,
|
||||
coredump , data , coredump , , 951K ,
|
||||
# Name , Type , SubType , Offset , Size , Flags
|
||||
nvs , data , nvs , 0x9000 , 16k ,
|
||||
otadata , data , ota , , 8k ,
|
||||
phy_init , data , phy , , 4k ,
|
||||
ota_0 , app , ota_0 , 0x10000 , 2M ,
|
||||
ota_1 , app , ota_1 , , 2M ,
|
||||
storage , data , fat , , 11M ,
|
||||
coredump , data , coredump , , 919k ,
|
||||
fctry , data , nvs , , 24k ,
|
||||
|
||||
|
@@ -36,3 +36,7 @@ CONFIG_LV_USE_LOG=y
|
||||
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
|
||||
#CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y
|
||||
|
||||
# PSRAM
|
||||
CONFIG_SPIRAM=y
|
||||
CONFIG_SPIRAM_USE_MALLOC=y
|
||||
CONFIG_SPIRAM_USE_CAPS_ALLOC=y
|
||||
|
||||
Reference in New Issue
Block a user