//cout << "MAC address is set. Value: ";
IoTRMIUtil::printBytes(bulbMacAddress, 8, false);
// Logging
- log.open("LifxLightBulb_cpp.log");
+ int i=0;
+ string file = "LifxLightBulb_cpp" + to_string(i) + ".log";
+ while (ifstream(file.c_str())) {
+ i++;
+ file = "LifxLightBulb_cpp" + to_string(i) + ".log";
+ }
+ log.open(file);
log << "MAC address is " << macAddress << endl;
// Initialize device address
if (didAlreadyInit.exchange(true))
return;
+ log << "lb_addresses has: " << lb_addresses->size() << endl;
unordered_set<void*>::const_iterator itr = lb_addresses->begin();
IoTDeviceAddress* deviceAddress = (IoTDeviceAddress*) *itr;
//cout << "Address: " << deviceAddress->getAddress() << endl;
// NOTE: "this" pointer is passed into the detached thread because it does not belong
// to this object anymore so if it executes certain methods of "this" object, then it needs
// the correct references to stuff
- thread th1 (&LifxLightBulb::workerFunction, this, this);
- th1.detach();
+// thread th1 (&LifxLightBulb::workerFunction, this, this);
+// th1.detach();
//cout << "Initialized LifxLightBulb!" << endl;
log << "Initialized LifxLightBulb!" << endl;
/*int main(int argc, char *argv[])
{
- string macAddress = "D073D5128E300000";
+ string macAddress1 = "D073D5128E300000";
//string macAddress = "D073D50241DA0000";
- string devIPAddress = "192.168.2.126";
+ string devIPAddress1 = "192.168.2.126";
//string devIPAddress = "192.168.2.232";
- //IoTDeviceAddress devAddress(devIPAddress, 12345, 56700, false, false);
- IoTDeviceAddress* devAddress = new IoTDeviceAddress(devIPAddress, 12345, 56700, false, false);
- unordered_set<IoTDeviceAddress*> myset = { devAddress };
+ IoTDeviceAddress* devAddress1 = new IoTDeviceAddress(devIPAddress1, 12345, 56700, false, false);
+ unordered_set<void*>* myset1 = new unordered_set<void*>();
+ myset1->insert(devAddress1);
- IoTSet<IoTDeviceAddress*> setDevAddress(myset);
- LifxLightBulb *llb = new LifxLightBulb(setDevAddress, macAddress);
+ IoTSet<void*>* setDevAddress1 = new IoTSet<void*>(myset1);
+ LifxLightBulb *llb1 = new LifxLightBulb(setDevAddress1, macAddress1);
cout << "Generated LifxLightBulb object!" << endl;
- llb->init();
- llb->turnOn();
- onOff(llb);
- adjustTemp(llb);
- adjustBright(llb);
+ llb1->init();
+ llb1->turnOn();
+ onOff(llb1);
+ adjustTemp(llb1);
+ adjustBright(llb1);
// llb->turnOff();
- delete devAddress;
- delete llb;
+// delete devAddress1;
+// delete llb1;
return 0;
}*/