#include "ocstack.h"
#include "ocpayload.h"
#include "pinoxmcommon.h"
+#include "srmutility.h"
#ifdef HAVE_WINDOWS_H
#include <windows.h>
gLedInstance[gCurrLedInstance].state = 0;
gLedInstance[gCurrLedInstance].power = 0;
gCurrLedInstance++;
- strncpy ((char *)response->resourceUri, newLedUri, MAX_URI_LENGTH);
+ strncpy ((char *)response->resourceUri, newLedUri, sizeof(response->resourceUri));
ehResult = OC_EH_RESOURCE_CREATED;
}
}
return fopen(CRED_FILE, mode);
}
+static void OtmEventHandler(void *ctx, const char *addr, uint16_t port,
+ const char* ownerId, OCOtmEvent_t event)
+{
+ (void)ctx;
+ printf("--------------------------------------\n");
+ printf("Get OTM event.\n");
+ printf("Address : %s\n", addr);
+ printf("Port : %d\n", port);
+ printf("Owner ID : %s\n", ownerId);
+
+ switch (event)
+ {
+ case OIC_OTM_READY:
+ printf("State : OIC_OTM_READY\n");
+ break;
+ case OIC_OTM_STARTED:
+ printf("State : OIC_OTM_STARTED\n");
+ break;
+ case OIC_OTM_DONE:
+ printf("State : OIC_OTM_DONE\n");
+ break;
+ case OIC_OTM_ERROR:
+ printf("State : OIC_OTM_ERROR\n");
+ break;
+ default:
+ printf("State : Unknown state.\n");
+ break;
+ }
+ printf("--------------------------------------\n");
+}
+
int main()
{
struct timespec timeout;
OIC_LOG(DEBUG, TAG, "OCServer is starting...");
+ //This function should be invoked before invoke OCInit
+ OCSetOtmEventHandler(NULL, OtmEventHandler);
+
// 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);