1 //******************************************************************
3 // Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 // Licensed under the Apache License, Version 2.0 (the "License");
8 // you may not use this file except in compliance with the License.
9 // You may obtain a copy of the License at
11 // http://www.apache.org/licenses/LICENSE-2.0
13 // Unless required by applicable law or agreed to in writing, software
14 // distributed under the License is distributed on an "AS IS" BASIS,
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 // See the License for the specific language governing permissions and
17 // limitations under the License.
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 #include <WrapperFactory.h>
24 #include <IServerWrapper.h>
25 #include <IClientWrapper.h>
26 #include <OCReflect.h>
33 using namespace OC::OCReflect;
35 // Demo of how to generate OCStack stuff:
38 using OC::OCReflect::property_type;
39 using OC::OCReflect::named_property_binding;
41 named_property_binding_vector sigs {
42 named_property_binding("state", property_type::boolean),
43 named_property_binding("power", property_type::integer),
46 using namespace OC::OCReflect::OCStack;
48 std::vector<std::string> reps { convert(sigs) };
50 for(const auto& r : reps)
51 std::cout << r << '\n';
53 char **LEDrep = convert(reps);
55 std::for_each(LEDrep, LEDrep + length(LEDrep), [](const char *s) { std::cout << s << '\n'; });
60 OCEntityHandler entityHandler;
61 OCResourceHandle resourceHandle;
63 OCCreateResource( &resourceHandle, // OCResourceHandle *handl
64 "core.led", // const char * resourceTypeName
65 "state:oc.bt.b;power:oc.bt.i", //const char * resourceTypeRepresentation
66 "core.rw", //const char * resourceInterfaceName
67 OC_REST_GET | OC_REST_PUT, // uint8_t allowedMethods
68 "/a/led", // const char * uri
69 entityHandler, // OCEntityHandler entityHandler
70 OC_DISCOVERABLE | OC_OBSERVABLE // uint8_t resourceProperties
81 cfg.ipAddress = "192.168.1.5";
83 cfg.mode = ModeType::Server;
84 cfg.serviceType = ServiceType::InProc;
86 IWrapperFactory::Ptr pFactory= std::make_shared<WrapperFactory>();
88 IServerWrapper::Ptr pServer = pFactory->CreateServerWrapper(cfg);