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_CONSTANTS_H_
22 #define _NS_CONSTANTS_H_
25 #define __NS_FILE__ ( strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__ )
35 #define LOG_TAG "NotificationService"
36 #define NS_CONVERT_LEVEL(level) ( \
37 ((level) == 0) ? DLOG_DEBUG : \
38 ((level) == 1) ? DLOG_INFO : \
39 ((level) == 2) ? DLOG_WARN : \
40 ((level) == 3) ? DLOG_ERROR : \
41 ((level) == 4) ? DLOG_ERROR : \
42 ((level) == 5) ? DLOG_INFO : \
43 ((level) == 6) ? DLOG_INFO : \
44 ((level) == 7) ? DLOG_INFO : DLOG_INFO)
45 #define NS_LOG_V(level, format, ...) (dlog_print(NS_CONVERT_LEVEL(level), LOG_TAG, (format), __VA_ARGS__))
46 #define NS_LOG(level, msg) (dlog_print(NS_CONVERT_LEVEL(level), LOG_TAG, (msg)))
48 #define NS_LOG_V(level, format, ...) OIC_LOG_V((level), __NS_FILE__, (format), __VA_ARGS__)
49 #define NS_LOG(level, msg) OIC_LOG((level), __NS_FILE__, (msg))
53 #define NS_CONVERT_LEVEL(level) ( \
54 ((level) == 0) ? "DEBUG" : \
55 ((level) == 1) ? "INFO" : \
56 ((level) == 2) ? "WARNING" : \
57 ((level) == 3) ? "ERROR" : \
58 ((level) == 4) ? "FATAL" : \
59 ((level) == 5) ? "DEBUG_LITE" : \
60 ((level) == 6) ? "INFO_LITE" : \
61 ((level) == 7) ? "INFO_PRIVATE" : "INFO_PRIVATE")
62 #define NS_LOG_V(level, format, ...) \
64 printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
65 printf((format), __VA_ARGS__); \
68 #define NS_LOG(level, msg) \
70 printf("%s: %s ", NS_CONVERT_LEVEL(level), __NS_FILE__); \
74 #else // (__PRINTLOG == 1)
75 #define NS_CONVERT_LEVEL(level)
76 #define NS_LOG(level, msg)
77 #define NS_LOG_V(level, format, ...) NS_LOG((level), ((format), __VA_ARGS__))
78 #endif // (__PRINTLOG == 1)
81 #define NS_TAG "IOT_NOTI"
84 #define THREAD_COUNT 5
87 #define NOTIOBJ_TITLE_KEY "x.org.iotivity.ns.title"
88 #define NOTIOBJ_ID_KEY "x.org.iotivity.ns.id"
89 #define NOTOOBJ_CONTENT_KEY "x.org.iotivity.ns.contenttext"
91 #define DISCOVERY_TAG "NS_PROVIDER_DISCOVERY"
92 #define SUBSCRIPTION_TAG "NS_PROVIDER_SUBSCRIPTION"
93 #define INTERFACE_TAG "NS_PROVIDER_INTERFACE"
94 #define NOTIFICATION_TAG "NS_PROVIDER_NOTIFICATION"
95 #define SCHEDULER_TAG "NS_PROVIDER_SCHEDULER"
96 #define LISTENER_TAG "NS_PROVIDER_LISTENER"
97 #define RESOURCE_TAG "NS_PROVIDER_RESOURCE"
98 #define TOPIC_TAG "NS_PROVIDER_TOPIC"
100 #define NS_ROOT_TYPE "x.org.iotivity.notification"
101 #define NS_COLLECTION_MESSAGE_TYPE "x.org.iotivity.notification.message"
102 #define NS_COLLECTION_SYNC_TYPE "x.org.iotivity.notification.sync"
103 #define NS_COLLECTION_TOPIC_TYPE "x.org.iotivity.notification.topic"
105 #define NS_INTERFACE_READ "oic.if.r"
106 #define NS_INTERFACE_READWRITE "oic.if.rw"
107 #define NS_INTERFACE_BASELINE "oic.if.baseline"
109 #define NS_ROOT_URI "/notification"
110 #define NS_COLLECTION_MESSAGE_URI "/notification/message"
111 #define NS_COLLECTION_SYNC_URI "/notification/sync"
112 #define NS_COLLECTION_TOPIC_URI "/notification/topic"
114 #define NS_QUERY_SEPARATOR "&;"
115 #define NS_KEY_VALUE_DELIMITER "="
117 #define NS_QUERY_CONSUMER_ID "x.org.iotivity.ns.consumerid"
118 #define NS_QUERY_PROVIDER_ID "x.org.iotivity.ns.providerid"
119 #define NS_QUERY_INTERFACE "if"
121 #define NS_QUERY_ID_SIZE 10
123 #define NS_POLICY_PROVIDER 1
124 #define NS_POLICY_CONSUMER 0
126 #define NS_RD_PUBLISH_QUERY "/oic/rd?rt=oic.wk.rdpub"
129 #define NS_ATTRIBUTE_MQ_MESSAGE "x.org.iotivity.ns.message"
130 #define NS_ATTIRBUTE_MQ_TOPICLIST "x.org.iotivity.ns.topiclist"
133 #define NS_VERIFY_NOT_NULL_V(obj) \
137 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
142 #define NS_VERIFY_NOT_NULL(obj, retVal) \
146 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
151 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING_V(obj, func) \
155 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
156 NS_LOG(ERROR, "execute deletion"); \
162 #define NS_VERIFY_NOT_NULL_WITH_POST_CLEANING(obj, retVal, func) \
166 NS_LOG_V(ERROR, "%s : %s is null", __func__, #obj); \
167 NS_LOG(ERROR, "execute deletion"); \
173 #define NS_VERIFY_STACK_SUCCESS_V(obj) \
178 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
183 #define NS_VERIFY_STACK_SUCCESS(obj, retVal) \
188 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
193 #define NS_VERIFY_STACK_SUCCESS_WITH_POST_CLEANING(obj, retVal, func) \
198 NS_LOG_V(ERROR, "%s : %s is not OC_STACK_OK : %d", __func__, #obj, _ret); \
204 #define NSOICFree(obj) \
210 NS_LOG_V(DEBUG, "%s : %s Removed", __func__, #obj); \
214 #define VERSION "1.2.1"
216 #define NS_ATTRIBUTE_VERSION "x.org.iotivity.ns.version"
217 #define NS_ATTRIBUTE_POLICY "x.org.iotivity.ns.subcontrollability"
218 #define NS_ATTRIBUTE_MESSAGE "x.org.iotivity.ns.messageuri"
219 #define NS_ATTRIBUTE_SYNC "x.org.iotivity.ns.syncuri"
220 #define NS_ATTRIBUTE_TOPIC "x.org.iotivity.ns.topicuri"
221 #define NS_ATTRIBUTE_MESSAGE_ID "x.org.iotivity.ns.messageid"
222 #define NS_ATTRIBUTE_PROVIDER_ID "x.org.iotivity.ns.providerid"
223 #define NS_ATTRIBUTE_CONSUMER_ID "x.org.iotivity.ns.consumerid"
224 #define NS_ATTRIBUTE_TOPIC_LIST "x.org.iotivity.ns.topiclist"
225 #define NS_ATTRIBUTE_TOPIC_NAME "x.org.iotivity.ns.topicname"
226 #define NS_ATTRIBUTE_TOPIC_SELECTION "x.org.iotivity.ns.topicstate"
227 #define NS_ATTRIBUTE_TITLE "x.org.iotivity.ns.title"
228 #define NS_ATTRIBUTE_TEXT "x.org.iotivity.ns.contenttext"
229 #define NS_ATTRIBUTE_SOURCE "x.org.iotivity.ns.source"
230 #define NS_ATTRIBUTE_STATE "x.org.iotivity.ns.state"
231 #define NS_ATTRIBUTE_DEVICE "x.org.iotivity.ns.device"
232 #define NS_ATTRIBUTE_TYPE "x.org.iotivity.ns.type"
233 #define NS_ATTRIBUTE_DATETIME "x.org.iotivity.ns.datetime"
234 #define NS_ATTRIBUTE_TTL "x.org.iotivity.ns.ttl"
235 #define NS_ATTRIBUTE_ICON_IMAGE "x.org.iotivity.ns.iconimage"
237 typedef enum eConnectionState
244 typedef enum eSchedulerType
246 CALLBACK_RESPONSE_SCHEDULER = 0,
247 DISCOVERY_SCHEDULER = 1,
248 SUBSCRIPTION_SCHEDULER = 2,
249 NOTIFICATION_SCHEDULER = 3,
254 typedef enum eTaskType
257 TASK_MQ_REQ_SUBSCRIBE = 20001,
260 TASK_REGISTER_RESOURCE = 1000,
261 TASK_PUBLISH_RESOURCE = 1001,
263 TASK_START_PRESENCE = 2000,
264 TASK_STOP_PRESENCE = 2001,
266 TASK_RECV_SUBSCRIPTION = 3000,
267 TASK_RECV_UNSUBSCRIPTION = 3001,
268 TASK_SEND_POLICY = 3002,
269 TASK_SEND_ALLOW = 3003,
270 TASK_SEND_DENY = 3004,
271 TASK_SYNC_SUBSCRIPTION = 3005,
273 TASK_SEND_NOTIFICATION = 4000,
274 TASK_SEND_PENDING_NOTI = 4001,
276 TASK_RECV_SYNCINFO = 5000,
277 TASK_RECV_READ = 5001,
278 TASK_RECV_DISMISS = 5003,
279 TASK_SEND_SYNCINFO = 5099,
280 TASK_MAKE_SYNCINFO = 5100,
281 TASK_SEND_READ = 5101,
282 TASK_SEND_DISMISS = 5102,
284 TASK_CONSUMER_REQ_DISCOVER = 8001,
285 TASK_CONSUMER_REQ_SUBSCRIBE = 8002,
286 TASK_CONSUMER_REQ_SUBSCRIBE_CANCEL = 8003,
287 TASK_CONSUMER_SENT_REQ_OBSERVE = 8004,
288 TASK_CONSUMER_RECV_PROVIDER_CHANGED = 8005,
289 TASK_CONSUMER_RECV_MESSAGE = 8101,
291 TASK_CONSUMER_PROVIDER_DISCOVERED = 8201,
292 TASK_CONSUMER_PROVIDER_DELETED = 8202,
293 TASK_CONSUMER_RECV_CONFIRM = 8206,
295 TASK_CONSUMER_REQ_TOPIC_URI = 8299,
296 TASK_CONSUMER_REQ_TOPIC_LIST = 8300,
297 TASK_CONSUMER_RECV_TOPIC_LIST = 8031,
298 TASK_CONSUMER_SELECT_TOPIC_LIST = 8303,
300 TASK_EVENT_CONNECTED = 9000,
301 TASK_EVENT_CONNECTED_TCP = 9001,
302 TASK_EVENT_DISCONNECTED = 9002,
304 TASK_CB_SUBSCRIPTION = 10000,
305 TASK_CB_SYNC = 10001,
307 TASK_SEND_TOPICS = 11000,
308 TASK_REGISTER_TOPIC = 11001,
309 TASK_UNREGISTER_TOPIC = 11002,
310 TASK_SUBSCRIBE_TOPIC = 11003,
311 TASK_UNSUBSCRIBE_TOPIC = 11004,
312 TASK_POST_TOPIC = 11005,
313 TASK_GET_TOPICS = 11006,
314 TAST_GET_CONSUMER_TOPICS = 11007
320 NS_CONSUMER_BLACKLIST = 0,
321 NS_CONSUMER_WHITELIST = 1,
325 typedef enum eCacheType
327 NS_PROVIDER_CACHE_SUBSCRIBER = 1000,
328 NS_PROVIDER_CACHE_MESSAGE = 1001,
329 NS_PROVIDER_CACHE_CONSUMER_TOPIC_NAME = 1002,
330 NS_PROVIDER_CACHE_CONSUMER_TOPIC_CID = 1003,
331 NS_PROVIDER_CACHE_REGISTER_TOPIC = 1004,
332 NS_PROVIDER_CACHE_SUBSCRIBER_OBSERVE_ID = 1005,
334 NS_CONSUMER_CACHE_PROVIDER = 2000,
335 NS_CONSUMER_CACHE_MESSAGE = 2001,
339 typedef enum eResourceType
341 NS_RESOURCE_MESSAGE = 1000,
342 NS_RESOURCE_SYNC = 1001,
343 NS_RESOURCE_TOPIC = 1002,
347 typedef enum eInterfaceType
349 NS_INTERFACE_TYPE_READ = 1,
350 NS_INTERFACE_TYPE_READWRITE = 2,
354 #endif /* _NS_CONSTANTS_H_ */