summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorErich Keane <erich.keane@intel.com>2015-04-09 17:50:26 -0700
committerErich Keane <erich.keane@intel.com>2015-04-10 12:06:24 -0700
commit9015fb1a75f3b43b57153b840f73a2ebc4bb8a63 (patch)
tree014c7d90ff551ecb211cc5d47a12b657fddfb6dd /examples
parentaf9f5813db40c69283b1d25e3aeade2924e2022e (diff)
parent8c3d005c76871cdcb238343e2563bdbfd6a7ee59 (diff)
downloadiotivity-9015fb1a75f3b43b57153b840f73a2ebc4bb8a63.tar.gz
iotivity-9015fb1a75f3b43b57153b840f73a2ebc4bb8a63.tar.bz2
iotivity-9015fb1a75f3b43b57153b840f73a2ebc4bb8a63.zip
Merge branch 'connectivity-abstraction' to master
Change-Id: I54ea8ab0ea7c4929576ac9b613ce19c79a5c92b8 Signed-off-by: Erich Keane <erich.keane@intel.com>
Diffstat (limited to 'examples')
-rw-r--r--examples/OICMiddle/Client.cpp20
-rw-r--r--examples/OICMiddle/SConscript77
-rw-r--r--examples/OICMiddle/makefile20
-rw-r--r--examples/OICSensorBoard/SConstruct33
4 files changed, 127 insertions, 23 deletions
diff --git a/examples/OICMiddle/Client.cpp b/examples/OICMiddle/Client.cpp
index 8d6e7d16e..c8576d676 100644
--- a/examples/OICMiddle/Client.cpp
+++ b/examples/OICMiddle/Client.cpp
@@ -1,6 +1,6 @@
//******************************************************************
//
-// Copyright 2014 Intel Corporation.
+// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
//
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
@@ -19,6 +19,7 @@
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include <map>
+#include <stdexcept>
#include "WrapResource.h"
#include "Client.h"
@@ -38,7 +39,7 @@ void MiddleClient::findResources()
{
m_resourceMap.clear();
- OC::OCPlatform::findResource("", OC_WELL_KNOWN_QUERY, m_findCB);
+ OC::OCPlatform::findResource("", OC_WELL_KNOWN_QUERY, OC_WIFI, m_findCB);
}
void MiddleClient::foundOCResource(shared_ptr<OCResource> resource)
@@ -66,14 +67,21 @@ void MiddleClient::foundOCResource(shared_ptr<OCResource> resource)
*/
string MiddleClient::formatResourceID(std::shared_ptr<OCResource> resource)
{
- string host = resource->host();
- if (host.compare(0, 7, "coap://") == 0)
- host = host.erase(0, 7);
- return host + resource->uri();
+ if(!resource)
+ {
+ throw invalid_argument("Invalid resource object in formatResourceID");
+ }
+
+ return resource->sid() + resource->uri();
}
void MiddleClient::addResource(WrapResource *wres)
{
+ if(!wres)
+ {
+ throw invalid_argument("Invalid WrapResource object in addResource");
+ }
+
string resourceID = wres->getResourceID();
try {
m_resourceMap[resourceID];
diff --git a/examples/OICMiddle/SConscript b/examples/OICMiddle/SConscript
new file mode 100644
index 000000000..04b26fe2b
--- /dev/null
+++ b/examples/OICMiddle/SConscript
@@ -0,0 +1,77 @@
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+##
+# Examples build script
+##
+Import('env')
+# Add third party libraries
+lib_env = env.Clone()
+SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
+
+examples_env = lib_env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+examples_env.AppendUnique(CPPPATH = [
+ '../../resource/include/',
+ '../../resource/csdk/stack/include',
+ '../../resource/csdk/ocrandom/include',
+ '../../resource/csdk/logger/include',
+ '../../resource/oc_logger/include'
+ ])
+
+target_os = env.get('TARGET_OS')
+if target_os not in ['windows', 'winrt']:
+ examples_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+
+ # Note: 'pthread' is in libc for android. On other platform, if use
+ # new gcc(>4.9?) it isn't required, otherwise, it's required
+ if target_os != 'android':
+ examples_env.AppendUnique(LIBS = ['-lpthread'])
+
+examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'coap'])
+if env.get('SECURED') == '1':
+ examples_env.AppendUnique(LIBS = ['tinydtls'])
+
+examples_env.ParseConfig('pkg-config --libs glib-2.0');
+
+if target_os == 'android':
+ examples_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
+ examples_env.AppendUnique(LIBS = ['gnustl_static'])
+
+ if not env.get('RELEASE'):
+ examples_env.AppendUnique(LIBS = ['log'])
+
+if target_os in ['darwin', 'ios']:
+ examples_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+OICMiddle = examples_env.Program('OICMiddle', ['OICMiddle.cpp', 'Client.cpp', 'LineInput.cpp', 'RestInput.cpp', 'Server.cpp', 'WrapResource.cpp'])
+
+Alias("examples", [OICMiddle])
+env.AppendTarget('examples')
+
+
+
diff --git a/examples/OICMiddle/makefile b/examples/OICMiddle/makefile
index 52c377210..4a40c9597 100644
--- a/examples/OICMiddle/makefile
+++ b/examples/OICMiddle/makefile
@@ -1,6 +1,6 @@
#//******************************************************************
#//
-#// Copyright 2014 Intel Corporation.
+#// Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
#//
#//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#//
@@ -34,7 +34,7 @@ OBJS := OICMiddle.o \
WrapResource.o \
LineInput.o \
RestInput.o
-
+
CXX_FLAGS.debug := -O0 -g3 -std=c++0x -Wall -pthread
CXX_FLAGS.release := -O3 -std=c++0x -Wall -pthread
@@ -42,24 +42,23 @@ CXX_FLAGS.release := -O3 -std=c++0x -Wall -pthread
CXX_INC := -I$(OIC_RES)/include/
CXX_INC += -I$(OIC_RES)/oc_logger/include
CXX_INC += -I$(OIC_RES)/csdk/stack/include
-CXX_INC += -I$(OIC_RES)/csdk/ocsocket/include
CXX_INC += -I$(OIC_RES)/csdk/ocrandom/include
CXX_INC += -I$(OIC_RES)/csdk/logger/include
-CXX_INC += -I$(OIC_RES)/csdk/libcoap
-CXX_INC += -I$(OIC_RES)/../extlibs/cereal/include
+CXX_INC += -I$(OIC_RES)/csdk/connectivity/lib/libcoap-4.1.1
CXX_LIBS := -L${OIC_LIB}
CXX_LIBS += -loc
CXX_LIBS += -loctbstack
CXX_LIBS += -loc_logger
-CXX_LIBS += -loc_logger_core
+#CXX_LIBS += -loc_logger_core
+CXX_LIBS += -lconnectivity_abstraction
CXX_LIBS += -lcoap
all: prep_dirs OICMiddle
prep_dirs:
-mkdir -p $(OUT_DIR)
-
+
OICMiddle: $(OBJS)
$(CXX) $(CXX_FLAGS.$(BUILD)) -o $(OUT_DIR)/$@ $(OBJS) $(CXX_LIBS)
@@ -74,15 +73,16 @@ Server.o: Server.cpp Server.h OICMiddle.h
WrapResource.o: WrapResource.cpp WrapResource.h OICMiddle.h
$(CXX) -c $(CXX_FLAGS.$(BUILD)) WrapResource.cpp $(CXX_INC)
-
+
LineInput.o: LineInput.cpp LineInput.h OICMiddle.h
$(CXX) -c $(CXX_FLAGS.$(BUILD)) LineInput.cpp $(CXX_INC)
-
+
RestInput.o: RestInput.cpp RestInput.h OICMiddle.h
$(CXX) -c $(CXX_FLAGS.$(BUILD)) RestInput.cpp $(CXX_INC)
-
+
clean:
rm $(OBJS)
rm -rf debug
rm -rf release
+
diff --git a/examples/OICSensorBoard/SConstruct b/examples/OICSensorBoard/SConstruct
index e9acb2d8e..2a468aaf9 100644
--- a/examples/OICSensorBoard/SConstruct
+++ b/examples/OICSensorBoard/SConstruct
@@ -1,9 +1,29 @@
-#This script builds edisonclient for Ubuntu and edisonserver for Yocto.
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#This script builds edisonclient for Ubuntu and edisonserver for Yocto.
#Client build for Ubuntu
#Set IOTIVITY_ROOT to the root of oic-resource on Ubuntu.
-IOTIVITY_ROOT = ''
-#Set IOTIVITY_LIBS_PATH to path on Ubuntu that contains liboc.so, liboctbstack.so, liboc_logger.so and libcoap.so.
+IOTIVITY_ROOT = ''
+#Set IOTIVITY_LIBS_PATH to path on Ubuntu that contains liboc.so, liboctbstack.so, liboc_logger.so and libcoap.so.
IOTIVITY_LIBS_PATH = ''
env = DefaultEnvironment()
@@ -13,9 +33,8 @@ env.AppendUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'coap'])
envClient = env.Clone()
envClient.AppendUnique(CPPPATH = [
- IOTIVITY_ROOT + '/resource/include',
+ IOTIVITY_ROOT + '/resource/include',
IOTIVITY_ROOT + '/resource/csdk/stack/include',
- IOTIVITY_ROOT + '/resource/csdk/ocsocket/include',
IOTIVITY_ROOT + '/resource/oc_logger/include',
])
envClient.AppendUnique(LIBPATH = [IOTIVITY_LIBS_PATH])
@@ -58,8 +77,8 @@ try:
envServer.AppendUnique(CPPPATH = [
sdk_root + '/usr/include/iotivity/',
sdk_root + '/usr/include/iotivity/stack/',
- sdk_root + '/usr/include/iotivity/ocsocket/',
sdk_root + '/usr/include/iotivity/oc_logger/',
- ])
+ ])
except:
print "ERROR configuring Yocto cross-toolchain environment. This is required for building the server"
+