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

Committer:
ansond
Date:
Mon Mar 24 19:29:37 2014 +0000
Revision:
142:e95256b893da
Parent:
35:89b9cf25a893
Child:
143:0698dbcf58f5
added observation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 35:89b9cf25a893 1 /* Copyright C2013 Doug Anson, MIT License
ansond 35:89b9cf25a893 2 *
ansond 35:89b9cf25a893 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 35:89b9cf25a893 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 35:89b9cf25a893 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 35:89b9cf25a893 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 35:89b9cf25a893 7 * furnished to do so, subject to the following conditions:
ansond 35:89b9cf25a893 8 *
ansond 35:89b9cf25a893 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 35:89b9cf25a893 10 * substantial portions of the Software.
ansond 35:89b9cf25a893 11 *
ansond 35:89b9cf25a893 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 35:89b9cf25a893 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 35:89b9cf25a893 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 35:89b9cf25a893 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 35:89b9cf25a893 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 35:89b9cf25a893 17 */
ansond 35:89b9cf25a893 18
ansond 35:89b9cf25a893 19 #include "NSPio.h"
ansond 35:89b9cf25a893 20
ansond 35:89b9cf25a893 21 // default constructor
ansond 142:e95256b893da 22 NSPio::NSPio(ErrorHandler *error_handler,Resource *resource,sn_send_observation_t obs_sender) : MBEDio(error_handler,resource) {
ansond 142:e95256b893da 23 this->m_obs_sender = obs_sender;
ansond 142:e95256b893da 24 this->m_mbed_io = NULL;
ansond 142:e95256b893da 25 }
ansond 142:e95256b893da 26
ansond 142:e95256b893da 27 // wrapping a generic MBEDio within a NSPio so that we can do things like NSP observation...
ansond 142:e95256b893da 28 NSPio::NSPio(MBEDio *mbed_io,sn_send_observation_t obs_sender) : MBEDio(mbed_io->logger(),mbed_io->resource()) {
ansond 142:e95256b893da 29 this->m_obs_sender = obs_sender;
ansond 142:e95256b893da 30 this->m_mbed_io = mbed_io;
ansond 142:e95256b893da 31 if (this->m_mbed_io != NULL && this->m_mbed_io->resource() != NULL) this->m_mbed_io->resource()->setIO(this);
ansond 35:89b9cf25a893 32 }
ansond 35:89b9cf25a893 33
ansond 35:89b9cf25a893 34 // destructor
ansond 35:89b9cf25a893 35 NSPio::~NSPio() {
ansond 35:89b9cf25a893 36 }
ansond 35:89b9cf25a893 37
ansond 142:e95256b893da 38 // send an observation
ansond 142:e95256b893da 39 void NSPio::sendObservation() { if (this->m_obs_sender != NULL) (*this->m_obs_sender)(); }
ansond 142:e95256b893da 40
ansond 35:89b9cf25a893 41 // update
ansond 142:e95256b893da 42 void NSPio::update() { if (this->m_mbed_io != NULL) this->m_mbed_io->update(); }
ansond 142:e95256b893da 43
ansond 142:e95256b893da 44 // get the float value (refreshes the value)
ansond 142:e95256b893da 45 float NSPio::floatValue() {
ansond 142:e95256b893da 46 if (this->m_mbed_io != NULL) return this->m_mbed_io->floatValue();
ansond 142:e95256b893da 47 return MBEDio::floatValue();
ansond 142:e95256b893da 48 }
ansond 142:e95256b893da 49
ansond 142:e95256b893da 50 // get the int value (refreshes the value)
ansond 142:e95256b893da 51 int NSPio::intValue() {
ansond 142:e95256b893da 52 if (this->m_mbed_io != NULL) return this->m_mbed_io->intValue();
ansond 142:e95256b893da 53 return MBEDio::intValue();
ansond 142:e95256b893da 54 }
ansond 142:e95256b893da 55
ansond 142:e95256b893da 56 // get the string value (refreshes the value)
ansond 142:e95256b893da 57 char *NSPio::stringValue() {
ansond 142:e95256b893da 58 if (this->m_mbed_io != NULL) return this->m_mbed_io->stringValue();
ansond 142:e95256b893da 59 return MBEDio::stringValue();
ansond 142:e95256b893da 60 }