/** * Initialize pstat resource by loading data from persistent storage. * * @retval OC_STACK_OK for Success, otherwise some error value */ OCStackResult InitPstatResource() { OCStackResult ret = OC_STACK_ERROR; // Read Pstat resource from PS char* jsonSVRDatabase = GetSVRDatabase(); if (jsonSVRDatabase) { // Convert JSON Pstat into binary format gPstat = JSONToPstatBin(jsonSVRDatabase, true); } /* * If SVR database in persistent storage got corrupted or * is not available for some reason, a default pstat is created * which allows user to initiate pstat provisioning again. */ if(!jsonSVRDatabase || !gPstat) { gPstat = GetPstatDefault(); } // Instantiate 'oic.sec.pstat' ret = CreatePstatResource(); OICFree(jsonSVRDatabase); return ret; }
/** * Initialize DOXM resource by loading data from persistent storage. * * @retval OC_STACK_OK for Success, otherwise some error value */ OCStackResult InitDoxmResource() { OCStackResult ret = OC_STACK_ERROR; //Read DOXM resource from PS char* jsonSVRDatabase = GetSVRDatabase(); if(jsonSVRDatabase) { //Convert JSON DOXM into binary format gDoxm = JSONToDoxmBin(jsonSVRDatabase); } /* * If SVR database in persistent storage got corrupted or * is not available for some reason, a default doxm is created * which allows user to initiate doxm provisioning again. */ if(!jsonSVRDatabase || !gDoxm) { gDoxm = GetDoxmDefault(); } //In case of the server is shut down unintentionally, we should initialize the owner if(false == gDoxm->owned) { OicUuid_t emptyUuid = {.id={0}}; memcpy(&gDoxm->owner, &emptyUuid, sizeof(OicUuid_t)); }
/** * Initialize DOXM resource by loading data from persistent storage. * * @retval OC_STACK_OK for Success, otherwise some error value */ OCStackResult InitDoxmResource() { OCStackResult ret = OC_STACK_ERROR; //Read DOXM resource from PS char* jsonSVRDatabase = GetSVRDatabase(); if(jsonSVRDatabase) { //Convert JSON DOXM into binary format gDoxm = JSONToDoxmBin(jsonSVRDatabase); } /* * If SVR database in persistent storage got corrupted or * is not available for some reason, a default doxm is created * which allows user to initiate doxm provisioning again. */ if(!jsonSVRDatabase || !gDoxm) { gDoxm = GetDoxmDefault(); } CheckDeviceID(); //Instantiate 'oic.sec.doxm' ret = CreateDoxmResource(); OICFree(jsonSVRDatabase); return ret; }