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 "rhsampleapp.h"
30 namespace PH = std::placeholders;
32 static uint8_t interfaceName[] = "wlan0";
35 static void printLog(int logType, string data)
37 (DLOG_ERROR == logType) ? LOGE(data.c_str()) : LOGI(data.c_str());
38 ecore_main_loop_thread_safe_call_sync((void * ( *)(void *))updateGroupLog,
42 // Method for Finding the resource and hosting it
43 static void start_hosting(int seconds)
45 string logMessage = "OCResourceHosting started <br>";
46 logMessage = logMessage + "Interface Name : " + reinterpret_cast<char *>(interfaceName) + "<br>";
47 printLog(DLOG_INFO, logMessage);
49 if (OICStartCoordinate() != OC_STACK_OK)
51 logMessage = "OICStartCoordinate FAILED <br>";
52 printLog(DLOG_ERROR, logMessage);
57 logMessage = "OICStartCoordinate done successfully <br>";
58 printLog(DLOG_INFO, logMessage);
62 if (OCProcess() != OC_STACK_OK)
65 logMessage = "OCStack process error <br>";
66 printLog(DLOG_ERROR, logMessage);
72 if (OICStopCoordinate() != OC_STACK_OK)
74 logMessage = "OICStopCoordinate FAILED <br>";
75 printLog(DLOG_ERROR, logMessage);
77 logMessage = "OICStopCoordinate done successfully <br>";
78 printLog(DLOG_INFO, logMessage);
82 // Method for Finding the resource and hosting it
85 string logMessage = "Terminating Resource Hosting <br>";
86 printLog(DLOG_INFO, logMessage);
94 string logMessage = "Resource Hosting already terminated <br>";
95 printLog(DLOG_INFO, logMessage);
97 LOGI("stop_hosting EXIT");
100 // Method to be called when the find and host UI Button is selected
101 void start_cb(void *data, Evas_Object *obj, void *event_info)
103 std::thread exec(std::function< void(int second) >(start_hosting), 3);
107 // Method to be called when the find and host UI Button is selected
108 void stop_cb(void *data, Evas_Object *obj, void *event_info)
110 LOGI("Stopping resource hosting");