Browse Source

NetworkClient debugging

v0.9.4
Guy Turcotte 3 years ago
parent
commit
ec05a6264f
  1. 4
      examples/Basic_Inkplate_Functionality/Inkplate-basic_custom_font/src/main.cpp
  2. 4
      examples/Basic_Inkplate_Functionality/Inkplate-basic_partial_update/src/main.cpp
  3. 64
      examples/Basic_Inkplate_Functionality/Inkplate_basic_BW/src/main.cpp
  4. 67
      examples/Basic_Inkplate_Functionality/Inkplate_basic_gray/src/main.cpp
  5. 3
      examples/Others/Inkplate_VariPass_Graphs/.gitignore
  6. 2
      examples/Others/Inkplate_VariPass_Graphs/CMakeLists.txt
  7. 72
      examples/Others/Inkplate_VariPass_Graphs/src/main.cpp
  8. 20
      src/services/network_client.cpp

4
examples/Basic_Inkplate_Functionality/Inkplate-basic_custom_font/src/main.cpp

@ -33,7 +33,7 @@ Inkplate display(DisplayMode::INKPLATE_1BIT); // Create an object on Inkplate li
uint16_t w;
uint16_t h;
void wait_a_bit() { vTaskDelay(10000 / portTICK_PERIOD_MS); }
void delay(int msec) { vTaskDelay(msec / portTICK_PERIOD_MS); }
static const char * TAG = "Main";
@ -75,7 +75,7 @@ void mainTask(void * param)
for (;;) {
ESP_LOGI(TAG, "Completed...");
wait_a_bit();
delay(10000);
}
}

4
examples/Basic_Inkplate_Functionality/Inkplate-basic_partial_update/src/main.cpp

@ -37,7 +37,7 @@ static const char * TAG = "Main";
int offset;
int w, h;
void wait_a_bit() { vTaskDelay(200 / portTICK_PERIOD_MS); }
void delay(int msec) { vTaskDelay(msec / portTICK_PERIOD_MS); }
// Variable that keeps count on how much screen has been partially updated
int n = 0;
@ -75,7 +75,7 @@ void mainTask(void * param)
offset -= 20; // Move text into new position
if (offset < 0)
offset = w; // Text is scrolled till the end of the screen? Get it back on the start!
wait_a_bit(); // Delay between refreshes.
delay(200); // Delay between refreshes.
}
}

64
examples/Basic_Inkplate_Functionality/Inkplate_basic_BW/src/main.cpp

