13 #define TAG PCF("SRM-AMSS")
17 //AMS service database, hold AMS service Identity and
18 //the PSK credentials of trusted devices
19 static char AMSS_DB_FILE[] = "oic_amss_db.json";
21 /* SIGINT handler: set gQuitFlag to 1 for graceful termination */
22 void handleSigInt(int signum)
30 FILE* service_fopen(const char *path, const char *mode)
33 return fopen(AMSS_DB_FILE, mode);
36 int main(int /*argc*/, char* /*argv*/[])
38 struct timespec timeout;
40 OIC_LOG(DEBUG, TAG, "OCAMS service is starting...");
42 // Initialize Persistent Storage for SVR database
43 OCPersistentStorage ps = { service_fopen, fread, fwrite, fclose, unlink };
44 OCRegisterPersistentStorageHandler(&ps);
46 if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
48 OIC_LOG(ERROR, TAG, "OCStack init error");
53 timeout.tv_nsec = 100000000L;
55 // Break from loop with Ctrl-C
56 OIC_LOG(INFO, TAG, "Entering ocamsservice main loop...");
57 signal(SIGINT, handleSigInt);
60 if (OCProcess() != OC_STACK_OK)
62 OIC_LOG(ERROR, TAG, "OCStack process error");
65 nanosleep(&timeout, NULL);
68 OIC_LOG(INFO, TAG, "Exiting ocamsservice main loop...");
70 if (OCStop() != OC_STACK_OK)
72 OIC_LOG(ERROR, TAG, "OCStack process error");