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
MBEDio.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 "MBEDio.h" 00020 00021 // default constructor 00022 MBEDio::MBEDio(Logger *logger,Resource *resource) : BaseClass(logger,resource) { 00023 if (resource != NULL) resource->setIO(this); 00024 } 00025 00026 // destructor 00027 MBEDio::~MBEDio() { 00028 } 00029 00030 // get the float value (refreshes the value) 00031 float MBEDio::floatValue() { 00032 this->update(); 00033 float floatValue = 0.0; 00034 if (this->resource() != NULL && this->resource()->getValuePointer() != NULL) sscanf(this->resource()->getValuePointer(),"%f",&floatValue); 00035 return floatValue; 00036 } 00037 00038 // get the int value (refreshes the value) 00039 int MBEDio::intValue() { 00040 this->update(); 00041 int intValue = 0; 00042 if (this->resource() != NULL && this->resource()->getValuePointer() != NULL) sscanf(this->resource()->getValuePointer(),"%d",&intValue); 00043 return intValue; 00044 } 00045 00046 // get the string value (refreshes the value) 00047 char *MBEDio::stringValue() { 00048 if (this->resource() != NULL) { 00049 this->update(); 00050 return this->resource()->getValuePointer(); 00051 } 00052 else { 00053 this->logger()->log("stringValue: returning NULL - no resource bound to me"); 00054 return NULL; 00055 } 00056 } 00057 00058 // get the Resource (held in BaseClass as endpoint()...) 00059 Resource *MBEDio::resource() { return (Resource *)this->getEndpoint(); }
Generated on Wed Jul 13 2022 13:30:47 by
1.7.2