Update to current API, and make them build by default.
Those samples files are good candidates
to illustrate C API in plain C and not C++,
specially for systems without recent g++ (ie: Tizen:2.2-)
Change-Id: I22e18903037a249e1dce4d29c2580ffe865caf50
Signed-off-by: Philippe Coval <philippe.coval@osg.samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/9515
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Habib Virji <habib.virji@samsung.com>
Reviewed-by: Dave Thaler <dthaler@microsoft.com>
Reviewed-by: Ziran Sun <ziran.sun@samsung.com>
if target_os in ['linux', 'windows']:
# Build C Samples
+ SConscript('csdk/stack/test/linux/SConscript')
SConscript('csdk/stack/samples/linux/SimpleClientServer/SConscript')
# Build secure samples
--- /dev/null
+#******************************************************************
+#
+# Copyright: 2016, Samsung Electronics Co., Ltd.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# 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.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('env')
+csdktest_env = env.Clone()
+
+######################################################################
+# Build flags
+######################################################################
+csdktest_env.PrependUnique(CPPPATH = [
+ '../../../stack/include',
+])
+
+csdktest_env.PrependUnique(LIBS = [
+ 'octbstack',
+])
+
+csdktest_env.AppendUnique(LIBPATH = [
+ csdktest_env.get('BUILD_DIR'),
+])
+
+######################################################################
+# Source files and Targets
+######################################################################
+occlient = csdktest_env.Program('occlient', ['occlient.c'])
+ocserver = csdktest_env.Program('ocserver', ['ocserver.c'])
#include <stdlib.h>
#include <string.h>
#include <signal.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
#include <ocstack.h>
#include <logger.h>
OCClientResponse * clientResponse) {
OIC_LOG(INFO, TAG, "Entering applicationDiscoverCB (Application Layer CB)");
OIC_LOG_V(INFO, TAG, "Device =============> Discovered %s @ %s:%d",
- clientResponse->resJSONPayload,
+ clientResponse->resourceUri,
clientResponse->devAddr.addr,
clientResponse->devAddr.port);
//return OC_STACK_DELETE_TRANSACTION;
}
int main() {
- OIC_LOG_V(INFO, TAG, "Starting occlient on address %s",addr);
+ OIC_LOG_V(INFO, TAG, "Starting occlient");
/* Initialize OCStack*/
if (OCInit(NULL, 0, OC_CLIENT) != OC_STACK_OK) {
/* Start a discovery query*/
char szQueryUri[MAX_QUERY_LENGTH] = { 0 };
- strcpy(szQueryUri, OC_EXPLICIT_DEVICE_DISCOVERY_URI);
- if (OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0, OC_LOW_QOS,
- 0, 0, 0) != OC_STACK_OK) {
+ strcpy(szQueryUri, OC_MULTICAST_DISCOVERY_URI);
+ if (OCDoResource(NULL, OC_REST_GET, szQueryUri, 0, 0,
+ CT_DEFAULT, OC_LOW_QOS, 0, 0, 0) != OC_STACK_OK) {
OIC_LOG(ERROR, TAG, "OCStack resource error");
return 0;
}
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
#include <signal.h>
#include <stdbool.h>
#include <ocstack.h>
}
int main() {
- OIC_LOG_V(INFO, TAG, "Starting ocserver on address %s:%d",addr,port);
+ OIC_LOG_V(INFO, TAG, "Starting ocserver");
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK) {
OIC_LOG(ERROR, TAG, "OCStack init error");
return 0;
"core.rw",
"/a/light",
0,
+ NULL,
OC_DISCOVERABLE|OC_OBSERVABLE);
return res;
}