1 //******************************************************************
3 // Copyright 2014 Intel Corporation All Rights Reserved.
4 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 #include <WrapperFactory.h>
9 #include <IServerWrapper.h>
10 #include <IClientWrapper.h>
11 #include <OCReflect.h>
18 using namespace OC::OCReflect;
20 // Demo of how to generate OCStack stuff:
23 using OC::OCReflect::property_type;
24 using OC::OCReflect::named_property_binding;
26 named_property_binding_vector sigs {
27 named_property_binding("state", property_type::boolean),
28 named_property_binding("power", property_type::integer),
31 using namespace OC::OCReflect::to_OCStack;
33 std::vector<std::string> reps { convert(sigs) };
35 for(const auto& r : reps)
36 std::cout << r << '\n';
38 char **LEDrep = convert(reps);
40 std::for_each(LEDrep, LEDrep + length(LEDrep), [](const char *s) { std::cout << s << '\n'; });
45 OCEntityHandler entityHandler;
46 OCResourceHandle resourceHandle;
48 OCCreateResource( &resourceHandle, // OCResourceHandle *handl
49 "core.led", // const char * resourceTypeName
50 "state:oc.bt.b;power:oc.bt.i", //const char * resourceTypeRepresentation
51 "core.rw", //const char * resourceInterfaceName
52 OC_REST_GET | OC_REST_PUT, // uint8_t allowedMethods
53 "/a/led", // const char * uri
54 entityHandler, // OCEntityHandler entityHandler
55 OC_DISCOVERABLE | OC_OBSERVABLE // uint8_t resourceProperties
66 cfg.ipAddress = "192.168.1.5";
68 cfg.mode = ModeType::Server;
69 cfg.serviceType = ServiceType::InProc;
71 IWrapperFactory::Ptr pFactory= std::make_shared<WrapperFactory>();
73 IServerWrapper::Ptr pServer = pFactory->CreateServerWrapper(cfg);