@ -49,7 +49,7 @@ int random(int a, int b)
return (a + (r * b) / RAND_MAX);
}
void wait_a_bit() { vTaskDelay(5000 / portTICK_PERIOD_MS); }
void delay(int msec) { vTaskDelay(msec / portTICK_PERIOD_MS); }
void mainTask(void * params)
{
@ -81,7 +81,7 @@ void mainTask(void * params)
#endif
display.display(); // Write hello message
wait_a_bit();
delay(5000);
for (;;) {
display.setRotation(0);
@ -99,7 +99,7 @@ void mainTask(void * params)
// since Inkplate is in BW mode)
display.display(); // Send image to display. You need to call this one each time you want to transfer frame buffer
// to the screen.
wait_a_bit();
delay(5000);
// -----
@ -111,7 +111,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing 600 random pixels");
display.display(); // Write everything from frame buffer to screen
wait_a_bit();
delay(5000);
// -----
@ -123,7 +123,7 @@ void mainTask(void * params)
display.drawLine(w - 1, 0, 0, h - 1, BLACK); // with those. Arguments are: start X, start Y, ending X, ending Y, color.
displayCurrentAction("Drawing two diagonal lines");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -135,7 +135,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing 50 random lines");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -148,7 +148,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing 50 random lines");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -157,7 +157,7 @@ void mainTask(void * params)
display.drawFastHLine(100, 100, w - 200, BLACK); // Arguments are: starting X, starting Y, length, color
displayCurrentAction("Drawing one horizontal line");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -166,7 +166,7 @@ void mainTask(void * params)
display.drawFastVLine(100, 100, h - 200, BLACK); // Arguments are: starting X, starting Y, length, color
displayCurrentAction("Drawing one vertical line");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -182,7 +182,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing a grid using horizontal and vertical lines");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -191,7 +191,7 @@ void mainTask(void * params)
display.drawRect(200, 200, 400, 300, BLACK); // Arguments are: start X, start Y, size X, size Y, color
displayCurrentAction("Drawing rectangle");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -203,7 +203,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many rectangles");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -212,7 +212,7 @@ void mainTask(void * params)
display.fillRect(200, 200, 400, 300, BLACK); // Arguments are: start X, start Y, size X, size Y, color
displayCurrentAction("Drawing black rectangle");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -224,7 +224,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many filled rectangles randomly");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -233,7 +233,7 @@ void mainTask(void * params)
display.drawCircle(w / 2, h / 2, 75, BLACK); // Arguments are: start X, start Y, radius, color
displayCurrentAction("Drawing a circle");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -245,7 +245,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many circles randomly");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -254,7 +254,7 @@ void mainTask(void * params)
display.fillCircle(w / 2, h / 2, 75, BLACK); // Arguments are: start X, start Y, radius, color
displayCurrentAction("Drawing black-filled circle");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -266,7 +266,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many filled circles randomly");
display.display(); // To show stuff on screen, you always need to call display.display();
wait_a_bit();
delay(5000);
// -----
@ -276,7 +276,7 @@ void mainTask(void * params)
BLACK); // Arguments are: start X, start Y, size X, size Y, radius, color
displayCurrentAction("Drawing rectangle with rounded edges");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -288,7 +288,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many rounded edges rectangles");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -298,7 +298,7 @@ void mainTask(void * params)
BLACK); // Arguments are: start X, start Y, size X, size Y, radius, color
displayCurrentAction("This is filled rectangle with rounded edges");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -310,7 +310,7 @@ void mainTask(void * params)
}
displayCurrentAction("Random rounded edge filled rectangles");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -318,7 +318,7 @@ void mainTask(void * params)
display.clearDisplay();
display.drawTriangle(250, 400, 550, 400, 400, 100, BLACK); // Arguments are: X1, Y1, X2, Y2, X3, Y3, color
display.display();
wait_a_bit();
delay(5000);
// -----
@ -326,7 +326,7 @@ void mainTask(void * params)
display.fillTriangle(300, 350, 500, 350, 400, 150, BLACK); // Arguments are: X1, Y1, X2, Y2, X3, Y3, color
displayCurrentAction("Drawing filled triangle inside exsisting one");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -337,7 +337,7 @@ void mainTask(void * params)
BLACK); // Arguments are: array variable name, start X, start Y, size X, size Y, color
displayCurrentAction("Drawing e-radionica.com logo");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -357,7 +357,7 @@ void mainTask(void * params)
}
displayCurrentAction("Text in different sizes and shadings");
display.display(); // To show stuff on screen, you always need to call display.display();
wait_a_bit();
delay(5000);
// -----
@ -377,7 +377,7 @@ void mainTask(void * params)
}
display.display();
display.setTextColor(BLACK, WHITE);
wait_a_bit();
delay(5000);
// -----
@ -386,7 +386,7 @@ void mainTask(void * params)
display.drawElipse(100, 200, w / 2, h / 2, BLACK);
displayCurrentAction("Drawing an elipse");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -395,7 +395,7 @@ void mainTask(void * params)
display.fillElipse(100, 200, w / 2, h / 2, BLACK);
displayCurrentAction("Drawing a filled elipse");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -423,7 +423,7 @@ void mainTask(void * params)
display.drawPolygon(xt, yt, n, BLACK);
displayCurrentAction("Drawing a polygon");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -434,7 +434,7 @@ void mainTask(void * params)
display.fillPolygon(xt, yt, n, BLACK);
displayCurrentAction("Drawing a filled polygon");
display.display();
wait_a_bit();
delay(5000);
// -----
@ -449,7 +449,7 @@ void mainTask(void * params)
r); // Set rotation will sent rotation for the entire display, so you can use it sideways or upside-down
display.print("INKPLATE6");
display.display();
wait_a_bit();
delay(5000);
}
display.setTextColor(BLACK, WHITE);

