Core Base Classes for the Light Endpoints

Dependencies:   BufferedSerial

Dependents:   mbed_mqtt_endpoint_ublox_ethernet mbed_mqtt_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_cellular mbed_nsp_endpoint_ublox_ethernet ... more

Committer:
ansond
Date:
Wed Feb 26 18:59:01 2014 +0000
Revision:
20:f2dbbd852e08
Parent:
12:9af48d60705f
removed splitter

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ansond 10:62107616fc6c 1 /* Copyright C2013 Doug Anson, MIT License
ansond 10:62107616fc6c 2 *
ansond 10:62107616fc6c 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
ansond 10:62107616fc6c 4 * and associated documentation files the "Software", to deal in the Software without restriction,
ansond 10:62107616fc6c 5 * including without limitation the rights to use, copy, modify, merge, publish, distribute,
ansond 10:62107616fc6c 6 * sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
ansond 10:62107616fc6c 7 * furnished to do so, subject to the following conditions:
ansond 10:62107616fc6c 8 *
ansond 10:62107616fc6c 9 * The above copyright notice and this permission notice shall be included in all copies or
ansond 10:62107616fc6c 10 * substantial portions of the Software.
ansond 10:62107616fc6c 11 *
ansond 10:62107616fc6c 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
ansond 10:62107616fc6c 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ansond 10:62107616fc6c 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
ansond 10:62107616fc6c 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
ansond 10:62107616fc6c 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
ansond 10:62107616fc6c 17 */
ansond 10:62107616fc6c 18
ansond 10:62107616fc6c 19 #include "mbed.h"
ansond 10:62107616fc6c 20 #include "MapEntry.h"
ansond 10:62107616fc6c 21
ansond 10:62107616fc6c 22 // default constructor
ansond 11:f1c9299a3ca1 23 MapEntry::MapEntry(char *ioc_name,char *mbed_name) {
ansond 10:62107616fc6c 24 memset(this->m_mbed_name,0,MAX_NAME_LENGTH+1);
ansond 10:62107616fc6c 25 memset(this->m_ioc_name,0,MAX_NAME_LENGTH+1);
ansond 12:9af48d60705f 26 memset(this->m_ioc_nickname,0,MAX_NAME_LENGTH+1);
ansond 10:62107616fc6c 27 strncpy(this->m_mbed_name,mbed_name,this->min(strlen(mbed_name),MAX_NAME_LENGTH));
ansond 10:62107616fc6c 28 strncpy(this->m_ioc_name,ioc_name,this->min(strlen(ioc_name),MAX_NAME_LENGTH));
ansond 10:62107616fc6c 29 }
ansond 10:62107616fc6c 30
ansond 12:9af48d60705f 31 // constructor
ansond 12:9af48d60705f 32 MapEntry::MapEntry(char *ioc_name,char *mbed_name,char *ioc_nickname) {
ansond 12:9af48d60705f 33 memset(this->m_mbed_name,0,MAX_NAME_LENGTH+1);
ansond 12:9af48d60705f 34 memset(this->m_ioc_name,0,MAX_NAME_LENGTH+1);
ansond 12:9af48d60705f 35 memset(this->m_ioc_nickname,0,MAX_NAME_LENGTH+1);
ansond 12:9af48d60705f 36 strncpy(this->m_mbed_name,mbed_name,this->min(strlen(mbed_name),MAX_NAME_LENGTH));
ansond 12:9af48d60705f 37 strncpy(this->m_ioc_name,ioc_name,this->min(strlen(ioc_name),MAX_NAME_LENGTH));
ansond 12:9af48d60705f 38 strncpy(this->m_ioc_nickname,ioc_nickname,this->min(strlen(ioc_nickname),MAX_NAME_LENGTH));
ansond 12:9af48d60705f 39 }
ansond 12:9af48d60705f 40
ansond 10:62107616fc6c 41 // destructor
ansond 10:62107616fc6c 42 MapEntry::~MapEntry() {
ansond 10:62107616fc6c 43 }
ansond 10:62107616fc6c 44
ansond 10:62107616fc6c 45 // get the IOC name
ansond 10:62107616fc6c 46 char *MapEntry::iocName() { return this->m_ioc_name; }
ansond 10:62107616fc6c 47
ansond 12:9af48d60705f 48 // get the IOC nickname
ansond 12:9af48d60705f 49 char *MapEntry::iocNickName() { if (strlen(this->m_ioc_nickname) > 0) return this->m_ioc_nickname; return NULL; }
ansond 12:9af48d60705f 50
ansond 10:62107616fc6c 51 // get the MBED name
ansond 10:62107616fc6c 52 char *MapEntry::mbedName() { return this->m_mbed_name; }
ansond 10:62107616fc6c 53
ansond 10:62107616fc6c 54 // min function
ansond 10:62107616fc6c 55 int MapEntry::min(int value1,int value2) {
ansond 10:62107616fc6c 56 if (value1 < value2) return value1;
ansond 10:62107616fc6c 57 return value2;
ansond 10:62107616fc6c 58 }