Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more
Revision 192:54b758a8eaaa, committed 2014-09-26
- Comitter:
- ansond
- Date:
- Fri Sep 26 05:16:07 2014 +0000
- Parent:
- 191:c83c1c5010ed
- Commit message:
- updates to new logger name
Changed in this revision
--- a/APMDemoLight.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/APMDemoLight.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -55,7 +55,7 @@
}
// default constructor
- APMDemoLight::APMDemoLight(ErrorHandler *error_handler) : BaseClass(error_handler,NULL) {
+ APMDemoLight::APMDemoLight(Logger *logger) : BaseClass(logger,NULL) {
this->m_dimming = false;
sscanf(LIGHT_DEFAULT_STATE,"%d",&this->m_state);
sscanf(LIGHT_DIM_STATE,"%f",&this->m_dim);
--- a/APMDemoLight.h Wed Sep 24 19:12:35 2014 +0000
+++ b/APMDemoLight.h Fri Sep 26 05:16:07 2014 +0000
@@ -33,7 +33,7 @@
int m_state;
public:
- APMDemoLight(ErrorHandler *error_handler);
+ APMDemoLight(Logger *logger);
virtual ~APMDemoLight();
virtual void on();
--- a/Action.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/Action.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "Action.h"
// default constructor
- Action::Action(ErrorHandler *error_handler) : BaseClass(error_handler,NULL) {
+ Action::Action(Logger *logger) : BaseClass(logger,NULL) {
}
// destructor
--- a/Action.h Wed Sep 24 19:12:35 2014 +0000
+++ b/Action.h Fri Sep 26 05:16:07 2014 +0000
@@ -24,7 +24,7 @@
class Action : public BaseClass {
public:
- Action(ErrorHandler *error_handler);
+ Action(Logger *logger);
virtual ~Action();
};
--- a/BaseClass.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/BaseClass.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -20,8 +20,8 @@
#include "BaseClass.h"
// default constructor
- BaseClass::BaseClass(ErrorHandler *error_handler,void *endpoint) {
- this->m_error_handler = error_handler;
+ BaseClass::BaseClass(Logger *logger,void *endpoint) {
+ this->m_logger = logger;
this->m_endpoint = endpoint;
}
@@ -29,8 +29,8 @@
BaseClass::~BaseClass() {
}
- // ErrorHandler accessor
- ErrorHandler *BaseClass::logger() { return this->m_error_handler; }
+ // Logger accessor
+ Logger *BaseClass::logger() { return this->m_logger; }
// Endpoint accessor
void *BaseClass::getEndpoint() { return this->m_endpoint; }
--- a/BaseClass.h Wed Sep 24 19:12:35 2014 +0000
+++ b/BaseClass.h Fri Sep 26 05:16:07 2014 +0000
@@ -19,19 +19,19 @@
#ifndef _BASECLASS_H_
#define _BASECLASS_H_
-// ErrorHandler Support
-#include "ErrorHandler.h"
+// Logger Support
+#include "Logger.h"
class BaseClass {
private:
- ErrorHandler *m_error_handler;
- void *m_endpoint;
+ Logger *m_logger;
+ void *m_endpoint;
public:
- BaseClass(ErrorHandler *error_handler,void *endpoint);
+ BaseClass(Logger *error_handler,void *endpoint);
virtual ~BaseClass();
- ErrorHandler *logger();
+ Logger *logger();
protected:
void *getEndpoint();
--- a/CommonDefinitions.h Wed Sep 24 19:12:35 2014 +0000 +++ b/CommonDefinitions.h Fri Sep 26 05:16:07 2014 +0000 @@ -22,6 +22,9 @@ // maximum memory buffer chunk (including HTTPS requests) #define MAX_BUFFER_LENGTH 256 +// maximum memory buffer chunk (including HTTPS requests) +#define MAX_SMALL_BUFFER_LENGTH 256 + // Error Handler Log Message Length #define MAX_LOG_MESSAGE MAX_BUFFER_LENGTH // maximum size of a logging message #define TEMP_BUFFER_LEN 128 // working/temp buffer length
--- a/CopCarLEDFlasher.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/CopCarLEDFlasher.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "CopCarLEDFlasher.h"
// default constructor
- CopCarLEDFlasher::CopCarLEDFlasher(PwmOut *led1,PwmOut *led2,ErrorHandler *error_handler) : ExternalLEDLight(led1,error_handler) {
+ CopCarLEDFlasher::CopCarLEDFlasher(PwmOut *led1,PwmOut *led2,Logger *logger) : ExternalLEDLight(led1,logger) {
this->m_led2 = led2;
this->m_toggle = false;
}
--- a/CopCarLEDFlasher.h Wed Sep 24 19:12:35 2014 +0000
+++ b/CopCarLEDFlasher.h Fri Sep 26 05:16:07 2014 +0000
@@ -27,7 +27,7 @@
bool m_toggle;
public:
- CopCarLEDFlasher(PwmOut *led1,PwmOut *led2,ErrorHandler *error_handler);
+ CopCarLEDFlasher(PwmOut *led1,PwmOut *led2,Logger *logger);
virtual ~CopCarLEDFlasher();
virtual void on();
--- a/ErrorHandler.cpp Wed Sep 24 19:12:35 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,365 +0,0 @@
-/* Copyright C2013 Doug Anson, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files the "Software", to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
- #include "ErrorHandler.h"
- #include "MBEDEndpoint.h"
-
-#ifdef _ENDPOINT_UBLOX_PLATFORM
- // Annunciations
- DigitalOut led1(P3_25);
- DigitalOut led2(P3_25);
- DigitalOut led3(P3_25);
- DigitalOut led4(P3_25);
-
- // Multi-color LED support
- PwmOut r(D5);
- PwmOut g(D9);
- PwmOut b(D8);
-#endif
-
-#ifdef _ENDPOINT_NXP_PLATFORM
- // Annunciations
- DigitalOut led1(LED1);
- DigitalOut led2(LED2);
- DigitalOut led3(LED3);
- DigitalOut led4(LED4);
-
- // Multi-color LED support
- PwmOut r(p23);
- PwmOut g(p24);
- PwmOut b(p25);
-#endif
-
-#ifdef _ENDPOINT_FREEDOM_PLATFORM
- // Annunciations
- DigitalOut led1(LED1);
- DigitalOut led2(LED2);
- DigitalOut led3(LED3);
- DigitalOut led4(LED4);
-
- // Multi-color LED support
- PwmOut r(p23);
- PwmOut g(p24);
- PwmOut b(p25);
-#endif
-
-// Memory statistics macro
-#define ERROR_HANDLER_MEM_STATS(x) \
- int s##x=0;\
- int *h##x = new int [1];\
- if (this->m_pc != NULL) this->m_pc->printf("\r\nMEMORY: stack: 0x%08x heap: 0x%08x avail: %d bytes\r\n", &s##x, h##x, &s##x-h##x);\
- if (h##x > &s##x)\
- error("collision\n");\
- delete [] h##x;\
- __nop();
-
- // close down connections
- extern void closedown(int code);
-
- // default constructor
- ErrorHandler::ErrorHandler(BufferedSerial *pc,LCDCLASS *lcd) {
- this->m_pc = pc;
- this->m_lcd = lcd;
- this->m_status_lcd = false;
- memset(this->m_message,0,MAX_LOG_MESSAGE+1);
-#ifdef EH_USE_MUTEXES
- this->m_mutex = NULL;
- this->m_close_mutex = NULL;
- this->m_led_mutex = NULL;
- this->m_rgb_mutex = NULL;
- this->m_mutex = new Mutex();
- this->m_close_mutex = new Mutex();
- this->m_led_mutex = new Mutex();
- this->m_rgb_mutex = new Mutex();
- this->releaseMutexes();
-#endif
- this->resetLEDs();
- }
-
- // default destructor
- ErrorHandler::~ErrorHandler() {
-#ifdef EH_USE_MUTEXES
- this->releaseMutexes();
- if (this->m_mutex != NULL) delete this->m_mutex;
- if (this->m_close_mutex != NULL) delete this->m_close_mutex;
- if (this->m_led_mutex != NULL) delete this->m_led_mutex;
- if (this->m_rgb_mutex != NULL) delete this->m_rgb_mutex;
-#endif
- }
-
- // enable LCD to only show summary status
- void ErrorHandler::lcdStatusOnly(bool status_lcd) { this->m_status_lcd = status_lcd; }
-
- #ifdef EH_USE_MUTEXES
- // release all mutexes
- void ErrorHandler::releaseMutexes() {
- if (this->m_mutex != NULL) this->m_mutex->unlock();
- if (this->m_close_mutex != NULL) this->m_close_mutex->unlock();
- if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
- if (this->m_rgb_mutex != NULL) this->m_rgb_mutex->unlock();
- }
- #endif
-
- // log information
- void ErrorHandler::log(const char *format, ...) {
-#ifndef HUSH_LOG
- memset(this->m_message,0,MAX_LOG_MESSAGE+1);
- va_list args;
- va_start(args, format);
- vsprintf(this->m_message, format, args);
- va_end(args);
-#ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->lock();
-#endif
- if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
- #ifdef ENABLE_MEMORY_DEBUG
- ERROR_HANDLER_MEM_STATS(0);
- #endif
- if (this->m_pc != NULL) this->m_pc->printf("\r\n");
- if (this->m_status_lcd) {
- MBEDEndpoint *endpoint = (MBEDEndpoint *)this->m_endpoint;
- if (endpoint != NULL) {
- this->m_lcd->cls();
- this->m_lcd->locate(0,0);
- this->m_lcd->printf(endpoint->getLCDStatus());
- }
- }
- else {
- this->m_lcd->cls();
- this->m_lcd->locate(0,0);
- this->m_lcd->printf(this->m_message);
- }
-#ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->unlock();
-#endif
-#else
-#ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->lock();
-#endif
- if (this->m_status_lcd) {
- MBEDEndpoint *endpoint = (MBEDEndpoint *)this->m_endpoint;
- if (endpoint != NULL) {
- this->m_lcd->cls();
- this->m_lcd->locate(0,0);
- this->m_lcd->printf(endpoint->getLCDStatus());
- }
- }
-#ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->unlock();
-#endif
-#endif
- }
-
- // log information
- void ErrorHandler::log_memory(const char *format, ...) {
- #ifndef HUSH_LOG
- #ifdef MEMORY_LOGGING
- memset(this->m_message,0,MAX_LOG_MESSAGE+1);
- va_list args;
- va_start(args, format);
- vsprintf(this->m_message, format, args);
- va_end(args);
- #ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->lock();
- #endif
- if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
- ERROR_HANDLER_MEM_STATS(0);
- #ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->unlock();
- #endif
- #endif
- #endif
- }
-
- // pause
- void ErrorHandler::pause(const char *format, ...) {
- #ifndef HUSH_LOG
- memset(this->m_message,0,MAX_LOG_MESSAGE+1);
- va_list args;
- va_start(args, format);
- vsprintf(this->m_message, format, args);
- va_end(args);
- #ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->lock();
- #endif
- if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
- if (this->m_pc != NULL) this->m_pc->printf("\r\n");
- this->m_lcd->cls();
- this->m_lcd->locate(0,0);
- this->m_lcd->printf(this->m_message);
- if (this->m_pc != NULL) {
- this->m_pc->printf("Press any key to continue...ctrl-c to stop\r\n");
- char c = this->m_pc->getc();
- if (c == 0x03) { // CTRL-C ASCII
- this->m_pc->printf("ctrl-c: closing down...\r\n");
- #ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->unlock();
- #endif
- closedown(1);
- }
- }
- #ifdef EH_USE_MUTEXES
- if (this->m_mutex != NULL) this->m_mutex->unlock();
- #endif
- #endif
- }
-
- // check for exit
- void ErrorHandler::checkForExit() {
- #ifdef EH_USE_MUTEXES
- if (this->m_close_mutex != NULL) this->m_close_mutex->lock();
- #endif
- if (this->m_pc != NULL && this->m_pc->readable()) {
- char c = this->m_pc->getc();
- if (c == 0x03) { // CTRL-C ASCII
- this->m_pc->printf("ctrl-c: closing down...\r\n");
- closedown(1);
- }
- }
- #ifdef EH_USE_MUTEXES
- if (this->m_close_mutex != NULL) this->m_close_mutex->unlock();
- #endif
-}
-
-// set the color LED
-void ErrorHandler::setRGBLED(float H, float S, float V) {
-#ifndef HUSH_LEDS
-#ifdef EH_USE_MUTEXES
- if (this->m_rgb_mutex != NULL) this->m_rgb_mutex->lock();
-#endif
- float f,h,p,q,t;
- int i;
- if( S == 0.0) {
- r = 1.0 - V; // invert pwm !
- g = 1.0 - V;
- b = 1.0 - V;
- return;
- }
- if(H > 360.0) H = 0.0; // check values
- if(S > 1.0) S = 1.0;
- if(S < 0.0) S = 0.0;
- if(V > 1.0) V = 1.0;
- if(V < 0.0) V = 0.0;
- h = H / 60.0;
- i = (int) h;
- f = h - i;
- p = V * (1.0 - S);
- q = V * (1.0 - (S * f));
- t = V * (1.0 - (S * (1.0 - f)));
-
- switch(i) {
- case 0:
- r = 1.0 - V; // invert pwm !
- g = 1.0 - t;
- b = 1.0 - p;
- break;
- case 1:
- r = 1.0 - q;
- g = 1.0 - V;
- b = 1.0 - p;
- break;
- case 2:
- r = 1.0 - p;
- g = 1.0 - V;
- b = 1.0 - t;
- break;
- case 3:
- r = 1.0 - p;
- g = 1.0 - q;
- b = 1.0 - V;
- break;
- case 4:
- r = 1.0 - t;
- g = 1.0 - p;
- b = 1.0 - V;
- break;
- case 5:
- default:
- r = 1.0 - V;
- g = 1.0 - p;
- b = 1.0 - q;
- break;
- }
- #ifdef EH_USE_MUTEXES
- if (this->m_rgb_mutex != NULL) this->m_rgb_mutex->unlock();
- #endif
- #endif
-}
-
-// turn the RGB LED specific colors
-void ErrorHandler::turnLEDRed() { this->setRGBLED(0.0,1.0,0.2); }
-void ErrorHandler::turnLEDGreen() { this->setRGBLED(120.0,1.0,0.2); }
-void ErrorHandler::turnLEDBlue() { this->setRGBLED(200.0,1.0,0.2); }
-void ErrorHandler::turnLEDPurple() { this->setRGBLED(261.9,1.0,0.2); }
-void ErrorHandler::turnLEDOrange() { this->setRGBLED(51.0,1.0,0.2); }
-void ErrorHandler::turnLEDBlack() { this->setRGBLED(0,0,0); }
-void ErrorHandler::turnLEDYellow() { this->setRGBLED(60.0,1.0,0.133); }
-
-// reset LEDs
-void ErrorHandler::resetLEDs() {
-#ifndef HUSH_LEDS
- // turn off all LEDs
- led1 = 0; led2 = 0; led3 = 0; led4 = 0;
-#endif
-}
-
-// blink an LED
-void ErrorHandler::blinkLED(DigitalOut led) {
-#ifndef HUSH_LEDS
-#ifdef EH_USE_MUTEXES
- if (this->m_led_mutex != NULL) this->m_led_mutex->lock();
-#endif
- led = 1;
-#ifdef EH_USE_MUTEXES
- if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
-#endif
- Thread::wait(BLINK_TIME);
-#ifdef EH_USE_MUTEXES
- if (this->m_led_mutex != NULL) this->m_led_mutex->lock();
-#endif
- led = 0;
-#ifdef EH_USE_MUTEXES
- if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
-#endif
-#endif
-}
-
-void ErrorHandler::changeLED(DigitalOut led,bool onoff) {
-#ifdef EH_USE_MUTEXES
- if (this->m_led_mutex != NULL) this->m_led_mutex->lock();
-#endif
- if (onoff) led = 1;
- else led = 0;
-#ifdef EH_USE_MUTEXES
- if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
-#endif
-}
-
-void ErrorHandler::led2On() { this->changeLED(led2,true); }
-void ErrorHandler::led2Off() { this->changeLED(led2,false); }
-void ErrorHandler::led3On() { this->changeLED(led3,true); }
-void ErrorHandler::led3Off() { this->changeLED(led3,false); }
-
-void ErrorHandler::setEndpoint(void *endpoint) { this->m_endpoint = endpoint; }
-void *ErrorHandler::getEndpoint() { return this->m_endpoint; }
-
-// blink the Transport TX LED
-void ErrorHandler::blinkTransportTxLED() { this->blinkLED(led4); }
-
-// blink the Transport RX LED
-void ErrorHandler::blinkTransportRxLED() { this->blinkLED(led1); }
\ No newline at end of file
--- a/ErrorHandler.h Wed Sep 24 19:12:35 2014 +0000
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,109 +0,0 @@
-/* Copyright C2013 Doug Anson, MIT License
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
- * and associated documentation files the "Software", to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge, publish, distribute,
- * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies or
- * substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
- * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
- * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- */
-
-#ifndef _ERROR_HANDLER_H_
-#define _ERROR_HANDLER_H_
-
-// Tunables
-#include "Definitions.h"
-
-// Buffered Serial
-#include "BufferedSerial.h"
-
-// Support for std args
-#include <stdarg.h>
-
-// LCD Support
-#ifdef _ENDPOINT_UBLOX_PLATFORM
- #include "C12832.h"
- #define LCDCLASS C12832
-#endif
-
-#ifdef _ENDPOINT_NXP_PLATFORM
- #include "C12832_lcd.h"
- #define LCDCLASS C12832_LCD
-#endif
-
-#ifdef _ENDPOINT_FREEDOM_PLATFORM
- #include "C12832_lcd.h"
- #define LCDCLASS C12832_LCD
-#endif
-
-#if defined(EH_USE_MUTEXES) || defined(NETWORK_MUTEX) || defined(ENABLE_THREADS) || defined(NSP_CELLULAR_NETWORK)
- // RTOS support
- #include "mbed.h"
- #include "rtos.h"
-#endif
-
-class ErrorHandler {
- private:
- BufferedSerial *m_pc;
- LCDCLASS *m_lcd;
- char m_message[MAX_LOG_MESSAGE+1];
-#ifdef EH_USE_MUTEXES
- Mutex *m_mutex;
- Mutex *m_close_mutex;
- Mutex *m_led_mutex;
- Mutex *m_rgb_mutex;
-#endif
- void *m_endpoint;
- bool m_status_lcd;
-
- public:
- ErrorHandler(BufferedSerial *pc,LCDCLASS *lcd);
- ~ErrorHandler();
-
- void lcdStatusOnly(bool status_lcd);
-
- void log(const char *format, ...);
- void log_memory(const char *format, ...);
- void checkForExit();
-
- void pause(const char *format, ...);
-
- void turnLEDRed();
- void turnLEDGreen();
- void turnLEDBlue();
- void turnLEDPurple();
- void turnLEDBlack();
- void turnLEDYellow();
- void turnLEDOrange();
-
- void blinkTransportTxLED();
- void blinkTransportRxLED();
-
-#ifdef EH_USE_MUTEXES
- void releaseMutexes();
-#endif
-
- void led2On();
- void led2Off();
- void led3On();
- void led3Off();
-
- void setEndpoint(void *endpoint);
- void *getEndpoint();
-
- private:
- void setRGBLED(float H, float S, float V);
- void blinkLED(DigitalOut led);
- void resetLEDs();
- void changeLED(DigitalOut led,bool onoff);
-};
-
-#endif // _ERROR_HANDLER_H_
\ No newline at end of file
--- a/ExternalLEDLight.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/ExternalLEDLight.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
//#endif
// default constructor
- ExternalLEDLight::ExternalLEDLight(PwmOut *led,ErrorHandler *error_handler) : BaseClass(error_handler,NULL) {
+ ExternalLEDLight::ExternalLEDLight(PwmOut *led,Logger *logger) : BaseClass(logger,NULL) {
this->m_led = led;
this->m_dimming = false;
sscanf(LIGHT_DEFAULT_STATE,"%d",&this->m_state);
--- a/ExternalLEDLight.h Wed Sep 24 19:12:35 2014 +0000
+++ b/ExternalLEDLight.h Fri Sep 26 05:16:07 2014 +0000
@@ -33,7 +33,7 @@
int m_state;
public:
- ExternalLEDLight(PwmOut *led,ErrorHandler *error_handler);
+ ExternalLEDLight(PwmOut *led,Logger *logger);
virtual ~ExternalLEDLight();
virtual void on();
--- a/HTTPTransport.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/HTTPTransport.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -31,13 +31,13 @@
extern HTTPClient _http;
// default constructor
- HTTPTransport::HTTPTransport(ErrorHandler *error_handler,void *endpoint) : Transport(error_handler,endpoint) {
+ HTTPTransport::HTTPTransport(Logger *logger,void *endpoint) : Transport(logger,endpoint) {
this->m_http = &_http;
this->m_connected = true;
}
// constructor with custom HTTPClient binding
- HTTPTransport::HTTPTransport(HTTPClient *http,ErrorHandler *error_handler,void *endpoint) : Transport(error_handler,endpoint) {
+ HTTPTransport::HTTPTransport(HTTPClient *http,Logger *logger,void *endpoint) : Transport(logger,endpoint) {
this->m_http = http;
this->m_connected = true;
}
--- a/HTTPTransport.h Wed Sep 24 19:12:35 2014 +0000
+++ b/HTTPTransport.h Fri Sep 26 05:16:07 2014 +0000
@@ -30,8 +30,8 @@
HTTPClient *m_http;
public:
- HTTPTransport(ErrorHandler *error_handler,void *endpoint);
- HTTPTransport(HTTPClient *http,ErrorHandler *error_handler,void *endpoint);
+ HTTPTransport(Logger *logger,void *endpoint);
+ HTTPTransport(HTTPClient *http,Logger *logger,void *endpoint);
virtual ~HTTPTransport();
virtual void basicAuth(char *username,char *pw);
--- a/Light.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/Light.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -35,7 +35,7 @@
}
// default constructor
- Light::Light(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) : Personality(error_handler,transports,instance,endpoint,LIGHT_TYPE_STRING) {
+ Light::Light(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) : Personality(logger,transports,instance,endpoint,LIGHT_TYPE_STRING) {
this->m_forward = true;
// setup the blinking thread
--- a/Light.h Wed Sep 24 19:12:35 2014 +0000
+++ b/Light.h Fri Sep 26 05:16:07 2014 +0000
@@ -53,7 +53,7 @@
int m_current_state;
public:
- Light(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint);
+ Light(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint);
virtual ~Light();
void setDimmerAction(void *dimmer_action);
--- a/LightDimmerAction.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/LightDimmerAction.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "LightDimmerAction.h"
// default constructor
- LightDimmerAction::LightDimmerAction(ErrorHandler *error_handler,Light *light) : Action(error_handler) {
+ LightDimmerAction::LightDimmerAction(Logger *logger,Light *light) : Action(logger) {
this->m_light = light;
}
--- a/LightDimmerAction.h Wed Sep 24 19:12:35 2014 +0000
+++ b/LightDimmerAction.h Fri Sep 26 05:16:07 2014 +0000
@@ -33,7 +33,7 @@
Light *m_light;
public:
- LightDimmerAction(ErrorHandler *error_handler,Light *light);
+ LightDimmerAction(Logger *logger,Light *light);
virtual ~LightDimmerAction();
void dim();
--- a/LightSwitchAction.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/LightSwitchAction.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "LightSwitchAction.h"
// default constructor
- LightSwitchAction::LightSwitchAction(ErrorHandler *error_handler,Light *light) : Action(error_handler) {
+ LightSwitchAction::LightSwitchAction(Logger *logger,Light *light) : Action(logger) {
this->m_light = light;
}
--- a/LightSwitchAction.h Wed Sep 24 19:12:35 2014 +0000
+++ b/LightSwitchAction.h Fri Sep 26 05:16:07 2014 +0000
@@ -33,7 +33,7 @@
Light *m_light;
public:
- LightSwitchAction(ErrorHandler *error_handler,Light *light);
+ LightSwitchAction(Logger *logger,Light *light);
virtual ~LightSwitchAction();
void toggle();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Logger.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -0,0 +1,386 @@
+/* Copyright C2013 Doug Anson, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files the "Software", to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+ #include "Logger.h"
+ #include "MBEDEndpoint.h"
+
+#ifdef _ENDPOINT_UBLOX_PLATFORM
+ // Annunciations
+ DigitalOut led1(P3_25);
+ DigitalOut led2(P3_25);
+ DigitalOut led3(P3_25);
+ DigitalOut led4(P3_25);
+
+ // Multi-color LED support
+ PwmOut r(D5);
+ PwmOut g(D9);
+ PwmOut b(D8);
+#endif
+
+#ifdef _ENDPOINT_NXP_PLATFORM
+ // Annunciations
+ DigitalOut led1(LED1);
+ DigitalOut led2(LED2);
+ DigitalOut led3(LED3);
+ DigitalOut led4(LED4);
+
+ // Multi-color LED support
+ PwmOut r(p23);
+ PwmOut g(p24);
+ PwmOut b(p25);
+#endif
+
+#ifdef _ENDPOINT_FREEDOM_PLATFORM
+ // Annunciations
+ DigitalOut led1(LED1);
+ DigitalOut led2(LED2);
+ DigitalOut led3(LED3);
+ DigitalOut led4(LED4);
+
+ // Multi-color LED support
+ PwmOut r(p23);
+ PwmOut g(p24);
+ PwmOut b(p25);
+#endif
+
+// Memory statistics macro
+#define LOGGER_MEM_STATS(x) \
+ int s##x=0;\
+ int *h##x = new int [1];\
+ if (this->m_pc != NULL) this->m_pc->printf("\r\nMEMORY: stack: 0x%08x heap: 0x%08x avail: %d bytes\r\n", &s##x, h##x, &s##x-h##x);\
+ if (h##x > &s##x)\
+ error("collision\n");\
+ delete [] h##x;\
+ __nop();
+
+ // close down connections
+ extern void closedown(int code);
+
+ // default constructor
+ Logger::Logger(RawSerial *pc,LCDCLASS *lcd) {
+ this->m_pc = pc;
+ this->m_lcd = lcd;
+ this->m_status_lcd = false;
+ memset(this->m_message,0,MAX_LOG_MESSAGE+1);
+#ifdef EH_USE_MUTEXES
+ this->m_mutex = NULL;
+ this->m_close_mutex = NULL;
+ this->m_led_mutex = NULL;
+ this->m_rgb_mutex = NULL;
+ this->m_mutex = new Mutex();
+ this->m_close_mutex = new Mutex();
+ this->m_led_mutex = new Mutex();
+ this->m_rgb_mutex = new Mutex();
+ this->releaseMutexes();
+#endif
+ this->resetLEDs();
+ }
+
+ // default destructor
+ Logger::~Logger() {
+#ifdef EH_USE_MUTEXES
+ this->releaseMutexes();
+ if (this->m_mutex != NULL) delete this->m_mutex;
+ if (this->m_close_mutex != NULL) delete this->m_close_mutex;
+ if (this->m_led_mutex != NULL) delete this->m_led_mutex;
+ if (this->m_rgb_mutex != NULL) delete this->m_rgb_mutex;
+#endif
+ }
+
+ // enable LCD to only show summary status
+ void Logger::lcdStatusOnly(bool status_lcd) { this->m_status_lcd = status_lcd; }
+
+ #ifdef EH_USE_MUTEXES
+ // release all mutexes
+ void Logger::releaseMutexes() {
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+ if (this->m_close_mutex != NULL) this->m_close_mutex->unlock();
+ if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
+ if (this->m_rgb_mutex != NULL) this->m_rgb_mutex->unlock();
+ }
+ #endif
+
+ // log information
+ void Logger::log(const char *format, ...) {
+#ifndef HUSH_LOG
+ memset(this->m_message,0,MAX_LOG_MESSAGE+1);
+ va_list args;
+ va_start(args, format);
+ vsprintf(this->m_message, format, args);
+ va_end(args);
+#ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->lock();
+#endif
+ if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
+ #ifdef ENABLE_MEMORY_DEBUG
+ LOGGER_MEM_STATS(0);
+ #endif
+ if (this->m_pc != NULL) this->m_pc->printf("\r\n");
+ if (this->m_status_lcd) {
+ MBEDEndpoint *endpoint = (MBEDEndpoint *)this->m_endpoint;
+ if (endpoint != NULL) {
+ this->m_lcd->cls();
+ this->m_lcd->locate(0,0);
+ this->m_lcd->printf(endpoint->getLCDStatus());
+ }
+ }
+ else {
+ this->m_lcd->cls();
+ this->m_lcd->locate(0,0);
+ this->m_lcd->printf(this->m_message);
+ }
+#ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+#endif
+#else
+#ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->lock();
+#endif
+ if (this->m_status_lcd) {
+ MBEDEndpoint *endpoint = (MBEDEndpoint *)this->m_endpoint;
+ if (endpoint != NULL) {
+ this->m_lcd->cls();
+ this->m_lcd->locate(0,0);
+ this->m_lcd->printf(endpoint->getLCDStatus());
+ }
+ }
+#ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+#endif
+#endif
+ }
+
+ // log ( to serial console only )information
+ void Logger::logConsole(const char *format, ...) {
+ memset(this->m_message,0,MAX_LOG_MESSAGE+1);
+ va_list args;
+ va_start(args, format);
+ vsprintf(this->m_message, format, args);
+ va_end(args);
+
+#ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->lock();
+#endif
+ if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
+ #ifdef ENABLE_MEMORY_DEBUG
+ LOGGER_MEM_STATS(0);
+ #endif
+ if (this->m_pc != NULL) this->m_pc->printf("\r\n");
+#ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+#endif
+ }
+
+ // log information
+ void Logger::log_memory(const char *format, ...) {
+ #ifndef HUSH_LOG
+ #ifdef MEMORY_LOGGING
+ memset(this->m_message,0,MAX_LOG_MESSAGE+1);
+ va_list args;
+ va_start(args, format);
+ vsprintf(this->m_message, format, args);
+ va_end(args);
+ #ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->lock();
+ #endif
+ if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
+ LOGGER_MEM_STATS(0);
+ #ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+ #endif
+ #endif
+ #endif
+ }
+
+ // pause
+ void Logger::pause(const char *format, ...) {
+ #ifndef HUSH_LOG
+ memset(this->m_message,0,MAX_LOG_MESSAGE+1);
+ va_list args;
+ va_start(args, format);
+ vsprintf(this->m_message, format, args);
+ va_end(args);
+ #ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->lock();
+ #endif
+ if (this->m_pc != NULL) this->m_pc->printf(this->m_message);
+ if (this->m_pc != NULL) this->m_pc->printf("\r\n");
+ this->m_lcd->cls();
+ this->m_lcd->locate(0,0);
+ this->m_lcd->printf(this->m_message);
+ if (this->m_pc != NULL) {
+ this->m_pc->printf("Press any key to continue...ctrl-c to stop\r\n");
+ char c = this->m_pc->getc();
+ if (c == 0x03) { // CTRL-C ASCII
+ this->m_pc->printf("ctrl-c: closing down...\r\n");
+ #ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+ #endif
+ closedown(1);
+ }
+ }
+ #ifdef EH_USE_MUTEXES
+ if (this->m_mutex != NULL) this->m_mutex->unlock();
+ #endif
+ #endif
+ }
+
+ // check for exit
+ void Logger::checkForExit() {
+ #ifdef EH_USE_MUTEXES
+ if (this->m_close_mutex != NULL) this->m_close_mutex->lock();
+ #endif
+ if (this->m_pc != NULL && this->m_pc->readable()) {
+ char c = this->m_pc->getc();
+ if (c == 0x03) { // CTRL-C ASCII
+ this->m_pc->printf("ctrl-c: closing down...\r\n");
+ closedown(1);
+ }
+ }
+ #ifdef EH_USE_MUTEXES
+ if (this->m_close_mutex != NULL) this->m_close_mutex->unlock();
+ #endif
+}
+
+// set the color LED
+void Logger::setRGBLED(float H, float S, float V) {
+#ifndef HUSH_LEDS
+#ifdef EH_USE_MUTEXES
+ if (this->m_rgb_mutex != NULL) this->m_rgb_mutex->lock();
+#endif
+ float f,h,p,q,t;
+ int i;
+ if( S == 0.0) {
+ r = 1.0 - V; // invert pwm !
+ g = 1.0 - V;
+ b = 1.0 - V;
+ return;
+ }
+ if(H > 360.0) H = 0.0; // check values
+ if(S > 1.0) S = 1.0;
+ if(S < 0.0) S = 0.0;
+ if(V > 1.0) V = 1.0;
+ if(V < 0.0) V = 0.0;
+ h = H / 60.0;
+ i = (int) h;
+ f = h - i;
+ p = V * (1.0 - S);
+ q = V * (1.0 - (S * f));
+ t = V * (1.0 - (S * (1.0 - f)));
+
+ switch(i) {
+ case 0:
+ r = 1.0 - V; // invert pwm !
+ g = 1.0 - t;
+ b = 1.0 - p;
+ break;
+ case 1:
+ r = 1.0 - q;
+ g = 1.0 - V;
+ b = 1.0 - p;
+ break;
+ case 2:
+ r = 1.0 - p;
+ g = 1.0 - V;
+ b = 1.0 - t;
+ break;
+ case 3:
+ r = 1.0 - p;
+ g = 1.0 - q;
+ b = 1.0 - V;
+ break;
+ case 4:
+ r = 1.0 - t;
+ g = 1.0 - p;
+ b = 1.0 - V;
+ break;
+ case 5:
+ default:
+ r = 1.0 - V;
+ g = 1.0 - p;
+ b = 1.0 - q;
+ break;
+ }
+ #ifdef EH_USE_MUTEXES
+ if (this->m_rgb_mutex != NULL) this->m_rgb_mutex->unlock();
+ #endif
+ #endif
+}
+
+// turn the RGB LED specific colors
+void Logger::turnLEDRed() { this->setRGBLED(0.0,1.0,0.2); }
+void Logger::turnLEDGreen() { this->setRGBLED(120.0,1.0,0.2); }
+void Logger::turnLEDBlue() { this->setRGBLED(200.0,1.0,0.2); }
+void Logger::turnLEDPurple() { this->setRGBLED(261.9,1.0,0.2); }
+void Logger::turnLEDOrange() { this->setRGBLED(51.0,1.0,0.2); }
+void Logger::turnLEDBlack() { this->setRGBLED(0,0,0); }
+void Logger::turnLEDYellow() { this->setRGBLED(60.0,1.0,0.133); }
+
+// reset LEDs
+void Logger::resetLEDs() {
+#ifndef HUSH_LEDS
+ // turn off all LEDs
+ led1 = 0; led2 = 0; led3 = 0; led4 = 0;
+#endif
+}
+
+// blink an LED
+void Logger::blinkLED(DigitalOut led) {
+#ifndef HUSH_LEDS
+#ifdef EH_USE_MUTEXES
+ if (this->m_led_mutex != NULL) this->m_led_mutex->lock();
+#endif
+ led = 1;
+#ifdef EH_USE_MUTEXES
+ if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
+#endif
+ Thread::wait(BLINK_TIME);
+#ifdef EH_USE_MUTEXES
+ if (this->m_led_mutex != NULL) this->m_led_mutex->lock();
+#endif
+ led = 0;
+#ifdef EH_USE_MUTEXES
+ if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
+#endif
+#endif
+}
+
+void Logger::changeLED(DigitalOut led,bool onoff) {
+#ifdef EH_USE_MUTEXES
+ if (this->m_led_mutex != NULL) this->m_led_mutex->lock();
+#endif
+ if (onoff) led = 1;
+ else led = 0;
+#ifdef EH_USE_MUTEXES
+ if (this->m_led_mutex != NULL) this->m_led_mutex->unlock();
+#endif
+}
+
+void Logger::led2On() { this->changeLED(led2,true); }
+void Logger::led2Off() { this->changeLED(led2,false); }
+void Logger::led3On() { this->changeLED(led3,true); }
+void Logger::led3Off() { this->changeLED(led3,false); }
+
+void Logger::setEndpoint(void *endpoint) { this->m_endpoint = endpoint; }
+void *Logger::getEndpoint() { return this->m_endpoint; }
+
+// blink the Transport TX LED
+void Logger::blinkTransportTxLED() { this->blinkLED(led4); }
+
+// blink the Transport RX LED
+void Logger::blinkTransportRxLED() { this->blinkLED(led1); }
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Logger.h Fri Sep 26 05:16:07 2014 +0000
@@ -0,0 +1,107 @@
+/* Copyright C2013 Doug Anson, MIT License
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
+ * and associated documentation files the "Software", to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge, publish, distribute,
+ * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in all copies or
+ * substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
+ * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+ * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _LOGGER_H_
+#define _LOGGER_H_
+
+// Tunables
+#include "Definitions.h"
+
+// Support for std args
+#include <stdarg.h>
+
+// LCD Support
+#ifdef _ENDPOINT_UBLOX_PLATFORM
+ #include "C12832.h"
+ #define LCDCLASS C12832
+#endif
+
+#ifdef _ENDPOINT_NXP_PLATFORM
+ #include "C12832_lcd.h"
+ #define LCDCLASS C12832_LCD
+#endif
+
+#ifdef _ENDPOINT_FREEDOM_PLATFORM
+ #include "C12832_lcd.h"
+ #define LCDCLASS C12832_LCD
+#endif
+
+#if defined(EH_USE_MUTEXES) || defined(NETWORK_MUTEX) || defined(ENABLE_THREADS) || defined(NSP_CELLULAR_NETWORK)
+ // RTOS support
+ #include "mbed.h"
+ #include "rtos.h"
+#endif
+
+class Logger {
+ private:
+ RawSerial *m_pc;
+ LCDCLASS *m_lcd;
+ char m_message[MAX_LOG_MESSAGE+1];
+#ifdef EH_USE_MUTEXES
+ Mutex *m_mutex;
+ Mutex *m_close_mutex;
+ Mutex *m_led_mutex;
+ Mutex *m_rgb_mutex;
+#endif
+ void *m_endpoint;
+ bool m_status_lcd;
+
+ public:
+ Logger(RawSerial *pc,LCDCLASS *lcd);
+ ~Logger();
+
+ void lcdStatusOnly(bool status_lcd);
+
+ void log(const char *format, ...);
+ void logConsole(const char *format, ...);
+ void log_memory(const char *format, ...);
+ void checkForExit();
+
+ void pause(const char *format, ...);
+
+ void turnLEDRed();
+ void turnLEDGreen();
+ void turnLEDBlue();
+ void turnLEDPurple();
+ void turnLEDBlack();
+ void turnLEDYellow();
+ void turnLEDOrange();
+
+ void blinkTransportTxLED();
+ void blinkTransportRxLED();
+
+#ifdef EH_USE_MUTEXES
+ void releaseMutexes();
+#endif
+
+ void led2On();
+ void led2Off();
+ void led3On();
+ void led3Off();
+
+ void setEndpoint(void *endpoint);
+ void *getEndpoint();
+
+ private:
+ void setRGBLED(float H, float S, float V);
+ void blinkLED(DigitalOut led);
+ void resetLEDs();
+ void changeLED(DigitalOut led,bool onoff);
+};
+
+#endif // _LOGGER_H_
\ No newline at end of file
--- a/MBEDBattery.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDBattery.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -24,7 +24,7 @@
AnalogIn battery_pot(BATTERY_POT_PIN);
// default constructor
- MBEDBattery::MBEDBattery(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDBattery::MBEDBattery(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDBattery.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDBattery.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDBattery : public MBEDio {
public:
- MBEDBattery(ErrorHandler *error_handler,Resource *resource);
+ MBEDBattery(Logger *logger,Resource *resource);
virtual ~MBEDBattery();
virtual void update();
--- a/MBEDCurrent.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDCurrent.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -21,7 +21,7 @@
#include "MBEDCurrent.h"
// default constructor
- MBEDCurrent::MBEDCurrent(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDCurrent::MBEDCurrent(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDCurrent.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDCurrent.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDCurrent : public MBEDio {
public:
- MBEDCurrent(ErrorHandler *error_handler,Resource *resource);
+ MBEDCurrent(Logger *logger,Resource *resource);
virtual ~MBEDCurrent();
virtual void update();
--- a/MBEDLight.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDLight.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
// default constructor
- MBEDLight::MBEDLight(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) : Light(error_handler,transports,instance,endpoint) {
+ MBEDLight::MBEDLight(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint) : Light(logger,transports,instance,endpoint) {
// initialize the default light state
this->initLight();
}
--- a/MBEDLight.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDLight.h Fri Sep 26 05:16:07 2014 +0000
@@ -24,7 +24,7 @@
class MBEDLight : public Light {
public:
- MBEDLight(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint);
+ MBEDLight(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint);
virtual ~MBEDLight();
void initLight();
--- a/MBEDTemperature.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDTemperature.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -33,7 +33,7 @@
#endif
// default constructor
- MBEDTemperature::MBEDTemperature(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDTemperature::MBEDTemperature(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDTemperature.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDTemperature.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDTemperature : public MBEDio {
public:
- MBEDTemperature(ErrorHandler *error_handler,Resource *resource);
+ MBEDTemperature(Logger *logger,Resource *resource);
virtual ~MBEDTemperature();
virtual void update();
--- a/MBEDToIOCResourceMap.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDToIOCResourceMap.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "MBEDToIOCResourceMap.h"
// default constructor
- MBEDToIOCResourceMap::MBEDToIOCResourceMap(ErrorHandler *error_handler) : BaseClass(error_handler,NULL) {
+ MBEDToIOCResourceMap::MBEDToIOCResourceMap(Logger *logger) : BaseClass(logger,NULL) {
for(int i=0;i<NUM_MAPPINGS;++i) this->m_map[i] = NULL;
this->m_count = 0;
this->createMap();
--- a/MBEDToIOCResourceMap.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDToIOCResourceMap.h Fri Sep 26 05:16:07 2014 +0000
@@ -28,7 +28,7 @@
int m_count;
public:
- MBEDToIOCResourceMap(ErrorHandler *error_handler);
+ MBEDToIOCResourceMap(Logger *logger);
virtual ~MBEDToIOCResourceMap();
char *iocNameToEndpointName(char *ioc_name);
--- a/MBEDVoltage.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDVoltage.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -24,7 +24,7 @@
AnalogIn voltage_pot(VOLTAGE_POT_PIN);
// default constructor
- MBEDVoltage::MBEDVoltage(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDVoltage::MBEDVoltage(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDVoltage.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDVoltage.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDVoltage : public MBEDio {
public:
- MBEDVoltage(ErrorHandler *error_handler,Resource *resource);
+ MBEDVoltage(Logger *logger,Resource *resource);
virtual ~MBEDVoltage();
virtual void update();
--- a/MBEDWattage.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDWattage.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -21,7 +21,7 @@
#include "MBEDWattage.h"
// default constructor
- MBEDWattage::MBEDWattage(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDWattage::MBEDWattage(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDWattage.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDWattage.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDWattage : public MBEDio {
public:
- MBEDWattage(ErrorHandler *error_handler,Resource *resource);
+ MBEDWattage(Logger *logger,Resource *resource);
virtual ~MBEDWattage();
virtual void update();
--- a/MBEDgps.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDgps.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
#include "MBEDEndpoint.h"
// default constructor
- MBEDgps::MBEDgps(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDgps::MBEDgps(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDgps.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDgps.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDgps : public MBEDio {
public:
- MBEDgps(ErrorHandler *error_handler,Resource *resource);
+ MBEDgps(Logger *logger,Resource *resource);
virtual ~MBEDgps();
virtual void update();
--- a/MBEDio.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDio.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "MBEDio.h"
// default constructor
- MBEDio::MBEDio(ErrorHandler *error_handler,Resource *resource) : BaseClass(error_handler,resource) {
+ MBEDio::MBEDio(Logger *logger,Resource *resource) : BaseClass(logger,resource) {
if (resource != NULL) resource->setIO(this);
}
--- a/MBEDio.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDio.h Fri Sep 26 05:16:07 2014 +0000
@@ -27,7 +27,7 @@
class MBEDio : public BaseClass {
public:
- MBEDio(ErrorHandler *error_handler,Resource *resource);
+ MBEDio(Logger *logger,Resource *resource);
virtual ~MBEDio();
float floatValue();
--- a/MBEDrssi.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDrssi.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
#include "MBEDEndpoint.h"
// default constructor
- MBEDrssi::MBEDrssi(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ MBEDrssi::MBEDrssi(Logger *logger,Resource *resource) : MBEDio(logger,resource) {
}
// destructor
--- a/MBEDrssi.h Wed Sep 24 19:12:35 2014 +0000
+++ b/MBEDrssi.h Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
class MBEDrssi : public MBEDio {
public:
- MBEDrssi(ErrorHandler *error_handler,Resource *resource);
+ MBEDrssi(Logger *logger,Resource *resource);
virtual ~MBEDrssi();
virtual void update();
--- a/Personality.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/Personality.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -23,7 +23,7 @@
#include "MBEDEndpoint.h"
// default constructor
- Personality::Personality(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint,char *type) : BaseClass(error_handler,endpoint) {
+ Personality::Personality(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint,char *type) : BaseClass(logger,endpoint) {
this->m_resources = ((MBEDEndpoint *)endpoint)->initResourceFactory();
this->m_external_id = 0;
--- a/Personality.h Wed Sep 24 19:12:35 2014 +0000
+++ b/Personality.h Fri Sep 26 05:16:07 2014 +0000
@@ -41,7 +41,7 @@
Transport *m_transports[NUM_TRANSPORTS];
public:
- Personality(ErrorHandler *error_handler,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint,char *type);
+ Personality(Logger *logger,Transport *transports[NUM_TRANSPORTS],int instance,void *endpoint,char *type);
virtual ~Personality();
Transport *getTransport(int index);
--- a/PhilipsLight.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/PhilipsLight.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -20,7 +20,7 @@
#include "HTTPTransport.h"
// default constructor
- PhilipsLight::PhilipsLight(int id,void *transport,ErrorHandler *error_handler) : BaseClass(error_handler,NULL) {
+ PhilipsLight::PhilipsLight(int id,void *transport,Logger *logger) : BaseClass(logger,NULL) {
this->m_id = id;
sscanf(PL_DEFAULT_STATE,"%d",&this->m_state);
this->m_dim = PL_DEFAULT_DIM;
--- a/PhilipsLight.h Wed Sep 24 19:12:35 2014 +0000
+++ b/PhilipsLight.h Fri Sep 26 05:16:07 2014 +0000
@@ -33,7 +33,7 @@
int m_dim;
public:
- PhilipsLight(int id,void *transport,ErrorHandler *error_handler);
+ PhilipsLight(int id,void *transport,Logger *logger);
virtual ~PhilipsLight();
void on();
--- a/Preferences.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/Preferences.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -28,7 +28,7 @@
#endif
// default constructor
- Preferences::Preferences(ErrorHandler *error_handler) : BaseClass(error_handler,NULL) {
+ Preferences::Preferences(Logger *logger) : BaseClass(logger,NULL) {
this->m_num_preferences = 0;
#ifndef NO_LOCAL_FILESYSTEM
this->initialize();
--- a/Preferences.h Wed Sep 24 19:12:35 2014 +0000
+++ b/Preferences.h Fri Sep 26 05:16:07 2014 +0000
@@ -32,7 +32,7 @@
int m_num_preferences;
public:
- Preferences(ErrorHandler *error_handler);
+ Preferences(Logger *logger);
virtual ~Preferences();
int numPreferences();
--- a/Resource.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/Resource.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -20,7 +20,7 @@
#include "MBEDio.h"
// default constructor
- Resource::Resource(ErrorHandler *error_handler,char *ep_name,char *name,char *value,void *cb) : BaseClass(error_handler,NULL) {
+ Resource::Resource(Logger *logger,char *ep_name,char *name,char *value,void *cb) : BaseClass(logger,NULL) {
this->m_io = NULL;
memset(this->m_name,0,RESOURCE_NAME_LEN+1);
memset(this->m_value,0,RESOURCE_VALUE_LEN+1);
--- a/Resource.h Wed Sep 24 19:12:35 2014 +0000
+++ b/Resource.h Fri Sep 26 05:16:07 2014 +0000
@@ -31,7 +31,7 @@
void *m_io;
public:
- Resource(ErrorHandler *error_handler,char *ep_name,char *name,char *value,void *cb);
+ Resource(Logger *logger,char *ep_name,char *name,char *value,void *cb);
virtual ~Resource();
char *getName();
--- a/ResourceFactory.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/ResourceFactory.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -20,7 +20,7 @@
#include "MBEDEndpoint.h"
// default constructor
- ResourceFactory::ResourceFactory(ErrorHandler *error_handler,void *endpoint) : BaseClass(error_handler,endpoint) {
+ ResourceFactory::ResourceFactory(Logger *logger,void *endpoint) : BaseClass(logger,endpoint) {
this->m_count = 0;
for(int i=0;i<NUM_RESOURCES;++i) this->m_list[i] = NULL;
}
--- a/ResourceFactory.h Wed Sep 24 19:12:35 2014 +0000
+++ b/ResourceFactory.h Fri Sep 26 05:16:07 2014 +0000
@@ -31,7 +31,7 @@
int m_count;
public:
- ResourceFactory(ErrorHandler *error_handler,void *endpoint);
+ ResourceFactory(Logger *logger,void *endpoint);
virtual ~ResourceFactory();
virtual void createResources(char *endpoint_name);
--- a/Transport.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/Transport.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -19,7 +19,7 @@
#include "Transport.h"
// default constructor
- Transport::Transport(ErrorHandler *error_handler,void *endpoint) : BaseClass(error_handler,endpoint) {
+ Transport::Transport(Logger *logger,void *endpoint) : BaseClass(logger,endpoint) {
this->m_connected = false;
}
--- a/Transport.h Wed Sep 24 19:12:35 2014 +0000
+++ b/Transport.h Fri Sep 26 05:16:07 2014 +0000
@@ -28,7 +28,7 @@
class Transport : public BaseClass {
public:
- Transport(ErrorHandler *error_handler,void *endpoint);
+ Transport(Logger *error_handler,void *endpoint);
virtual ~Transport();
virtual bool connect();
--- a/main.cpp Wed Sep 24 19:12:35 2014 +0000
+++ b/main.cpp Fri Sep 26 05:16:07 2014 +0000
@@ -67,7 +67,7 @@
#endif
// Instances for the Endpoint
- ErrorHandler *error_handler = NULL;
+ Logger *m_logger = NULL;
MBEDEndpoint *endpoint = NULL;
// HTTP support
@@ -85,8 +85,8 @@
char fmt_mac[RESOURCE_VALUE_LEN+1];
#endif
- // ErrorHandler (logger)
- ErrorHandler *logger() { return error_handler; }
+ // Logger (logger)
+ Logger *logger() { return m_logger; }
// translate a closedown code to a string
char str_code[16];
@@ -101,12 +101,12 @@
void closedown(int code) {
if (endpoint != NULL) {
#ifdef EH_USE_MUTEXES
- error_handler->releaseMutexes();
+ m_logger->releaseMutexes();
#endif
- error_handler->log("Closing down Endpoint...");
+ m_logger->log("Closing down Endpoint...");
delete endpoint;
}
- if (error_handler != NULL) delete error_handler;
+ if (m_logger != NULL) delete m_logger;
#ifndef _ENDPOINT_UBLOX_PLATFORM
pc.printf("Exiting...\r\n");
#endif
@@ -141,10 +141,10 @@
memset(fmt_mac,0,RESOURCE_VALUE_LEN+1);
sprintf(fmt_mac,"%02x:%02x:%02x:%02x:%02x:%02x",mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
#endif
- error_handler = new ErrorHandler(&pc,&lcd);
+ m_logger = new Logger(&pc,&lcd);
#if SF_STATUS_REPORTING
- StatusReporter status_reporter(error_handler,(void *)&_http);
+ StatusReporter status_reporter(&_http,m_logger);
sf_status_reporter = (void *)&status_reporter;
#endif
@@ -154,9 +154,9 @@
#else
MDMSerial modem;
#endif
- endpoint = new MBEDEndpoint(error_handler,&modem,sf_status_reporter,NULL);
+ endpoint = new MBEDEndpoint(m_logger,&modem,sf_status_reporter,NULL);
#else
- endpoint = new MBEDEndpoint(error_handler,ðernet,sf_status_reporter,NULL);
+ endpoint = new MBEDEndpoint(m_logger,ðernet,sf_status_reporter,NULL);
#endif
if (endpoint != NULL) endpoint->run();
}