Merge branch 'master' into ra.to.merge
authorMandeep Shetty <mandeep.shetty@intel.com>
Thu, 10 Sep 2015 00:58:44 +0000 (17:58 -0700)
committerMandeep Shetty <mandeep.shetty@intel.com>
Thu, 10 Sep 2015 00:58:44 +0000 (17:58 -0700)
Conflicts:
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp

Change-Id: I70ecb709845861789f326053b2135ca964bd21a5
Signed-off-by: Mandeep Shetty <mandeep.shetty@intel.com>
1  2 
Readme.scons.txt
build_common/SConscript
resource/csdk/SConscript
resource/csdk/stack/samples/linux/SimpleClientServer/ocremoteaccessclient.cpp
resource/csdk/stack/samples/linux/SimpleClientServer/ocserver.cpp

diff --combined Readme.scons.txt
@@@ -5,12 -5,12 +5,12 @@@
  command in this directory)
  
      Install external libraries:
 -      $ sudo apt-get install libboost-dev libboost-program-options-dev libexpat1-dev libboost-thread-dev uuid-dev libssl-dev
 +      $ sudo apt-get install libboost-dev libboost-program-options-dev libexpat1-dev libboost-thread-dev uuid-dev libssl-dev libtool
  
      Build release binaries:
        $ scons
- (Note: C sdk requires tiny-cbor. Please follow the instruction in the build
- message to install tiny-cbor)
+ (Note: C sdk requires tinycbor. Please follow the instruction in the build
+ message to install tinycbor)
  
      Build debug binaries:
        $scons RELEASE=false
@@@ -116,8 -116,8 +116,8 @@@ so you don't need to add it in command 
  guide you to do that.)
  
  Tizen:
- To build for tizen platform tiny-cbor library is needed.
- Please download tiny-cbor if it is not present in extlibs/tiny-cbor folder
+ To build for tizen platform tinycbor library is needed.
+ Please download tinycbor if it is not present in extlibs/tinycbor folder
  by doing the following:
        $ git clone https://github.com/01org/tinycbor.git extlibs/tinycbor/tinycbor
  
@@@ -137,7 -137,7 +137,7 @@@ to skip it
  
  1. Build IoTivity project for Linux
        $ cd <top directory of the project>
 -      $ sudo apt-get install libboost-dev libexpat1-dev libboost-thread-dev libssl-dev
 +      $ sudo apt-get install libboost-dev libexpat1-dev libboost-thread-dev libssl-dev libtool
        $ scons
  
  2. Build IoTivity project for Android
diff --combined build_common/SConscript
@@@ -79,7 -79,6 +79,7 @@@ help_vars.Add(EnumVariable('TARGET_OS'
  
  
  help_vars.Add(BoolVariable('WITH_RA', 'Build with Remote Access module', False))
 +help_vars.Add(BoolVariable('WITH_RA_IBB', 'Build with Remote Access module(workssys)', False))
  
  if target_os in targets_disallow_multitransport:
        help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'IP', ['BT', 'BLE', 'IP']))
@@@ -219,6 -218,14 +219,14 @@@ def __installbin(ienv, targets, name)
                i_n = ienv.Install(env.get('BUILD_DIR'), targets)
        ienv.Alias("install", i_n)
  
+ def __installheader(ienv, targets, dir, name):
+       user_prefix = env.get('PREFIX')
+       if user_prefix:
+               i_n = ienv.Install(user_prefix + '/include/' + dir ,targets)
+       else:
+               i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+       ienv.Alias("install", i_n)
  def __append_target(ienv, name, targets = None):
        if targets:
                env.Alias(name, targets)
