+ return OC_STACK_ERROR;
+ }
+ if(!DuplicateString(&deviceInfo.specVersion, specVersion))
+ {
+ return OC_STACK_ERROR;
+ }
+ if(!DuplicateString(&deviceInfo.dataModleVersion, dataModleVersion))
+ {
+ return OC_STACK_ERROR;
+ }
+ return OC_STACK_OK;
+}
+
+static void PrintUsage()
+{
+ OIC_LOG(INFO, TAG, "Usage : ocserver -o <0|1>");
+ OIC_LOG(INFO, TAG, "-o 0 : Notify all observers");
+ OIC_LOG(INFO, TAG, "-o 1 : Notify list of observers");
+}
+
+#ifdef RA_ADAPTER
+static void jidbound(char *jid)
+{
+ OIC_LOG_V(INFO, TAG, "\n\n Bound JID: %s\n\n", jid);
+}
+#endif
+
+int main(int argc, char* argv[])
+{
+
+#ifdef RA_ADAPTER
+ char host[] = "localhost";
+ char user[] = "test1";
+ char pass[] = "intel123";
+ char empstr[] = "";
+ OCRAInfo_t rainfo = {};
+
+ rainfo.hostname = host;
+ rainfo.port = 5222;
+ rainfo.xmpp_domain = host;
+ rainfo.username = user;
+ rainfo.password = pass;
+ rainfo.resource = empstr;
+ rainfo.user_jid = empstr;
+ rainfo.jidbound = jidbound;
+#endif
+
+ int opt = 0;
+ while ((opt = getopt(argc, argv, "o:s:p:d:u:w:r:j:")) != -1)
+ {
+ switch(opt)
+ {
+ case 'o':
+ gObserveNotifyType = atoi(optarg);
+ break;
+#ifdef RA_ADAPTER
+ case 's':
+ rainfo.hostname = optarg;
+ break;
+ case 'p':
+ rainfo.port = atoi(optarg);
+ break;
+ case 'd':
+ rainfo.xmpp_domain = optarg;
+ break;
+ case 'u':
+ rainfo.username = optarg;
+ break;
+ case 'w':
+ rainfo.password = optarg;
+ break;
+ case 'j':
+ rainfo.user_jid = optarg;
+ break;
+ case 'r':
+ rainfo.resource = optarg;
+ break;
+#endif
+ default:
+ PrintUsage();
+ return -1;
+ }
+ }
+
+ if ((gObserveNotifyType != 0) && (gObserveNotifyType != 1))
+ {
+ PrintUsage();
+ return -1;
+ }
+
+#ifdef RA_ADAPTER
+ OCSetRAInfo(&rainfo);
+#endif
+
+ OIC_LOG(DEBUG, TAG, "OCServer is starting...");
+
+ if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "OCStack init error");
+ return 0;
+ }
+#ifdef WITH_PRESENCE
+ if (OCStartPresence(0) != OC_STACK_OK)
+ {
+ OIC_LOG(ERROR, TAG, "OCStack presence/discovery error");
+ return 0;