2 #include "iotivity_config.h"
10 #ifdef HAVE_WINSOCK2_H
20 #define TAG PCF("SRM-AMSS")
24 //AMS service database, hold AMS service Identity and
25 //the PSK credentials of trusted devices
26 static char AMSS_DB_FILE[] = "oic_amss_db.dat";
28 /* SIGINT handler: set gQuitFlag to 1 for graceful termination */
29 void handleSigInt(int signum)
37 FILE* service_fopen(const char *path, const char *mode)
40 return fopen(AMSS_DB_FILE, mode);
43 int main(int /*argc*/, char* /*argv*/[])
45 struct timespec timeout;
47 OIC_LOG(DEBUG, TAG, "OCAMS service is starting...");
49 // Initialize Persistent Storage for SVR database
50 OCPersistentStorage ps = { service_fopen, fread, fwrite, fclose, unlink };
51 OCRegisterPersistentStorageHandler(&ps);
53 if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
55 OIC_LOG(ERROR, TAG, "OCStack init error");
60 timeout.tv_nsec = 100000000L;
62 // Break from loop with Ctrl-C
63 OIC_LOG(INFO, TAG, "Entering ocamsservice main loop...");
64 signal(SIGINT, handleSigInt);
67 if (OCProcess() != OC_STACK_OK)
69 OIC_LOG(ERROR, TAG, "OCStack process error");
72 nanosleep(&timeout, NULL);
75 OIC_LOG(INFO, TAG, "Exiting ocamsservice main loop...");
77 if (OCStop() != OC_STACK_OK)
79 OIC_LOG(ERROR, TAG, "OCStack process error");