projects
/
platform
/
upstream
/
iotivity.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into windows-port
[platform/upstream/iotivity.git]
/
resource
/
csdk
/
stack
/
samples
/
linux
/
SimpleClientServer
/
ocserver.cpp
diff --git
a/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
b/resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
index
018d34d
..
13cf61b
100644
(file)
--- a/
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
+++ b/
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp
@@
-23,14
+23,24
@@
#include <string.h>
#include <string>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <stdlib.h>
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
#include <unistd.h>
+#endif
+#ifdef HAVE_WINDOWS_H
+#include <windows.h>
+#endif
#include <signal.h>
#include <signal.h>
+#ifdef HAVE_PTHREAD_H
#include <pthread.h>
#include <pthread.h>
+#endif
#include <array>
#include <array>
+#include <getopt.h>
#include "ocstack.h"
#include "logger.h"
#include "ocpayload.h"
#include "ocserver.h"
#include "ocstack.h"
#include "logger.h"
#include "ocpayload.h"
#include "ocserver.h"
+#include "common.h"
+#include "platform_features.h"
//string length of "/a/light/" + std::numeric_limits<int>::digits10 + '\0'"
// 9 + 9 + 1 = 19
//string length of "/a/light/" + std::numeric_limits<int>::digits10 + '\0'"
// 9 + 9 + 1 = 19
@@
-74,6
+84,8
@@
const char *platformVersion = "myPlatformVersion";
const char *supportUrl = "mySupportUrl";
const char *version = "myVersion";
const char *systemTime = "2015-05-15T11.04";
const char *supportUrl = "mySupportUrl";
const char *version = "myVersion";
const char *systemTime = "2015-05-15T11.04";
+const char *specVersion = "myDeviceSpecVersion";
+const char* dataModleVersion = "myDeviceModleVersion";
// Entity handler should check for resourceTypeName and ResourceInterface in order to GET
// the existence of a known resource
// Entity handler should check for resourceTypeName and ResourceInterface in order to GET
// the existence of a known resource
@@
-662,8
+674,7
@@
void *ChangeLightRepresentation (void *param)
OCStackResult result = OC_STACK_ERROR;
uint8_t j = 0;
OCStackResult result = OC_STACK_ERROR;
uint8_t j = 0;
- uint8_t numNotifies = (SAMPLE_MAX_NUM_OBSERVATIONS)/2;
- OCObservationId obsNotify[numNotifies];
+ OCObservationId obsNotify[(SAMPLE_MAX_NUM_OBSERVATIONS)/2];
while (!gQuitFlag)
{
while (!gQuitFlag)
{
@@
-814,6
+825,8
@@
void DeletePlatformInfo()
void DeleteDeviceInfo()
{
free (deviceInfo.deviceName);
void DeleteDeviceInfo()
{
free (deviceInfo.deviceName);
+ free (deviceInfo.specVersion);
+ free (deviceInfo.dataModleVersion);
}
bool DuplicateString(char** targetString, const char* sourceString)
}
bool DuplicateString(char** targetString, const char* sourceString)
@@
-917,12
+930,20
@@
OCStackResult SetPlatformInfo(const char* platformID, const char *manufacturerNa
return OC_STACK_ERROR;
}
return OC_STACK_ERROR;
}
-OCStackResult SetDeviceInfo(const char* deviceName)
+OCStackResult SetDeviceInfo(const char* deviceName
, const char* specVersion, const char* dataModleVersion
)
{
if(!DuplicateString(&deviceInfo.deviceName, deviceName))
{
return OC_STACK_ERROR;
}
{
if(!DuplicateString(&deviceInfo.deviceName, deviceName))
{
return OC_STACK_ERROR;
}
+ if(!DuplicateString(&deviceInfo.specVersion, specVersion))
+ {
+ return OC_STACK_ERROR;
+ }
+ if(!DuplicateString(&deviceInfo.dataModleVersion, dataModleVersion))
+ {
+ return OC_STACK_ERROR;
+ }
return OC_STACK_OK;
}
return OC_STACK_OK;
}
@@
-1043,7
+1064,7
@@
int main(int argc, char* argv[])
exit (EXIT_FAILURE);
}
exit (EXIT_FAILURE);
}
- registrationResult = SetDeviceInfo(deviceName);
+ registrationResult = SetDeviceInfo(deviceName
, specVersion, dataModleVersion
);
if (registrationResult != OC_STACK_OK)
{
if (registrationResult != OC_STACK_OK)
{
@@
-1051,6
+1072,8
@@
int main(int argc, char* argv[])
exit (EXIT_FAILURE);
}
exit (EXIT_FAILURE);
}
+ OCResourcePayloadAddStringLL(&deviceInfo.types, "oic.d.tv");
+
registrationResult = OCSetDeviceInfo(deviceInfo);
if (registrationResult != OC_STACK_OK)
registrationResult = OCSetDeviceInfo(deviceInfo);
if (registrationResult != OC_STACK_OK)
@@
-1099,12
+1122,16
@@
int main(int argc, char* argv[])
if (observeThreadStarted)
{
if (observeThreadStarted)
{
+#ifdef HAVE_PTHREAD_H
pthread_cancel(threadId_observe);
pthread_join(threadId_observe, NULL);
pthread_cancel(threadId_observe);
pthread_join(threadId_observe, NULL);
+#endif
}
}
+#ifdef HAVE_PTHREAD_H
pthread_cancel(threadId_presence);
pthread_join(threadId_presence, NULL);
pthread_cancel(threadId_presence);
pthread_join(threadId_presence, NULL);
+#endif
OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");
OIC_LOG(INFO, TAG, "Exiting ocserver main loop...");