Axeda Ready Demo for Freescale FRDM-KL46Z as accident alert system

Dependencies:   FRDM_MMA8451Q KL46Z-USBHost MAG3110 SocketModem TSI mbed FATFileSystem

Fork of AxedaGo-Freescal_FRDM-KL46Z revert by Axeda Corp

Committer:
AxedaCorp
Date:
Wed Jul 02 15:59:38 2014 +0000
Revision:
1:5ad12c581db4
Parent:
0:65004368569c
url ip switch
;

Who changed what in which revision?

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