nsp specific components for the NSP version of the impact endpoint
Dependents: mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet mbed_nsp_endpoint_nxp
NSPio.cpp
00001 /* Copyright C2013 Doug Anson, MIT License 00002 * 00003 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software 00004 * and associated documentation files the "Software", to deal in the Software without restriction, 00005 * including without limitation the rights to use, copy, modify, merge, publish, distribute, 00006 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is 00007 * furnished to do so, subject to the following conditions: 00008 * 00009 * The above copyright notice and this permission notice shall be included in all copies or 00010 * substantial portions of the Software. 00011 * 00012 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING 00013 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 00014 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, 00015 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00016 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 00017 */ 00018 00019 #include "NSPio.h" 00020 00021 // default constructor 00022 NSPio::NSPio(Logger *logger,Resource *resource,sn_send_observation_t obs_sender) : MBEDio(logger,resource) { 00023 this->m_obs_sender = obs_sender; 00024 this->m_mbed_io = NULL; 00025 } 00026 00027 // wrapping a generic MBEDio within a NSPio so that we can do things like NSP observation... 00028 NSPio::NSPio(MBEDio *mbed_io,sn_send_observation_t obs_sender) : MBEDio(mbed_io->logger(),mbed_io->resource()) { 00029 this->m_obs_sender = obs_sender; 00030 this->m_mbed_io = mbed_io; 00031 if (this->m_mbed_io != NULL && this->m_mbed_io->resource() != NULL) this->m_mbed_io->resource()->setIO(this); 00032 } 00033 00034 // destructor 00035 NSPio::~NSPio() { 00036 } 00037 00038 // send an observation 00039 void NSPio::sendObservation() { if (this->m_obs_sender != NULL) (this->m_obs_sender)(); } 00040 00041 // update 00042 void NSPio::update() { if (this->m_mbed_io != NULL) this->m_mbed_io->update(); } 00043 00044 // get the float value (refreshes the value) 00045 float NSPio::floatValue() { 00046 if (this->m_mbed_io != NULL) return this->m_mbed_io->floatValue(); 00047 return MBEDio::floatValue(); 00048 } 00049 00050 // get the int value (refreshes the value) 00051 int NSPio::intValue() { 00052 if (this->m_mbed_io != NULL) return this->m_mbed_io->intValue(); 00053 return MBEDio::intValue(); 00054 } 00055 00056 // get the string value (refreshes the value) 00057 char *NSPio::stringValue() { 00058 if (this->m_mbed_io != NULL) return this->m_mbed_io->stringValue(); 00059 return MBEDio::stringValue(); 00060 }
Generated on Thu Jul 14 2022 08:46:57 by 1.7.2