GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Caerbannog/esphttpclient: A simple ESP8266 http client library to make GET and POST requests with the native SDK

BranchesTags
Open more actions menu

Latest commit

 

History

39 Commits
39 Commits

Folders and files

NameName
Last commit message
Last commit date
test
test
 
 
README.md
README.md
 
 
espmissingincludes.h
espmissingincludes.h
 
 
httpclient.c
httpclient.c
 
 
httpclient.h
httpclient.h
 
 

Repository files navigation

esphttpclient

This is a short library for ESP8266(EX) chips to make HTTP requests.

Features

  • Easy to use.
  • Supports multiple requests in parallel.
  • Supports GET and POST requests.
  • Tested with Espressif SDK v1.0.0

Building

If you don't have a toolchain yet, install one with https://github.com/pfalcon/esp-open-sdk then get Espressif's SDK.

The submodule way

If your project looks like esphttpd from Sprite_tm:

git clone http://git.spritesserver.nl/esphttpd.git/
cd esphttpd
git submodule add https://github.com/Caerbannog/esphttpclient.git lib/esphttpclient
git submodule update --init

Now append lib/esphttpclient to the following Makefile line and you should be ready:

MODULES = driver user lib/esphttpclient

In case you want to use SSL don't forget to add ssl to LIBS in the Makefile

LIBS = c gcc hal pp phy net80211 lwip wpa main ssl

The dirty way

Alternatively you could create a simple project:

git clone https://github.com/esp8266/source-code-examples.git
cd source-code-examples/basic_example
# Set your Wifi credentials in user_config.h
# I could not test this because of the UART baud rate (74880)

Then download this library and move the files to user/:

git clone https://github.com/Caerbannog/esphttpclient.git
mv esphttpclient/*.* user/

Usage

Include httpclient.h from user_main.c then call one of these functions:

void http_get(const char * url, const char * headers, http_callback user_callback);
void http_post(const char * url, const char * post_data, const char * headers, http_callback user_callback);

void http_callback_example(char * response_body, int http_status, char * response_headers, int body_size)
{
	os_printf("http_status=%d\n", http_status);
	if (http_status != HTTP_STATUS_GENERIC_ERROR) {
		os_printf("strlen(headers)=%d\n", strlen(response_headers));
		os_printf("body_size=%d\n", body_size);
		os_printf("body=%s<EOF>\n", response_body);
	}
}

Example

The following code performs a single request, then calls http_callback_example to display your public IP address.

http_get("http://wtfismyip.com/text", "", http_callback_example);

The output looks like this:

http_status=200
strlen(full_response)=244
body_size=15
body=208.97.177.124
<EOF>

About

A simple ESP8266 http client library to make GET and POST requests with the native SDK

Resources

Readme
Activity

Stars

111 stars

Watchers

22 watching

Forks

38 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.