FIAP (IEEE1888) library

Dependents:   Fetch_IEEE1888_Storage IEEE1888_MULTI_SENSOR_GW

Fork of FiapV2 by Yasushi TAUCHI

Committer:
strysd
Date:
Sun Feb 24 05:57:19 2013 +0000
Revision:
14:a9ec0e6e22c8
Parent:
13:13cceccf6bfb
Child:
15:3bd6f70e57e2
TYPO

Who changed what in which revision?

UserRevisionLine numberNew contents of line
yueee_yt 0:d34a9148b19e 1 // IEEE1888 / FIAP Uploader Library for Arduino
yueee_yt 0:d34a9148b19e 2 //
yueee_yt 0:d34a9148b19e 3 // 2011/09/19 ver.1 H.Inoue & H.Ochiai
yueee_yt 0:d34a9148b19e 4 // 2011/12/31 Ver.1 for mbed Y.Tauchi
strysd 13:13cceccf6bfb 5 // 2013/02 inherited repository by S.Yoshida
yueee_yt 0:d34a9148b19e 6
yueee_yt 0:d34a9148b19e 7 // --------- FIAP.h ---------
yueee_yt 0:d34a9148b19e 8 #ifndef MBED_FIAP_H
yueee_yt 0:d34a9148b19e 9 #define MBED_FIAP_H
yueee_yt 0:d34a9148b19e 10
yueee_yt 0:d34a9148b19e 11 #include "mbed.h"
yueee_yt 0:d34a9148b19e 12 #include "HTTPClient.h"
yueee_yt 0:d34a9148b19e 13
yueee_yt 0:d34a9148b19e 14 // return code of post method
yueee_yt 0:d34a9148b19e 15 #define FIAP_UPLOAD_OK 0 // Succeeded
yueee_yt 0:d34a9148b19e 16 #define FIAP_UPLOAD_CONNFAIL 1 // Connection faild (Socket I/O error)
yueee_yt 0:d34a9148b19e 17 #define FIAP_UPLOAD_DNSERR 2 // DNS error
yueee_yt 0:d34a9148b19e 18 #define FIAP_UPLOAD_HTTPERR 3 // HTTP Server error (The response was not "200 OK")
yueee_yt 0:d34a9148b19e 19 #define FIAP_UPLOAD_FIAPERR 4 // FIAP Server error
yueee_yt 0:d34a9148b19e 20
strysd 13:13cceccf6bfb 21 // use fetch_last_data(struct fiap_element* v, unsigned int esize) if true
strysd 13:13cceccf6bfb 22 #define USE_FETCH_MULTI false
strysd 13:13cceccf6bfb 23
strysd 13:13cceccf6bfb 24 // use fetch_last_data(struct fiap_element* v) if true, but it seems to be broken
strysd 12:f4e59ab2bab0 25 #define USE_FETCH_ONLY_1 false
strysd 11:db42339d6cce 26
yueee_yt 0:d34a9148b19e 27 /** fiap_element
strysd 10:b355957e01f4 28 *@param char* cid Point ID
strysd 10:b355957e01f4 29 *@param char* value data
strysd 10:b355957e01f4 30 *@param uint16_t year nnnn
strysd 10:b355957e01f4 31 *@param uint8_t month 1-12
strysd 10:b355957e01f4 32 *@param uint8_t day 1-31
strysd 10:b355957e01f4 33 *@param uint8_t hour 0-23
yueee_yt 2:2ba00be13585 34 *@param uint8_t minute 0-59
yueee_yt 2:2ba00be13585 35 *@param uint8_t second 0-59
strysd 10:b355957e01f4 36 *@param char* timezone -nn:nn, +nn:nn
yueee_yt 0:d34a9148b19e 37 */
yueee_yt 0:d34a9148b19e 38 struct fiap_element {
strysd 10:b355957e01f4 39 char* cid;
strysd 10:b355957e01f4 40 char* value;
strysd 10:b355957e01f4 41 uint16_t year;
strysd 10:b355957e01f4 42 uint8_t month;
strysd 10:b355957e01f4 43 uint8_t day;
strysd 10:b355957e01f4 44 uint8_t hour;
strysd 10:b355957e01f4 45 uint8_t minute;
strysd 10:b355957e01f4 46 uint8_t second;
strysd 10:b355957e01f4 47 char* timezone;
yueee_yt 0:d34a9148b19e 48 };
yueee_yt 0:d34a9148b19e 49
strysd 10:b355957e01f4 50 /** FIAP Class */
yueee_yt 0:d34a9148b19e 51 class FIAP {
yueee_yt 0:d34a9148b19e 52 public:
strysd 13:13cceccf6bfb 53 /** Create fiap object
strysd 13:13cceccf6bfb 54 * @param Storage FIAP Storage Addrees
strysd 13:13cceccf6bfb 55 * @param _use_fetch use fetch mode if true, write mode if false
strysd 13:13cceccf6bfb 56 */
strysd 13:13cceccf6bfb 57 FIAP(char Storage[], bool _use_fetch);
strysd 13:13cceccf6bfb 58 FIAP(char Storage[]);
strysd 9:02ae92c06e52 59 FIAP();
strysd 9:02ae92c06e52 60
strysd 10:b355957e01f4 61 /** Set Storage URL
strysd 13:13cceccf6bfb 62 * @param Storage FIAP Storage Addrees
yueee_yt 0:d34a9148b19e 63 */
strysd 9:02ae92c06e52 64 void setStorage(char Storage[]);
yueee_yt 0:d34a9148b19e 65
yueee_yt 0:d34a9148b19e 66 /** post
yueee_yt 0:d34a9148b19e 67 * @param v data vaule
yueee_yt 0:d34a9148b19e 68 * @param esize number of data
yueee_yt 0:d34a9148b19e 69 */
yueee_yt 0:d34a9148b19e 70 int post(struct fiap_element* v, unsigned int esize);
yueee_yt 0:d34a9148b19e 71
yueee_yt 0:d34a9148b19e 72 /** fetch_maximum
yueee_yt 0:d34a9148b19e 73 * @param cid Point ID s
yueee_yt 0:d34a9148b19e 74 * @param v Return Values
yueee_yt 0:d34a9148b19e 75 * @param esize <=2
yueee_yt 0:d34a9148b19e 76 * @return network_error
yueee_yt 0:d34a9148b19e 77 */
strysd 12:f4e59ab2bab0 78 int fetch_last_data(struct fiap_element* v, unsigned int esize);
strysd 14:a9ec0e6e22c8 79 int fetch_last_data(struct fiap_element* v);
yueee_yt 0:d34a9148b19e 80
yueee_yt 0:d34a9148b19e 81 /** debug_mode
yueee_yt 0:d34a9148b19e 82 * Output XML and Error
yueee_yt 0:d34a9148b19e 83 */
yueee_yt 0:d34a9148b19e 84 bool debug_mode;
strysd 12:f4e59ab2bab0 85
yueee_yt 0:d34a9148b19e 86 private:
strysd 13:13cceccf6bfb 87 bool _use_fetch;//use fetch mode if true, write mode if false
strysd 13:13cceccf6bfb 88 char _fiap_storage[100];//FIAP Storage Addrees
strysd 11:db42339d6cce 89 //char _fiap_id_prefix[100];
yueee_yt 0:d34a9148b19e 90 char _soap_header[256];
yueee_yt 0:d34a9148b19e 91 char _soap_footer[256];
strysd 11:db42339d6cce 92 char _soap_action[32];
strysd 11:db42339d6cce 93 char _soap_text[2000];
strysd 11:db42339d6cce 94 char _uuid[37];
strysd 11:db42339d6cce 95 void xml_initialize(void);
strysd 11:db42339d6cce 96 void generateUUID();
strysd 10:b355957e01f4 97 char* HTTPStatusText(HTTPResult r);
strysd 11:db42339d6cce 98 void myprintf(char*);
yueee_yt 0:d34a9148b19e 99 };
yueee_yt 0:d34a9148b19e 100
yueee_yt 0:d34a9148b19e 101 #endif