esp-http-protocol-demo's People
esp-http-protocol-demo's Issues
Compiles fine, connects to my wifi, does not return anything from worldtimeapi.org
Board: ESP32 Cam (AI Thinker) with PSRAM.
ESP-IDF version: 4.4.2
Other details in the first few lines of the log output.
Issue: There is no response from the HTTPS server from the _https_client.c example.
Possible explanation: :(
I added some additional debug statements to ensure the task is being created. As to my observation the function https_client() is being executed, but the buffer being printed out is empty and it's just the \n that is being printed in the printf() statement at line 28.
Here is the (not all that much) modified main.c:
#include <stdio.h>
#include <string.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/event_groups.h"
#include "esp_wifi.h"
#include "esp_log.h"
#include "nvs_flash.h"
#include "esp_netif.h"
#include "esp_http_client.h"
#include "web_demo.h"
void OnConnected(void *params)
{
//comment out all except 1
//http_client();
//http_server();
for(;;){
ESP_LOGI(pcTaskGetName(NULL),"In Task loop start.");
https_client();
//https_server();
//https_chunked_client();
//json_server_responce();
//json_server_post();
//json_client();
ESP_LOGI(pcTaskGetName(NULL),"In Task loop end.");
vTaskDelay(pdMS_TO_TICKS(1000));
}
//leave this in place
vTaskDelete(NULL);
}
void app_main(void)
{
connect_simple();
xTaskCreate(&OnConnected, "handel comms", 1024 * 10, NULL, 5, NULL);
}
here is the _3_https_client.c
#include <stdio.h>
#include <string.h>
#include "esp_wifi.h"
#include "esp_log.h"
#include "esp_http_client.h"
#define TAG "HTTPS CLIENT"
void https_client(void)
{
extern const unsigned char wordtime_cert[] asm("_binary_worldtime_pem_start");
esp_http_client_config_t clientConfig = {
.url = "https://worldtimeapi.org/api/timezone/Europe/London/",
//.url = "https://www.google.com",
.cert_pem = (char *)wordtime_cert
};
esp_http_client_handle_t client = esp_http_client_init(&clientConfig);
esp_err_t err = esp_http_client_perform(client);
if (err == ESP_OK)
{
int length = esp_http_client_get_content_length(client);
char *buffer = malloc(length + 1);
memset(buffer, 0, length + 1);
esp_http_client_read(client, buffer, length);
printf("%s\n", buffer);
}
else
{
ESP_LOGE(TAG, "HTTPS GET request failed: %s", esp_err_to_name(err));
}
esp_http_client_close(client);
while (true)
{
printf("done!\n");
vTaskDelay(portMAX_DELAY);
}
}
and here is my log output:
entry 0x40080694
I (27) boot: ESP-IDF v4.4.2-dirty 2nd stage bootloader
I (27) boot: compile time 11:02:33
I (27) boot: chip revision: 3
I (31) boot_comm: chip revision: 3, min. bootloader chip revision: 0
I (38) boot.esp32: SPI Speed : 40MHz
I (42) boot.esp32: SPI Mode : DIO
I (47) boot.esp32: SPI Flash Size : 4MB
I (51) boot: Enabling RNG early entropy source...
I (57) boot: Partition Table:
I (60) boot: ## Label Usage Type ST Offset Length
I (68) boot: 0 nvs WiFi data 01 02 00009000 00004000
I (75) boot: 1 otadata OTA data 01 00 0000d000 00002000
I (83) boot: 2 phy_init RF data 01 01 0000f000 00001000
I (90) boot: 3 ota_0 OTA app 00 10 00010000 00100000
I (98) boot: 4 ota_1 OTA app 00 11 00110000 00100000
I (105) boot: 5 storage Unknown data 01 82 00210000 00100000
I (113) boot: End of partition table
I (117) boot: No factory image, trying OTA 0
I (122) boot_comm: chip revision: 3, min. application chip revision: 0
I (129) esp_image: segment 0: paddr=00010020 vaddr=3f400020 size=1e354h (123732) map
I (182) esp_image: segment 1: paddr=0002e37c vaddr=3ffb0000 size=01c9ch ( 7324) load
I (186) esp_image: segment 2: paddr=00030020 vaddr=400d0020 size=95b84h (613252) map
I (410) esp_image: segment 3: paddr=000c5bac vaddr=3ffb1c9c size=01c44h ( 7236) load
I (413) esp_image: segment 4: paddr=000c77f8 vaddr=40080000 size=189a0h (100768) load
I (457) esp_image: segment 5: paddr=000e01a0 vaddr=50000000 size=00010h ( 16) load
I (469) boot: Loaded app from partition at offset 0x10000
I (533) boot: Set actual ota_seq=1 in otadata[0]
I (533) boot: Disabling RNG early entropy source...
I (544) psram: This chip is ESP32-D0WD
I (546) spiram: Found 16MBit SPI RAM device
I (546) spiram: SPI RAM mode: flash 40m sram 40m
I (549) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (556) cpu_start: Pro cpu up.
I (560) cpu_start: Starting app cpu, entry point is 0x40081408
0x40081408: call_start_cpu1 at C:/ESP/esp-idf/esp-idf/components/esp_system/port/cpu_start.c:160
I (0) cpu_start: App cpu up.
I (1018) spiram: SPI SRAM memory test OK
I (1026) cpu_start: Pro cpu start user code
I (1026) cpu_start: cpu freq: 240000000
I (1026) cpu_start: Application information:
I (1029) cpu_start: Project name: esp32-web-client
I (1035) cpu_start: App version: b47bb91-dirty
I (1040) cpu_start: Compile time: Aug 25 2022 11:02:23
I (1046) cpu_start: ELF file SHA256: c34163c3f4ed6f93...
I (1053) cpu_start: ESP-IDF: v4.4.2-dirty
I (1058) heap_init: Initializing. RAM available for dynamic allocation:
I (1065) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1072) heap_init: At 3FFB76F0 len 00028910 (162 KiB): DRAM
I (1078) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1084) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1091) heap_init: At 400989A0 len 00007660 (29 KiB): IRAM
I (1097) spiram: Adding pool of 2047K of external SPI memory to heap allocator
I (1106) spi_flash: detected chip: generic
I (1110) spi_flash: flash io: dio
I (1115) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (1124) spiram: Reserving pool of 32K of internal memory for DMA/internal allocations
I (1174) wifi:wifi driver task: 3ffc8310, prio:23, stack:6656, core=0
I (1174) system_api: Base MAC address is not set
I (1174) system_api: read default base MAC address from EFUSE
I (1184) wifi:wifi firmware version: eeaa27d
I (1184) wifi:wifi certification version: v7.0
I (1184) wifi:config NVS flash: enabled
I (1184) wifi:config nano formating: disabled
I (1194) wifi:Init data frame dynamic rx buffer num: 32
I (1194) wifi:Init management frame dynamic rx buffer num: 32
I (1204) wifi:Init management short buffer num: 32
I (1204) wifi:Init static tx buffer num: 16
I (1214) wifi:Init tx cache buffer num: 32
I (1214) wifi:Init static rx buffer size: 1600
I (1224) wifi:Init static rx buffer num: 10
I (1224) wifi:Init dynamic rx buffer num: 32
I (1224) wifi_init: rx ba win: 6
I (1234) wifi_init: tcpip mbox: 32
I (1234) wifi_init: udp mbox: 6
I (1234) wifi_init: tcp mbox: 6
I (1244) wifi_init: tcp tx win: 5744
I (1244) wifi_init: tcp rx win: 5744
I (1254) wifi_init: tcp mss: 1440
I (1254) wifi_init: WiFi IRAM OP enabled
I (1264) wifi_init: WiFi RX IRAM OP enabled
I (1264) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (1364) wifi:mode : sta (c4:dd:57:eb:cb:c0)
I (1364) wifi:enable tsf
I (2094) wifi:new:<7,0>, old:<1,0>, ap:<255,255>, sta:<7,0>, prof:1
I (2634) wifi:state: init -> auth (b0)
I (2744) wifi:state: auth -> assoc (0)
I (2814) wifi:state: assoc -> run (10)
I (2844) wifi:connected with Wraith Maxima, aid = 7, channel 7, BW20, bssid = a2:91:9d:2d:d8:50
I (2844) wifi:security: WPA2-PSK, phy: bgn, rssi: -39
I (2854) wifi:pm start, type: 1
I (2884) wifi:AP's beacon interval = 102400 us, DTIM period = 2
W (4424) wifi:<ba-add>idx:0 (ifx:0, a2:91:9d:2d:d8:50), tid:0, ssn:0, winSize:64
I (5154) esp_netif_handlers: sta ip: 192.168.210.110, mask: 255.255.255.0, gw: 192.168.210.62
I (5154) handel comms: In Task loop start.
done!
Newbie cannot figure mem leak ):
Hello mair, first I want to say that I'm a fan and I really appreciate your work putting out knowledge in an easy to understand manner. Anyway, I just used your sketch to post a temperature to my server, but Each time I rerun the code in a loop, If I do xPortGetFreeHeapSize() Each iteration the heap size seems to get smaller, but in your example: https://github.com/Mair/esp-http-protocol-demo/blob/master/main/_8_json_client_post.c You do use
cJSON_Delete(json);
free(mesage_payload);
So I don't really understand where the leak is coming from. Again thanks a lot for the teaching in a clear manner!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.