replace : iotivity -> iotivity-sec
[platform/upstream/iotivity.git] / resource / csdk / security / provisioning / sample / sampleserver_randompin.cpp
index 81b07c4..0f750a0 100644 (file)
@@ -142,7 +142,7 @@ const char *getResult(OCStackResult result) {
     }
 }
 
-#ifdef _ENABLE_MULTIPLE_OWNER_
+#ifdef MULTIPLE_OWNER
 
 #include <assert.h>
 #include <thread>
@@ -177,7 +177,7 @@ static void StopOCProcessThread()
     g_LoopFlag = false;
     oc_process_thread->join();
 }
-#endif //_ENABLE_MULTIPLE_OWNER_
+#endif //MULTIPLE_OWNER
 
 OCRepPayload* getPayload(const char* uri, int64_t power, bool state)
 {
@@ -460,12 +460,19 @@ void GeneratePinCB(char* pin, size_t pinSize)
     OIC_LOG(INFO, TAG, "============================");
 }
 
+void ClosePinDisplayCB(void)
+{
+    OIC_LOG(INFO, TAG, "============================");
+    OIC_LOG(INFO, TAG, "    PIN DISPLAY CLOSED.");
+    OIC_LOG(INFO, TAG, "============================");
+}
+
 int main()
 {
     OIC_LOG(DEBUG, TAG, "OCServer is starting...");
 
     // Initialize Persistent Storage for SVR database
-    OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink};
+    OCPersistentStorage ps = {server_fopen, fread, fwrite, fclose, unlink, NULL, NULL};
     OCRegisterPersistentStorageHandler(&ps);
 
     if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
@@ -481,6 +488,13 @@ int main()
     SetGeneratePinCB(GeneratePinCB);
 
     /**
+     * If ther server supports random pin based OTM,
+     * the callback to close PIN display can be registered.
+     * This callback will be invoked when random PIN based OTM is done.
+     */
+    SetClosePinDisplayCB(ClosePinDisplayCB);
+
+    /**
      * Random PIN generation policy can be changed through SetRandomPinPolicy() API.
      * first param : byte length of random PIN ( 4 <= first param <= 32)
      * second param : PIN type (This is bitmask)
@@ -500,7 +514,7 @@ int main()
     OIC_LOG(INFO, TAG, "Entering ocserver main loop...");
     signal(SIGINT, handleSigInt);
 
-#ifdef _ENABLE_MULTIPLE_OWNER_
+#ifdef MULTIPLE_OWNER
     StartOCProcessThread();
 
     while(!gQuitFlag)
@@ -534,7 +548,7 @@ int main()
         }
         nanosleep(&timeout, NULL);
     }
-#endif //_ENABLE_MULTIPLE_OWNER_
+#endif //MULTIPLE_OWNER
 
     OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");