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:
Tue Feb 25 16:33:18 2014 +0000
Revision:
11:f1c9299a3ca1
Parent:
10:62107616fc6c
Child:
12:9af48d60705f
updates

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 "MBEDToIOCResourceMap.h"
ansond 10:62107616fc6c 20
ansond 10:62107616fc6c 21 // default constructor
ansond 10:62107616fc6c 22 MBEDToIOCResourceMap::MBEDToIOCResourceMap() {
ansond 10:62107616fc6c 23 this->m_map.clear();
ansond 10:62107616fc6c 24 this->createMap();
ansond 10:62107616fc6c 25 }
ansond 10:62107616fc6c 26
ansond 10:62107616fc6c 27 // destructor
ansond 10:62107616fc6c 28 MBEDToIOCResourceMap::~MBEDToIOCResourceMap() {
ansond 10:62107616fc6c 29 }
ansond 10:62107616fc6c 30
ansond 10:62107616fc6c 31 // lookup MBED equivalent to IOC input
ansond 10:62107616fc6c 32 char *MBEDToIOCResourceMap::getMBEDMappedName(char *ioc_name) {
ansond 10:62107616fc6c 33 bool found = false;
ansond 10:62107616fc6c 34 char *mbed_name = NULL;
ansond 10:62107616fc6c 35
ansond 10:62107616fc6c 36 for(int i=0;i<this->m_map.size() && !found;++i) {
ansond 11:f1c9299a3ca1 37 if (strcmp(this->m_map[i]->iocName(),ioc_name) == 0) {
ansond 10:62107616fc6c 38 found = true;
ansond 11:f1c9299a3ca1 39 mbed_name = this->m_map[i]->mbedName();
ansond 10:62107616fc6c 40 }
ansond 10:62107616fc6c 41 }
ansond 10:62107616fc6c 42 return mbed_name;
ansond 10:62107616fc6c 43 }
ansond 10:62107616fc6c 44
ansond 10:62107616fc6c 45 // create our map - this MUST match the Resource Mapping found in the gateway mapping database
ansond 10:62107616fc6c 46 void MBEDToIOCResourceMap::createMap() {
ansond 11:f1c9299a3ca1 47 this->m_map.push_back(new MapEntry("Property_1","/dev/addldata"));
ansond 11:f1c9299a3ca1 48 this->m_map.push_back(new MapEntry("Property_2","/dev/location"));
ansond 11:f1c9299a3ca1 49 this->m_map.push_back(new MapEntry("Property_3","/dev/bat"));
ansond 11:f1c9299a3ca1 50 this->m_map.push_back(new MapEntry("Property_4","/sen/I"));
ansond 11:f1c9299a3ca1 51 this->m_map.push_back(new MapEntry("Property_5","/nw/ipaddr"));
ansond 11:f1c9299a3ca1 52 this->m_map.push_back(new MapEntry("Property_6","/lt/0/dim"));
ansond 11:f1c9299a3ca1 53 this->m_map.push_back(new MapEntry("Property_7","/nw/eripaddr"));
ansond 11:f1c9299a3ca1 54 this->m_map.push_back(new MapEntry("Property_8","/lt/0/on"));
ansond 11:f1c9299a3ca1 55 this->m_map.push_back(new MapEntry("Property_9","/dev/mdl"));
ansond 11:f1c9299a3ca1 56 this->m_map.push_back(new MapEntry("Property_10","/gps/int"));
ansond 11:f1c9299a3ca1 57 this->m_map.push_back(new MapEntry("Property_11","/gps/fix"));
ansond 11:f1c9299a3ca1 58 this->m_map.push_back(new MapEntry("Property_12","/nw/pipaddr"));
ansond 11:f1c9299a3ca1 59 this->m_map.push_back(new MapEntry("Property_13","/nw/prssi"));
ansond 11:f1c9299a3ca1 60 this->m_map.push_back(new MapEntry("Property_14","/sen/temp"));
ansond 11:f1c9299a3ca1 61 this->m_map.push_back(new MapEntry("Property_15","/sen/V"));
ansond 11:f1c9299a3ca1 62 this->m_map.push_back(new MapEntry("LOCATION","/gps/loc"));
ansond 10:62107616fc6c 63 }