@@@ -244,6 -251,7 +252,7 @@@ env.AddMethod(__append_target, 'AppendT
  env.AddMethod(__install, 'InstallTarget')
  env.AddMethod(__installlib, 'UserInstallTargetLib')
  env.AddMethod(__installbin, 'UserInstallTargetBin')
+ env.AddMethod(__installheader, 'UserInstallTargetHeader')
  env.SetDir(env.GetLaunchDir())
  env['ROOT_DIR']=env.GetLaunchDir()+'/..'
  
diff --combined resource/csdk/SConscript
@@@ -30,7 -30,6 +30,7 @@@ liboctbstack_env = lib_env.Clone(
  
  target_os = env.get('TARGET_OS')
  with_ra = env.get('WITH_RA')
 +with_ra_ibb = env.get('WITH_RA_IBB')
  # As in the source code, it includes arduino Time library (C++)
  # It requires compile the .c with g++
  if target_os == 'arduino':
@@@ -69,11 -68,9 +69,11 @@@ liboctbstack_env.AppendUnique(LIBPATH 
  
  if target_os in ['android', 'linux', 'tizen']:
        liboctbstack_env.PrependUnique(LIBS = ['connectivity_abstraction'])
 -      if with_ra:
 -              liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
 -
 +      if with_ra_ibb:
 +              liboctbstack_env.AppendUnique(LIBS = liboctbstack_env['RALIBS'], LIBPATH = liboctbstack_env['RALIBPATH'], RPATH = liboctbstack_env['RARPATH'])
 +      else :
 +              if with_ra:
 +                      liboctbstack_env.AppendUnique(LIBS = ['ra_xmpp'])
  liboctbstack_env.AppendUnique(LIBS = ['coap', 'm'])
  
  if target_os == 'tizen':
@@@ -128,9 -125,14 +128,14 @@@ if target_os in ['arduino','darwin','io
        static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
        liboctbstack_env.InstallTarget(static_liboctbstack, 'liboctbstack')
        liboctbstack_env.UserInstallTargetLib(static_liboctbstack, 'liboctbstack')
+       liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
+       liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
  else:
        static_liboctbstack = liboctbstack_env.StaticLibrary('octbstack', liboctbstack_src)
        shared_liboctbstack = liboctbstack_env.SharedLibrary('octbstack', liboctbstack_src)
        liboctbstack_env.InstallTarget([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
        liboctbstack_env.UserInstallTargetLib([static_liboctbstack, shared_liboctbstack], 'liboctbstack')
+       liboctbstack_env.UserInstallTargetHeader('stack/include/ocstackconfig.h', 'resource', 'ocstackconfig.h')
+       liboctbstack_env.UserInstallTargetHeader('stack/include/octypes.h', 'resource', 'octypes.h')
+       liboctbstack_env.UserInstallTargetHeader('stack/include/ocstack.h', 'resource', 'ocstack.h')
  
@@@ -28,6 -28,7 +28,7 @@@
  #include "ocstack.h"
  #include "logger.h"
  #include "ocpayload.h"
+ #include "payload_logging.h"
  #include "ocremoteaccessclient.h"
  
  // Tracking user input
@@@ -155,7 -156,7 +156,7 @@@ OCStackApplicationResult restRequestCB(
  
      OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
      OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
-     OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+     OC_LOG_PAYLOAD(INFO, clientResponse->payload);
  
      if(clientResponse->numRcvdVendorSpecificHeaderOptions > 0)
      {
@@@ -177,7 -178,7 +178,7 @@@ OCStackApplicationResult obsReqCB(void
      OC_LOG_V(INFO, TAG, "StackResult: %s",  getResult(clientResponse->result));
      OC_LOG_V(INFO, TAG, "SEQUENCE NUMBER: %d", clientResponse->sequenceNumber);
      OC_LOG_V(INFO, TAG, "OBSERVE notification %d recvd", gNumObserveNotifies);
-     OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+     OC_LOG_PAYLOAD(INFO, clientResponse->payload);
  
      gNumObserveNotifies++;
      if (gNumObserveNotifies == maxNotification)
@@@ -226,7 -227,7 +227,7 @@@ OCStackApplicationResult presenceCB(voi
          OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
          OC_LOG_V(INFO, TAG, "NONCE NUMBER: %u", clientResponse->sequenceNumber);
          OC_LOG_V(INFO, TAG, "PRESENCE notification %d recvd", gNumPresenceNotifies);
-         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+         OC_LOG_PAYLOAD(INFO, clientResponse->payload);
  
          gNumPresenceNotifies++;
          if (gNumPresenceNotifies == maxNotification)
@@@ -261,7 -262,7 +262,7 @@@ OCStackApplicationResult discoveryReqCB
      }
  
      OC_LOG_V(INFO, TAG, "StackResult: %s", getResult(clientResponse->result));
-     OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+     OC_LOG_PAYLOAD(INFO, clientResponse->payload);
  
      responseAddr = clientResponse->devAddr;
  
@@@ -301,7 -302,7 +302,7 @@@ OCStackApplicationResult PlatformDiscov
  
      if(clientResponse)
      {
-         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+         OC_LOG_PAYLOAD(INFO, clientResponse->payload);
      }
      else
      {
@@@ -321,7 -322,7 +322,7 @@@ OCStackApplicationResult DeviceDiscover
  
      if(clientResponse)
      {
-         OC_LOG_PAYLOAD(INFO, TAG, clientResponse->payload);
+         OC_LOG_PAYLOAD(INFO, clientResponse->payload);
      }
      else
      {
@@@ -437,48 -438,38 +438,48 @@@ int InitDiscovery(OCQualityOfService qo
      return ret;
  }
  
 -OCStackResult initRemoteAccessAdapter ()
 -{
 -    OCRAInfo_t rainfo;
 -    rainfo.hostname = "localhost";
 -    rainfo.port = 5222;
 -    rainfo.xmpp_domain = "localhost";
 -    rainfo.username = "test1";
 -    rainfo.password = "intel123";
 -    rainfo.resource = "";
 -    rainfo.user_jid = "";
 -
 -    return OCSetRAInfo(&rainfo);
 -}
 -
  int main(int argc, char* argv[])
  {
 -    int opt;
 +    OCRAInfo_t rainfo = {.hostname = "localhost", .port = 5222,
 +        .xmpp_domain = "localhost", .username = "test1", .password = "intel123",
 +        .resource = "", .user_jid = ""};
  
 -    while ((opt = getopt(argc, argv, "t:")) != -1)
 +    int opt = 0;
 +    while ((opt = getopt(argc, argv, "t:s:p:d:u:w:r:j:")) != -1)
      {
          switch(opt)
          {
              case 't':
                  TEST_CASE = atoi(optarg);
                  break;
 +            case 's':
 +                rainfo.hostname = optarg;
 +                break;
 +            case 'p':
 +                rainfo.port = atoi(optarg);
 +                break;
 +            case 'd':
 +                rainfo.xmpp_domain = optarg;
 +                break;
 +            case 'u':
 +                rainfo.username = optarg;
 +                break;
 +            case 'w':
 +                rainfo.password = optarg;
 +                break;
 +            case 'j':
 +                rainfo.user_jid = optarg;
 +                break;
 +            case 'r':
 +                rainfo.resource = optarg;
 +                break;
              default:
                  PrintUsage();
                  return -1;
          }
      }
  
 -    if (initRemoteAccessAdapter() != OC_STACK_OK)
 +    if (OCSetRAInfo(&rainfo) != OC_STACK_OK)
      {
          OC_LOG(ERROR, TAG, "Error initiating remote access adapter");
          return 0;
@@@ -367,7 -367,7 +367,7 @@@ OCEntityHandlerResult ProcessDeleteRequ
      return ehResult;
  }
  
- OCEntityHandlerResult ProcessNonExistingResourceRequest(OCEntityHandlerRequest *ehRequest)
+ OCEntityHandlerResult ProcessNonExistingResourceRequest(OCEntityHandlerRequest * /*ehRequest*/)
  {
      OC_LOG_V(INFO, TAG, "\n\nExecuting %s ", __func__);
  
@@@ -414,7 -414,9 +414,9 @@@ void ProcessObserveDeregister (OCEntity
  
  OCEntityHandlerResult
  OCDeviceEntityHandlerCb (OCEntityHandlerFlag flag,
-         OCEntityHandlerRequest *entityHandlerRequest, char* uri, void* callbackParam)
+                          OCEntityHandlerRequest *entityHandlerRequest,
+                          char* uri,
+                          void* /*callbackParam*/)
  {
      OC_LOG_V (INFO, TAG, "Inside device default entity handler - flags: 0x%x, uri: %s", flag, uri);
  
  }
  
  OCEntityHandlerResult
- OCNOPEntityHandlerCb (OCEntityHandlerFlag flag,
-         OCEntityHandlerRequest *entityHandlerRequest, void* callbackParam)
+ OCNOPEntityHandlerCb (OCEntityHandlerFlag /*flag*/,
+                       OCEntityHandlerRequest * /*entityHandlerRequest*/,
+                       void* /*callbackParam*/)
  {
      // This is callback is associated with the 2 presence notification
      // resources. They are non-operational.
  
  OCEntityHandlerResult
  OCEntityHandlerCb (OCEntityHandlerFlag flag,
-         OCEntityHandlerRequest *entityHandlerRequest, void* callback)
+         OCEntityHandlerRequest *entityHandlerRequest, void* /*callback*/)
  {
      OC_LOG_V (INFO, TAG, "Inside entity handler - flags: 0x%x", flag);
  
      OCEntityHandlerResult ehResult = OC_EH_OK;
-     OCEntityHandlerResponse response = { 0 };
+     OCEntityHandlerResponse response = { 0, 0, OC_EH_ERROR, 0, 0, { },{ 0 }, false };
  
      // Validate pointer
      if (!entityHandlerRequest)
@@@ -929,44 -932,15 +932,44 @@@ int main(int argc, char* argv[]
  {
      pthread_t threadId;
      pthread_t threadId_presence;
 -    int opt;
  
 -    while ((opt = getopt(argc, argv, "o:")) != -1)
 +#ifdef RA_ADAPTER
 +    OCRAInfo_t rainfo = {.hostname = "localhost", .port = 5222,
 +        .xmpp_domain = "localhost", .username = "test1", .password = "intel123",
 +        .resource = "", .user_jid = ""};
 +#endif
 +
 +    int opt = 0;
 +    while ((opt = getopt(argc, argv, "o:s:p:d:u:w:r:j:")) != -1)
      {
          switch(opt)
          {
              case 'o':
                  gObserveNotifyType = atoi(optarg);
                  break;
 +#ifdef RA_ADAPTER
 +            case 's':
 +                rainfo.hostname = optarg;
 +                break;
 +            case 'p':
 +                rainfo.port = atoi(optarg);
 +                break;
 +            case 'd':
 +                rainfo.xmpp_domain = optarg;
 +                break;
 +            case 'u':
 +                rainfo.username = optarg;
 +                break;
 +            case 'w':
 +                rainfo.password = optarg;
 +                break;
 +            case 'j':
 +                rainfo.user_jid = optarg;
 +                break;
 +            case 'r':
 +                rainfo.resource = optarg;
 +                break;
 +#endif
              default:
                  PrintUsage();
                  return -1;
          PrintUsage();
          return -1;
      }
 +
  #ifdef RA_ADAPTER
+     OCRAInfo_t rainfo;
+     rainfo.hostname = "localhost";
+     rainfo.port = 5222;
+     rainfo.xmpp_domain = "localhost";
+     rainfo.username = "test1";
+     rainfo.password = "intel123";
+     rainfo.resource = "";
+     rainfo.user_jid = "";
      OCSetRAInfo(&rainfo);
  #endif