67
examples/Basic_Inkplate_Functionality/Inkplate_basic_gray/src/main.cpp

@ -57,7 +57,8 @@ int random(int a, int b)
return (a + (r * b) / RAND_MAX);
}
void wait_a_bit() { vTaskDelay(DELAY_MS / portTICK_PERIOD_MS); }
void delay(int msec) { vTaskDelay(msec / portTICK_PERIOD_MS); }
void mainTask(void * params)
{
@ -81,7 +82,7 @@ void mainTask(void * params)
display.print("Welcome to Inkplate 10!");
#endif
display.display(); // Write hello message
wait_a_bit(); // Wait a little bit
delay(5000); // Wait a little bit
for (;;) {
@ -98,7 +99,7 @@ void mainTask(void * params)
// NOTE: you do not need displayCurrentAction function to use Inkplate!
display.display(); // Send image to display. You need to call this one each time you want to transfer frame buffer
// to the screen.
wait_a_bit(); // Wait a little bit
delay(5000); // Wait a little bit
// Now, let's draw some random pixels!
display.clearDisplay(); // Clear everything that is inside frame buffer in ESP32
@ -109,7 +110,7 @@ void mainTask(void * params)
} // where 0 mens black, 7 white and gray is in between
displayCurrentAction("Drawing 600 random pixels in random colors");
display.display(); // Write everything from frame buffer to screen
wait_a_bit(); // Wait
delay(5000); // Wait
// Draw two diagonal lines accros screen
display.clearDisplay();
@ -119,7 +120,7 @@ void mainTask(void * params)
display.drawLine(w - 1, 0, 0, h - 1, 0); // with those. Arguments are: start X, start Y, ending X, ending Y, color.
displayCurrentAction("Drawing two diagonal lines");
display.display();
wait_a_bit();
delay(5000);
// And again, let's draw some random lines on screen!
display.clearDisplay();
@ -129,7 +130,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing 50 random lines in random colors");
display.display();
wait_a_bit();
delay(5000);
// Let's draw some random thick lines on screen!
display.clearDisplay();
@ -140,7 +141,7 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing 50 random lines in random colors and thickness");
display.display();
wait_a_bit();
delay(5000);
// Let's draw some random gradient thick lines on screen!
display.clearDisplay();
@ -153,21 +154,21 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing 50 random gradient lines in random colors and thickness");
display.display();
wait_a_bit();
delay(5000);
// Now draw one horizontal...
display.clearDisplay();
display.drawFastHLine(100, 100, h - 200, 0); // Arguments are: starting X, starting Y, length, color
displayCurrentAction("Drawing one horizontal line");
display.display();
wait_a_bit();
delay(5000);
//... and one vertical line
display.clearDisplay();
display.drawFastVLine(100, 100, w - 200, 0); // Arguments are: starting X, starting Y, length, color
displayCurrentAction("Drawing one vertical line");
display.display();
wait_a_bit();
delay(5000);
// Now, let' make a grid using only horizontal and vertical lines in random colors!
display.clearDisplay();
@ -181,14 +182,14 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing a grid using horizontal and vertical lines in different colors");
display.display();
wait_a_bit();
delay(5000);
// Draw rectangle at X = 200, Y = 200 and size of 400x300 pixels
display.clearDisplay();
display.drawRect(200, 200, w / 2, h / 2, 0); // Arguments are: start X, start Y, size X, size Y, color
displayCurrentAction("Drawing rectangle");
display.display();
wait_a_bit();
delay(5000);
// Draw rectangles on random location, size 100x150 pixels in random color
display.clearDisplay();
@ -198,14 +199,14 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many rectangles in random colors");
display.display();
wait_a_bit();
delay(5000);
// Draw filled black rectangle at X = 200, Y = 200, size of 400x300 pixels in gray color
display.clearDisplay();
display.fillRect(200, 200, w / 2, h / 2, 4); // Arguments are: start X, start Y, size X, size Y, color
displayCurrentAction("Drawing gray rectangle");
display.display();
wait_a_bit();
delay(5000);
// Draw filled random colored rectangles on random location, size of 30x30 pixels in radnom color
display.clearDisplay();
@ -215,14 +216,14 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many filled rectangles randomly in random colors");
display.display();
wait_a_bit();
delay(5000);
// Draw circle at center of a screen with radius of 75 pixels
display.clearDisplay();
display.drawCircle(w / 2, h / 2, 75, 0); // Arguments are: start X, start Y, radius, color
displayCurrentAction("Drawing a circle");
display.display();
wait_a_bit();
delay(5000);
// Draw some random colored circles at random location with radius of 25 pixels in random color
display.clearDisplay();
@ -232,14 +233,14 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many circles randomly in random colors");
display.display();
wait_a_bit();
delay(5000);
// Draw black filled circle at center of a screen with radius of 75 pixels
display.clearDisplay();
display.fillCircle(w / 2, h / 2, 75, 0); // Arguments are: start X, start Y, radius, color
displayCurrentAction("Drawing black-filled circle");
display.display();
wait_a_bit();
delay(5000);
// Draw some random colored filled circles at random location with radius of 15 pixels
display.clearDisplay();
@ -249,14 +250,14 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many filled circles randomly in random colors");
display.display(); // To show stuff on screen, you always need to call display.display();
wait_a_bit();
delay(5000);
// Draw rounded rectangle at X = 200, Y = 200 and size of 400x300 pixels and radius of 10 pixels
display.clearDisplay();
display.drawRoundRect(200, 200, w / 2, h / 2, 10, 0); // Arguments are: start X, start Y, size X, size Y, radius, color
displayCurrentAction("Drawing rectangle with rounded edges");
display.display();
wait_a_bit();
delay(5000);
// Draw rounded rectangles on random location, size 100x150 pixels, radius of 5 pixels in radnom color
display.clearDisplay();
@ -266,14 +267,14 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many rounded edges rectangles");
display.display();
wait_a_bit();
delay(5000);
// Draw filled random colored rectangle at X = 200, Y = 200, size of 400x300 pixels and radius of 10 pixels
display.clearDisplay();
display.fillRoundRect(200, 200, w / 2, h / 2, 10, 0); // Arguments are: start X, start Y, size X, size Y, radius, color
displayCurrentAction("Drawing filled rectangle with rounded edges");
display.display();
wait_a_bit();
delay(5000);
// Draw filled random colored rectangle on random location, size of 30x30 pixels, radius of 3 pixels in radnom color
display.clearDisplay();
@ -283,19 +284,19 @@ void mainTask(void * params)
}
displayCurrentAction("Drawing many filled rectangle with rounded edges in random colors");
display.display();
wait_a_bit();
delay(5000);
// Draw simple triangle
display.clearDisplay();
display.drawTriangle(250, 400, 550, 400, 400, 100, 0); // Arguments are: X1, Y1, X2, Y2, X3, Y3, color
display.display();
wait_a_bit();
delay(5000);
// Draw filled triangle inside simple triangle (so no display.clearDisplay() this time)
display.fillTriangle(300, 350, 500, 350, 400, 150, 0); // Arguments are: X1, Y1, X2, Y2, X3, Y3, color
displayCurrentAction("Drawing filled triangle inside exsisting one");
display.display();
wait_a_bit();
delay(5000);
// Display some grayscale image on screen. We are going to display e-radionica logo on display at location X = 100,
// Y = 100 Image size is 500x332 pixels.
@ -304,7 +305,7 @@ void mainTask(void * params)
332); // Arguments are: array variable name, start X, start Y, size X, size Y
displayCurrentAction("Drawing a bitmap image");
display.display();
wait_a_bit();
delay(5000);
// Write some text on screen with different sizes and color
display.clearDisplay();
@ -323,7 +324,7 @@ void mainTask(void * params)
}
displayCurrentAction("Text in different sizes and shadings");
display.display(); // To show stuff on screen, you always need to call display.display();
wait_a_bit();
delay(5000);
// Write same text on different location, but now invert colors (text is white, text background is black)
display.setTextColor(7, 0); // First argument is text color, while second argument is background color. In
@ -339,7 +340,7 @@ void mainTask(void * params)
#endif
}
display.display();
wait_a_bit();
delay(5000);
display.setTextColor(0, 7);
// Draws an elipse with x radius, y radius, center x, center y and color
@ -348,7 +349,7 @@ void mainTask(void * params)
displayCurrentAction("Drawing an elipse");
display.display();
wait_a_bit();
delay(5000);
// Fills an elipse with x radius, y radius, center x, center y and color
display.clearDisplay();
@ -356,7 +357,7 @@ void mainTask(void * params)
displayCurrentAction("Drawing a filled elipse");
display.display();
wait_a_bit();
delay(5000);
// Code block for generating random points and sorting them in a counter
// clockwise direction.
@ -383,7 +384,7 @@ void mainTask(void * params)
displayCurrentAction("Drawing a polygon");
display.display();
wait_a_bit();
delay(5000);
// Fills a polygon, from x and y coordinate arrays of n points in color c,
// Points need to be counter clockwise sorted
@ -393,7 +394,7 @@ void mainTask(void * params)
displayCurrentAction("Drawing a filled polygon");
display.display();
wait_a_bit();
delay(5000);
// Write text and rotate it by 90 deg. forever
display.setTextSize(8);
@ -410,7 +411,7 @@ void mainTask(void * params)
display.print("INKPLATE 10!");
#endif
display.display();
wait_a_bit();
delay(5000);
}
display.setTextColor(0, 7);

