get bsvg string

text_rendering
Eggert Jung 2 years ago
parent 23eb8d5bce
commit f062b492fc

@ -1,3 +1,3 @@
idf_component_register(SRCS "main.c" "font.c" "display.c" "text.c" "wlan.c" "http.c" idf_component_register(SRCS "main.c" "font.c" "display.c" "text.c" "wlan.c" "https.c"
REQUIRES esp_driver_gpio esp_wifi nvs_flash esp_timer REQUIRES esp_driver_gpio esp_wifi nvs_flash esp_timer esp-tls
INCLUDE_DIRS "") INCLUDE_DIRS "")

@ -0,0 +1,10 @@
#include "esp_system.h"
/* Constants that aren't configurable in menuconfig */
#define WEB_SERVER "mustbehax.de"
#define WEB_PORT "80"
#define WEB_PATH "/test"
#define RCV_BUFSIZE 8000
esp_err_t http_request(char* buf);

@ -7,9 +7,18 @@
static const char *TAG = "https"; static const char *TAG = "https";
#define WEB_SERVER "bsvg.efa.de"
#define WEB_PORT "443"
#define WEB_URL "/bsvagstd/XML_DM_REQUEST?outputFormat=JSON&stateless=1&locationServerActive=1&type_dm=stop&name_dm=\"Freiastr,Braunschweig\"&mode=direct&ptOptionsActive=1&useRealtime=1"
static const char HOWSMYSSL_REQUEST[] = "GET " WEB_URL " HTTP/1.1\r\n"
"Host: "WEB_SERVER"\r\n"
"User-Agent: esp-idf/1.0 esp32\r\n"
"\r\n";
static void https_get_request(esp_tls_cfg_t cfg, const char *WEB_SERVER_URL, const char *REQUEST) static void https_get_request(esp_tls_cfg_t cfg, const char *WEB_SERVER_URL, const char *REQUEST)
{ {
char buf[512]; char buf[47000];
int ret, len; int ret, len;
esp_tls_t *tls = esp_tls_init(); esp_tls_t *tls = esp_tls_init();
@ -89,20 +98,11 @@ exit:
} }
} }
#define WEB_SERVER "www.howsmyssl.com"
#define WEB_PORT "443"
#define WEB_URL "https://www.howsmyssl.com/a/check"
static const char HOWSMYSSL_REQUEST[] = "GET " WEB_URL " HTTP/1.1\r\n"
"Host: "WEB_SERVER"\r\n"
"User-Agent: esp-idf/1.0 esp32\r\n"
"\r\n";
void https_get_request_using_crt_bundle(void) void https_get_request_using_crt_bundle(void)
{ {
ESP_LOGI(TAG, "https_request using crt bundle"); ESP_LOGI(TAG, "https_request using crt bundle");
esp_tls_cfg_t cfg = { esp_tls_cfg_t cfg = {
.crt_bundle_attach = esp_crt_bundle_attach, .crt_bundle_attach = esp_crt_bundle_attach,
}; };
https_get_request(cfg, WEB_URL, HOWSMYSSL_REQUEST); https_get_request(cfg, "https://"WEB_SERVER""WEB_URL, HOWSMYSSL_REQUEST);
} }

@ -18,7 +18,7 @@
#include "display.h" #include "display.h"
#include "text.h" #include "text.h"
#include "wlan.h" #include "wlan.h"
#include "http.h" #include "https.h"
#ifdef CONFIG_IDF_TARGET_ESP32 #ifdef CONFIG_IDF_TARGET_ESP32
#define CHIP_NAME "ESP32" #define CHIP_NAME "ESP32"
@ -47,15 +47,16 @@ void app_main(void)
put_line(fb, 2, "wifi", 1, 1); put_line(fb, 2, "wifi", 1, 1);
//xTaskCreate(&http_get_task, "http_get_task", 4096, NULL, 5, NULL); ////xTaskCreate(&http_get_task, "http_get_task", 4096, NULL, 5, NULL);
char buf[RCV_BUFSIZE]; //char buf[RCV_BUFSIZE];
bzero(buf, RCV_BUFSIZE); //bzero(buf, RCV_BUFSIZE);
http_request(buf); //http_request(buf);
for(uint32_t i=0; i<RCV_BUFSIZE; i++){ //for(uint32_t i=0; i<RCV_BUFSIZE; i++){
if(buf[i] == 0) // if(buf[i] == 0)
break; // break;
putchar(buf[i]); // putchar(buf[i]);
} //}
https_get_request_using_crt_bundle();
put_line(fb, 3, "http", 1, 1); put_line(fb, 3, "http", 1, 1);

Loading…
Cancel
Save