1 //******************************************************************
\r
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
\r
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
7 // Licensed under the Apache License, Version 2.0 (the "License");
\r
8 // you may not use this file except in compliance with the License.
\r
9 // You may obtain a copy of the License at
\r
11 // http://www.apache.org/licenses/LICENSE-2.0
\r
13 // Unless required by applicable law or agreed to in writing, software
\r
14 // distributed under the License is distributed on an "AS IS" BASIS,
\r
15 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 // See the License for the specific language governing permissions and
\r
17 // limitations under the License.
\r
19 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
\r
21 #include "NSProviderDiscovery.h"
\r
23 NSResult NSStartPresence()
\r
25 NS_LOG(DEBUG, "NSStartPresence()");
\r
27 if (OCStartPresence(0) != OC_STACK_OK)
\r
29 NS_LOG(DEBUG, "NSStartPresence() NS_ERROR");
\r
33 NS_LOG(DEBUG, "NSStartPresence() NS_OK");
\r
37 NSResult NSStopPresence()
\r
39 NS_LOG(DEBUG, "NSStopPresence()");
\r
41 if (OCStopPresence() != OC_STACK_OK)
\r
43 NS_LOG(DEBUG, "NSStopPresence() NS_ERROR");
\r
47 NS_LOG(DEBUG, "NSStopPresence() NS_OK");
\r
51 void * NSDiscoverySchedule(void * ptr)
\r
55 NS_LOG(DEBUG, "Create NSDiscoverySchedule");
\r
58 while (NSIsRunning[DISCOVERY_SCHEDULER])
\r
60 sem_wait(&NSSemaphore[DISCOVERY_SCHEDULER]);
\r
61 pthread_mutex_lock(&NSMutex[DISCOVERY_SCHEDULER]);
\r
63 if (NSHeadMsg[DISCOVERY_SCHEDULER] != NULL)
\r
65 NSTask *node = NSHeadMsg[DISCOVERY_SCHEDULER];
\r
66 NSHeadMsg[DISCOVERY_SCHEDULER] = node->nextTask;
\r
68 switch (node->taskType)
\r
70 case TASK_START_PRESENCE:
\r
71 NS_LOG(DEBUG, "CASE TASK_START_PRESENCE : ");
\r
74 case TASK_STOP_PRESENCE:
\r
75 NS_LOG(DEBUG, "CASE TASK_STOP_PRESENCE : ");
\r
78 case TASK_REGISTER_RESOURCE:
\r
79 NS_LOG(DEBUG, "CASE TASK_REGISTER_RESOURCE : ");
\r
80 NSRegisterResource();
\r
82 #if (defined WITH_CLOUD)
\r
83 case TASK_PUBLISH_RESOURCE:
\r
84 NS_LOG(DEBUG, "CASE TASK_PUBLISH_PESOURCE : ");
\r
85 NSPublishResourceToCloud((char*)node->taskData);
\r
95 pthread_mutex_unlock(&NSMutex[DISCOVERY_SCHEDULER]);
\r
98 NS_LOG(DEBUG, "Destroy NSDiscoverySchedule");
\r