RFID tracking with mbed & RS-EDP reference design

Dependencies:   RWDModule mbed SDCard

Committer:
donatien
Date:
Wed Jul 28 11:02:36 2010 +0000
Revision:
0:fd63457452f4

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
donatien 0:fd63457452f4 1 /*
donatien 0:fd63457452f4 2 Copyright (c) 2010 ARM Limited
donatien 0:fd63457452f4 3
donatien 0:fd63457452f4 4 Permission is hereby granted, free of charge, to any person obtaining a copy
donatien 0:fd63457452f4 5 of this software and associated documentation files (the "Software"), to deal
donatien 0:fd63457452f4 6 in the Software without restriction, including without limitation the rights
donatien 0:fd63457452f4 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
donatien 0:fd63457452f4 8 copies of the Software, and to permit persons to whom the Software is
donatien 0:fd63457452f4 9 furnished to do so, subject to the following conditions:
donatien 0:fd63457452f4 10
donatien 0:fd63457452f4 11 The above copyright notice and this permission notice shall be included in
donatien 0:fd63457452f4 12 all copies or substantial portions of the Software.
donatien 0:fd63457452f4 13
donatien 0:fd63457452f4 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
donatien 0:fd63457452f4 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
donatien 0:fd63457452f4 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
donatien 0:fd63457452f4 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
donatien 0:fd63457452f4 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
donatien 0:fd63457452f4 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
donatien 0:fd63457452f4 20 THE SOFTWARE.
donatien 0:fd63457452f4 21 */
donatien 0:fd63457452f4 22
donatien 0:fd63457452f4 23 #ifndef LOGGER_H
donatien 0:fd63457452f4 24 #define LOGGER_H
donatien 0:fd63457452f4 25
donatien 0:fd63457452f4 26 #include "MySQLClient.h"
donatien 0:fd63457452f4 27
donatien 0:fd63457452f4 28 #include "queue.h"
donatien 0:fd63457452f4 29
donatien 0:fd63457452f4 30 #include <string>
donatien 0:fd63457452f4 31 using std::string;
donatien 0:fd63457452f4 32
donatien 0:fd63457452f4 33 #include "mbed.h"
donatien 0:fd63457452f4 34
donatien 0:fd63457452f4 35 #include "loginfo.h"
donatien 0:fd63457452f4 36
donatien 0:fd63457452f4 37 /*
donatien 0:fd63457452f4 38 The logger is responsible for writing data in the CSV file and queueing SQL requests and executing them on the SQL server using a MySQL client instance.
donatien 0:fd63457452f4 39 */
donatien 0:fd63457452f4 40 class Logger
donatien 0:fd63457452f4 41 {
donatien 0:fd63457452f4 42 public:
donatien 0:fd63457452f4 43 Logger(const string& table);
donatien 0:fd63457452f4 44 ~Logger();
donatien 0:fd63457452f4 45
donatien 0:fd63457452f4 46 //File Logging
donatien 0:fd63457452f4 47 int fileOpen(const char* filename);
donatien 0:fd63457452f4 48 int fileClose();
donatien 0:fd63457452f4 49
donatien 0:fd63457452f4 50 //SQL Logging
donatien 0:fd63457452f4 51 int sqlOpen(Host& host, const string& user, const string& password, const string& db);
donatien 0:fd63457452f4 52 int sqlClose();
donatien 0:fd63457452f4 53
donatien 0:fd63457452f4 54 //Log an event
donatien 0:fd63457452f4 55 int log(LogInfo* pInfo); //Returns 0 on success, -1 on failure
donatien 0:fd63457452f4 56
donatien 0:fd63457452f4 57 //Main service routine, must be called regularly
donatien 0:fd63457452f4 58 void service();
donatien 0:fd63457452f4 59
donatien 0:fd63457452f4 60 //Checks if requests queue is empty
donatien 0:fd63457452f4 61 bool isEmpty();
donatien 0:fd63457452f4 62
donatien 0:fd63457452f4 63 //Status info about SQL connection
donatien 0:fd63457452f4 64 bool isConnecting();
donatien 0:fd63457452f4 65 bool isConnected();
donatien 0:fd63457452f4 66 bool connectionError();
donatien 0:fd63457452f4 67
donatien 0:fd63457452f4 68 MySQLResult getLastResult();
donatien 0:fd63457452f4 69
donatien 0:fd63457452f4 70 protected:
donatien 0:fd63457452f4 71 //Callback from MySQL client
donatien 0:fd63457452f4 72 void onMySQLResult(MySQLResult r);
donatien 0:fd63457452f4 73
donatien 0:fd63457452f4 74 private:
donatien 0:fd63457452f4 75 mbed::queue<string> m_lSQLReq;
donatien 0:fd63457452f4 76 FILE* m_fd;
donatien 0:fd63457452f4 77
donatien 0:fd63457452f4 78 string m_table;
donatien 0:fd63457452f4 79
donatien 0:fd63457452f4 80 // Timer m_reqTimer;
donatien 0:fd63457452f4 81 MySQLClient m_sqlClient;
donatien 0:fd63457452f4 82 MySQLResult m_sqlLastResult;
donatien 0:fd63457452f4 83
donatien 0:fd63457452f4 84 bool m_sqlConnecting;
donatien 0:fd63457452f4 85 bool m_sqlConnected;
donatien 0:fd63457452f4 86 bool m_sqlConnectionError;
donatien 0:fd63457452f4 87 bool m_sqlCommand;
donatien 0:fd63457452f4 88
donatien 0:fd63457452f4 89 };
donatien 0:fd63457452f4 90
donatien 0:fd63457452f4 91 #endif