3
examples/Others/Inkplate_VariPass_Graphs/.gitignore

@ -1,3 +1,4 @@
.pio
.vscode
build
build
src/secur.hpp

2
examples/Others/Inkplate_VariPass_Graphs/CMakeLists.txt

@ -1,3 +1,3 @@
cmake_minimum_required(VERSION 3.16.0)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(Inkplate_basic_BW)
project(Inkplate_VariPass_Graphs)

72
examples/Others/Inkplate_VariPass_Graphs/src/Inkplate_VariPass_Graphs.ino → examples/Others/Inkplate_VariPass_Graphs/src/main.cpp

@ -24,31 +24,34 @@
23 July 2020 by e-radionica.com
*/
#include "Inkplate.h" //Include Inkplate library to the sketch
#include "WiFi.h" //Include library for WiFi
Inkplate display(INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "logging.hpp"
const char *ssid = "e-radionica.com"; // Your WiFi SSID
const char *password = "croduino"; // Your WiFi password
#include "secur.hpp"
void setup()
#include "inkplate.hpp" //Include Inkplate library to the sketch
Inkplate display(DisplayMode::INKPLATE_1BIT); // Create an object on Inkplate library and also set library into 1 Bit mode (BW)
static const char * TAG = "VariPassGraph";
const char *ssid = YOUR_SSID; // Your WiFi SSID
const char *password = YOUR_PASSWORD; // Your WiFi password
void delay(int msec) { vTaskDelay(msec / portTICK_PERIOD_MS); }
void mainTask(void * param)
{
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.display(); // Put clear image on display
display.begin(); // Init Inkplate library (you should call this function ONLY ONCE)
display.clearDisplay(); // Clear frame buffer of display
display.display(); // Put clear image on display
display.print("Connecting to WiFi...");
display.partialUpdate();
display.print("Connecting to WiFi...");
display.partialUpdate();
// Connect to the WiFi network.
if (display.joinAP(ssid, password)) {
// Connect to the WiFi network.
WiFi.mode(WIFI_MODE_STA);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
display.print(".");
display.partialUpdate();
}
display.println("\nWiFi OK! Downloading...");
display.partialUpdate();
@ -61,18 +64,35 @@ void setup()
// height - Height of the generated graph, here set to half the Inkplate's height.
// eink - Should be set to true to generate a BW 1 bit bitmap better suitable for Inkplate.
// For more detailed explanation and more parameters, please visit the docs page: https://varipass.org/docs/
if (!display.drawBitmapFromWeb("https://api.varipass.org/?action=sgraph&id=kbg3eQfA&width=400&height=300&eink=true",
200, 150))
200, 150))
{
display.println("Image open error");
display.partialUpdate();
}
display.partialUpdate();
WiFi.mode(WIFI_OFF);
}
display.disconnect();
}
void loop()
{
// Nothing...
for (;;) {
ESP_LOGI(TAG, "Completed...");
delai(10000);
}
}
#define STACK_SIZE 10000
extern "C" {
void app_main()
{
TaskHandle_t xHandle = NULL;
xTaskCreate(peripheral_task, "mainTask", STACK_SIZE, (void *) 1, tskIDLE_PRIORITY, &xHandle);
configASSERT(xHandle);
}
} // extern "C"

