5 #include "NSConsumerInterface.h"
8 void onNotificationPosted(NSProvider * provider, NSMessage * notification)
10 printf("Notification from : %s:%d\n", ((OCDevAddr *)provider->mUserData)->addr,
11 ((OCDevAddr *)provider->mUserData)->port);
12 printf("id : %s\n", notification->mId);
13 printf("title : %s\n", notification->mTitle);
14 printf("content : %s\n", notification->mContentText);
15 // NSDropNSObject(notification);
19 void onDiscoverNotification(NSProvider * provider)
21 printf("notification resource discovered\n");
22 printf("subscribe result %d\n", NSSubscribeProvider(provider));
23 printf("startSubscribing\n");
26 void onNotificationSync(NSProvider * provider, NSSync * sync)
28 printf("Sync from : %s:%d\n", ((OCDevAddr *)provider->mUserData)->addr,
29 ((OCDevAddr *)provider->mUserData)->port);
30 printf("Sync ID : %s\n", sync->mMessageId);
31 printf("Sync STATE : %d\n", sync->mState);
37 printf("start Iotivity\n");
38 if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
40 printf("OCInit fail\n");
46 printf("start notification consumer service\n");
47 NSResult ret = NSStartConsumer(
48 onDiscoverNotification,
53 printf("error discoverNoti %d\n", ret);
59 if(OCProcess() != OC_STACK_OK)