Simple code to upload temperature readings to SensorUp SensorThings Playground (http://pg.sensorup.com) from the XBee moudle. It works with mbed LPC1768. (https://developer.mbed.org/platforms/mbed-LPC1768/)
Dependencies: C12832 EthernetNetIf LM75B mbed
TinyHTTP.h@0:a3d37c44560a, 2016-01-11 (annotated)
- Committer:
- robinlk
- Date:
- Mon Jan 11 05:37:01 2016 +0000
- Revision:
- 0:a3d37c44560a
Simple code to upload temperature readings to SensorUp SensorThings Playground (http://pg.sensorup.com) from the XBee moudle. It works with mbed LPC1768. (https://developer.mbed.org/platforms/mbed-LPC1768/)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
robinlk | 0:a3d37c44560a | 1 | /* |
robinlk | 0:a3d37c44560a | 2 | * mbed Tiny HTTP Client |
robinlk | 0:a3d37c44560a | 3 | * Copyright (c) 2011 Hiroshi Suga |
robinlk | 0:a3d37c44560a | 4 | * Released under the MIT License: http://mbed.org/license/mit |
robinlk | 0:a3d37c44560a | 5 | */ |
robinlk | 0:a3d37c44560a | 6 | |
robinlk | 0:a3d37c44560a | 7 | /** @file |
robinlk | 0:a3d37c44560a | 8 | * @brief Tiny HTTP Client |
robinlk | 0:a3d37c44560a | 9 | */ |
robinlk | 0:a3d37c44560a | 10 | |
robinlk | 0:a3d37c44560a | 11 | #ifndef TinyHTTP_h |
robinlk | 0:a3d37c44560a | 12 | #define TinyHTTP_h |
robinlk | 0:a3d37c44560a | 13 | |
robinlk | 0:a3d37c44560a | 14 | #define DEBUG |
robinlk | 0:a3d37c44560a | 15 | |
robinlk | 0:a3d37c44560a | 16 | #define HTTP_PORT 80 |
robinlk | 0:a3d37c44560a | 17 | #define HTTP_TIMEOUT 15000 // ms |
robinlk | 0:a3d37c44560a | 18 | |
robinlk | 0:a3d37c44560a | 19 | #define METHOD_GET 0 |
robinlk | 0:a3d37c44560a | 20 | #define METHOD_POST 1 |
robinlk | 0:a3d37c44560a | 21 | |
robinlk | 0:a3d37c44560a | 22 | /** send http request |
robinlk | 0:a3d37c44560a | 23 | * @param method METHOD_GET or METHOD_POST |
robinlk | 0:a3d37c44560a | 24 | * @param host http server |
robinlk | 0:a3d37c44560a | 25 | * @param uri URI |
robinlk | 0:a3d37c44560a | 26 | * @param head http header (CR+LF) (or NULL) |
robinlk | 0:a3d37c44560a | 27 | * @param body POST body (or NULL) |
robinlk | 0:a3d37c44560a | 28 | * @return http code, -1:failue |
robinlk | 0:a3d37c44560a | 29 | */ |
robinlk | 0:a3d37c44560a | 30 | int httpRequest (int method, Host *host, char *uri, char *head, char *body); |
robinlk | 0:a3d37c44560a | 31 | |
robinlk | 0:a3d37c44560a | 32 | void createauth (char *user, char *pwd, char *buf, int len); |
robinlk | 0:a3d37c44560a | 33 | |
robinlk | 0:a3d37c44560a | 34 | int base64enc(const char *input, unsigned int length, char *output, int len); |
robinlk | 0:a3d37c44560a | 35 | |
robinlk | 0:a3d37c44560a | 36 | int urlencode(char *str, char *buf, int len); |
robinlk | 0:a3d37c44560a | 37 | |
robinlk | 0:a3d37c44560a | 38 | #endif |