1 //******************************************************************
3 // Copyright 2016 Samsung Electronics All Rights Reserved.
5 //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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 #ifndef _NS_CONSUMER_CONSTANTS_H_
22 #define _NS_CONSUMER_CONSTANTS_H_
31 #include "NSConsumerInterface.h"
32 #include "NSStructs.h"
35 #define NS_QOS OC_LOW_QOS
36 #define NS_RESOURCE_TYPE "oic.r.notification"
37 #define NS_RESOURCE_URI "/notification"
38 #define NS_INTERFACE_BASELINE "oic.if.baseline"
39 #define NS_INTERFACE_NOTIFICATION "oic.if.notification"
40 #define NS_RESOURCE_QUERY "/oic/res"
42 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
44 #define NS_VERTIFY_NOT_NULL_V(obj) { if ((obj) == NULL) \
46 NS_LOG_V(ERROR, "%s : obj is null", __func__); \
50 #define NS_VERTIFY_NOT_NULL(obj, retVal) { if ((obj) == NULL) \
52 NS_LOG_V(ERROR, "%s : obj is null", __func__); \
56 #define NS_VERTIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) { \
59 NS_LOG_V(ERROR, "%s : obj is null", __func__); \
60 NS_LOG(ERROR, "execute deletion"); \
65 #define NS_VERTIFY_STACK_OK_V(obj) { OCStackResult _ret = (obj); \
66 if ( _ret != OC_STACK_OK) \
68 NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
72 #define NS_VERTIFY_STACK_OK(obj, retVal) { OCStackResult _ret = (obj); \
73 if ( _ret != OC_STACK_OK) \
75 NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
79 #define NS_VERTIFY_STACK_OK_WITH_POST_CLEANING(obj, retVal, func) { \
80 OCStackResult _ret = (obj); \
81 if ( _ret != OC_STACK_OK) \
83 NS_LOG_V(ERROR, "%s : obj is not OC_STACK_OK : %d", __func__, _ret); \
93 } NSConsumerMessageTypes;
107 NSConsumerMessageTypes type;
108 } NSMessage_consumer;
110 bool NSIsStartedConsumer();
111 void NSSetIsStartedConsumer(bool setValue);
113 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
114 void NSDiscoveredProvider(NSProvider * handle);
116 void NSSetNotificationPostedCb(NSNotificationReceivedCallback cb);
117 void NSNotificationPost(NSProvider * provider, NSMessage * obj);
119 void NSSetNotificationSyncCb(NSSyncCallback cb);
120 void NSNotificationSync(NSProvider * provider, NSSyncInfo * sync);
122 NSTask * NSMakeTask(NSTaskType, void *);
124 NSResult NSConsumerPushEvent(NSTask *);
126 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
127 void NSRemoveMessage(NSMessage_consumer *);
129 OCStackResult NSInvokeRequest(OCDoHandle * handle,
130 OCMethod method, const OCDevAddr * addr,
131 const char * queryUrl, OCPayload * payload,
132 void * callbackFunc, void * callbackData);
136 #endif // __cplusplus
138 #endif // _NS_CONSUMER_CONSTANTS_H_