Commit 913c247a authored by Madan's avatar Madan Committed by Uze Choi

Added latest IoTivity Primitive Service commits from master branch to 0.9.1 release branch

Following IoTivity Primitive Service modifications are merged
Change 1060
Change 915
Change 1070
Change 1067
Change 1065
Change 1064
Change 1063
Change 1061
Change 1060
Change 1058
Change 1059 
Change 1049

Change-Id: I1f0e671b958ecf4e37d789eacd0bb9878e66e8e1
Signed-off-by: default avatarMadan <lanka.madan@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1085Reviewed-by: default avatarUze Choi <uzchoi@samsung.com>
Tested-by: default avatarUze Choi <uzchoi@samsung.com>
parent 28360f5e
......@@ -115,6 +115,16 @@ Java codes, this isn't required)
so you don't need to add it in command line each time. The build script will
guide you to do that.)
Tizen:
To build for tizen platform cereal library is needed.
Please download cereal if it is not present in extlibs/cereal folder
and apply the patch as following:
$ git clone https://github.com/USCiLab/cereal.git extlibs/cereal/cereal
$ cd extlibs/cereal/cereal
$ git reset --hard 7121e91e6ab8c3e6a6516d9d9c3e6804e6f65245
$ git apply ../../../resource/patches/cereal_gcc46.patch
* 3. External libraries
IoTivity project depends on some external libraries, such as boost, expat ...
During building, the existence of external library will be checked, if it doesn't
......@@ -151,10 +161,10 @@ it's unnecessary to specify it)
4. Build Iotivity project for Tizen
$ cd <top directory of the project>
$ gbs build -A xxx --packaging-dir tools/tizen/
(xxx can be i586 or armv7l, we provide the spec file required by gbs tool at
toools/tizen directory. gbs is default build tool for Tizen platfrom, we can
refer the following wiki to setup Tizen development environment:
$ sh gbsbuild.sh
(we provide the spec file required by gbs tool at toools/tizen directory.
gbs is default build tool for Tizen platfrom, we can refer the following
wiki to setup Tizen development environment:
https://source.tizen.org/documentation/developer-guide/getting-started-guide)
=== Build IoTivity project on Android ===
......
......@@ -267,10 +267,7 @@ else:
If target_os is not Yocto, continue with the regular build process
'''
# Load config of target os
if target_os in ['linux', 'tizen']:
env.SConscript('linux/SConscript')
else:
env.SConscript(target_os + '/SConscript')
env.SConscript(target_os + '/SConscript')
# Delete the temp files of configuration
if env.GetOption('clean'):
......
......@@ -231,3 +231,4 @@ SConscript('compatibility/cpp11_compat.scons')
# Make sure that boost for android is available
SConscript(env.get('SRC_DIR') + '/extlibs/boost/SConscript')
SConscript(env.get('SRC_DIR') + '/extlibs/expat/SConscript')
......@@ -22,11 +22,6 @@ env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC'])
env.AppendUnique(LIBS = ['uuid'])
env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread'])
if env.get('TARGET_OS') == 'tizen':
env.AppendUnique(CCFLAGS = ['-D__TIZEN__', '-DSLP_SDK_LOG', '-D_GNU_SOURCE', '-DTIZEN_DEBUG_ENABLE'])
env.ParseConfig("pkg-config glib-2.0 gthread-2.0 --cflags --libs")
env.ParseConfig("pkg-config dlog --cflags --libs")
# Set arch flags
target_arch = env.get('TARGET_ARCH')
if target_arch in ['x86']:
......
......@@ -14,7 +14,7 @@ import os
Import('env')
expat_env = env.Clone()
SConscript(env.get('SRC_DIR') + '/build_common/tools/UnpackAll.py')
######################################################################
# Build flags
######################################################################
......@@ -26,7 +26,7 @@ if not os.path.exists(src_dir):
expat_src = env.UnpackAll(src_dir + '/Makefile', 'expat.tar.gz')
env.Configure(src_dir, './configure')
expat_env.AppendUnique(CPPPATH = [src_dir, src_dir + 'lib'])
expat_env.AppendUnique(CPPPATH = [src_dir, src_dir + 'lib', src_dir + 'vms'])
target_os = env.get('TARGET_OS')
if target_os not in ['windows', 'winrt']:
......
......@@ -63,10 +63,13 @@ if target_os not in ['windows', 'winrt']:
liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
if target_os in ['android', 'linux']:
if target_os in ['android', 'linux', 'tizen']:
liboctbstack_env.AppendUnique(LIBS = ['connectivity_abstraction'])
liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
if target_os == 'tizen':
liboctbstack_env.ParseConfig("pkg-config --cflags --libs uuid")
if target_os not in ['android', 'arduino', 'windows', 'winrt']:
liboctbstack_env.AppendUnique(LIBS = ['pthread'])
......@@ -75,6 +78,7 @@ if target_os == 'arduino':
elif target_os not in ['darwin','ios']:
liboctbstack_env.AppendUnique(CFLAGS = ['-fPIC'])
if target_os in ['darwin', 'ios']:
env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
liboctbstack_env.AppendUnique(CPPDEFINES = ['_DARWIN_C_SOURCE'])
liboctbstack_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
if target_os not in ['arduino']:
......
......@@ -10,6 +10,9 @@ target_os = env.get('TARGET_OS')
inc_files = env.get('CPPPATH')
src_dir = './ip_adapter/'
if target_os == 'tizen':
env.ParseConfig("pkg-config --cflags --libs capi-network-wifi")
#Source files to build common for all platforms
if target_os == 'arduino':
env.AppendUnique(CA_SRC=[src_dir+'caipadapter_singlethread.c'])
......
......@@ -669,6 +669,10 @@ INPUT = . \
../resource/csdk/stack/include/octypes.h \
../resource/csdk/stack/include/ocstackconfig.h \
guides \
../../service/things-manager/sdk/inc \
../../service/soft-sensor-manager/SDK/cpp/include \
../../service/protocol-plugin/plugin-manager/src/PluginManager.h \
../../service/noification-manager/NotificationManager/include/hosting.h
# This tag can be used to specify the character encoding of the source files
# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
......
......@@ -47,11 +47,6 @@ if target_os in ['linux', 'tizen']:
''' % target_arch
conf = Configure(lib_env)
if target_os in ['tizen'] and not conf.CheckLib('glib-2.0'):
print 'Install glib-2.0 to compile on Tizen platforms'
Exit(1)
conf.Finish()
......
......@@ -26,7 +26,7 @@ Import('env')
target_os = env.get('TARGET_OS')
if target_os not in ['arduino','darwin']:
if target_os not in ['arduino','darwin','ios']:
# Build things manager project
SConscript('things-manager/SConscript')
......
......@@ -328,21 +328,24 @@ OCStackResult registerResourceAsCoordinatable(OCResourceHandle *handle,
OCEntityHandler entityHandler,
uint8_t resourceProperties)
{
char *coordinatingURI = (char *)malloc(sizeof(char) *
(strlen(resourceUri) + strlen(OIC_COORDINATING_FLAG)));
OCStackResult ret = OC_STACK_OK;
size_t coordinateUriLen = sizeof(char) * (strlen(resourceUri) +
strlen(OIC_COORDINATING_FLAG) + 1);
char *coordinatingURI = (char *)malloc(coordinateUriLen);
if(coordinatingURI == NULL)
{
OC_LOG_V(DEBUG, HOSTING_TAG, "memory alloc fail : coordinatingURI");
return OC_STACK_NO_MEMORY;
}
snprintf(coordinatingURI, sizeof(coordinatingURI), "%s%s", resourceUri, OIC_COORDINATING_FLAG);
snprintf(coordinatingURI, coordinateUriLen,"%s%s", resourceUri, OIC_COORDINATING_FLAG);
OC_LOG_V(DEBUG, HOSTING_TAG, "requiredUri+coordinatingFlag = %s", coordinatingURI);
return OCCreateResource(handle, resourceTypeName, resourceInterfaceName,
ret = OCCreateResource(handle, resourceTypeName, resourceInterfaceName,
coordinatingURI, entityHandler, resourceProperties);
free(coordinatingURI);
return ret;
}
/*
......@@ -514,6 +517,7 @@ OCStackApplicationResult requestCoordinateeCandidateDiscoveryCB(void *ctx, OCDoH
if (vList->headerNode == NULL)
{
OC_LOG(DEBUG, HOSTING_TAG, "This Discover Response is empty");
destroyMirrorResourceList(vList);
return ret;
}
......@@ -640,12 +644,10 @@ MirrorResourceList *buildMirrorResourceList(OCDoHandle handle, OCClientResponse
MirrorResource *buildMirrorResource(cJSON *ocArray_sub)
{
MirrorResource *mirrorResource = NULL;
char temp[OIC_STRING_MAX_VALUE] = {'\0'};
strncpy(temp, cJSON_GetObjectItem(ocArray_sub, "href")->valuestring, sizeof(temp));
const char *curValuestring = cJSON_GetObjectItem(ocArray_sub, "href")->valuestring;
if ( strstr(temp, OIC_COORDINATING_FLAG) )
if ( strstr(curValuestring, OIC_COORDINATING_FLAG) )
{
mirrorResource = createMirrorResource();
if(mirrorResource == NULL)
......@@ -660,8 +662,8 @@ MirrorResource *buildMirrorResource(cJSON *ocArray_sub)
OC_LOG_V(DEBUG, HOSTING_TAG, "memory alloc fail for mirrorResource uri");
goto RET_ERROR;
}
strncpy(mirrorResource->uri, temp, strlen(temp) - strlen(OIC_COORDINATING_FLAG));
mirrorResource->uri[strlen(temp) - strlen(OIC_COORDINATING_FLAG)] = '\0';
strncpy(mirrorResource->uri, curValuestring, strlen(curValuestring) - strlen(OIC_COORDINATING_FLAG));
mirrorResource->uri[strlen(curValuestring) - strlen(OIC_COORDINATING_FLAG)] = '\0';
OC_LOG_V(DEBUG, HOSTING_TAG, "VirtualResource URI : %s", mirrorResource->uri);
cJSON *inArray_sub = cJSON_GetObjectItem(ocArray_sub, "prop");
......@@ -966,7 +968,7 @@ MirrorResource *updateMirrorResource(OCDoHandle handle, const char *payload)
cJSON *json = cJSON_CreateObject();
char nodeData[OIC_STRING_MAX_VALUE] = {'\0'};
snprintf(nodeData, sizeof(foundMirrorResource->uri), "%s", foundMirrorResource->uri);
snprintf(nodeData, sizeof(nodeData), "%s", foundMirrorResource->uri);
cJSON_AddStringToObject(json, "href", nodeData);
cJSON *nodeRep = cJSON_Parse(cJSON_PrintUnformatted(foundMirrorResource->rep));
......@@ -1249,7 +1251,9 @@ OCStackResult requestIsAlive(const char *address)
if (result != OC_STACK_OK)
{
OC_LOG_V(DEBUG, HOSTING_TAG, "Insert request list : fail3");
return result;
destroyRequestHandle(requestAlive);
mirrorResource = mirrorResource->next;
continue;
}
result = requestQuery(requestAlive, OC_REST_GET, address, mirrorResource->uri);
......@@ -1463,6 +1467,7 @@ OCEntityHandlerResponse buildEntityHandlerResponse(OCEntityHandlerRequest *entit
{
OC_LOG_V(DEBUG, HOSTING_TAG, "enter buildEntityHandlerResponse");
OCEntityHandlerResponse response;
memset(&response, 0, sizeof(response));
OCEntityHandlerResult entityHandlerResult = OC_EH_OK;
char payload[MAX_RESPONSE_LENGTH] = {'\0'};
......@@ -1517,7 +1522,7 @@ OCEntityHandlerResult handleRequestPayload (OCEntityHandlerRequest *entityHandle
if (entityHandlerRequest->method == OC_REST_DELETE)
{
memset(payload, '\0', sizeof(payload));
memset(payload, '\0', sizeof(char) * (maxPayloadSize + 1));
OC_LOG_V(DEBUG, HOSTING_TAG, "DELETE");
return OC_EH_RESOURCE_DELETED;
}
......@@ -1530,7 +1535,7 @@ OCEntityHandlerResult handleRequestPayload (OCEntityHandlerRequest *entityHandle
if (maxPayloadSize > strlen ((char *)responsePayload))
{
strncpy(payload, responsePayload, sizeof(payload));
strncpy(payload, responsePayload, strlen ((char *)responsePayload));
entityHandlerResult = OC_EH_OK;
}
else
......
......@@ -166,14 +166,14 @@ OCStackResult insertMirrorResource(MirrorResourceList *mirrorResourceList,
MirrorResource *findMirrorResourceUsingAddressAndURI(MirrorResourceList *mirrorResourceList,
const char *address, OICResourceCoordinatorParamType paramType, const char *uri)
{
if (mirrorResourceList->headerNode == NULL)
if (mirrorResourceList == NULL || address == NULL)
{
OC_LOG_V(DEBUG, VR_TAG,"Find Virtual Resource : Empty Virtual Resource List.");
OC_LOG_V(DEBUG, VR_TAG,"Find Virtual Resource : invalid parameter.");
return NULL;
}
if (mirrorResourceList == NULL || address == NULL)
if (mirrorResourceList->headerNode == NULL)
{
OC_LOG_V(DEBUG, VR_TAG,"Find Virtual Resource : invalid parameter.");
OC_LOG_V(DEBUG, VR_TAG,"Find Virtual Resource : Empty Virtual Resource List.");
return NULL;
}
......@@ -281,6 +281,7 @@ OCStackResult ejectMirrorResource(MirrorResourceList *mirrorResourceList,
if (mirrorResourceList->headerNode == NULL)
{
OC_LOG_V(DEBUG, VR_TAG, "Eject Virtual Resource : Empty Virtual Resource List.");
return OC_STACK_ERROR;
}
if (mirrorResource == mirrorResourceList->headerNode)
......@@ -340,22 +341,12 @@ MirrorResource *cloneMirrorResource(MirrorResource *sourceMirrorResource)
strcpy(clonedMirrorResource->address[i], sourceMirrorResource->address[i]);
}
// copy prop ??
return clonedMirrorResource;
}
MirrorResourceList *findMirrorResourceListUsingAddress(MirrorResourceList *mirrorResourceList,
const char *address, OICResourceCoordinatorParamType paramType)
{
MirrorResource *tempNode = mirrorResourceList->headerNode;
while (tempNode != NULL)
{
OC_LOG_V(DEBUG, VR_TAG, "uri = %s", tempNode->uri);
tempNode = tempNode->next;
}
if (mirrorResourceList == NULL || address == NULL)
{
OC_LOG_V(DEBUG, VR_TAG,"Find Virtual Resource List : invalid parameter.");
......@@ -367,6 +358,14 @@ MirrorResourceList *findMirrorResourceListUsingAddress(MirrorResourceList *mirro
return NULL;
}
MirrorResource *tempNode = mirrorResourceList->headerNode;
while (tempNode != NULL)
{
OC_LOG_V(DEBUG, VR_TAG, "uri = %s", tempNode->uri);
tempNode = tempNode->next;
}
MirrorResourceList *resultMirrorResourceList = createMirrorResourceList();
MirrorResource *mirrorResource = mirrorResourceList->headerNode;
while (mirrorResource != NULL)
......
......@@ -369,27 +369,27 @@ int main(int argc , char *argv[])
continue;
}
switch ((int)in)
{
case OBSERVE:
startObserve(g_curResource);
break;
case GET:
startGet(g_curResource);
break;
case PUT:
startPut(g_curResource);
break;
case DELETE:
try {
try {
switch ((int)in)
{
case OBSERVE:
startObserve(g_curResource);
break;
case GET:
startGet(g_curResource);
break;
case PUT:
startPut(g_curResource);
break;
case DELETE:
startDelete(g_curResource);
}catch(OCException e) {
std::cout<< "Caught OCException [Code: "<<e.code()<<" Reason: "<<e.reason()<<std::endl;
}
break;
default:
std::cout << "Invalid input, please try again" << std::endl;
break;
break;
default:
std::cout << "Invalid input, please try again" << std::endl;
break;
}
}catch(OCException e) {
std::cout<< "Caught OCException [Code: "<<e.code()<<" Reason: "<<e.reason()<<std::endl;
}
}
......
......@@ -10,7 +10,6 @@ SConscript('plugin-manager/SConscript')
# The code include pthread_cancel method, can't build on android
# MQTT requires openssl, forbid cross compile as it isn't ready
#if env.get('TARGET_OS') != 'android' and env.get('TARGET_ARCH') == platform.machine():
if env.get('TARGET_OS') != 'android':
SConscript('plugins/SConscript')
......
......@@ -61,3 +61,7 @@ pmimpl_env.PrependUnique(LIBS = File(env.get('BUILD_DIR') + '/libcpluff.a'))
pmimpl = pmimpl_env.SharedLibrary('pmimpl', pmimpl_src)
plugin_manager_env.InstallTarget([ppm, pmimpl], 'libppm')
# Build JNI library for android
if env.get('TARGET_OS') == 'android':
SConscript('src/Android/jni/SConscript')
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
<classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="gen"/>
<classpathentry exported="true" kind="lib" path="/home/minji/JUDO/out/felix.jar"/>
<classpathentry exported="true" kind="lib" path="/home/minji/JUDO/150520/iotivity/android/android_api/base/build/intermediates/bundles/release/classes.jar"/>
<classpathentry kind="output" path="bin/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MainActivity</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>com.android.ide.eclipse.adt.ApkBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.android.ide.eclipse.adt.AndroidNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.iotivity.service.ppm"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.INTERACT_ACROSS_USERS_FULL" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_TASKS"/>
<uses-permission android:name="com.samsung.wmanager.ENABLE_NOTIFICATION"/>
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.CALL_PHONE" />
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE"/>
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE"/>
<uses-permission android:name="com.samsung.android.providers.context.permission.WRITE_USE_APP_FEATURE_SURVEY"/>
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:largeHeap="true" >
<activity
android:name="org.iotivity.service.ppm.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<pluginManager>
<pluginInfo
pluginPath="/data/data/org.iotivity.service.ppm/files"
maxMEM="64M"
maxPlugin=""
version="1.0"
name="pluginmanager">
</pluginInfo>
<specailpluginInfo>
</specailpluginInfo>
</pluginManager>
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libexpat
LOCAL_SRC_FILES := ../../../../../../deps/android/lib/armeabi/libexpat.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libboost_thread
LOCAL_SRC_FILES := ../../../../../../deps/android/lib/armeabi/libboost_thread.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libboost_system
LOCAL_SRC_FILES := ../../../../../../deps/android/lib/armeabi/libboost_system.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcpluff
LOCAL_SRC_FILES := ../../../../../../out/android/armeabi/release/libcpluff.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libpmimpl
LOCAL_SRC_FILES := ../../../../../../out/android/armeabi/release/libpmimpl.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_DEFAULT_CPP_EXTENSION := cpp
LOCAL_MODULE := PluginManager
LOCAL_SRC_FILES := PluginManager.cpp
LOCAL_CPPFLAGS := -std=c++0x -frtti -fexceptions
LOCAL_LDLIBS := -llog -ldl -lz
LOCAL_STATIC_LIBRARIES := libcpluff
LOCAL_STATIC_LIBRARIES += libpmimpl
LOCAL_STATIC_LIBRARIES += libboost_thread
LOCAL_STATIC_LIBRARIES += libboost_system
LOCAL_STATIC_LIBRARIES += libexpat
LOCAL_C_INCLUDES := ../../../../../../extlibs/boost/boost_1_57_0
LOCAL_C_INCLUDES += ../../../../lib/cpluff/libcpluff
LOCAL_C_INCLUDES += ../../../src
LOCAL_C_INCLUDES += ../../../../../../extlibs/rapidxml
include $(BUILD_SHARED_LIBRARY)
NDK_TOOLCHAIN_VERSION := 4.9
APP_STL := gnustl_shared
//******************************************************************
//
// Copyright 2014 Samsung Electronics All Rights Reserved.