Perfecting IoTSlave for C++; Found one issue with SSH/Java process execution in which...
[iot2.git] / benchmarks / drivers / Cpp / LifxLightBulb / LightBulb_Skeleton.cpp
index aab1ac859ddd24bccf89e3d889c239c02183268b..f12e77ebd757f25dbd720707df755d9d3f530aae 100644 (file)
@@ -1,11 +1,48 @@
 #include <iostream>
 #include "LightBulb_Skeleton.hpp"
 
-// External creator/destroyer
-/*extern "C" LightBulb_Skeleton* create(LightBulb *_mainObj, string _callbackAddress, int _port) {
-       return new LightBulb_Skeleton(_mainObj, _callbackAddress, _port);
+#include <unordered_set>
+#include "IoTSet.hpp"
+#include "LifxLightBulb.cpp"
+#include "IoTDeviceAddress.hpp"
+
+// External create, destroy, and init functions
+extern "C" void* createLightBulb_Skeleton(void** params) {
+       // Arguments: LightBulb *_mainObj, string _callbackAddress, int _port
+       return new LightBulb_Skeleton((LightBulb*) params[0], *((string*) params[1]), *((int*) params[2]));
+}
+
+
+extern "C" void destroyLightBulb_Skeleton(void* t) {
+       LightBulb_Skeleton* lbs = (LightBulb_Skeleton*) t;
+       delete lbs;
 }
 
-extern "C" void destroy(LightBulb_Skeleton* t) {
-       delete t;
-}*/
+
+extern "C" void initLightBulb_Skeleton(void* t) {
+       LightBulb_Skeleton* lbs = (LightBulb_Skeleton*) t;
+       lbs->init();
+}
+
+
+int main(int argc, char *argv[])
+{
+       // LightBulb #1
+       string macAddress1 = "D073D5128E300000";
+       string devIPAddress1 = "192.168.2.126";
+       //string macAddress1 = "D073D50241DA0000";
+       //string devIPAddress1 = "192.168.2.232";
+       IoTDeviceAddress* devAddress1 = new IoTDeviceAddress(devIPAddress1, 43583, 56700, false, false);
+       unordered_set<void*>* myset1 = new unordered_set<void*>();
+       myset1->insert(devAddress1);
+       IoTSet<void*>* setDevAddress1 = new IoTSet<void*>(myset1);
+       LifxLightBulb *llb1 = new LifxLightBulb(setDevAddress1, macAddress1);
+       //cout << "Generated LifxLightBulb object!" << endl;
+
+       string callbackAddress = "localhost";
+       int stubPort = 55179;
+       LightBulb_Skeleton *lbs = new LightBulb_Skeleton(llb1, callbackAddress, stubPort);
+       cout << "Successfully instantiated object and its skeleton!" << endl;
+
+       return 0;
+}