Last piece to connect client to provider: actually downloading the image and displaying it
This commit is contained in:
+44
-35
@@ -37,41 +37,43 @@ extern "C" void app_main()
|
||||
|
||||
setup_led();
|
||||
|
||||
static uint8 display_buffer[96000];
|
||||
bool received_from_provider = false;
|
||||
|
||||
// Connect to WiFi
|
||||
if (false)
|
||||
ESP_LOGI(TAG, "Initializing WiFi connection");
|
||||
initialize_network();
|
||||
|
||||
esp_err_t err = connect_wifi(CONFIG_CALENDINK_WIFI_SSID,
|
||||
CONFIG_CALENDINK_WIFI_PASSWORD, false);
|
||||
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
ESP_LOGI(TAG, "Initializing WiFi connection");
|
||||
initialize_network();
|
||||
|
||||
esp_err_t err = connect_wifi(CONFIG_CALENDINK_WIFI_SSID,
|
||||
CONFIG_CALENDINK_WIFI_PASSWORD, false);
|
||||
|
||||
if (err == ESP_OK)
|
||||
uint8_t retries = 1;
|
||||
do
|
||||
{
|
||||
uint8_t retries = 1;
|
||||
do
|
||||
err = check_wifi_connection(retries);
|
||||
if (err != ESP_OK)
|
||||
{
|
||||
err = check_wifi_connection(retries);
|
||||
if (err != ESP_OK)
|
||||
{
|
||||
ESP_LOGW(TAG, "WiFi connection check timeout, retrying... (%d)",
|
||||
retries);
|
||||
led_blink_number(3, 255, 0, 0);
|
||||
}
|
||||
retries++;
|
||||
} while (err == ESP_ERR_TIMEOUT &&
|
||||
retries <= CONFIG_CALENDINK_WIFI_RETRIES);
|
||||
}
|
||||
ESP_LOGW(TAG, "WiFi connection check timeout, retrying... (%d)",
|
||||
retries);
|
||||
led_blink_number(3, 255, 0, 0);
|
||||
}
|
||||
retries++;
|
||||
} while (err == ESP_ERR_TIMEOUT &&
|
||||
retries <= CONFIG_CALENDINK_WIFI_RETRIES);
|
||||
}
|
||||
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
ESP_LOGI(TAG, "Successfully connected to WiFi!");
|
||||
test_provider_communication();
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to connect to WiFi.");
|
||||
}
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
ESP_LOGI(TAG, "Successfully connected to WiFi!");
|
||||
ESP_LOGI(TAG, "Fetching screen from Provider...");
|
||||
received_from_provider = test_provider_communication(display_buffer, sizeof(display_buffer));
|
||||
ESP_LOGI(TAG, "Provider result: %s", received_from_provider ? "SUCCESS" : "FAILED");
|
||||
}
|
||||
else
|
||||
{
|
||||
ESP_LOGE(TAG, "Failed to connect to WiFi.");
|
||||
}
|
||||
|
||||
turn_off_led();
|
||||
@@ -79,21 +81,28 @@ extern "C" void app_main()
|
||||
ESP_LOGI(TAG, "Initializing EPD");
|
||||
epd_init();
|
||||
epd_init_display(true);
|
||||
// epd_clear(epd_color::WHITE);
|
||||
epd_draw_bitmap_grayscale(epd_color::WHITE, gImage_4G1);
|
||||
|
||||
if (received_from_provider) {
|
||||
ESP_LOGI(TAG, "Drawing image from Provider");
|
||||
epd_draw_bitmap_grayscale(epd_color::WHITE, display_buffer);
|
||||
} else {
|
||||
ESP_LOGW(TAG, "Drawing fallback test image");
|
||||
epd_draw_bitmap_grayscale(epd_color::WHITE, gImage_4G1);
|
||||
}
|
||||
|
||||
epd_refresh();
|
||||
epd_shutdown_display();
|
||||
|
||||
if (false)
|
||||
if (err == ESP_OK)
|
||||
{
|
||||
disconnect_wifi();
|
||||
shutdown_network();
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Waiting 5 seconds before deep sleep...");
|
||||
vTaskDelay(pdMS_TO_TICKS(5000));
|
||||
vTaskDelay(pdMS_TO_TICKS(15000));
|
||||
|
||||
ESP_LOGI(TAG, "Entering Deep Sleep for 60 seconds...");
|
||||
esp_sleep_enable_timer_wakeup(60ULL * 1000000ULL);
|
||||
esp_sleep_enable_timer_wakeup(30ULL * 1000000ULL);
|
||||
esp_deep_sleep_start();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user