5 #include "NSConsumerInterface.h"
8 void onNotificationPosted(NSProvider * provider, NSMessage * notification)
11 // printf("Notification from : %s:%d\n", ((OCDevAddr *)provider->mUserData)->addr,
12 // ((OCDevAddr *)provider->mUserData)->port);
13 printf("id : %ld\n", notification->messageId);
14 printf("title : %s\n", notification->title);
15 printf("content : %s\n", notification->contentText);
16 printf("source : %s\n", notification->sourceName);
17 // NSDropNSObject(notification);
18 NSConsumerReadCheck(notification);
21 void onDiscoverNotification(NSProvider * provider)
23 printf("notification resource discovered\n");
24 printf("subscribe result %d\n", NSSubscribe(provider));
25 printf("startSubscribing\n");
28 void onNotificationSync(NSProvider * provider, NSSyncInfo * sync)
31 // printf("Sync from : %s:%d\n", ((OCDevAddr *)provider->mUserData)->addr,
32 // ((OCDevAddr *)provider->mUserData)->port);
33 printf("Sync ID : %ld\n", sync->messageId);
34 printf("Sync STATE : %d\n", sync->state);
40 printf("start Iotivity\n");
41 if (OCInit1(OC_CLIENT, OC_DEFAULT_FLAGS, OC_DEFAULT_FLAGS) != OC_STACK_OK)
43 printf("OCInit fail\n");
49 printf("start notification consumer service\n");
50 NSResult ret = NSStartConsumer(
51 onDiscoverNotification,
56 printf("error discoverNoti %d\n", ret);
62 if(OCProcess() != OC_STACK_OK)