Changing a few things to pointer; Testing Lifxtest benchmark without using runtime...
[iot2.git] / benchmarks / drivers / Cpp / LifxLightBulb / LifxLightBulb.cpp
index 669548ffcb744a6a4bc7816007db674a480bd31c..3f2cea8e31d6bec40cfac5fd65ae9f321c006a8c 100644 (file)
@@ -40,7 +40,7 @@ LifxLightBulb::LifxLightBulb() {
 }
 
 
-LifxLightBulb::LifxLightBulb(IoTSet<IoTDeviceAddress*> _devAddress, string macAddress) {
+LifxLightBulb::LifxLightBulb(IoTSet<IoTDeviceAddress*>* _devAddress, string macAddress) {
 
        // Initialize macAddress
        char tmpMacAddress[16];
@@ -70,6 +70,15 @@ LifxLightBulb::~LifxLightBulb() {
                delete communicationSocket;
                communicationSocket = NULL;             
        }
+       for(IoTDeviceAddress* dev : *lb_addresses) {
+               delete dev;
+               dev = NULL;
+       }
+       if (lb_addresses != NULL) {
+
+               delete lb_addresses;
+               lb_addresses = NULL;            
+       }
 }
 
 
@@ -80,7 +89,7 @@ void LifxLightBulb::init() {
        if (didAlreadyInit.exchange(true))
                return;
 
-       unordered_set<IoTDeviceAddress*>::const_iterator itr = lb_addresses.begin();
+       unordered_set<IoTDeviceAddress*>::const_iterator itr = lb_addresses->begin();
        IoTDeviceAddress* deviceAddress = *itr;
        cout << "Address: " << deviceAddress->getAddress() << endl;
 
@@ -1126,7 +1135,7 @@ void LifxLightBulb::handleLightStateMessageReceived(char* payloadData) {
 // Functions for the main function
 void onOff(LifxLightBulb *llb) {
 
-       for (int i = 0; i < 5; i++) {
+       for (int i = 0; i < 2; i++) {
                llb->turnOff();
                cout << "Turning off!" << endl;
                this_thread::sleep_for (chrono::milliseconds(1000));
@@ -1170,7 +1179,7 @@ void adjustBright(LifxLightBulb *llb) {
 }
 
 
-int main(int argc, char *argv[])
+/*int main(int argc, char *argv[])
 {
        string macAddress = "D073D5128E300000";
        //string macAddress = "D073D50241DA0000";
@@ -1194,4 +1203,4 @@ int main(int argc, char *argv[])
        delete llb;
 
        return 0;
-}
+}*/