1 /******************************************************************
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
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 ******************************************************************/
21 #include "nmsampleapp.h"
26 #include "virtualResource.h"
31 namespace PH = std::placeholders;
33 static uint8_t interfaceName[] = "wlan0";
36 static void printLog(int logType, string data)
38 (DLOG_ERROR == logType) ? LOGE(data.c_str()) : LOGI(data.c_str());
39 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
43 // Method for Finding the resource and hosting it
44 static void start_hosting(int seconds)
46 string logMessage = "OCResourceHosting started <br>";
47 logMessage = logMessage + "Interface Name : " + reinterpret_cast<char *>(interfaceName) + "<br>";
48 printLog(DLOG_INFO, logMessage);
50 if (OCInit((char *) NULL, 0, OC_CLIENT_SERVER) != OC_STACK_OK)
52 logMessage = "OCStack init error <br>";
53 printLog(DLOG_ERROR, logMessage);
59 logMessage = "OICStartCoordinate done successfully";
60 printLog(DLOG_INFO, logMessage);
64 if (OCProcess() != OC_STACK_OK)
67 logMessage = "OCStack process error <br>";
68 printLog(DLOG_ERROR, logMessage);
75 logMessage = "OICStopCoordinate done successfully <br>";
76 printLog(DLOG_INFO, logMessage);
78 if (OCStop() != OC_STACK_OK)
80 logMessage = "OCStack stop error <br>";
81 printLog(DLOG_ERROR, logMessage);
86 // Method for Finding the resource and hosting it
89 string logMessage = "Terminating Resource Hosting <br>";
90 printLog(DLOG_INFO, logMessage);
93 LOGI("stop_hosting EXIT");
96 // Method to be called when the find and host UI Button is selected
97 void start_cb(void *data, Evas_Object *obj, void *event_info)
99 std::thread exec(std::function< void(int second) >(start_hosting), 3);
103 // Method to be called when the find and host UI Button is selected
104 void stop_cb(void *data, Evas_Object *obj, void *event_info)
106 LOGI("Stopping resource hosting");