20
src/services/network_client.cpp

@ -190,6 +190,7 @@ NetworkClient::disconnect()
}
}
static uint8_t * buffer;
static uint8_t * buffer_ptr;
static int32_t buffer_size;
@ -207,12 +208,22 @@ static esp_err_t http_event_handler(esp_http_client_event_t * evt)
break;
case HTTP_EVENT_ON_HEADER:
ESP_LOGI(TAG, "HTTP_EVENT_ON_HEADER");
ESP_LOGI(TAG, "key = %s, value = %s", evt->header_key, evt->header_value);
//ESP_LOGI(TAG, "key = %s, value = %s", evt->header_key, evt->header_value);
if (strcmp("Content-Length", evt->header_key) == 0) {
buffer_size = atoi(evt->header_value);
if (buffer_size > 0) {
buffer_ptr = buffer = new uint8_t[buffer_size];
}
}
break;
case HTTP_EVENT_ON_DATA:
ESP_LOGI(TAG, "HTTP_EVENT_ON_DATA, len=%d", evt->data_len);
if (!esp_http_client_is_chunked_response(evt->client)) {
ESP_LOGI(TAG, "len = %d, %.*s", evt->data_len, evt->data_len, (char*)evt->data);
//ESP_LOGI(TAG, "len = %d, %.*s", evt->data_len, evt->data_len, (char*)evt->data);
if ((buffer_ptr != nullptr) && ((buffer_ptr + evt->data_len) <= (buffer + buffer_size))) {
memcpy(buffer_ptr, evt->data, evt->data_len);
buffer_ptr += evt->data_len;
}
}
break;
@ -232,7 +243,8 @@ NetworkClient::downloadFile(const char * url, int32_t * defaultLen)
{
if (!connected) return nullptr;
buffer_ptr = nullptr;
buffer = buffer_ptr = nullptr;
buffer_size = -1;
esp_http_client_config_t config;
@ -251,5 +263,5 @@ NetworkClient::downloadFile(const char * url, int32_t * defaultLen)
}
esp_http_client_cleanup(client);
return buffer_ptr;
return buffer;
}

Loading…
Cancel
Save