IoTSlave::IoTSlave(string _serverAddress, int _serverPort, string _objectName) {
- //isDriverObject = false; // Default to false
serverAddress = _serverAddress;
serverPort = _serverPort;
objectName = _objectName;
void IoTSlave::openFile(string fileName) {
- log.open(FILEPATH + fileName + FILEEXT);
+ log.open(LOGFILEPATH + fileName + FILEEXT);
}
objMainCls = create_object(params);
writeToFile("Object created for " + mainObjectName);
init_object(objMainCls);
+ // TODO: Maybe we want to change this into multithreading at some point
//thread th1 (&IoTSlave::runInitObject, this, this);
//th1.detach();
//thread th1 (&IoTSlave::runInitObject, this, this);
void* params[SKELPARAMSIZE];
params[0] = objMainCls;
- //string callbackAddress = LOCALHOST;
- //params[1] = &callbackAddress;
- //params[2] = &objectStubPort;
params[1] = &objectStubPort;
params[2] = &objectRegPort;
writeToFile("Skeleton Object " + objectSkelClass + " created for " + objectClassName);
params[0] = &objectStubPort;
params[1] = &objectRegPort;
params[2] = &hostAddress;
- //params[0] = &objectStubPort;
- //params[1] = &hostAddress;
- //string callbackAddress = LOCALHOST;
- //params[2] = &callbackAddress;
int rev = 0;
params[3] = &rev;
bool result = false;
params[4] = &result;
- //params[5] = ports;
writeToFile("Stub Object " + objectStubClass + " created for " + objectClassName);
writeToFile("Success 1!");
objStubCls = create_object(params);
char recvInt[sizeof(int)]; // Normally 4 bytes
// Receive and iterate until complete
- //writeToFile("Receiving Integer! Size: " + to_string(toBeReceived));
recvIter(recvInt, toBeReceived);
int retVal = 0;
char* recvStr = new char[strLen];
// Receive and iterate until complete
- //writeToFile("Receiving String! Size: " + to_string(strLen));
recvIter(recvStr, strLen);
string retVal(recvStr, strLen);
// TODO: perhaps we need to replace this with libzip or zlib later
writeToFile("Unzipping file!");
string chmodCmd = FILEPATH + fileName + SHELL;
- //std::system(chmodCmd.c_str());
thread th1 (std::system, chmodCmd.c_str());
th1.detach();
writeToFile("Finished unzipping file!");
fileStream.write(recvFil, fileLen);
delete[] recvFil;
fileStream.close();
- // TODO: Experimental
- //string chmodCmd = FILEPATH + fileName + SHELL;
- //execv(chmodCmd.c_str(), 0);
return fileName;
}
isetObject->insert(objDeviceAddress);
writeToFile("=> Inserting IoTDeviceAddress into set...");
writeToFile("==> Now we have " + to_string(isetObject->size()) + " object(s)!");
- // Set flag to true;
- //isDriverObject = true;
}
instantiateStubObject();
mapObjNameStub.insert(make_pair(objectName,objStubCls));
writeToFile("=> Map has: " + to_string(mapObjNameStub.size()) + " members");
- // vector<int> for ports has been copied - now delete it
- delete ports;
}
}
writeToFile("=> Driver object registry port: " + to_string(objectRegPort));
objectStubPort = recvInteger(); sendAck();
writeToFile("=> Driver object stub port: " + to_string(objectStubPort));
- int numOfPorts = recvInteger(); sendAck();
- ports = new vector<int>();
- for (int i = 0; i < numOfPorts; i++) {
- int port = recvInteger(); sendAck();
- ports->push_back(port);
- writeToFile("==> Got a new port: " + to_string(port));
- }
}
break;
case GET_ZB_DEV_IOTSET_OBJECT:
+ // TODO: Support ZigBee in the future
//getZBDevIoTSetObject();
break;