Kansai Electric Power usage meter (Denki-yohou)

Dependencies:   mbed mbed-rtos EthernetInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers TinyHTTP_b.h Source File

TinyHTTP_b.h

Go to the documentation of this file.
00001 /*
00002  * mbed Tiny HTTP Client for Ethernet Interface Library
00003  * Copyright (c) 2012 Hiroshi Suga
00004  * Released under the MIT License: http://mbed.org/license/mit
00005  */
00006 
00007 /** @file
00008  * @brief Tiny HTTP Client
00009  */
00010 
00011 #ifndef TinyHTTP_h
00012 #define TinyHTTP_h
00013 
00014 #include "mbed.h"
00015 #include "EthernetInterface.h"
00016 
00017 #define HTTP_PORT 80
00018 #define HTTP_TIMEOUT 3000 // ms
00019 
00020 #define METHOD_GET 0
00021 #define METHOD_POST 1
00022 
00023 typedef void (*onHttpReceiveFunc)(char *buf, int len);
00024 
00025 /** send http request
00026  * @param method METHOD_GET or METHOD_POST
00027  * @param host http server
00028  * @param uri URI
00029  * @param head http header (CR+LF) (or NULL)
00030  * @param body POST body (or NULL)
00031  * @return http code, -1:failue
00032  */
00033 int httpRequest (int method, char *host, int port, char *uri, char *head, char *body, onHttpReceiveFunc func);
00034 
00035 void createauth (char *user, char *pwd, char *buf, int len);
00036 
00037 int base64enc(const char *input, unsigned int length, char *output, int len);
00038 
00039 int urlencode(char *str, char *buf, int len);
00040 
00041 #endif