{\r
switch (type) {\r
case 0:\r
- return OCConnectivityType::OC_ETHERNET;\r
+ return OCConnectivityType::OC_IPV4;\r
case 1:\r
- return OCConnectivityType::OC_WIFI;\r
+ return OCConnectivityType::OC_IPV6;\r
case 2:\r
return OCConnectivityType::OC_EDR;\r
case 3:\r
return "";\r
}\r
}\r
-};
\ No newline at end of file
+};\r
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPresenceHandle presenceHandle = OcPlatform.subscribePresence(
resource.getHost(),
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
presenceListener
);
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//server
//client
OcPlatform.findResource(null,
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
OcPlatform.getDeviceInfo(
"",
OcPlatform.WELL_KNOWN_QUERY + "/d",
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
deviceFoundListener);
//wait for onDeviceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener1);
//wait for onResourceFound event to find 3 registered resources
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener3);
//wait for onResourceFound event to find 1 collection resources
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener2);
//wait for onResourceFound event to find 2 resources
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener4);
//wait for onResourceFound event to find 3 registered resources
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener6);
//wait for onResourceFound event to find 1 collection resources
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener5);
//wait for onResourceFound event to find 1 collection resources
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType1,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType2,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
OcResource resourceProxy = OcPlatform.constructResourceObject(
resource.getHost(),
resource.getUri(),
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resource.isObservable(),
resource.getResourceTypes(),
resource.getResourceInterfaces());
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
//client
OcPlatform.findResource("",
OcPlatform.WELL_KNOWN_QUERY + "?rt=" + resourceType,
- OcConnectivityType.WIFI,
+ OcConnectivityType.IPV4,
resourceFoundListener);
//wait for onResourceFound event
private OcRepresentation getRepresentation() {
return getRepresentation(74);
}
-}
\ No newline at end of file
+}
import java.security.InvalidParameterException;\r
\r
public enum OcConnectivityType {\r
- ETHERNET(0),\r
- WIFI (1),\r
+ IPV4 (0),\r
+ IPV6 (1),\r
EDR (2),\r
LE (3),\r
ALL (4),\r
* If empty, performs multicast resource discovery query\r
* @param resourceUri name of the resource. If null or empty, performs search for all\r
* resource names\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param onResourceFoundListener Handles events, success states and failure states.\r
* @throws OcException\r
*/\r
* If empty, performs multicast resource discovery query\r
* @param resourceUri name of the resource. If null or empty, performs search for all\r
* resource names\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param onResourceFoundListener Handles events, success states and failure states.\r
* @param qualityOfService the quality of communication\r
* @throws OcException\r
*\r
* @param host Host IP Address. If null or empty, Multicast is performed.\r
* @param deviceUri Uri containing address to the virtual device\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param onDeviceFoundListener Handles events, success states and failure states.\r
* @throws OcException\r
*/\r
*\r
* @param host Host IP Address. If null or empty, Multicast is performed.\r
* @param deviceUri Uri containing address to the virtual device\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param onDeviceFoundListener Handles events, success states and failure states.\r
* @param qualityOfService the quality of communication\r
* @throws OcException\r
* server adds/removes/alters a resource, starts or is intentionally stopped\r
*\r
* @param host The IP address/addressable name of the server to subscribe to\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param onPresenceListener listener that will receive notifications/subscription events\r
* @return a handle object that can be used to identify this subscription request. It can be\r
* used to unsubscribe from these events in the future\r
*\r
* @param host The IP address/addressable name of the server to subscribe to\r
* @param resourceType a resource type specified as a filter for subscription events.\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param onPresenceListener listener that will receive notifications/subscription events\r
* @return a handle object that can be used to identify this subscription request. It can be\r
* used to unsubscribe from these events in the future\r
* @param uri the rest of the resource's URI that will permit messages to be\r
* properly routed.\r
* Example: /a/light\r
- * @param connectivityType a type of connectivity indicating the interface. Example: WIFI,\r
- * ETHERNET, ALL\r
+ * @param connectivityType a type of connectivity indicating the interface. Example: IPV4,\r
+ * IPV6, ALL\r
* @param isObservable a boolean containing whether the resource supports observation\r
* @param resourceTypeList a collection of resource types implemented by the resource\r
* @param interfaceList a collection of interfaces that the resource supports/implements\r
"OcPlatform.Configure before any other API calls are permitted");\r
}\r
}\r
-}
\ No newline at end of file
+}\r
#include "ocrandom.h"
#include <stdio.h>
-#if defined(__linux__) || defined(__APPLE__)
+#if !defined(__ANDROID__) && (defined(__linux__) || defined(__APPLE__))
#include <uuid/uuid.h>
#endif
{
return RAND_UUID_INVALID_PARAM;
}
-#if defined(__linux__) || defined(__APPLE__)
- // note: uuid_t is typedefed as unsigned char[16] on linux/apple
- uuid_generate(uuid);
- return RAND_UUID_OK;
-#elif defined(__ANDROID__)
+#if defined(__ANDROID__)
char uuidString[UUID_STRING_SIZE];
int8_t ret = OCGenerateUuidString(uuidString);
uuid[15] = parseUuidPart(&uuidString[34]);
return RAND_UUID_OK;
+#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__APPLE__))
+ // note: uuid_t is typedefed as unsigned char[16] on linux/apple
+ uuid_generate(uuid);
+ return RAND_UUID_OK;
#else
// Fallback for all platforms is filling the array with random data
OCFillRandomMem(uuid, UUID_SIZE);
{
return RAND_UUID_INVALID_PARAM;
}
-#if defined(__linux__) || defined(__APPLE__)
- uint8_t uuid[UUID_SIZE];
- int8_t ret = OCGenerateUuid(uuid);
-
- if(ret != 0)
- {
- return ret;
- }
-
- uuid_unparse_lower(uuid, uuidString);
- return RAND_UUID_OK;
-
-#elif defined(__ANDROID__)
+#if defined(__ANDROID__)
int32_t fd = open("/proc/sys/kernel/random/uuid", O_RDONLY);
if(fd > 0)
{
close(fd);
return RAND_UUID_READ_ERROR;
}
+#elif !defined(__ANDROID__) && (defined(__linux__) || defined(__APPLE__))
+ uint8_t uuid[UUID_SIZE];
+ int8_t ret = OCGenerateUuid(uuid);
+
+ if(ret != 0)
+ {
+ return ret;
+ }
+
+ uuid_unparse_lower(uuid, uuidString);
+ return RAND_UUID_OK;
+
#else
uint8_t uuid[UUID_SIZE];
OCGenerateUuid(uuid);
--- /dev/null
+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+Import('env')
+import os
+import os.path
+randomtest_env = env.Clone()
+
+src_dir = randomtest_env.get('SRC_DIR')
+
+######################################################################
+# Build flags
+######################################################################
+randomtest_env.PrependUnique(CPPPATH = [
+ '../include',
+ '../../logger/include',
+ '../../ocmalloc/include',
+ '../../../oc_logger/include',
+ '../../../../extlibs/gtest/gtest-1.7.0/include'
+ ])
+
+randomtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
+randomtest_env.AppendUnique(LIBS = ['-lpthread'])
+randomtest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+randomtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
+randomtest_env.PrependUnique(LIBS = ['m',
+ 'octbstack',
+ 'uuid',
+ 'gtest',
+ 'gtest_main'])
+
+
+if env.get('LOGGING'):
+ randomtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
+
+######################################################################
+# Source files and Targets
+######################################################################
+randomtests = randomtest_env.Program('randomtests', ['linux/randomtest.cpp'])
+
+Alias("test", [randomtests])
+
+env.AppendTarget('test')
+if env.get('TEST') == '1':
+ target_os = env.get('TARGET_OS')
+ if target_os == 'linux':
+ out_dir = env.get('BUILD_DIR')
+ result_dir = env.get('BUILD_DIR') + '/test_out/'
+ if not os.path.isdir(result_dir):
+ os.makedirs(result_dir)
+ randomtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
+ randomtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
+ randomtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
+ ut = randomtest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_random_test.memcheck ' + out_dir + 'resource/csdk/ocrandom/test/randomtests')
+ AlwaysBuild ('ut')