Axeda demo software for u-blox C027 (GSM)

Dependencies:   mbed

Committer:
AxedaCorp
Date:
Mon Aug 11 19:07:20 2014 +0000
Revision:
1:ff6d8adaf6b9
Parent:
0:a725e8eab383
Pointed to platform (prod)

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AxedaCorp 0:a725e8eab383 1 /************************************************************************************/
AxedaCorp 0:a725e8eab383 2 /* axHTTP.h */
AxedaCorp 0:a725e8eab383 3 /* �2013 Axeda Corporation */
AxedaCorp 0:a725e8eab383 4 /* */
AxedaCorp 0:a725e8eab383 5 /*Provides a basic, bare bones implementation of the HTTP 1.1 protocol spec to allow*/
AxedaCorp 0:a725e8eab383 6 /*this library to be more platform independent. The function calls in this file */
AxedaCorp 0:a725e8eab383 7 /*depend on the socket calls provided in axTransport */
AxedaCorp 0:a725e8eab383 8 /* */
AxedaCorp 0:a725e8eab383 9 /************************************************************************************/
AxedaCorp 0:a725e8eab383 10 #ifndef AXHTTP_H
AxedaCorp 0:a725e8eab383 11 #define AXHTTP_H
AxedaCorp 0:a725e8eab383 12
AxedaCorp 0:a725e8eab383 13 #include "axTransport.h"
AxedaCorp 0:a725e8eab383 14
AxedaCorp 0:a725e8eab383 15 #define AX_HTTP_GET 0 //Standard GET Operation
AxedaCorp 0:a725e8eab383 16 #define AX_HTTP_POST 1 //Standard HTTP Post operation
AxedaCorp 0:a725e8eab383 17 #define AX_HTTP_MPOST 2 //Multipart form data operation, POST
AxedaCorp 0:a725e8eab383 18 #define AX_HTTP_PUT 3
AxedaCorp 0:a725e8eab383 19
AxedaCorp 0:a725e8eab383 20
AxedaCorp 0:a725e8eab383 21
AxedaCorp 0:a725e8eab383 22 typedef struct {
AxedaCorp 0:a725e8eab383 23 // char *host; //..Host is passed in when sending to the
AxedaCorp 0:a725e8eab383 24 char *contentType;
AxedaCorp 0:a725e8eab383 25 }HTTP_Headers;
AxedaCorp 0:a725e8eab383 26
AxedaCorp 0:a725e8eab383 27 typedef struct HTTP_Part{
AxedaCorp 0:a725e8eab383 28 char *file_name;
AxedaCorp 0:a725e8eab383 29 unsigned char *data;
AxedaCorp 0:a725e8eab383 30 int data_sz;
AxedaCorp 0:a725e8eab383 31 char *hint;
AxedaCorp 0:a725e8eab383 32 struct HTTP_Part *next;
AxedaCorp 0:a725e8eab383 33 }HTTP_Part;
AxedaCorp 0:a725e8eab383 34
AxedaCorp 0:a725e8eab383 35 typedef struct {
AxedaCorp 0:a725e8eab383 36 int operation; //POST, GET, MPOST.
AxedaCorp 0:a725e8eab383 37 char *resource; //A pointer to a string that the resource is identified by
AxedaCorp 0:a725e8eab383 38 HTTP_Headers headers; //a structure of headers for the request
AxedaCorp 0:a725e8eab383 39 char *body; //the body of the request, used only for post and mpost
AxedaCorp 0:a725e8eab383 40 int body_length; //the length of the main body, used only for post and mpost
AxedaCorp 0:a725e8eab383 41 HTTP_Part *mpData; //the first link in a chain of data to be uploaded as part of a multipart post request
AxedaCorp 0:a725e8eab383 42 int response_code; //For responses only, this field will be populated after calling http_parse
AxedaCorp 0:a725e8eab383 43 int secure; //use SSL or TLS
AxedaCorp 0:a725e8eab383 44 }HTTP_Transmission;
AxedaCorp 0:a725e8eab383 45
AxedaCorp 0:a725e8eab383 46 //Flag used to turn on debug x-count header.
AxedaCorp 0:a725e8eab383 47 extern int http_debug;
AxedaCorp 0:a725e8eab383 48
AxedaCorp 0:a725e8eab383 49 //struct ax_socket; //incomplete declaration, see axTransport.h for full declaration
AxedaCorp 0:a725e8eab383 50
AxedaCorp 0:a725e8eab383 51 #ifdef __cplusplus
AxedaCorp 0:a725e8eab383 52 extern "C" {
AxedaCorp 0:a725e8eab383 53 #endif
AxedaCorp 0:a725e8eab383 54
AxedaCorp 0:a725e8eab383 55
AxedaCorp 0:a725e8eab383 56 //Operations
AxedaCorp 0:a725e8eab383 57 int http_send(HTTP_Transmission *request, char *host, int port, int secure, HTTP_Transmission *response);
AxedaCorp 0:a725e8eab383 58 int http_send_get(char *resource, char *host, int port, int secure, HTTP_Transmission *response);
AxedaCorp 0:a725e8eab383 59 int http_send_put(char *resource, char *host, int port, int secure, HTTP_Headers *headers, char *data, int data_sz, HTTP_Transmission *response);
AxedaCorp 0:a725e8eab383 60 int http_send_post(char *resource, char *host, int port, int secure, HTTP_Headers *headers, char *data, int data_sz, HTTP_Transmission *response);
AxedaCorp 0:a725e8eab383 61 int http_send_mpost(char *resource, char *host, int port, int secure, HTTP_Headers *headers, char *data, int data_sz, HTTP_Part *files, int part_ct, HTTP_Transmission *response);
AxedaCorp 0:a725e8eab383 62 void http_add_mpart(HTTP_Transmission *request, char *file_name, unsigned char *data, int file_sz); //For Future expansion, do not use.
AxedaCorp 0:a725e8eab383 63
AxedaCorp 0:a725e8eab383 64 //Return Handling
AxedaCorp 0:a725e8eab383 65 HTTP_Transmission *http_parse(HTTP_Transmission *response, char *data);
AxedaCorp 0:a725e8eab383 66
AxedaCorp 0:a725e8eab383 67 //Supporting Methods
AxedaCorp 0:a725e8eab383 68 char *http_getBoundary(char *buff, int length);
AxedaCorp 0:a725e8eab383 69 void zeroOutHTTPXmission(HTTP_Transmission *tgt);
AxedaCorp 0:a725e8eab383 70 char *createHeaders(char *tgtBuff, int http_operation, char *resource, int httpver, char *hostname, char *contentType, int contentLength, int xCount);
AxedaCorp 0:a725e8eab383 71
AxedaCorp 0:a725e8eab383 72 #ifdef __cplusplus
AxedaCorp 0:a725e8eab383 73 }
AxedaCorp 0:a725e8eab383 74 #endif
AxedaCorp 0:a725e8eab383 75 #endif
AxedaCorp 0:a725e8eab383 76