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 OIC_LOG(INFO, DISCOVERY_TAG, "NSStartPresence()");
\r
26 NS_LOG(INFO, "NSStartPresence()");
\r
28 if (OCStartPresence(0) != OC_STACK_OK)
\r
30 OIC_LOG(INFO, DISCOVERY_TAG, "NSStartPresence() NS_ERROR");
\r
31 NS_LOG(INFO, "NSStartPresence() NS_ERROR");
\r
35 OIC_LOG(INFO, DISCOVERY_TAG, "NSStartPresence() NS_OK");
\r
36 NS_LOG(INFO, "NSStartPresence() NS_OK");
\r
40 NSResult NSStopPresence()
\r
42 OIC_LOG(INFO, DISCOVERY_TAG, "NSStopPresence()");
\r
43 NS_LOG(INFO, "NSStopPresence()");
\r
45 if (OCStopPresence() != OC_STACK_OK)
\r
47 OIC_LOG(INFO, DISCOVERY_TAG, "NSStopPresence() NS_ERROR");
\r
48 NS_LOG(INFO, "NSStopPresence() NS_ERROR");
\r
52 OIC_LOG(INFO, DISCOVERY_TAG, "NSStopPresence() NS_OK");
\r
53 NS_LOG(INFO, "NSStopPresence() NS_OK");
\r
57 void * NSDiscoverySchedule(void * ptr)
\r
61 OIC_LOG(INFO, DISCOVERY_TAG, "Create NSDiscoverySchedule");
\r
62 NS_LOG(INFO, "Create NSDiscoverySchedule");
\r
65 while (NSIsRunning[DISCOVERY_SCHEDULER])
\r
67 sem_wait(&NSSemaphore[DISCOVERY_SCHEDULER]);
\r
68 pthread_mutex_lock(&NSMutex[DISCOVERY_SCHEDULER]);
\r
70 if (NSHeadMsg[DISCOVERY_SCHEDULER] != NULL)
\r
72 NSTask *node = NSHeadMsg[DISCOVERY_SCHEDULER];
\r
73 NSHeadMsg[DISCOVERY_SCHEDULER] = node->nextTask;
\r
75 switch (node->taskType)
\r
77 case TASK_START_PRESENCE:
\r
78 NS_LOG(INFO, "CASE TASK_START_PRESENCE : ");
\r
81 case TASK_STOP_PRESENCE:
\r
82 NS_LOG(INFO, "CASE TASK_STOP_PRESENCE : ");
\r
85 case TASK_REGISTER_RESOURCE:
\r
86 NS_LOG(INFO, "CASE TASK_REGISTER_RESOURCE : ");
\r
87 NSRegisterResource();
\r
96 pthread_mutex_unlock(&NSMutex[DISCOVERY_SCHEDULER]);
\r