CXX_INC=-I./include/ -I./csdk/stack/include -I./csdk/ocsocket/include -I./csdk/ocrandom/include -I./csdk/logger/include
# Force metatargets to build:
-.PHONY: c_sdk single_resource client examples
+.PHONY: c_sdk simpleserver simpleclient examples
all: .PHONY
examples:
cd examples && $(MAKE)
-single_resource: OCLib.a single_resource.o
- $(CXX) $(CXX_FLAGS) -o single_resource single_resource.o OCLib.a csdk/liboctbstack.a
+simpleserver: OCLib.a simpleserver.o
+ $(CXX) $(CXX_FLAGS) -o simpleserver simpleserver.o OCLib.a csdk/liboctbstack.a
-client: OCLib.a OCClient.o
- $(CXX) $(CXX_FLAGS) -o client OCClient.o OCLib.a csdk/liboctbstack.a
+simpleclient: OCLib.a simpleclient.o
+ $(CXX) $(CXX_FLAGS) -o simpleclient simpleclient.o OCLib.a csdk/liboctbstack.a
OCLib.a: OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o
ar -cvq OCLib.a OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o
InProcClientWrapper.o: OCLib/InProcClientWrapper.cpp
$(CXX) $(CXX_FLAGS) -c OCLib/InProcClientWrapper.cpp $(CXX_INC)
-single_resource.o : examples/server/single_resource.cpp
- $(CXX) $(CXX_FLAGS) -c examples/server/single_resource.cpp $(CXX_INC)
+simpleserver.o : examples/simpleserver.cpp
+ $(CXX) $(CXX_FLAGS) -c examples/simpleserver.cpp $(CXX_INC)
-OCClient.o : examples/client/OCClient.cpp
- $(CXX) $(CXX_FLAGS) -c examples/client/OCClient.cpp $(CXX_INC)
+simpleclient.o : examples/simpleclient.cpp
+ $(CXX) $(CXX_FLAGS) -c examples/simpleclient.cpp $(CXX_INC)
clean:
- rm -f -v OCLib.a *.o single_resource client
- cd examples && $(MAKE) clean
-
- cd csdk && $(MAKE) clean
- cd csdk && $(MAKE) deepclean
-
-
-# Force metatargets to build:
-.PHONY: c_sdk single_resource client examples
-
-all: .PHONY
-
-c_sdk:
- cd csdk && $(MAKE)
-
-examples:
- cd examples && $(MAKE)
-
-single_resource: OCLib.a single_resource.o
- $(CXX) $(CXX_FLAGS) -o single_resource single_resource.o OCLib.a csdk/liboctbstack.a
-
-client: OCLib.a OCClient.o
- $(CXX) $(CXX_FLAGS) -o client OCClient.o OCLib.a csdk/liboctbstack.a
-
-OCLib.a: OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o
- ar -cvq OCLib.a OCPlatform.o OCResource.o OCReflect.o InProcServerWrapper.o InProcClientWrapper.o
-
-OCReflect.o: OCLib/OCReflect.cpp
- $(CXX) $(CXX_FLAGS) -c OCLib/OCReflect.cpp $(CXX_INC)
-
-OCPlatform.o: OCLib/OCPlatform.cpp
- $(CXX) $(CXX_FLAGS) -c OCLib/OCPlatform.cpp $(CXX_INC)
-
-OCResource.o: OCLib/OCResource.cpp
- $(CXX) $(CXX_FLAGS) -c OCLib/OCResource.cpp $(CXX_INC)
-
-InProcServerWrapper.o: OCLib/InProcServerWrapper.cpp
- $(CXX) $(CXX_FLAGS) -c OCLib/InProcServerWrapper.cpp $(CXX_INC)
-
-InProcClientWrapper.o: OCLib/InProcClientWrapper.cpp
- $(CXX) $(CXX_FLAGS) -c OCLib/InProcClientWrapper.cpp $(CXX_INC)
-
-single_resource.o : examples/server/single_resource.cpp
- $(CXX) $(CXX_FLAGS) -c examples/server/single_resource.cpp $(CXX_INC)
-
-OCClient.o : examples/client/OCClient.cpp
- $(CXX) $(CXX_FLAGS) -c examples/client/OCClient.cpp $(CXX_INC)
-
-clean:
- rm -f -v OCLib.a *.o single_resource client
+ rm -f -v OCLib.a *.o simpleserver simpleclient
cd examples && $(MAKE) clean
cd csdk && $(MAKE) clean
void InProcServerWrapper::registerResource(const std::string& resourceURI,
const std::string& resourceTypeName,
- named_property_binding_vector properties)
+ named_property_binding_vector& properties)
{
using OC::OCReflect::property_type;
using OC::OCReflect::named_property_binding;
std::vector<std::string> reps { convert(properties) };
- for(const auto& r : reps)
- std::cout << r << '\n';
+ char *resourceTypeRepresentation = flatten(reps);
- char *resourTypeRepresentation = flatten(reps);
-
- std::cout << resourTypeRepresentation << "\n";
+ std::cout << "Resource type representation: " << resourceTypeRepresentation << "\n";
OCResourceHandle resourceHandle;
{
std::lock_guard<std::mutex> lock(m_csdkLock);
- cout << "Creating a resource" << endl;
-
OCStackResult result;
result = OCCreateResource(&resourceHandle, // OCResourceHandle *handl
resourceTypeName.c_str(), // const char * resourceTypeName
- resourTypeRepresentation, //const char * resourceTypeRepresentation
+ resourceTypeRepresentation, //const char * resourceTypeRepresentation
"core.rw", //const char * resourceInterfaceName
OC_REST_GET | OC_REST_PUT, // uint8_t allowedMethods
resourceURI.c_str(), // const char * uri
CXX_INC=-I../include/ -I./client/ -I../csdk/stack/include -I../csdk/ocsocket/include -I../csdk/ocrandom/include -I../csdk/logger/include
-LIB_SRC0=../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp ../OCLib/OCObserver.cpp ../OCLib/OCResource.cpp ./client/MyObserverHandler.cpp
+LIB_SRC0=../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp ../OCLib/OCObserver.cpp ../OCLib/OCResource.cpp
+
LIB_SRC1=../OCLib/OCReflect.cpp ../OCLib/OCObserver.cpp ./client/MyObserverHandler.cpp ../OCLib/OCResource.cpp ../OCLib/OCSecurityModel.cpp ../OCLib/InProcClientWrapper.cpp ../OCLib/OCPlatform.cpp ../OCLib/InProcServerWrapper.cpp ../csdk/liboctbstack.a
-all: ocreflect resources
+all: ocreflect
ocreflect: test_properties test_OCClient
test_properties:
- $(CXX) $(CXX_FLAGS) -o test_properties test_properties.cpp $(LIB_SRC0) $(CXX_INC)
+ $(CXX) $(CXX_FLAGS) -o test_properties reflect/test_properties.cpp $(LIB_SRC0) $(CXX_INC)
test_OCReflect:
- $(CXX) $(CXX_FLAGS) -o test_OCReflect test_OCReflect.cpp ../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp $(CXX_INC)
+ $(CXX) $(CXX_FLAGS) -o test_OCReflect reflect/test_OCReflect.cpp ../OCLib/OCReflect.cpp ../OCLib/OCProperties.cpp $(CXX_INC)
test_OCClient:
- $(CXX) $(CXX_FLAGS) -o test_OCClient test_OCClient.cpp $(LIB_SRC0) $(CXX_INC)
-
-resources: single_resource multiple_resources
-
-single_resource:
- $(CXX) $(CXX_FLAGS) -o single_resource ./server/single_resource.cpp $(LIB_SRC1) $(CXX_INC)
-
-multiple_resources:
- #$(CXX) $(CXX_FLAGS) -o multiple_resources ./server/multiple_resources.cpp $(LIB_SRC1) $(CXX_INC)
+ $(CXX) $(CXX_FLAGS) -o test_OCClient reflect/test_OCClient.cpp $(LIB_SRC0) $(CXX_INC)
clean:
- rm -f -v test_properties test_OCReflect test_OCClient single_resource multiple_resources
+ rm -f -v test_properties test_OCReflect test_OCClient
// Create PlatformConfig object
PlatformConfig cfg;
- cfg.ipAddress = "134.134.161.166";
+ cfg.ipAddress = "134.134.161.33";
cfg.port = 5683;
cfg.mode = ModeType::Client;
cfg.serviceType = ServiceType::InProc;
/// This function binds the properties and methods to the server.
void createResourceWithPropeties(OC::OCPlatform& platform)
{
- using OC::OCReflect::property_type;
- using OC::OCReflect::named_property_binding;
-
- named_property_binding_vector properties {
- named_property_binding("state", property_type::boolean),
- named_property_binding("power", property_type::integer)
+ /*
+ We could typedef to simpler namers! :)
+ typedef named_property_binding_vector OCPropertyBindings;
+ typedef named_property_binding OCPropertyBinding;
+
+ OCPropertyBindings properties {
+ OCPropertyBinding("state", property_type::boolean),
+ OCPropertyBidning("power", property_type::integer)
};
+ */
+
+ auto properties {
+ named_property_binding{"state", property_type::boolean},
+ named_property_binding{"power", property_type::integer}
+ };
std::string resourceURI = "/a/light";
std::string resourceTypeName = "light";
PlatformConfig cfg;
//cfg.ipAddress = "192.168.1.5";
- cfg.ipAddress = "134.134.161.166";
+ cfg.ipAddress = "134.134.161.33";
cfg.port = 5683;
cfg.mode = ModeType::Server;
cfg.serviceType = ServiceType::InProc;
virtual ~IServerWrapper(){};
- // TODO: SASHI : parameters by reference???
virtual void registerResource( const std::string& resourceURI,
const std::string& resourceTypeName,
- named_property_binding_vector properties) = 0;
+ named_property_binding_vector& properties) = 0;
};
}
void registerResource( const std::string& resourceURI,
const std::string& resourceTypeName,
- named_property_binding_vector properties);
+ named_property_binding_vector& properties);
private:
void processFunc();