Adjusting C++ files to compile with gcc 4.9.3
[iot2.git] / benchmarks / drivers / Cpp / LifxLightBulb / LifxLightBulb.cpp
index fbb295befb571ea8b9aaa2be62742e997177fd56..976ec547216f0d6c8865ce9ccf67e0f9ebafa30c 100644 (file)
@@ -139,8 +139,8 @@ void LifxLightBulb::init() {
        //              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;
@@ -339,7 +339,6 @@ void LifxLightBulb::receivedPacket(char* packetData) {
        recHeader.setFromBytes(headerBytes);
 
        // load the payload bytes (strip away the header)
-       //char payloadBytes[recHeader.getSize()];
        char* payloadBytes = new char[recHeader.getSize()];
        for (int i = 36; i < recHeader.getSize(); i++) {
                payloadBytes[i - 36] = packetData[i];
@@ -347,6 +346,7 @@ void LifxLightBulb::receivedPacket(char* packetData) {
 
        int type = recHeader.getType();
        //cout << "Received: " << type << endl;
+       log << "Received: " << type << endl;
 
        DeviceStateService* dat = NULL;
        switch (type) {
@@ -403,6 +403,8 @@ void LifxLightBulb::workerFunction(LifxLightBulb* llb) {
        int64_t lastSentGetBulbVersionRequest = 0;      // time last request sent
        char dat[1024];
 
+       llb->log << "Turning off and entering while loop!" << endl;
+
        while (true) {
                // Check if we got the bulb version yet
                // could have requested it but message could have gotten lost (UDP)
@@ -1221,8 +1223,8 @@ void adjustBright(LifxLightBulb *llb) {
 {
        string macAddress1 = "D073D5128E300000";
        //string macAddress = "D073D50241DA0000";
-       string devIPAddress1 = "192.168.2.126";
-       //string devIPAddress = "192.168.2.232";
+       string devIPAddress1 = "192.168.1.126";
+       //string devIPAddress = "192.168.1.232";
        IoTDeviceAddress* devAddress1 = new IoTDeviceAddress(devIPAddress1, 12345, 56700, false, false);
        unordered_set<void*>* myset1 = new unordered_set<void*>();
        myset1->insert(devAddress1);
@@ -1231,11 +1233,13 @@ void adjustBright(LifxLightBulb *llb) {
        LifxLightBulb *llb1 = new LifxLightBulb(setDevAddress1, macAddress1);
        cout << "Generated LifxLightBulb object!" << endl;
        llb1->init();
+       cout << "Initialized!" << endl;
        llb1->turnOn();
+       cout << "Turning on!" << endl;
        onOff(llb1);
-       adjustTemp(llb1);
-       adjustBright(llb1);
-//     llb->turnOff();
+//     adjustTemp(llb1);
+//     adjustBright(llb1);
+       llb1->turnOff();
 
 //     delete devAddress1;
 //     delete llb1;