MBED_DEMOS / Mbed 2 deprecated mbed_nsp_endpoint_ublox_ethernet

Dependencies:   C027 C12832 EthernetInterface StatusReporter LM75B endpoint_core endpoint_nsp mbed-rtos mbed nsp_resources

Revision:
142:e95256b893da
Parent:
35:89b9cf25a893
Child:
143:0698dbcf58f5
--- a/NSPio.cpp	Fri Mar 21 22:54:45 2014 +0000
+++ b/NSPio.cpp	Mon Mar 24 19:29:37 2014 +0000
@@ -19,12 +19,42 @@
  #include "NSPio.h"
  
  // default constructor
- NSPio::NSPio(ErrorHandler *error_handler,Resource *resource) : MBEDio(error_handler,resource) {
+ NSPio::NSPio(ErrorHandler *error_handler,Resource *resource,sn_send_observation_t obs_sender) : MBEDio(error_handler,resource) {
+     this->m_obs_sender = obs_sender;
+     this->m_mbed_io = NULL;
+ }
+ 
+ // wrapping a generic MBEDio within a NSPio so that we can do things like NSP observation...
+ NSPio::NSPio(MBEDio *mbed_io,sn_send_observation_t obs_sender) : MBEDio(mbed_io->logger(),mbed_io->resource()) {
+     this->m_obs_sender = obs_sender;
+     this->m_mbed_io = mbed_io;
+     if (this->m_mbed_io != NULL && this->m_mbed_io->resource() != NULL) this->m_mbed_io->resource()->setIO(this);
  }
  
  // destructor
  NSPio::~NSPio() {
  }
  
+ // send an observation
+ void NSPio::sendObservation() { if (this->m_obs_sender != NULL) (*this->m_obs_sender)(); }
+ 
  // update
- void NSPio::update() { ; }
\ No newline at end of file
+ void NSPio::update() { if (this->m_mbed_io != NULL) this->m_mbed_io->update(); }
+ 
+ // get the float value (refreshes the value)
+ float NSPio::floatValue() { 
+    if (this->m_mbed_io != NULL) return this->m_mbed_io->floatValue();
+    return MBEDio::floatValue();
+ }
+ 
+ // get the int value (refreshes the value)
+ int NSPio::intValue() { 
+    if (this->m_mbed_io != NULL) return this->m_mbed_io->intValue();
+    return MBEDio::intValue(); 
+ }
+ 
+ // get the string value (refreshes the value)
+ char *NSPio::stringValue() { 
+    if (this->m_mbed_io != NULL) return this->m_mbed_io->stringValue();
+    return MBEDio::stringValue();
+ }
\ No newline at end of file