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_
32 #include "NSStructs.h"
35 #define NS_LOG_PRINTF 0
37 #define __NS_FILE__ ( strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__ )
39 const char * NS_CONVERT_LEVEL(int level);
41 // TODO fix ns log using oic log.
44 #define NS_CONSUMER_LOG_V(level, format, ...) (OIC_LOG_V((level), __NS_FILE__, (format), __VA_ARGS__))
45 #define NS_CONSUMER_LOG(level, msg) (OIC_LOG((level), __NS_FILE__, (msg)))
48 #define NS_CONSUMER_LOG_V(level, format, ...) { \
49 printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
50 printf((format), __VA_ARGS__); \
52 #define NS_CONSUMER_LOG(level, msg) { \
53 printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
59 #define NS_QOS OC_LOW_QOS
60 #define NS_RESOURCE_TYPE "oic.r.notification"
61 #define NS_RESOURCE_URI "/notification"
62 #define NS_INTERFACE_BASELINE "oic.if.baseline"
63 #define NS_INTERFACE_NOTIFICATION "oic.if.notification"
64 #define NS_RESOURCE_QUERY "/oic/res"
66 #define NS_DISCOVER_QUERY "/oic/res?rt=oic.r.notification"
68 typedef OCStackApplicationResult (*onRIResponseListener)(
69 void *, OCDoHandle, OCClientResponse *);
76 } NSConsumerMessageTypes;
89 NSConsumerMessageTypes type;
92 bool NSIsStartedConsumer();
93 void NSSetIsStartedConsumer(bool setValue);
95 void NSSetDiscoverProviderCb(NSProviderDiscoveredCallback cb);
96 void NSDiscoveredProvider(NSProvider * handle);
98 void NSSetNotificationPostedCb(NSNotificationReceivedCallback cb);
99 void NSNotificationPost(NSProvider * provider, NSMessage * obj);
101 void NSSetNotificationSyncCb(NSSyncCallback cb);
102 void NSNotificationSync(NSProvider * provider, NSSync * sync);
104 onRIResponseListener NSGetResponseListener();
105 void NSSetResponseListener(onRIResponseListener cb);
107 NSTask * NSMakeTask(NSTaskType, void *);
109 NSResult NSConsumerPushEvent(NSTask *);
111 NSMessage_consumer * NSCopyMessage(NSMessage_consumer *);
112 void NSRemoveMessage(NSMessage_consumer *);
114 OCStackResult NSRequestToResourceIntrospection(OCDoHandle * handle,
115 OCMethod method, const OCDevAddr * addr,
116 const char * queryUrl, OCPayload * payload, void * callback);
120 #endif // __cplusplus
122 #endif // _NS_CONSUMER_CONSTANTS_H_