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
Diff: MBEDToIOCResourceMap.cpp
- Revision:
- 47:fa96ddc36f04
- Parent:
- 43:361a61395588
- Child:
- 85:8af3f3101ba3
diff -r 1041f7efee73 -r fa96ddc36f04 MBEDToIOCResourceMap.cpp
--- a/MBEDToIOCResourceMap.cpp Sat Mar 01 16:10:08 2014 +0000
+++ b/MBEDToIOCResourceMap.cpp Sat Mar 01 17:01:46 2014 +0000
@@ -22,12 +22,13 @@
MBEDToIOCResourceMap::MBEDToIOCResourceMap(ErrorHandler *error_handler) {
this->m_error_handler = error_handler;
for(int i=0;i<NUM_MAPPINGS;++i) this->m_map[i] = NULL;
+ this->m_count = 0;
this->createMap();
}
// destructor
MBEDToIOCResourceMap::~MBEDToIOCResourceMap() {
- for(int i=0;i<NUM_MAPPINGS;++i)
+ for(int i=0;i<this->m_count;++i)
if (this->m_map[i] != NULL) delete this->m_map[i];
}
@@ -40,7 +41,7 @@
char *ioc_name = NULL;
// lookup the IOC name and map it to an MBED (NSP) name
- for(int i=0;i<NUM_MAPPINGS && !found && this->m_map[i] != NULL;++i) {
+ for(int i=0;i<this->m_count && !found && this->m_map[i] != NULL && mbed_name != NULL;++i) {
if (strcmp(this->m_map[i]->mbedName(),mbed_name) == 0) {
found = true;
ioc_name = this->m_map[i]->iocName();
@@ -58,7 +59,7 @@
char *actual_ioc_name = this->convertFromNickName(ioc_name);
// lookup the IOC name and map it to an MBED (NSP) name
- for(int i=0;i<NUM_MAPPINGS && !found && this->m_map[i] != NULL;++i) {
+ for(int i=0;i<this->m_count && !found && this->m_map[i] != NULL && ioc_name != NULL;++i) {
if (strcmp(this->m_map[i]->iocName(),actual_ioc_name) == 0) {
found = true;
mbed_name = this->m_map[i]->mbedName();
@@ -72,8 +73,8 @@
char *actual_name = ioc_name;
bool found = false;
- for(int i=0;i<NUM_MAPPINGS && !found && this->m_map[i] != NULL;++i) {
- if (strcmp(this->m_map[i]->iocNickName(),ioc_name) == 0) {
+ for(int i=0;i<this->m_count && !found && this->m_map[i] != NULL && ioc_name != NULL;++i) {
+ if (this->m_map[i]->iocNickName() != NULL && strcmp(this->m_map[i]->iocNickName(),ioc_name) == 0) {
found = true;
actual_name = this->m_map[i]->iocName();
}
@@ -84,24 +85,23 @@
// create our map - this MUST match the Resource Mapping found in the gateway mapping database
void MBEDToIOCResourceMap::createMap() {
- int i = 0;
- this->m_map[i++] = new MapEntry("Property_1","/dev/addldata");
- this->m_map[i++] = new MapEntry("Property_2","/dev/location");
- this->m_map[i++] = new MapEntry("Property_3","/dev/bat");
- this->m_map[i++] = new MapEntry("Property_4","/sen/I");
- this->m_map[i++] = new MapEntry("Property_5","/nw/ipaddr");
- this->m_map[i++] = new MapEntry("Property_6","/lt/0/dim","Dimming");
- this->m_map[i++] = new MapEntry("Property_7","/nw/eripaddr");
- this->m_map[i++] = new MapEntry("Property_8","/lt/0/on","EndpointStatus");
- this->m_map[i++] = new MapEntry("Property_9","/dev/mdl");
- this->m_map[i++] = new MapEntry("Property_10","/gps/int");
- this->m_map[i++] = new MapEntry("Property_11","/gps/fix");
- this->m_map[i++] = new MapEntry("Property_12","/nw/pipaddr");
- this->m_map[i++] = new MapEntry("Property_13","/nw/prssi");
- this->m_map[i++] = new MapEntry("Property_14","/sen/temp");
- this->m_map[i++] = new MapEntry("Property_15","/sen/V");
- this->m_map[i++] = new MapEntry("LOCATION","/gps/loc");
+ this->m_map[this->m_count++] = new MapEntry("Property_1","/dev/addldata");
+ this->m_map[this->m_count++] = new MapEntry("Property_2","/dev/location");
+ this->m_map[this->m_count++] = new MapEntry("Property_3","/dev/bat");
+ this->m_map[this->m_count++] = new MapEntry("Property_4","/sen/I");
+ this->m_map[this->m_count++] = new MapEntry("Property_5","/nw/ipaddr");
+ this->m_map[this->m_count++] = new MapEntry("Property_6","/lt/0/dim","Dimming");
+ this->m_map[this->m_count++] = new MapEntry("Property_7","/nw/eripaddr");
+ this->m_map[this->m_count++] = new MapEntry("Property_8","/lt/0/on","EndpointStatus");
+ this->m_map[this->m_count++] = new MapEntry("Property_9","/dev/mdl");
+ this->m_map[this->m_count++] = new MapEntry("Property_10","/gps/int");
+ this->m_map[this->m_count++] = new MapEntry("Property_11","/gps/fix");
+ this->m_map[this->m_count++] = new MapEntry("Property_12","/nw/pipaddr");
+ this->m_map[this->m_count++] = new MapEntry("Property_13","/nw/prssi");
+ this->m_map[this->m_count++] = new MapEntry("Property_14","/sen/temp");
+ this->m_map[this->m_count++] = new MapEntry("Property_15","/sen/V");
+ this->m_map[this->m_count++] = new MapEntry("LOCATION","/gps/loc");
// DEBUG
- this->logger()->log("Installed %d Resource Mappings.",i);
+ this->logger()->log("Installed %d Resource Mappings.",this->m_count);
}
\ No newline at end of file