A new API is added for DTLS credential registration.
SCons scripts for connectivity abstraction with secured flag.
Different platforms with secured flag ==1 can be built with modifications.
Change-Id: I6a94ce27eb8c2cdd62899b7810ebbec35b3cf385
Signed-off-by: Ashok Channa <ashok.channa@samsung.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/145
Tested-by: jenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: Sudarshan Prasad <sudarshan.prasad@intel.com>
target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
+# True if binary needs to be installed on board. (Might need root permissions)
+# set to 'no', 'false' or 0 for only compilation
+require_upload = ARGUMENTS.get('UPLOAD', True)
+
######################################################################
# Common build options (release, target os, target arch)
######################################################################
help_vars = Variables()
help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
+help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'WIFI', 'BT', 'BLE', 'ETHERNET']))
help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
-
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_upload))
+help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
######################################################################
# Platform(build target) specific options: SDK/NDK & toolchain
######################################################################
-targets_support_cc = ['linux', 'arduino']
+targets_support_cc = ['linux', 'arduino', 'tizen']
if target_os in targets_support_cc:
# Set cross compile toolchain
env.AddMethod(__append_target, 'AppendTarget')
env.AddMethod(__install, 'InstallTarget')
env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()+'/..'
Export('env')
##
Import('env')
+print "Reading linux configuration script"
+
# Set release/debug flags
if env.get('RELEASE'):
env.AppendUnique(CCFLAGS = ['-Os'])
else:
env.AppendUnique(CCFLAGS = ['-g'])
+env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__LINUX__','-DTB_LOG'])
+env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC','`pkg-config','--cflags','glib-2.0`'])
+env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread', '-lglib-2.0', '-lgthread-2.0'])
+
+env.Append(LIBS=[
+ '-lglib-2.0', '-lgthread-2.0'
+])
+
# Set arch flags
target_arch = env.get('TARGET_ARCH')
if target_arch in ['x86']:
##
-# CA library (share library) build script
+# CA build script
##
-Import('env')
-# Add third party libraries
-lib_env = env.Clone()
-SConscript(env.get('SRC_DIR') + '/resource/third_party_libs.scons', 'lib_env')
+Import('env')
-calib_env = lib_env.Clone()
+ca_os = env.get('TARGET_OS')
+ca_transport = env.get('TARGET_TRANSPORT')
+secured = env.get('SECURED')
+root_dir = './'
+ca_path = './src/'
+build_dir = env.get('BUILD_DIR')
+#####################################################################
+# Source files and Target(s)
######################################################################
-# Add build options (WITH_DTLS) info for help command
-######################################################################
-help_vars = Variables()
-help_vars.Add(BoolVariable('WITH_DTLS', 'enable security support?', False))
-help_vars.Update(env)
-Help(help_vars.GenerateHelpText(env))
-######################################################################
-# Get build options (the options from command line)
-######################################################################
-with_dtls = env.get('WITH_DTLS')
-if (with_dtls):
- print "Info: Building CA library with DTLS support"
+print"Reading ca script %s"%ca_transport
-######################################################################
-# Build flags
-######################################################################
-calib_env.AppendUnique(CPPPATH = [
- './common/inc',
- './api',
- './inc',
- './src/ethernet_adapter/linux',
- './src/wifi_adapter/linux',
- './src/bt_edr_adapter/linux',
- './src/bt_le_adapter/linux',
- './lib/libcoap-4.1.1'
- ])
-
-if (with_dtls):
- calib_env.AppendUnique(CPPPATH = [
- './lib/extlibs/tinydtls',
- '../stack/include'
- ])
-
-target_os = env.get('TARGET_OS')
-
-if target_os not in ['windows', 'winrt']:
- calib_env.AppendUnique(CFLAGS = ['-Wall', '-fPIC', '-fstack-protector-all']);
- calib_env.AppendUnique(CPPDEFINES = [
- '__LINUX__', 'WITH_POSIX',
- 'NO_EDR_ADAPTER', 'NO_LE_ADAPTER',
- 'WIFI_ADAPTER', 'ETHERNET_ADAPTER',
- #'TB_LOG'
- ])
- if (with_dtls):
- calib_env.AppendUnique(CPPDEFINES = [
- '__WITH_DTLS__',
- ])
- calib_env.AppendUnique(LIBPATH = ['./lib/extlibs/tinydtls'])
- calib_env.PrependUnique(LIBS = ['tinydtls'])
-
-
-calib_env.ParseConfig('pkg-config --cflags glib-2.0')
-
-#TODO add SConscript for libcoap
-#`/home/tester/iotivity/resource/csdk/connectivity/lib/libcoap-4.1.1'
+env.PrependUnique(CPPPATH = [root_dir + '/api/'])
+env.AppendUnique(CPPPATH = [root_dir + '/inc/'])
+env.AppendUnique(CPPPATH = [root_dir + '/lib/libcoap-4.1.1/'])
+env.AppendUnique(CPPPATH = [root_dir + '/common/inc/'])
-######################################################################
-# Source files and Targets
-######################################################################
-calib_src = [
- './common/src/logger.c',
- './common/src/oic_logger.c',
- './common/src/oic_console_logger.c',
- './common/src/oic_malloc.c',
- './common/src/oic_string.c',
- './common/src/uqueue.c',
- './common/src/uarraylist.c',
- './common/src/umutex.c',
- './common/src/uthreadpool.c',
- './src/caretransmission.c',
- './src/caconnectivitymanager.c',
- './src/caremotehandler.c',
- './src/cainterfacecontroller.c',
- './src/camessagehandler.c',
- './src/caqueueingthread.c',
- './src/canetworkconfigurator.c',
- './src/caprotocolmessage.c',
- './src/adapter_util/caadapterutils.c',
- './src/ethernet_adapter/caethernetadapter.c',
- './src/wifi_adapter/cawifiadapter.c',
- './src/bt_edr_adapter/linux/caedradapter.c',
- './src/bt_le_adapter/linux/caleadapter.c',
- './src/wifi_adapter/linux/cawifiserver.c',
- './src/wifi_adapter/linux/cawificlient.c',
- './src/wifi_adapter/linux/cawifinwmonitor.c',
- './src/ethernet_adapter/linux/caethernetserver.c',
- './src/ethernet_adapter/linux/caethernetclient.c',
- './src/ethernet_adapter/linux/caethernetnwmonitor.c'
- ]
-
-if (with_dtls):
- calib_src = calib_src + ['./src/adapter_util/caadapternetdtls.c']
-
-calib = calib_env.SharedLibrary('connectivity_abstraction', calib_src)
-calib_env.InstallTarget(calib, 'libconnectivity_abstraction')
+#Getting common source files
+env.SConscript('./common/SConscript')
+
+
+env.AppendUnique(CA_SRC=[ca_path+'adapter_util/caadapterutils.c'])
+env.AppendUnique(CA_SRC=[ca_path+'adapter_util/camsgparser.c'])
+if env.get('SECURED') == '1':
+ env.AppendUnique(CA_SRC=[ca_path+'adapter_util/caadapternetdtls.c'])
+ env.AppendUnique(CPPPATH = [root_dir + '/external/inc/'])
+
+if ca_os == 'arduino':
+ ca_common_src = [
+ ca_path + 'caconnectivitymanager_singlethread.c',
+ ca_path + 'cainterfacecontroller_singlethread.c',
+ ca_path + 'camessagehandler_singlethread.c',
+ ca_path + 'canetworkconfigurator_singlethread.c',
+ ca_path + 'caprotocolmessage_singlethread.c',
+ ca_path + 'caremotehandler.c',
+ ca_path + 'caretransmission_singlethread.cpp',
+ ]
+else:
+ ca_common_src = [
+ ca_path + 'caconnectivitymanager.c',
+ ca_path + 'cainterfacecontroller.c',
+ ca_path + 'camessagehandler.c',
+ ca_path + 'canetworkconfigurator.c',
+ ca_path + 'caprotocolmessage.c',
+ ca_path + 'caqueueingthread.c',
+ ca_path + 'caremotehandler.c',
+ ca_path + 'caretransmission.c',
+ ]
+ if secured == '1':
+ env.AppendUnique(CPPDEFINES = ['__WITH_DTLS__'])
+ env.AppendUnique(CPPPATH = [root_dir + '/lib/tinydtls'])
+env.AppendUnique(CA_SRC = ca_common_src)
+
+
+
+if 'ALL' in ca_transport:
+ env.SConscript(ca_path + 'ethernet_adapter/SConscript')
+ env.SConscript(ca_path + 'wifi_adapter/SConscript')
+ env.SConscript(ca_path + 'bt_edr_adapter/SConscript')
+ env.SConscript(ca_path + 'bt_le_adapter/SConscript')
+
+if 'WIFI' in ca_transport:
+ env.SConscript(ca_path + 'wifi_adapter/SConscript')
+
+if 'ETHERNET' in ca_transport:
+ env.SConscript(ca_path + 'ethernet_adapter/SConscript')
+
+if 'BT' in ca_transport:
+ env.SConscript(ca_path + 'bt_edr_adapter/SConscript')
+
+if 'BLE' in ca_transport:
+ env.SConscript(ca_path + 'bt_le_adapter/SConscript')
+
+print "Include path is %s" %env.get('CPPPATH')
+print "Files path is %s" %env.get('CA_SRC')
+
+calib = env.StaticLibrary('connectivity_abstraction', env.get('CA_SRC'))
+env.InstallTarget(calib, 'libconnectivity_abstraction')
+if env.get('SECURED') == '1':
+ env.Install(build_dir, './lib/tinydtls/libtinydtls.a')
--- /dev/null
+##
+# The main build script
+#
+##
+
+# Load common build config
+# Load common build config
+SConscript('./build/SConscript')
+
+SConscript('extra_options.scons')
+Import('env')
+
+sample_env = env.Clone()
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+secured = env.get('SECURED')
+buildsample = env.get('BUILD_SAMPLE')
+
+print "Given Transport is %s" % transport
+print "Given OS is %s" % target_os
+print "Secured %s" % env.get('SECURED')
+print "Build sample is set to %s" % buildsample
+
+build_dir = env.get('BUILD_DIR')
+
+
+if 'ALL' in transport:
+ if target_os == 'linux':
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'ETHERNET_ADAPTER','NO_EDR_ADAPTER','NO_LE_ADAPTER'])
+ elif target_os == 'tizen':
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
+ else:
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
+ print "CA Transport is ALL"
+else:
+ if 'BT' in transport:
+ env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER'])
+ print "CA Transport is BT"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
+
+ if 'BLE' in transport:
+ env.AppendUnique(CPPDEFINES = ['LE_ADAPTER'])
+ print "CA Transport is BLE"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
+
+ if 'WIFI' in transport:
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER'])
+ print "CA Transport is WIFI"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_WIFI_ADAPTER'])
+ if 'ETHERNET' in transport:
+ env.AppendUnique(CPPDEFINES = ['ETHERNET_ADAPTER'])
+ print "CA Transport is ETHERNET"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_ETHERNET_ADAPTER'])
+
+
+if target_os == 'tizen':
+ command = "sh build/tizen/gbsbuild.sh %s %s" % (transport, buildsample)
+ print "Created Command is %s" % command
+ gbs_script = env.Command('gbs_build', None, command)
+ AlwaysBuild ('gbs_script')
+elif target_os == 'arduino':
+ SConscript('build/arduino/arduino.scons')
+
+ # Build 'libcoap' library
+ SConscript(build_dir + 'lib/libcoap-4.1.1/SConscript')
+
+ # Build 'src' sub-project
+ SConscript(build_dir + 'SConscript')
+
+ # Build 'samples' sub-project
+ SConscript(build_dir + 'samples/arduino/SConscript')
+elif target_os == 'linux':
+
+ # Build 'libcoap' library
+ SConscript(build_dir + 'lib/libcoap-4.1.1/SConscript')
+
+ # Build 'src' sub-project
+ SConscript(build_dir + 'SConscript')
+
+ # Build 'samples' sub-project
+ sample_env.SConscript(build_dir + 'samples/linux/SConscript')
+elif target_os == 'android':
+
+ # Build 'libcoap' library
+ SConscript(build_dir + 'lib/libcoap-4.1.1/SConscript')
+
+ # Build 'src' sub-project
+ SConscript(build_dir + 'SConscript')
*/
#include "cacommon.h"
+#ifdef __WITH_DTLS__
+#include "ocsecurityconfig.h"
+#endif
+
#ifdef __cplusplus
extern "C"
{
*/
typedef void (*CAResponseCallback)(const CARemoteEndpoint_t *object,
const CAResponseInfo_t *responseInfo);
+
+#ifdef __WITH_DTLS__
+/**
+ * @brief Callback function type for getting DTLS credentials.
+ * @param credInfo [OUT] DTLS credentials info
+ * @return NONE
+ */
+typedef void (*CAGetDTLSCredentialsHandler)(OCDtlsPskCredsBlob **credInfo);
+#endif //__WITH_DTLS__
/**
* @brief Initialize the connectivity abstraction module.
*/
void CARegisterHandler(CARequestCallback ReqHandler, CAResponseCallback RespHandler);
+#ifdef __WITH_DTLS__
+/**
+ * @brief Register callback to get DTLS PSK credentials.
+ * @param GetDTLSCredentials [IN] GetDTLS Credetials callback
+ * @return #CA_STATUS_OK or Appropriate error code
+ */
+CAResult_t CARegisterDTLSCredentialsHandler(
+ CAGetDTLSCredentialsHandler GetDTLSCredentials);
+#endif //__WITH_DTLS__
+
/**
* @brief Create a Remote endpoint if the URI is available already.
* This is a Helper function which can be used before calling
--- /dev/null
+=== Pre requites ===
+
+* 1. Scons
+
+Please refer to the following page to install scons:
+ http://www.scons.org/doc/production/HTML/scons-user.html#chap-build-install
+(Note: on Windows, install Python 2.x before installing scons)
+
+* 2. IDE/SDK Pre-requites
+To build for some OS (Android / Arduino / IOS ...), an IDE/SDK may be required,
+please go to the relative page to download and install the required IDE/SDK.
+
+Linux Build:
+
+1) Go to "connectivity/" folder.
+
+2) Execute following command(s) to start build based on transport selection required :
+
+ -> Building for all transports :
+ scons TARGET_OS=linux TARGET_TRANSPORT=ALL
+
+ -> Building for a specific transport :
+ scons TARGET_OS=linux TARGET_TRANSPORT=WIFI
+
+ -> Building for multiple transports :
+ scons TARGET_OS=linux TARGET_TRANSPORT=WIFI,ETHERNET
+
+ sudo scons TARGET_OS=linux TARGET_TRANSPORT=ALL -c ( for clean)
+
+
+3)The above command will build sample also.
+
+For Enabling Secured server,
+ *Note: tinydtls libray has to copied to "connectivity/lib/tinydtls" for secured build.
+
+ Secured Server will be only used for WIFI and ETHERNET transports.
+
+ Give command "sudo scons TARGET_OS=linux TARGET_TRANSPORT=WIFI SECURED=1
+
+ or(For multiple transports will be mentioned using comma)
+
+ Give command "sudo scons TARGET_OS=linux TARGET_TRANSPORT=WIFI,ETHERNET SECURED=1
+
+
+Android Build:
+
+1) Go to "connectivity/build" folder.
+
+2) Execute following command(s) to start build based on transport selection required :
+
+ -> Building for all transports :
+ scons TARGET_OS=android TARGET_TRANSPORT=ALL TARGET_ARCH=x86 ANDROID_NDK=your_ndk_path
+
+ -> Building for a specific transport :
+ scons TARGET_OS=android TARGET_TRANSPORT=WIFI TARGET_ARCH=x86 ANDROID_NDK=your_ndk_path
+
+ -> Building for multiple transports :
+ scons TARGET_OS=android TARGET_TRANSPORT=WIFI,BT TARGET_ARCH=x86 ANDROID_NDK=your_ndk_path
+
+Note :- Upon successful execution of above command(s) CA library will be generated at path
+ "~/connectivity/build/out/android/TARGET_ARCH/release or debug".
+
+Tizen Build:
+
+1) If you are building first time, then delete GBS-ROOT folder from home directory.
+
+2) Go to "connectivity/" folder.
+
+3) Execute following command(s) to start build based on transport selection required :
+
+ -> Building for all transports :
+ scons TARGET_OS=tizen TARGET_TRANSPORT=ALL
+
+ -> Building for a specific transport :
+ scons TARGET_OS=tizen TARGET_TRANSPORT=WIFI
+
+ -> Building for multiple transports :
+ scons TARGET_OS=tizen TARGET_TRANSPORT=WIFI,BT,BLE
+
+4) By default, above command will build sample also.
+ To disable building sample, add BUILD_SAMPLE=OFF to the build command.
+ Ex: scons TARGET_OS=tizen TARGET_TRANSPORT=ALL BUILD_SAMPLE=OFF
+ Making this flag ON builds the sample.
+
+Note :- Upon successful execution of above command(s) CA library and sample applications will be
+ generated at path "~/GBS-ROOT/local/repos/redwood/armv7l/RPMS".
+
+Arduino Build:
+
+Note :- Currently only megaADK build is supported.
+
+1) Set up Arduino first before building. Refer to connectivity\build\arduino\Arduino_Setup_README.txt file for help.
+
+2) Go to "connectivity/" folder.
+
+3) Execute following command to start build :
+
+ scons TARGET_OS=arduino TARGET_TRANSPORT=<transport> TARGET_ARCH=avr BOARD=megaADK ARDUINO_HOME=<path_to_arduino_installation>
+
+ Possible values for <transport> are:
+ -> ETHERNET :
+ scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=megaADK ARDUINO_HOME=<path_to_arduino_installation>
+ -> WIFI :
+ scons TARGET_OS=arduino TARGET_TRANSPORT=WIFI TARGET_ARCH=avr BOARD=megaADK ARDUINO_HOME=<path_to_arduino_installation>
+ -> BLE :
+ scons TARGET_OS=arduino TARGET_TRANSPORT=BLE TARGET_ARCH=avr BOARD=megaADK ARDUINO_HOME=<path_to_arduino_installation>
+
+ Note :- Only single transport can be built at a time for Arduino.
+
+4) The above command will build sample also. The "CASample.hex" can be found at "/samples/arduino/"
+
+5) After building sample, script will try to install on "/dev/ttyACM0" port in sudo mode.
+ To skip installation, set command line argument 'UPLOAD=false'.
+ "scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=megaADK ARDUINO_HOME=<path_to_arduino_installation> UPLOAD=false"
+
+6) To set BLE Shield Name, include the option DEVICE_NAME during scon build.
+ "scons TARGET_OS=arduino TARGET_TRANSPORT=ETHERNET TARGET_ARCH=avr BOARD=megaADK ARDUINO_HOME=<path_to_arduino_installation> DEVICE_NAME=OIC"
+ Specified Device name length MUST be less than 10 characters. RBL Library has this limitation.
+ By Default DEVICE_NAME=OIC-DEVICE, if device name option is not specified
+
+ To change the port number, please modify "port" variable in __upload() function in: "/build/arduino/SConscript".
\ No newline at end of file
--- /dev/null
+##
+# This script includes generic build options:
+# release/debug, target os, target arch, cross toolchain, build environment etc
+##
+import os
+import platform
+
+# Map of host os and allowed target os (host: allowed target os)
+host_target_map = {
+ 'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
+ 'windows': ['windows', 'winrt', 'android', 'arduino'],
+ 'darwin': ['darwin', 'ios', 'android', 'arduino'],
+ }
+
+# Map of os and allowed archs (os: allowed archs)
+os_arch_map = {
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+ 'tizen': ['x86', 'x86_64', 'arm', 'arm64'],
+ 'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
+ 'windows': ['x86', 'amd64', 'arm'],
+ 'winrt': ['arm'],
+ 'darwin': ['i386', 'x86_64'],
+ 'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+ 'arduino': ['avr', 'arm'],
+ 'yocto': ['x86', 'x86_64'],
+ }
+
+host = platform.system().lower()
+
+if not host_target_map.has_key(host):
+ print "\nError: Current system (%s) isn't supported\n" % host
+ Exit(1)
+
+######################################################################
+# Get build options (the optins from command line)
+######################################################################
+target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
+
+if target_os not in host_target_map[host]:
+ print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
+ Exit(1)
+
+default_arch = platform.machine()
+if default_arch not in os_arch_map[target_os]:
+ default_arch = os_arch_map[target_os][0].lower()
+
+target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
+
+# True if binary needs to be installed on board. (Might need root permissions)
+# set to 'no', 'false' or 0 for only compilation
+require_upload = ARGUMENTS.get('UPLOAD', True)
+
+######################################################################
+# Common build options (release, target os, target arch)
+######################################################################
+help_vars = Variables()
+help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
+help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
+help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'WIFI', 'BT', 'BLE', 'ETHERNET']))
+help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+help_vars.Add(BoolVariable('UPLOAD', 'Upload binary ? (For Arduino)', require_upload))
+help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
+######################################################################
+# Platform(build target) specific options: SDK/NDK & toolchain
+######################################################################
+targets_support_cc = ['linux', 'arduino', 'tizen', 'android']
+
+if target_os in targets_support_cc:
+ # Set cross compile toolchain
+ help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
+ help_vars.Add(PathVariable('TC_PATH',
+ 'Toolchain path (Generally only be required for cross-compiling)',
+ os.environ.get('TC_PATH')))
+
+if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
+ env = Environment(variables = help_vars,
+ tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
+ )
+else:
+ env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+
+Help(help_vars.GenerateHelpText(env))
+
+# Get the device name and set it to __OIC_DEVICE_NAME__
+device_name = ARGUMENTS.get('DEVICE_NAME', "OIC-DEVICE")
+print device_name
+env.AppendUnique(CPPDEFINES = ['-D__OIC_DEVICE_NAME__=' + "\'\"" + device_name + "\"\'"])
+
+tc_set_msg = '''
+************************************ Warning **********************************
+* Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default *
+* toolchain, if it isn't what you expect you should unset it, otherwise it may*
+* cause inexplicable errors. *
+*******************************************************************************
+'''
+
+if target_os in targets_support_cc:
+ prefix = env.get('TC_PREFIX')
+ tc_path = env.get('TC_PATH')
+ if prefix:
+ env.Replace(CC = prefix + 'gcc')
+ env.Replace(CXX = prefix + 'g++')
+ env.Replace(AR = prefix + 'ar')
+ env.Replace(AS = prefix + 'as')
+ env.Replace(LINK = prefix + 'ld')
+ env.Replace(RANLIB = prefix + 'ranlib')
+
+ if tc_path:
+ env.PrependENVPath('PATH', tc_path)
+ sys_root = os.path.abspath(tc_path + '/../')
+ env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
+ env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+ if prefix or tc_path:
+ print tc_set_msg
+
+# Ensure scons be able to change its working directory
+env.SConscriptChdir(1)
+
+# Set the source directory and build directory
+# Source directory: 'dir'
+# Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
+#
+# You can get the directory as following:
+# env.get('SRC_DIR')
+# env.get('BUILD_DIR')
+
+def __set_dir(env, dir):
+ if not os.path.exists(dir + '/SConstruct'):
+ print '''
+*************************************** Error *********************************
+* The directory(%s) seems isn't a source code directory, no SConstruct file is
+* found. *
+*******************************************************************************
+''' % dir
+ Exit(1)
+
+ if env.get('RELEASE'):
+ build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
+ else:
+ build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
+ env.VariantDir(build_dir, dir, duplicate=0)
+
+ env.Replace(BUILD_DIR = build_dir)
+ env.Replace(SRC_DIR = dir)
+
+def __src_to_obj(env, src, home = ''):
+ obj = env.get('BUILD_DIR') + src.replace(home, '')
+ if env.get('OBJSUFFIX'):
+ obj += env.get('OBJSUFFIX')
+ return env.Object(obj, src)
+
+def __install(ienv, targets, name):
+ i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+ Alias(name, i_n)
+ env.AppendUnique(TS = [name])
+
+def __append_target(ienv, target):
+ env.AppendUnique(TS = [target])
+
+def __print_targets(env):
+ Help('''
+===============================================================================
+Targets:\n ''')
+ for t in env.get('TS'):
+ Help(t + ' ')
+ Help('''
+\nDefault all targets will be built. You can specify the target to build:
+
+ $ scons [options] [target]
+===============================================================================
+''')
+
+env.AddMethod(__set_dir, 'SetDir')
+env.AddMethod(__print_targets, 'PrintTargets')
+env.AddMethod(__src_to_obj, 'SrcToObj')
+env.AddMethod(__append_target, 'AppendTarget')
+env.AddMethod(__install, 'InstallTarget')
+env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()+'/..'
+
+Export('env')
+
+######################################################################
+# Link scons to Yocto cross-toolchain ONLY when target_os is yocto
+######################################################################
+if target_os == "yocto":
+ '''
+ This code injects Yocto cross-compilation tools+flags into scons'
+ build environment in order to invoke the relevant tools while
+ performing a build.
+ '''
+ import os.path
+ try:
+ CC = os.environ['CC']
+ target_prefix = CC.split()[0]
+ target_prefix = target_prefix[:len(target_prefix)-3]
+ tools = {"CC" : target_prefix+"gcc",
+ "CXX" : target_prefix+"g++",
+ "AS" : target_prefix+"as",
+ "LD" : target_prefix+"ld",
+ "GDB" : target_prefix+"gdb",
+ "STRIP" : target_prefix+"strip",
+ "RANLIB" : target_prefix+"ranlib",
+ "OBJCOPY" : target_prefix+"objcopy",
+ "OBJDUMP" : target_prefix+"objdump",
+ "AR" : target_prefix+"ar",
+ "NM" : target_prefix+"nm",
+ "M4" : "m4",
+ "STRINGS": target_prefix+"strings"}
+ PATH = os.environ['PATH'].split(os.pathsep)
+ for tool in tools:
+ if tool in os.environ:
+ for path in PATH:
+ if os.path.isfile(os.path.join(path, tools[tool])):
+ env[tool] = os.path.join(path, os.environ[tool])
+ break
+ except:
+ print "ERROR in Yocto cross-toolchain environment"
+ Exit(1)
+ '''
+ Now reset TARGET_OS to linux so that all linux specific build configurations
+ hereupon apply for the entirety of the build process.
+ '''
+ env['TARGET_OS'] = 'linux'
+ '''
+ We want to preserve debug symbols to allow BitBake to generate both DEBUG and
+ RELEASE packages for OIC.
+ '''
+ env['CCFLAGS'].append('-g')
+ Export('env')
+else:
+ '''
+ If target_os is not Yocto, continue with the regular build process
+ '''
+ # Load config of target os
+ if target_os in ['linux', 'tizen']:
+ env.SConscript('linux/SConscript')
+ else:
+ env.SConscript(target_os + '/SConscript')
+
+# Delete the temp files of configuration
+if env.GetOption('clean'):
+ dir = env.get('SRC_DIR')
+
+ if os.path.exists(dir + '/config.log'):
+ Execute(Delete(dir + '/config.log'))
+ Execute(Delete(dir + '/.sconsign.dblite'))
+ Execute(Delete(dir + '/.sconf_temp'))
+
+Return('env')
--- /dev/null
+##
+# This script includes android specific config (GNU GCC)
+##
+import os
+import platform
+import subprocess
+
+Import('env')
+
+help_vars = Variables()
+help_vars.Add(PathVariable('ANDROID_NDK', 'Android NDK root directory', os.environ.get('ANDROID_NDK')))
+help_vars.Update(env)
+Help(help_vars.GenerateHelpText(env))
+
+android_ndk = env.get('ANDROID_NDK')
+if not android_ndk:
+ print '''
+*************************************** Error *********************************
+* Android NDK path isn't set, you can set enviornment variable ANDROID_NDK *
+* or add it in command line as: *
+* # scons ANDROID_NDK=<path to android NDK> ... *
+*******************************************************************************
+'''
+ Exit(1)
+
+# Overwrite suffixes and prefixes
+if env['HOST_OS'] == 'win32':
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJSUFFIX'] = '.os'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = 'lib'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = ['lib']
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+elif platform.system().lower() == 'darwin':
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+
+######################################################################
+# Set common flags
+######################################################################
+
+# Android build system default cofig
+env.AppendUnique(CPPDEFINES = ['ANDROID'])
+env.AppendUnique(SHCFLAGS = ['-Wa,--noexecstack'])
+env.AppendUnique(LINKFLAGS = ['-Wl,--gc-sections', '-Wl,-z,nocopyreloc'])
+
+env.AppendUnique(CPPPATH = [android_ndk + '/platforms/android-19/arch-x86/usr/include/'])
+
+######################################################################
+# Probe Android NDK default flags
+######################################################################
+ndk_build_cmd = android_ndk + '/ndk-build'
+if env['HOST_OS'] == 'win32':
+ if os.path.isfile(ndk_build_cmd + '.cmd'):
+ ndk_build_cmd += '.cmd'
+
+if not os.path.isfile(ndk_build_cmd):
+ print '''
+*************************************** Error *********************************
+* It seems android ndk path is not set properly, please check if "%s"
+* is the root directory of android ndk. *
+*******************************************************************************
+''' % android_ndk
+ Exit(1)
+
+ANDROID_HOME = os.environ.get('ANDROID_HOME')
+if ANDROID_HOME is not None:
+ ANDROID_HOME = os.path.abspath(ANDROID_HOME)
+
+if ANDROID_HOME is None or not os.path.exists(ANDROID_HOME):
+ print '''
+*************************************** Warning *******************************
+* Enviornment variable ANDROID_HOME is not set properly. It should be the *
+* root directory of android sdk. If you'd like build Java code, it's required.*
+*******************************************************************************
+'''
+
+target_arch = env.get('TARGET_ARCH')
+
+# Android ndk early version doesn't support C++11. Detect the toolchain version
+# to make sure proper toolchain is used
+for tc_ver in ['4.7', '4.8', '4.9', '']:
+ if os.path.exists(android_ndk + '/toolchains/x86-' + tc_ver):
+ break
+
+cmd = [ndk_build_cmd]
+cmd.append('APP_ABI=' + target_arch)
+cmd.append('APP_STL=gnustl_shared')
+if env.get('RELEASE'):
+ cmd.append('APP_OPTIM=release')
+else:
+ cmd.append('APP_OPTIM=debug')
+if tc_ver != '':
+ cmd.append('NDK_TOOLCHAIN_VERSION=' + tc_ver)
+else:
+ print '''
+*************************************** Warning *******************************
+* To support C++11, the toolchain should be >= 4.7, please make sure your *
+* android NDK is at least r8e! *
+*******************************************************************************
+'''
+
+cmd.append('-n')
+
+p = subprocess.Popen(cmd, stdout = subprocess.PIPE)
+
+for flags in p.stdout.readlines():
+ if cmp(flags[0:10], 'TC_PREFIX=') == 0: # toolchain prefix (include path)
+ prefix = flags[10:].strip()
+ env.Replace(CC = prefix + 'gcc')
+ env.Replace(CXX = prefix + 'g++')
+ env.Replace(AR = prefix + 'ar')
+ env.Replace(RANLIB = prefix + 'ranlib')
+
+ elif cmp(flags[0:7], 'CFLAGS=') == 0:
+ env.AppendUnique(CFLAGS = Split(flags[7:]))
+
+ elif cmp(flags[0:9], 'CXXFLAGS=') == 0:
+ env.AppendUnique(CXXFLAGS = Split(flags[9:]))
+
+ elif cmp(flags[0:8], 'CPPPATH=') == 0:
+ env.AppendUnique(CPPPATH = Split(flags[8:]))
+
+ elif cmp(flags[0:8], 'SYSROOT=') == 0:
+ sysroot = flags[8:].strip()
+ env.AppendUnique(LINKFLAGS = ['--sysroot=' + sysroot])
+ env.AppendUnique(LIBPATH = [sysroot + '/usr/lib'])
+
+ elif cmp(flags[0:8], 'LDFLAGS=') == 0:
+ env.AppendUnique(LINKFLAGS = Split(flags[8:]))
+
+ elif cmp(flags[0:7], 'TC_VER=') == 0: # set gnustl library path
+ ver = flags[7:].strip()
+ env.AppendUnique(LIBPATH = [android_ndk + '/sources/cxx-stl/gnu-libstdc++/'
+ + ver + '/libs/' + target_arch])
+
+ elif cmp(flags[0:9], 'PLATFORM=') == 0: # get target platform: android-x
+ platform_ver = flags[9+8:].strip()
+ if not platform_ver.isdigit():
+ platform_ver = ''
+
+######################################################################
+# Set release/debug flags
+######################################################################
+
+if env.get('RELEASE'):
+ env.AppendUnique(CCFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ env.AppendUnique(LINKFLAGS = ['-s'])
+else:
+ env.AppendUnique(CCFLAGS = ['-g'])
+
+env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__ANDROID__','-DTB_LOG'])
+env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC','`pkg-config','--cflags','glib-2.0`'])
+env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread', '-lglib-2.0', '-lgthread-2.0', '-llog', '-landroid'])
+
+env.Append(LIBS=[
+ '-lglib-2.0', '-lgthread-2.0'
+])
+
+# From android-5 (API > 20), all application must be built with flags '-fPIE' '-pie'.
+# Due to the limitation of Scons, it's required to added it into the command line
+# directly (otherwise, it will also be added when build share library)
+env.Replace(CCCOM = '$CC -o $TARGET -c $CFLAGS $CCFLAGS $_CCCOMCOM -fPIE $SOURCES')
+env.Replace(CXXCOM = '$CXX -o $TARGET -c $CXXFLAGS $CCFLAGS $_CCCOMCOM -fPIE $SOURCES')
+env.Replace(LINKCOM = '$LINK -o $TARGET -pie $LINKFLAGS $__RPATH $SOURCES $_LIBDIRFLAGS $_LIBFLAGS')
\ No newline at end of file
--- /dev/null
+STEPS to setup Arduino on linux machine for building CA code:
+
+1) Download the Arduino package as per your system specification from the given link :
+ http://arduino.cc/en/main/software
+
+2) Unzip the downloaded package to some location say ARDUINO_DIR(This is the arduino installation directory).
+ ARDUINO_DIR = <PATH_TO_ARDUINO_INSTALL_DIR>/arduino-1.5.x
+
+3) Change permissions for executable in "ARDUINO_DIR"
+ chmod -R +x ./*
+
+4) ONE TIME ONLY - ADDITIONAL LIBRARIES
+ Arduino builds are dependent on latest Time library. Download it from here:
+ I. http://playground.arduino.cc/Code/Time
+ Place this library in the "ARDUINO_DIR/libraries/Time" folder where remaining libraries are present.
+ [P.S - The Time library files path should be as follows "ARDUINO_DIR/libraries/Time/Time/{***files***}"]
+
+5) ONE TIME ONLY - PATCH
+ Complete patch has been provided at : "connectivity\lib\arduino\arduino_libraries.patch"
+ Copy this patch file to "ARDUINO_DIR/libraries/"
+
+6) To apply patch give the command :
+ patch -p1 < arduino_libraries.patch
+ To undo the patch give the command :
+ patch -R -p1 < arduino_libraries.patch
+
+7) Launch Arduino IDE (required for logs and port and board selection.)
+ Goto to "ARDUINO_DIR" directory.
+ Launch command := sudo ./arduino
+
+8) Select your board and port under the tools option in Arduino IDE.
\ No newline at end of file
--- /dev/null
+##
+# This script includes arduino specific config
+##
+import os
+import platform
+
+Import('env')
+
+def __parse_config(f):
+ dict = {}
+
+ if not os.path.isfile(f):
+ return dict
+
+ file = open(f, 'r')
+ strs = file.readlines()
+ for str in strs:
+ str = str.strip()
+ if len(str) > 0 and str[0] == '#':
+ continue
+
+ idx = str.find('=')
+ if idx > 0:
+ dict.setdefault(str[0:idx], str[idx + 1:])
+
+ return dict
+
+def __get_boards(dict):
+ boards = []
+ keys = dict.keys()
+ for key in keys:
+ idx = key.find('.name')
+ if idx > 0:
+ if key.endswith('.name'):
+ boards.append(key[0:idx])
+ return boards
+
+def __get_cpu(dict, board):
+ cpus = []
+ keys = dict.keys()
+ for key in keys:
+ idx = key.find(board + '.menu.cpu.')
+ start = len(board + '.menu.cpu.')
+ if idx >= 0:
+ end = key.find('.', start)
+ if end > 0:
+ cpu = key[start:end]
+ exist = False
+ for c in cpus:
+ if c == cpu:
+ exist = True
+ break
+
+ if not exist:
+ cpus.append(cpu)
+ return cpus
+
+def __get_board_info(board, key):
+ if cpu:
+ v = boards_info.get(board + '.menu.cpu.' + cpu + key)
+ if not v:
+ v = boards_info.get(board + key)
+ else:
+ v = boards_info.get(board + key)
+ return v
+
+def __search_files(path, pattern, ondisk=True, source=True, strings=False, recursive=True):
+ if not recursive:
+ return Glob(pattern, ondisk, source, strings)
+
+ matches = []
+ for root, dirnames, filenames in os.walk(path):
+ #BLE library examples throw lot of errors. We dont need examples.
+ if 'examples' not in root:
+ matches.extend(Glob(root + '/' + pattern, ondisk, source, strings))
+ return matches
+
+# To make sure the src is built in 'BUILD_DIR' (by default it will be built at
+# the same directory as the .c .cpp .S)
+def __src_to_obj(env, srcs):
+ objs = []
+ prefix = env.get('BOARD') + '_'
+ if env.get('CPU'):
+ prefix += env.get('CPU') + '_'
+
+ build_dir = env.get('BUILD_DIR') + '/arduino/'
+ for src in srcs:
+ obj = src.path.replace(arduino_home, build_dir)
+ i = obj.rfind('.')
+ obj = obj[0:i]
+ if env.get('OBJSUFFIX'):
+ obj += env.get('OBJSUFFIX')
+ objs.extend(env.Object(obj, src, OBJPREFIX=prefix))
+ return objs
+
+def __import_lib(env, lib):
+ lib_path = arduino_home + '/libraries/' + lib
+ if not os.path.exists(lib_path):
+ if target_arch == 'avr':
+ lib_path = arduino_home + '/hardware/arduino/avr/libraries/' + lib
+ else:
+ lib_path = arduino_home + '/hardware/arduino/sam/libraries/' + lib
+
+ if os.path.exists(lib_path + '/src'):
+ lib_path = lib_path + '/src'
+
+ env.AppendUnique(CPPPATH = [lib_path])
+
+ if os.path.exists(lib_path + '/utility'):
+ env.AppendUnique(CPPPATH = [lib_path + '/utility'])
+
+ lib_src = []
+ lib_src.extend(__search_files(lib_path, '*.S'))
+ lib_src.extend(__search_files(lib_path, '*.c'))
+ lib_src.extend(__search_files(lib_path, '*.cpp'))
+
+ build_dir = env.get('BUILD_DIR')
+ if build_dir:
+ lib_a = env.StaticLibrary(build_dir + lib, __src_to_obj(env, lib_src))
+ else:
+ lib_a = env.StaticLibrary(lib, __src_to_obj(env, lib_src))
+ env.PrependUnique(LIBS = [File(lib_a[0])])
+
+def __build_core(env):
+ core_src = __search_files(core_folder, '*.S')
+ core_src.extend(__search_files(core_folder, '*.c'))
+ core_src.extend(__search_files(core_folder, '*.cpp'))
+
+ core_src.extend(__search_files(variant_folder, '*.S'))
+ core_src.extend(__search_files(variant_folder, '*.c'))
+ core_src.extend(__search_files(variant_folder, '*.cpp'))
+
+ core_obj = __src_to_obj(env, core_src)
+ build_dir = env.get('BUILD_DIR')
+ if build_dir:
+ s_core = env.StaticLibrary(build_dir + 'core', core_obj)
+ else:
+ s_core = env.StaticLibrary('core', core_obj)
+ env.AppendUnique(LIBS = [File(s_core[0])])
+
+ # To avoid compiler issue. Otherewise there may be warnings:
+ # undefined reference to '_exit' '_close', '_getpid' ...
+ # Above functions are used in libc.a and implemented in syscalls_sam3.c
+ if env.get('TARGET_ARCH') == 'arm':
+ for obj in core_obj:
+ if obj.name.endswith('syscalls_sam3.o'):
+ env.AppendUnique(LIBS = [File(obj)])
+
+def __create_bin(env, source):
+ name = source
+ if target_arch == 'avr':
+ eep = env.Command(name + '.eep', source, 'avr-objcopy -O ihex -j .eeprom --set-section-flags=.eeprom=alloc,load --no-change-warnings --change-section-lma .eeprom=0 $SOURCE $TARGET')
+ hex = env.Command(name + '.hex', source, 'avr-objcopy -O ihex -R .eeprom $SOURCE $TARGET')
+ else:
+ hex = env.Command(name + '.hex', source, 'arm-none-eabi-objcopy -O binary $SOURCE $TARGET')
+
+#Currently supporting only megaADK build
+def __upload(env, binary):
+ if target_arch == 'avr':
+ protocol = __get_board_info(board, '.upload.protocol')
+ speed = __get_board_info(board, '.upload.speed')
+ port = '/dev/ttyACM0'
+ upload_cmd = 'sudo ' + arduino_home + '/hardware/tools/avr/bin/avrdude -C' + arduino_home +'/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -p' \
+ + mcu + ' -c' + protocol + ' -P' + port + ' -b' + speed + ' -D -Uflash:w:' + binary + ':i'
+
+ print "Upload command: %s" %upload_cmd
+ install_cmd = env.Command('install_cmd', None, upload_cmd)
+ env.Default('install_cmd')
+
+# Print the command line that to upload binary to the board
+def __upload_help(env):
+ if target_arch == 'avr':
+ protocol = __get_board_info(board, '.upload.protocol')
+ speed = __get_board_info(board, '.upload.speed')
+
+ upload_cmd = arduino_home + '/hardware/tools/avr/bin/avrdude -C' + arduino_home +'/hardware/tools/avr/etc/avrdude.conf -v -v -v -v -p' \
+ + mcu + ' -c' + protocol + ' -P<serial_port>' + ' -b' + speed + ' -D -Uflash:w:<hex_file>:i'
+ else:
+ uu = __get_board_info(board, '.upload.native_usb')
+ upload_cmd = arduino_home + '/hardware/tools/bossac -i -d --port=<serial_port> -U ' + uu + ' -e -w -v -b <bin file> -R'
+
+ Help('''
+===============================================================================
+You can upload the bin file with following command line:
+''')
+ Help('\n $ ' + upload_cmd)
+ Help('''
+\nPlease replace <xxx> according to the actual situation.
+===============================================================================
+''')
+
+# ARDUINO_HOME build option
+help_vars = Variables()
+help_vars.Add(PathVariable('ARDUINO_HOME', 'ARDUINO root directory', os.environ.get('ARDUINO_HOME')))
+help_vars.Update(env)
+Help(help_vars.GenerateHelpText(env))
+
+target_arch = env.get('TARGET_ARCH')
+arduino_home = env.get('ARDUINO_HOME')
+if not arduino_home:
+ print '''
+************************************* Error ***********************************
+* Arduino root directory isn't set, you can set enviornment variable *
+* ARDUINO_HOME or add it in command line as: *
+* # scons ARDUINO_HOME=<path to arduino root directory> ... *
+*******************************************************************************
+'''
+ Exit(1)
+
+# Overwrite suffixes and prefixes
+if env['HOST_OS'] == 'win32':
+ env['OBJSUFFIX'] = '.o'
+ env['SHOBJSUFFIX'] = '.os'
+ env['LIBPREFIX'] = 'lib'
+ env['LIBSUFFIX'] = '.a'
+ env['SHLIBPREFIX'] = 'lib'
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBPREFIXES'] = ['lib']
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+elif platform.system().lower() == 'darwin':
+ env['SHLIBSUFFIX'] = '.so'
+ env['LIBSUFFIXES'] = ['.a', '.so']
+ env['PROGSUFFIX'] = ''
+
+# Debug/release relative flags
+if env.get('RELEASE'):
+ env.AppendUnique(CCFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+else:
+ env.AppendUnique(CCFLAGS = ['-g'])
+
+# BOARD / CPU option
+
+# Get IDE version
+if os.path.exists(arduino_home + '/lib/version.txt'):
+ vf = open(arduino_home + '/lib/version.txt', 'r')
+ version = vf.readline().replace('.', '')
+else:
+ print '''
+************************************* Error ***********************************
+* Can't find version file (lib/version.txt), please check if (%s)
+* is arduino root directory. *
+*******************************************************************************
+''' % arduino_home
+ Exit(1)
+
+if version[0:2] == '10':
+ is_1_0_x = True
+ boards_info = __parse_config(arduino_home + '/hardware/arduino/boards.txt')
+ env.PrependENVPath('PATH', arduino_home + '/hardware/tools/avr/bin/')
+ env.Replace(CC = 'avr-gcc')
+ env.Replace(CXX = 'avr-gcc')
+ env.Replace(AR = 'avr-ar')
+ env.Replace(AS = 'avr-as')
+ env.Replace(LINK = 'avr-gcc')
+ env.Replace(RANLIB = 'avr-ranlib')
+ if target_arch != 'avr':
+ print '''
+************************************* Error ***********************************
+* Arduino 1.0.x IDE only support 'avr', to support other arch at least 1.5.x *
+* is required.
+*******************************************************************************
+'''
+ Exit(1)
+else:
+ is_1_0_x = False
+ if target_arch == 'avr':
+ boards_info = __parse_config(arduino_home + '/hardware/arduino/avr/boards.txt')
+ platform_info = __parse_config(arduino_home + '/hardware/arduino/avr/platform.txt')
+ elif target_arch == 'arm':
+ boards_info = __parse_config(arduino_home + '/hardware/arduino/sam/boards.txt')
+ platform_info = __parse_config(arduino_home + '/hardware/arduino/sam/platform.txt')
+ else:
+ print '''
+************************************* Error ***********************************
+* CPU arch %s isn't supported currently.
+*******************************************************************************
+''' % target_arch
+
+#Board option, let user to select the board
+boards = __get_boards(boards_info)
+help_vars = Variables()
+help_vars.Add(EnumVariable('BOARD', 'arduino board', boards[0], boards))
+help_vars.Update(env)
+Help(help_vars.GenerateHelpText(env))
+
+#CPU option
+board = env.get('BOARD')
+cpus = __get_cpu(boards_info, board)
+if len(cpus) > 0:
+ help_vars = Variables()
+ help_vars.Add(EnumVariable('CPU', 'arduino board cpu', cpus[0], cpus))
+ help_vars.Update(env)
+ Help(help_vars.GenerateHelpText(env))
+
+# Arduino commom flags
+cpu = env.get('CPU')
+board = env.get('BOARD')
+mcu = __get_board_info(board, '.build.mcu')
+f_cpu = __get_board_info(board, '.build.f_cpu')
+usb_vid = __get_board_info(board, '.build.vid')
+usb_pid = __get_board_info(board, '.build.pid')
+variant = __get_board_info(board, '.build.variant')
+
+if not usb_vid:
+ usb_vid = __get_board_info(board, '.vid.0')
+if not usb_pid:
+ usb_pid = __get_board_info(board, '.pid.0')
+
+if is_1_0_x:
+ core_base = arduino_home + '/hardware/arduino/'
+else:
+ if target_arch == 'avr':
+ core_base = arduino_home + '/hardware/arduino/avr/'
+ else:
+ core_base = arduino_home + '/hardware/arduino/sam/'
+
+variant_folder = core_base + 'variants/' + variant
+env.AppendUnique(CPPPATH = [variant_folder])
+
+core = __get_board_info(board, '.build.core')
+core_folder = core_base + 'cores/' + core + '/'
+env.AppendUnique(CPPPATH = [core_folder])
+
+if is_1_0_x:
+ comm_flags = []
+ if mcu:
+ comm_flags.extend(['-mmcu=' + mcu])
+ if f_cpu:
+ comm_flags.extend(['-DF_CPU=' + f_cpu])
+ comm_flags.extend(['-DARDUINO=' + version])
+ if usb_vid:
+ comm_flags.extend(['-DUSB_VID=' + usb_vid])
+ if usb_pid:
+ comm_flags.extend(['-DUSB_PID=' + usb_pid])
+
+ env.AppendUnique(ASFLAGS = ['-x', 'assembler-with-cpp'])
+ env.AppendUnique(ASFLAGS = comm_flags)
+
+ env.AppendUnique(CFLAGS = ['-Os', '-ffunction-sections', '-fdata-sections', '-MMD'])
+ env.AppendUnique(CFLAGS = comm_flags)
+
+ env.AppendUnique(CXXFLAGS = ['-Os', '-fno-exceptions', '-ffunction-sections', '-fdata-sections','-MMD'])
+ env.AppendUnique(CXXFLAGS = comm_flags)
+
+ env.AppendUnique(LINKFLAGS = ['-Os'])
+ if mcu == 'atmega2560':
+ env.AppendUnique(LINKFLAGS = ['-Wl,--gc-sections,--relax'])
+ else:
+ env.AppendUnique(LINKFLAGS = ['-Wl,--gc-sections'])
+ env.AppendUnique(LINKFLAGS = ['-mmcu=' + mcu])
+else:
+ if target_arch == 'avr':
+ cpu_flag = '-mmcu=' + mcu
+ else:
+ cpu_flag = '-mcpu=' + mcu
+
+ comm_flag = [cpu_flag, '-DF_CPU=' + f_cpu, '-DARDUINO=' + version, '-DARDUINO_' + __get_board_info(board, '.build.board')]
+ if target_arch == 'arm':
+ comm_flag.extend(['-DARDUINO_ARCH_SAM'])
+ else:
+ comm_flag.extend(['-DARDUINO_ARCH_AVR'])
+
+ compiler_path = platform_info.get('compiler.path')
+ compiler_path = compiler_path.replace('{runtime.ide.path}', arduino_home)
+ env.PrependENVPath('PATH', compiler_path)
+ env.Replace(CC = platform_info.get('compiler.c.cmd'))
+ env.Replace(CXX = platform_info.get('compiler.cpp.cmd'))
+ env.Replace(AR = platform_info.get('compiler.ar.cmd'))
+ if target_arch == 'arm':
+ env.AppendUnique(CPPPATH = [arduino_home + '/hardware/arduino/sam/system/libsam',
+ arduino_home + '/hardware/arduino/sam/system/CMSIS/CMSIS/Include/',
+ arduino_home + '/hardware/arduino/sam/system//CMSIS/Device/ATMEL'])
+ env.AppendUnique(ASFLAGS = ['-x', 'assembler-with-cpp'])
+ env.AppendUnique(ASFLAGS = comm_flag)
+ env.AppendUnique(CFLAGS = Split(platform_info.get('compiler.c.flags')))
+ env.AppendUnique(CXXFLAGS = Split(platform_info.get('compiler.cpp.flags')))
+ env.AppendUnique(ARFLAGS = Split(platform_info.get('compiler.ar.flags')))
+ env.AppendUnique(CCFLAGS = comm_flag)
+
+ extra_flags = __get_board_info(board, '.build.extra_flags')
+ if extra_flags:
+ extra_flags = extra_flags.replace('{build.usb_flags}', '')
+ env.AppendUnique(CCFLAGS = Split(extra_flags))
+ usb_flags = ['-DUSB_VID=' + usb_vid, '-DUSB_PID=' + usb_pid, '-DUSBCON', '-DUSB_MANUFACTURER="Unknown"']
+ env.AppendUnique(CCFLAGS = usb_flags)
+
+ if target_arch == 'arm':
+ env.AppendUnique(LINKFLAGS = ['-Os', '-Wl,--gc-sections', cpu_flag,
+ '-T' + variant_folder + '/' + __get_board_info(board, '.build.ldscript'),
+ '-Wl,-Map,' + env.get('BUILD_DIR') + 'arduino_prj.map'])
+ env.AppendUnique(LINKFLAGS = Split('-lm -lgcc -mthumb -Wl,--cref -Wl,--check-sections -Wl,--gc-sections -Wl,--entry=Reset_Handler -Wl,--unresolved-symbols=report-all -Wl,--warn-common -Wl,--warn-section-align -Wl,--warn-unresolved-symbols -Wl,--start-group'))
+
+ variant_system_lib = __get_board_info(board, '.build.variant_system_lib')
+ if variant_system_lib:
+ if variant_folder.find(' ') >= 0:
+ variant_folder = '"' + variant_folder + '"'
+ env.Replace(LINKCOM = '$LINK -o $TARGET $_LIBDIRFLAGS $LINKFLAGS $SOURCES $_LIBFLAGS '
+ + variant_folder + '/' + variant_system_lib + ' -Wl,--end-group')
+ else:
+ env.Replace(LINKCOM = '$LINK -o $TARGET $_LIBDIRFLAGS $LINKFLAGS $SOURCES $_LIBFLAGS -Wl,--end-group')
+ else:
+ env.AppendUnique(LINKFLAGS = Split(platform_info.get('compiler.c.elf.flags')))
+ env.AppendUnique(LINKFLAGS = [cpu_flag])
+ env.AppendUnique(LIBS = 'm')
+ env.Replace(ARCOM = '$AR ' + platform_info.get('compiler.ar.flags') + ' $TARGET $SOURCES')
+
+__build_core(env)
+
+env.AddMethod(__import_lib, "ImportLib") #import arduino library
+#env.AddMethod(__build_core, "BuildCore") #build arduino core
+env.AddMethod(__create_bin, "CreateBin") #create binary files(.eep and .hex)
+env.AddMethod(__upload, "Upload") #Upload binary to board
+env.AddMethod(__upload_help, "UploadHelp") #print the command line that to upload binary to the boardf
--- /dev/null
+##
+# This script includes arduino specific config for oic-resource
+##
+Import('env')
+
+env.ImportLib('SPI')
+if 'ETHERNET' in env.get('TARGET_TRANSPORT'):
+ env.ImportLib('Ethernet')
+if 'WIFI' in env.get('TARGET_TRANSPORT'):
+ env.ImportLib('WiFi')
+if 'BLE' in env.get('TARGET_TRANSPORT'):
+ env.ImportLib('BLE')
+ env.ImportLib('RBL_nRF8001')
+
+env.ImportLib('Time/Time')
+# we have variety of macros for arduino!!
+env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__', 'TB_LOG'])
--- /dev/null
+##
+# This script set linux specific flags (GNU GCC)
+#
+##
+Import('env')
+
+print "Reading linux configuration script"
+
+# Set release/debug flags
+if env.get('RELEASE'):
+ env.AppendUnique(CCFLAGS = ['-Os'])
+ env.AppendUnique(CPPDEFINES = ['NDEBUG'])
+ env.AppendUnique(LINKFLAGS = ['-s'])
+else:
+ env.AppendUnique(CCFLAGS = ['-g'])
+
+env.AppendUnique(CPPDEFINES = ['WITH_POSIX', '__LINUX__','-DTB_LOG'])
+env.AppendUnique(CCFLAGS = ['-Wall', '-fPIC','`pkg-config','--cflags','glib-2.0`'])
+env.AppendUnique(LINKFLAGS = ['-ldl', '-lpthread', '-lglib-2.0', '-lgthread-2.0'])
+
+env.Append(LIBS=[
+ '-lglib-2.0', '-lgthread-2.0'
+])
+
+# Set arch flags
+target_arch = env.get('TARGET_ARCH')
+if target_arch in ['x86']:
+ env.AppendUnique(CCFLAGS = ['-m32'])
+ env.AppendUnique(LINKFLAGS = ['-m32'])
+elif target_arch in ['x86_64']:
+ env.AppendUnique(CCFLAGS = ['-m64'])
+ env.AppendUnique(LINKFLAGS = ['-m64'])
+elif target_arch.find('v7a-hard') > 0:
+ env.AppendUnique(CPPFLAGS = ['-march=armv7-a'])
+ env.AppendUnique(CPPFLAGS = ['-mfloat-abi=hard'])
+ env.AppendUnique(CCFLAGS = ['-mfloat-abi=hard'])
+ env.AppendUnique(LINKFLAGS = ['-mfloat-abi=hard'])
+elif target_arch.find('v7a') > 0:
+ env.AppendUnique(CPPFLAGS = ['-march=armv7-a'])
+elif target_arch.find('arm64') > 0:
+ env.AppendUnique(CPPFLAGS = ['-march=armv8-a'])
+else:
+ env.AppendUnique(CPPFLAGS = ['-march=armv5te'])
+++ /dev/null
-Compiling Interface APIs FOR TIZEN:
-===================================
-1) Get the latest interface APIs code from repo and build it in Tizen GBS[connectivity/build]
- To Build in Tizen GBS Platform, Use this command "sudo make PLATFORM=tizen" from the above directory.
-
- By Default, "ALL" the TRANSPORTS are built. To build a specific TRANSPORT [BT,BLE,WIFI], use the following command :
- sudo make PLATFORM=tizen TRANSPORT=BLE
-
- [Note: Combination of Transports can be build by giving the option as TRANSPORT=BLE,BT. Transport names are case insensitive]
-
-2) For Verification, Build Sample Console App and execute in Tizen Device.
-
-Note:
-====
-For Tizen BLE, please copy headers present in "external\headers\include" folder to your GBS configuration(GBS has old BLE headers).
\ No newline at end of file
--- /dev/null
+##
+# This script includes generic build options:
+# release/debug, target os, target arch, cross toolchain, build environment etc
+##
+import os
+import platform
+
+# Map of host os and allowed target os (host: allowed target os)
+host_target_map = {
+ 'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
+ 'windows': ['windows', 'winrt', 'android', 'arduino', 'tizen'],
+ 'darwin': ['darwin', 'ios', 'android', 'arduino'],
+ }
+
+# Map of os and allowed archs (os: allowed archs)
+os_arch_map = {
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+ 'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
+ 'windows': ['x86', 'amd64', 'arm'],
+ 'winrt': ['arm'],
+ 'darwin': ['i386', 'x86_64'],
+ 'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+ 'arduino': ['avr', 'arm'],
+ 'yocto': ['x86', 'x86_64'],
+ 'tizen': ['armv7'],
+ }
+
+host = platform.system().lower()
+
+if not host_target_map.has_key(host):
+ print "\nError: Current system (%s) isn't supported\n" % host
+ Exit(1)
+
+######################################################################
+# Get build options (the optins from command line)
+######################################################################
+target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
+
+if target_os not in host_target_map[host]:
+ print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
+ Exit(1)
+
+default_arch = platform.machine()
+if default_arch not in os_arch_map[target_os]:
+ default_arch = os_arch_map[target_os][0].lower()
+
+target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
+
+######################################################################
+# Common build options (release, target os, target arch)
+######################################################################
+help_vars = Variables()
+help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
+help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
+help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'WIFI', 'ETHERNET', 'BT', 'BLE']))
+help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+help_vars.Add(EnumVariable('BUILD_SAMPLE', 'Build with sample', 'ON', allowed_values=('ON', 'OFF')))
+
+######################################################################
+# Platform(build target) specific options: SDK/NDK & toolchain
+######################################################################
+targets_support_cc = ['linux', 'arduino', 'tizen']
+
+if target_os in targets_support_cc:
+ # Set cross compile toolchain
+ help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
+ help_vars.Add(PathVariable('TC_PATH',
+ 'Toolchain path (Generally only be required for cross-compiling)',
+ os.environ.get('TC_PATH')))
+
+if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
+ env = Environment(variables = help_vars,
+ tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
+ )
+else:
+ env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+
+Help(help_vars.GenerateHelpText(env))
+
+tc_set_msg = '''
+************************************ Warning **********************************
+* Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default *
+* toolchain, if it isn't what you expect you should unset it, otherwise it may*
+* cause inexplicable errors. *
+*******************************************************************************
+'''
+
+if target_os in targets_support_cc:
+ prefix = env.get('TC_PREFIX')
+ tc_path = env.get('TC_PATH')
+ if prefix:
+ env.Replace(CC = prefix + 'gcc')
+ env.Replace(CXX = prefix + 'g++')
+ env.Replace(AR = prefix + 'ar')
+ env.Replace(AS = prefix + 'as')
+ env.Replace(LINK = prefix + 'ld')
+ env.Replace(RANLIB = prefix + 'ranlib')
+
+ if tc_path:
+ env.PrependENVPath('PATH', tc_path)
+ sys_root = os.path.abspath(tc_path + '/../')
+ env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
+ env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+ if prefix or tc_path:
+ print tc_set_msg
+
+# Ensure scons be able to change its working directory
+env.SConscriptChdir(1)
+
+# Set the source directory and build directory
+# Source directory: 'dir'
+# Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
+#
+# You can get the directory as following:
+# env.get('SRC_DIR')
+# env.get('BUILD_DIR')
+
+def __set_dir(env, dir):
+ if not os.path.exists(dir + '/SConstruct'):
+ print '''
+*************************************** Error *********************************
+* The directory(%s) seems isn't a source code directory, no SConstruct file is
+* found. *
+*******************************************************************************
+''' % dir
+ Exit(1)
+
+ if env.get('RELEASE'):
+ build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
+ else:
+ build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
+ env.VariantDir(build_dir, dir, duplicate=0)
+
+ env.Replace(BUILD_DIR = build_dir)
+ env.Replace(SRC_DIR = dir)
+
+def __src_to_obj(env, src, home = ''):
+ obj = env.get('BUILD_DIR') + src.replace(home, '')
+ if env.get('OBJSUFFIX'):
+ obj += env.get('OBJSUFFIX')
+ return env.Object(obj, src)
+
+def __install(ienv, targets, name):
+ i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+ Alias(name, i_n)
+ env.AppendUnique(TS = [name])
+
+def __append_target(ienv, target):
+ env.AppendUnique(TS = [target])
+
+def __print_targets(env):
+ Help('''
+===============================================================================
+Targets:\n ''')
+ for t in env.get('TS'):
+ Help(t + ' ')
+ Help('''
+\nDefault all targets will be built. You can specify the target to build:
+
+ $ scons [options] [target]
+===============================================================================
+''')
+
+env.AddMethod(__set_dir, 'SetDir')
+env.AddMethod(__print_targets, 'PrintTargets')
+env.AddMethod(__src_to_obj, 'SrcToObj')
+env.AddMethod(__append_target, 'AppendTarget')
+env.AddMethod(__install, 'InstallTarget')
+env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()
+
+Export('env')
+
+######################################################################
+# Link scons to Yocto cross-toolchain ONLY when target_os is yocto
+######################################################################
+if target_os == "yocto":
+ '''
+ This code injects Yocto cross-compilation tools+flags into scons'
+ build environment in order to invoke the relevant tools while
+ performing a build.
+ '''
+ import os.path
+ try:
+ CC = os.environ['CC']
+ target_prefix = CC.split()[0]
+ target_prefix = target_prefix[:len(target_prefix)-3]
+ tools = {"CC" : target_prefix+"gcc",
+ "CXX" : target_prefix+"g++",
+ "AS" : target_prefix+"as",
+ "LD" : target_prefix+"ld",
+ "GDB" : target_prefix+"gdb",
+ "STRIP" : target_prefix+"strip",
+ "RANLIB" : target_prefix+"ranlib",
+ "OBJCOPY" : target_prefix+"objcopy",
+ "OBJDUMP" : target_prefix+"objdump",
+ "AR" : target_prefix+"ar",
+ "NM" : target_prefix+"nm",
+ "M4" : "m4",
+ "STRINGS": target_prefix+"strings"}
+ PATH = os.environ['PATH'].split(os.pathsep)
+ for tool in tools:
+ if tool in os.environ:
+ for path in PATH:
+ if os.path.isfile(os.path.join(path, tools[tool])):
+ env[tool] = os.path.join(path, os.environ[tool])
+ break
+ except:
+ print "ERROR in Yocto cross-toolchain environment"
+ Exit(1)
+ '''
+ Now reset TARGET_OS to linux so that all linux specific build configurations
+ hereupon apply for the entirety of the build process.
+ '''
+ env['TARGET_OS'] = 'linux'
+ '''
+ We want to preserve debug symbols to allow BitBake to generate both DEBUG and
+ RELEASE packages for OIC.
+ '''
+ env['CCFLAGS'].append('-g')
+ Export('env')
+else:
+ '''
+ If target_os is not Yocto, continue with the regular build process
+ '''
+ # Load config of target os
+ env.SConscript(target_os + '/SConscript')
+
+# Delete the temp files of configuration
+if env.GetOption('clean'):
+ dir = env.get('SRC_DIR')
+
+ if os.path.exists(dir + '/config.log'):
+ Execute(Delete(dir + '/config.log'))
+ Execute(Delete(dir + '/.sconsign.dblite'))
+ Execute(Delete(dir + '/.sconf_temp'))
+
+Return('env')
--- /dev/null
+##
+# The main build script
+#
+##
+
+# Load common build config
+
+# Load common build config
+env = SConscript('SConscript')
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+
+print "Given Transport is %s" % transport
+print "Given OS is %s" % target_os
+
+env.SConscript('scons/SConscript')
--- /dev/null
+##
+# 'resource' sub-project main build script
+#
+##
+
+Import('env')
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+
+print "Given Transport is %s" % transport
+
+env.AppendUnique(CFLAGS = ['-std=c99', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE', '-DTB_LOG','`pkg-config', '--cflags', '--libs','capi-network-wifi', 'dlog',
+ 'glib-2.0`'])
+
+
+if 'ALL' in transport:
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER'])
+ print "CA Transport is ALL"
+else:
+ if 'BT' in transport:
+ env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER'])
+ print "CA Transport is BT"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
+
+ if 'BLE' in transport:
+ env.AppendUnique(CPPDEFINES = ['LE_ADAPTER'])
+ print "CA Transport is BLE"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
+
+ if 'WIFI' in transport:
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER'])
+ print "CA Transport is WIFI"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_WIFI_ADAPTER'])
+
+
+env.SConscript(['../con/lib/libcoap-4.1.1/SConscript'])
+env.SConscript(['../con/SConscript'])
--- /dev/null
+##
+# CA build script
+##
+
+Import('env')
+
+print "Reading common folder script"
+
+ca_os = env.get('TARGET_OS')
+root_dir = './'
+ca_common_path = root_dir + '/common/'
+ca_common_src_path = ca_common_path + 'src/'
+
+env.AppendUnique(CPPPATH = [
+ ca_common_path + 'inc/',
+ ])
+
+######################################################################
+# Source files and Target(s)
+######################################################################
+ca_common_src = [
+ ca_common_src_path + 'oic_malloc.c',
+ ca_common_src_path + 'oic_string.c',
+ ca_common_src_path + 'uarraylist.c',
+ ca_common_src_path + 'uqueue.c',
+ ]
+
+if ca_os == 'arduino':
+ platform_src = [
+ ca_common_src_path + 'logger.cpp',
+ ]
+else:
+ platform_src = [
+ ca_common_src_path + 'logger.c',
+ ca_common_src_path + 'oic_logger.c',
+ ca_common_src_path + 'oic_console_logger.c',
+ ca_common_src_path + 'umutex.c',
+ ca_common_src_path + 'uthreadpool.c',
+ ]
+
+env.AppendUnique(CA_SRC = ca_common_src)
+env.AppendUnique(CA_SRC = platform_src)
--- /dev/null
+//******************************************************************
+//
+// Copyright 2014 Intel Corporation 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.
+//
+//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+
+#ifndef OC_SECURITY_CONFIG_H
+#define OC_SECURITY_CONFIG_H
+
+#include <stdint.h>
+
+#define DTLS_PSK_ID_LEN 16
+#define DTLS_PSK_PSK_LEN 16
+
+#define DtlsPskCredsBlobVer_1 1 /**< Credentials stored in plaintext */
+#define DtlsPskCredsBlobVer_CurrentVersion DtlsPskCredsBlobVer_1
+
+/**
+ * Credentials for a device. Includes identity and the associated PSK.
+ */
+typedef struct
+{
+ unsigned char id[DTLS_PSK_ID_LEN];
+ unsigned char psk[DTLS_PSK_PSK_LEN];
+} OCDtlsPskCreds;
+
+/**
+ * Binary blob containing device identity and the credentials for all devices
+ * trusted by this device.
+ */
+typedef struct
+{
+ uint16_t blobVer; /**< version of the blob */
+ uint16_t reserved; /**< reserved for future use */
+ unsigned char identity[DTLS_PSK_ID_LEN]; /**< identity of self */
+ uint32_t num; /**< number of credentials in this blob */
+ OCDtlsPskCreds *creds; /**< list of credentials. Size of this
+ array is determined by 'num' variable. */
+} OCDtlsPskCredsBlob;
+
+
+#endif //OC_SECURITY_CONFIG_H
+
+
#include "umutex.h"
#include "caadapterutils.h"
#include "ocsecurityconfig.h"
+#include "cainterface.h"
#define MAX_SUPPORTED_ADAPTERS 2
* @retval void
*
*/
-
void CADTLSSetAdapterCallbacks(CAPacketReceivedCallback recvCallback,
CAPacketSendCallback sendCallback, eDtlsAdapterType_t type);
/**
+ * @brief Register callback to get DTLS PSK credentials.
+ * @param credCallback [IN] callback to get DTLS credentials
+ * @retval void
+ */
+void CADTLSSetCredentialsCallback(CAGetDTLSCredentialsHandler credCallback);
+
+/**
* @fn CAAdapterNetDtlsInit
* @brief initialize tinyDTLS library and other necessary intialization.
*
OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
return CA_STATUS_INVALID_PARAM; \
} \
-
+
/**
* @def VERIFY_NON_NULL_RET
* @brief Macro to verify the validity of input argument
OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
return ret; \
} \
-
+
/**
* @def VERIFY_NON_NULL_VOID
* @brief Macro to verify the validity of input argument
OIC_LOG_V(ERROR, log_tag, "Invalid input:%s", log_message); \
return; \
} \
-
+
/**
* @fn CAAdapterCreateLocalEndpoint
* @brief Create CALocalConnectivity_t instance.
--- /dev/null
+diff -rupN RBL_nRF8001_old/RBL_nRF8001.cpp RBL_nRF8001_new/RBL_nRF8001.cpp
+--- RBL_nRF8001_old/RBL_nRF8001.cpp 2015-01-06 15:38:21.000000000 +0530
++++ RBL_nRF8001_new/RBL_nRF8001.cpp 2015-01-06 15:39:20.000000000 +0530
+@@ -22,7 +22,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOU
+ #endif
+
+ /* Store the setup for the nRF8001 in the flash of the AVR to save on RAM */
+-static hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;
++static const hal_aci_data_t setup_msgs[NB_SETUP_MESSAGES] PROGMEM = SETUP_MESSAGES_CONTENT;
+
+ #if defined(BLEND_MICRO)
+ static char device_name[11] = "BlendMicro";
+@@ -31,7 +31,10 @@ static char device_name[11] = "Blend
+ #else
+ static char device_name[11] = "BLE Shield";
+ #endif
+-
++
++#define BLE_ADDRESS_SIZE 18
++static unsigned char *gLeAddress = NULL;
++
+ static uint16_t Adv_Timeout = 0; // Advertising all the time
+ static uint16_t Adv_Interval = 0x0050; /* advertising interval 50ms
+
+@@ -117,7 +120,7 @@ void ble_begin()
+ aci_state.aci_setup_info.services_pipe_type_mapping = NULL;
+ }
+ aci_state.aci_setup_info.number_of_pipes = NUMBER_OF_PIPES;
+- aci_state.aci_setup_info.setup_msgs = setup_msgs;
++ aci_state.aci_setup_info.setup_msgs = (hal_aci_data_t*)setup_msgs;
+ aci_state.aci_setup_info.num_setup_msgs = NB_SETUP_MESSAGES;
+
+ /*
+@@ -236,6 +239,10 @@ void ble_reset(uint8_t reset_pin)
+ void ble_disconnect(void)
+ {
+ lib_aci_disconnect(&aci_state, ACI_REASON_TERMINATE);
++ if (NULL != gLeAddress)
++ {
++ free(gLeAddress);
++ }
+ }
+
+ static void process_events()
+@@ -271,6 +278,7 @@ static void process_events()
+ lib_aci_set_local_data(&aci_state, PIPE_GAP_DEVICE_NAME_SET , (uint8_t *)&device_name , strlen(device_name));
+ lib_aci_connect(Adv_Timeout/* in seconds */, Adv_Interval /* advertising interval 50ms*/);
+ Serial.println(F("Advertising started"));
++ lib_aci_get_address();
+ }
+ break;
+ }
+@@ -294,6 +302,32 @@ static void process_events()
+ lib_aci_set_local_data(&aci_state, PIPE_DEVICE_INFORMATION_HARDWARE_REVISION_STRING_SET,
+ (uint8_t *)&(aci_evt->params.cmd_rsp.params.get_device_version), sizeof(aci_evt_cmd_rsp_params_get_device_version_t));
+ }
++
++ if (ACI_CMD_GET_DEVICE_ADDRESS == aci_evt->params.cmd_rsp.cmd_opcode)
++ {
++ if (NULL != gLeAddress)
++ {
++ free(gLeAddress);
++ }
++ gLeAddress = (unsigned char *) malloc (BLE_ADDRESS_SIZE);
++ if (NULL == gLeAddress)
++ {
++ Serial.println("error");
++ break;
++ }
++ char *tempAddr = (char *) gLeAddress;
++ int8_t iter = 0;
++ for (iter = BTLE_DEVICE_ADDRESS_SIZE - 1; iter >= 0; iter--)
++ {
++ sprintf(tempAddr, "%02x%c",
++ (uint8_t)aci_evt->params.cmd_rsp.params.get_device_address.bd_addr_own[iter], 58);
++ tempAddr += 3;
++ }
++ gLeAddress[BLE_ADDRESS_SIZE - 1] = '\0';
++ Serial.println("LEAddress :");
++ Serial.println((char *)gLeAddress);
++ return;
++ }
+ break;
+
+ case ACI_EVT_CONNECTED:
+@@ -471,3 +505,7 @@ void ble_do_events()
+ #endif
+ }
+
++unsigned char* ble_getAddress()
++{
++ return gLeAddress;
++}
+diff -rupN RBL_nRF8001_old/RBL_nRF8001.h RBL_nRF8001_new/RBL_nRF8001.h
+--- RBL_nRF8001_old/RBL_nRF8001.h 2015-01-06 15:38:21.000000000 +0530
++++ RBL_nRF8001_new/RBL_nRF8001.h 2015-01-06 14:48:20.000000000 +0530
+@@ -48,6 +48,7 @@ void ble_set_pins(uint8_t reqn, uint8_t
+ unsigned char ble_busy();
+ void ble_reset(uint8_t reset_pin);
+ void ble_disconnect(void);
++unsigned char* ble_getAddress();
+
+ #endif
+
+Binary files RBL_nRF8001_old/SI/Untitled Project.IAB and RBL_nRF8001_new/SI/Untitled Project.IAB differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.IAD and RBL_nRF8001_new/SI/Untitled Project.IAD differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.IMB and RBL_nRF8001_new/SI/Untitled Project.IMB differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.IMD and RBL_nRF8001_new/SI/Untitled Project.IMD differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.PFI and RBL_nRF8001_new/SI/Untitled Project.PFI differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.PO and RBL_nRF8001_new/SI/Untitled Project.PO differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.PR and RBL_nRF8001_new/SI/Untitled Project.PR differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.PRI and RBL_nRF8001_new/SI/Untitled Project.PRI differ
+Binary files RBL_nRF8001_old/SI/Untitled Project.PS and RBL_nRF8001_new/SI/Untitled Project.PS differ
--- /dev/null
+External libs for arduino platform
+
-diff -rupN /Ethernet/src/Ethernet.cpp /Ethernet/src/Ethernet.cpp
---- /Ethernet/src/Ethernet.cpp 2014-10-01 20:45:35.000000000 +0530
-+++ /Ethernet/src/Ethernet.cpp 2014-12-12 16:39:26.000000000 +0530
+diff -rupN ./Ethernet/src/Ethernet.cpp ../../arduino-1.5.8/libraries/Ethernet/src/Ethernet.cpp
+--- ./Ethernet/src/Ethernet.cpp 2014-10-01 20:45:35.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Ethernet/src/Ethernet.cpp 2014-12-12 16:39:26.000000000 +0530
@@ -7,10 +7,11 @@ uint8_t EthernetClass::_state[MAX_SOCK_N
0, 0, 0, 0 };
uint16_t EthernetClass::_server_port[MAX_SOCK_NUM] = {
_dhcp = &s_dhcp;
-diff -rupN /Ethernet/src/utility/socket.cpp /Ethernet/src/utility/socket.cpp
---- /Ethernet/src/utility/socket.cpp 2014-10-01 20:45:35.000000000 +0530
-+++ /Ethernet/src/utility/socket.cpp 2014-12-17 17:02:20.000000000 +0530
+diff -rupN ./Ethernet/src/utility/socket.cpp ../../arduino-1.5.8/libraries/Ethernet/src/utility/socket.cpp
+--- ./Ethernet/src/utility/socket.cpp 2014-10-01 20:45:35.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Ethernet/src/utility/socket.cpp 2014-12-17 17:02:20.000000000 +0530
@@ -295,6 +295,7 @@ uint16_t recvfrom(SOCKET s, uint8_t *buf
{
uint8_t head[8];
}
/**
-diff -rupN /Time/Time/DateStrings.cpp /Time/Time/DateStrings.cpp
---- /Time/Time/DateStrings.cpp 2010-03-06 11:09:22.000000000 +0530
-+++ /Time/Time/DateStrings.cpp 2013-03-24 00:28:08.000000000 +0530
+diff -rupN ./Time/Time/DateStrings.cpp ../../arduino-1.5.8/libraries/Time/Time/DateStrings.cpp
+--- ./Time/Time/DateStrings.cpp 2010-03-06 11:09:22.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/DateStrings.cpp 2013-03-24 00:28:08.000000000 +0530
@@ -1,80 +1,90 @@
-/* DateStrings.cpp
- * Definitions for date strings for use with the Time library
+ buffer[dt_SHORT_STR_LEN] = 0;
+ return buffer;
+}
-diff -rupN /Time/Time/examples/Processing/SyncArduinoClock/readme.txt /Time/Time/examples/Processing/SyncArduinoClock/readme.txt
---- /Time/Time/examples/Processing/SyncArduinoClock/readme.txt 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/Processing/SyncArduinoClock/readme.txt 2013-03-28 07:20:13.000000000 +0530
+diff -rupN ./Time/Time/examples/Processing/SyncArduinoClock/readme.txt ../../arduino-1.5.8/libraries/Time/Time/examples/Processing/SyncArduinoClock/readme.txt
+--- ./Time/Time/examples/Processing/SyncArduinoClock/readme.txt 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/Processing/SyncArduinoClock/readme.txt 2013-03-28 07:20:13.000000000 +0530
@@ -0,0 +1,9 @@
+SyncArduinoClock is a Processing sketch that responds to Arduino requests for
+time synchronization messages.
+message displayed when you run SyncArduinoClock in Processing.
+The Arduino time is set from the time on your computer through the
+Processing sketch.
-diff -rupN /Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde /Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde
---- /Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 2013-03-28 08:26:26.000000000 +0530
+diff -rupN ./Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde ../../arduino-1.5.8/libraries/Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde
+--- ./Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 2013-03-28 08:26:26.000000000 +0530
@@ -0,0 +1,78 @@
+/**
+ * SyncArduinoClock.
+ long daylight = cal.get(cal.DST_OFFSET)/1000;
+ return current + timezone + daylight;
+}
-diff -rupN /Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino /Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino
---- /Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino 2013-03-28 06:08:18.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino
+--- ./Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeArduinoDue/TimeArduinoDue.ino 2013-03-28 06:08:18.000000000 +0530
@@ -0,0 +1,69 @@
+/*
+ * TimeRTC.pde
+ Serial.print(digits);
+}
+
-diff -rupN /Time/Time/examples/TimeGPS/TimeGPS.ino /Time/Time/examples/TimeGPS/TimeGPS.ino
---- /Time/Time/examples/TimeGPS/TimeGPS.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeGPS/TimeGPS.ino 2013-03-31 01:18:40.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeGPS/TimeGPS.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeGPS/TimeGPS.ino
+--- ./Time/Time/examples/TimeGPS/TimeGPS.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeGPS/TimeGPS.ino 2013-03-31 01:18:40.000000000 +0530
@@ -0,0 +1,87 @@
+/*
+ * TimeGPS.pde
+ Serial.print(digits);
+}
+
-diff -rupN /Time/Time/examples/TimeNTP/TimeNTP.ino /Time/Time/examples/TimeNTP/TimeNTP.ino
---- /Time/Time/examples/TimeNTP/TimeNTP.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeNTP/TimeNTP.ino 2013-03-31 01:19:07.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeNTP/TimeNTP.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeNTP/TimeNTP.ino
+--- ./Time/Time/examples/TimeNTP/TimeNTP.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeNTP/TimeNTP.ino 2013-03-31 01:19:07.000000000 +0530
@@ -0,0 +1,135 @@
+/*
+ * Time_NTP.pde
+ Udp.endPacket();
+}
+
-diff -rupN /Time/Time/examples/TimeRTC/TimeRTC.pde /Time/Time/examples/TimeRTC/TimeRTC.pde
---- /Time/Time/examples/TimeRTC/TimeRTC.pde 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeRTC/TimeRTC.pde 2013-03-24 10:27:58.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeRTC/TimeRTC.pde ../../arduino-1.5.8/libraries/Time/Time/examples/TimeRTC/TimeRTC.pde
+--- ./Time/Time/examples/TimeRTC/TimeRTC.pde 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeRTC/TimeRTC.pde 2013-03-24 10:27:58.000000000 +0530
@@ -0,0 +1,55 @@
+/*
+ * TimeRTC.pde
+ Serial.print(digits);
+}
+
-diff -rupN /Time/Time/examples/TimeRTCLog/TimeRTCLog.pde /Time/Time/examples/TimeRTCLog/TimeRTCLog.pde
---- /Time/Time/examples/TimeRTCLog/TimeRTCLog.pde 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeRTCLog/TimeRTCLog.pde 2013-03-24 14:52:52.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeRTCLog/TimeRTCLog.pde ../../arduino-1.5.8/libraries/Time/Time/examples/TimeRTCLog/TimeRTCLog.pde
+--- ./Time/Time/examples/TimeRTCLog/TimeRTCLog.pde 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeRTCLog/TimeRTCLog.pde 2013-03-24 14:52:52.000000000 +0530
@@ -0,0 +1,107 @@
+/*
+ * TimeRTCLogger.pde
+ Serial.print(" second(s) ");
+}
+
-diff -rupN /Time/Time/examples/TimeRTCSet/TimeRTCSet.ino /Time/Time/examples/TimeRTCSet/TimeRTCSet.ino
---- /Time/Time/examples/TimeRTCSet/TimeRTCSet.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeRTCSet/TimeRTCSet.ino 2013-03-31 01:19:58.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeRTCSet/TimeRTCSet.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeRTCSet/TimeRTCSet.ino
+--- ./Time/Time/examples/TimeRTCSet/TimeRTCSet.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeRTCSet/TimeRTCSet.ino 2013-03-31 01:19:58.000000000 +0530
@@ -0,0 +1,80 @@
+/*
+ * TimeRTCSet.pde
+
+
+
-diff -rupN /Time/Time/examples/TimeSerial/TimeSerial.ino /Time/Time/examples/TimeSerial/TimeSerial.ino
---- /Time/Time/examples/TimeSerial/TimeSerial.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeSerial/TimeSerial.ino 2013-03-31 01:20:31.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeSerial/TimeSerial.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeSerial/TimeSerial.ino
+--- ./Time/Time/examples/TimeSerial/TimeSerial.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeSerial/TimeSerial.ino 2013-03-31 01:20:31.000000000 +0530
@@ -0,0 +1,81 @@
+/*
+ * TimeSerial.pde
+ return 0; // the time will be sent later in response to serial mesg
+}
+
-diff -rupN /Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino /Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino
---- /Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino 2013-03-31 01:21:31.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino
+--- ./Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeSerialDateStrings/TimeSerialDateStrings.ino 2013-03-31 01:21:31.000000000 +0530
@@ -0,0 +1,110 @@
+/*
+ * TimeSerialDateStrings.pde
+ return 0; // the time will be sent later in response to serial mesg
+}
+
-diff -rupN /Time/Time/examples/TimeTeensy3/TimeTeensy3.ino /Time/Time/examples/TimeTeensy3/TimeTeensy3.ino
---- /Time/Time/examples/TimeTeensy3/TimeTeensy3.ino 1970-01-01 05:30:00.000000000 +0530
-+++ /Time/Time/examples/TimeTeensy3/TimeTeensy3.ino 2013-03-28 13:53:21.000000000 +0530
+diff -rupN ./Time/Time/examples/TimeTeensy3/TimeTeensy3.ino ../../arduino-1.5.8/libraries/Time/Time/examples/TimeTeensy3/TimeTeensy3.ino
+--- ./Time/Time/examples/TimeTeensy3/TimeTeensy3.ino 1970-01-01 05:30:00.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/examples/TimeTeensy3/TimeTeensy3.ino 2013-03-28 13:53:21.000000000 +0530
@@ -0,0 +1,78 @@
+/*
+ * TimeRTC.pde
+ Serial.print(digits);
+}
+
-diff -rupN /Time/Time/Examples/Processing/SyncArduinoClock/readme.txt /Time/Time/Examples/Processing/SyncArduinoClock/readme.txt
---- /Time/Time/Examples/Processing/SyncArduinoClock/readme.txt 2009-12-29 17:24:28.000000000 +0530
-+++ /Time/Time/Examples/Processing/SyncArduinoClock/readme.txt 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/Processing/SyncArduinoClock/readme.txt ../../arduino-1.5.8/libraries/Time/Time/Examples/Processing/SyncArduinoClock/readme.txt
+--- ./Time/Time/Examples/Processing/SyncArduinoClock/readme.txt 2009-12-29 17:24:28.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/Processing/SyncArduinoClock/readme.txt 1970-01-01 05:30:00.000000000 +0530
@@ -1,9 +0,0 @@
-SyncArduinoClock is a Processing sketch that responds to Arduino requests for
-time synchronization messages.
-The Arduino time is set from the time on your computer through the
-Processing sketch.
\ No newline at end of file
-diff -rupN /Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde /Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde
---- /Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 2009-12-30 18:02:06.000000000 +0530
-+++ /Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde
+--- ./Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 2009-12-30 18:02:06.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/Processing/SyncArduinoClock/SyncArduinoClock.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,70 +0,0 @@
-/**
- * SyncArduinoClock.
- now = now + (tzo/1000) + (dst/1000);
- return now;
-}
-diff -rupN /Time/Time/Examples/TimeGPS/TimeGPS.pde /Time/Time/Examples/TimeGPS/TimeGPS.pde
---- /Time/Time/Examples/TimeGPS/TimeGPS.pde 2010-01-06 09:45:10.000000000 +0530
-+++ /Time/Time/Examples/TimeGPS/TimeGPS.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeGPS/TimeGPS.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeGPS/TimeGPS.pde
+--- ./Time/Time/Examples/TimeGPS/TimeGPS.pde 2010-01-06 09:45:10.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeGPS/TimeGPS.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,82 +0,0 @@
-/*
- * TimeGPS.pde
- time_t time = makeTime(tm);
- return time + (offset * SECS_PER_HOUR);
-}
-diff -rupN /Time/Time/Examples/TimeNTP/TimeNTP.pde /Time/Time/Examples/TimeNTP/TimeNTP.pde
---- /Time/Time/Examples/TimeNTP/TimeNTP.pde 2010-03-06 19:20:14.000000000 +0530
-+++ /Time/Time/Examples/TimeNTP/TimeNTP.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeNTP/TimeNTP.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeNTP/TimeNTP.pde
+--- ./Time/Time/Examples/TimeNTP/TimeNTP.pde 2010-03-06 19:20:14.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeNTP/TimeNTP.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,120 +0,0 @@
-/*
- * Time_NTP.pde
- for( int i = 0; i < how_many; i++ )
- UdpBytewise.write(what);
-}
-diff -rupN /Time/Time/Examples/TimeRTC/TimeRTC.pde /Time/Time/Examples/TimeRTC/TimeRTC.pde
---- /Time/Time/Examples/TimeRTC/TimeRTC.pde 2010-01-05 14:13:46.000000000 +0530
-+++ /Time/Time/Examples/TimeRTC/TimeRTC.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeRTC/TimeRTC.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeRTC/TimeRTC.pde
+--- ./Time/Time/Examples/TimeRTC/TimeRTC.pde 2010-01-05 14:13:46.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeRTC/TimeRTC.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,47 +0,0 @@
-/*
- * TimeRTC.pde
- Serial.print(digits);
-}
-
-diff -rupN /Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde /Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde
---- /Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde 2010-01-06 10:30:36.000000000 +0530
-+++ /Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde
+--- ./Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde 2010-01-06 10:30:36.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeRTCLog/TimeRTCLog.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,106 +0,0 @@
-/*
- * TimeRTCLogger.pde
- Serial.print(" second(s) ");
-}
-
-diff -rupN /Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde /Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde
---- /Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde 2010-01-06 09:53:08.000000000 +0530
-+++ /Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde
+--- ./Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde 2010-01-06 09:53:08.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeRTCSet/TimeRTCSet.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,82 +0,0 @@
-/*
- * TimeRTCSet.pde
- return 0;
-}
-
-diff -rupN /Time/Time/Examples/TimeSerial/TimeSerial.pde /Time/Time/Examples/TimeSerial/TimeSerial.pde
---- /Time/Time/Examples/TimeSerial/TimeSerial.pde 2010-01-06 10:55:18.000000000 +0530
-+++ /Time/Time/Examples/TimeSerial/TimeSerial.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeSerial/TimeSerial.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeSerial/TimeSerial.pde
+--- ./Time/Time/Examples/TimeSerial/TimeSerial.pde 2010-01-06 10:55:18.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeSerial/TimeSerial.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,82 +0,0 @@
-/*
- * TimeSerial.pde
- return 0; // the time will be sent later in response to serial mesg
-}
-
-diff -rupN /Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde /Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde
---- /Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde 2010-01-06 10:55:48.000000000 +0530
-+++ /Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde 1970-01-01 05:30:00.000000000 +0530
+diff -rupN ./Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde
+--- ./Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde 2010-01-06 10:55:48.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Examples/TimeSerialDateStrings/TimeSerialDateStrings.pde 1970-01-01 05:30:00.000000000 +0530
@@ -1,80 +0,0 @@
-/*
- * TimeSerialDateStrings.pde
- return 0; // the time will be sent later in response to serial mesg
-}
-
-diff -rupN /Time/Time/keywords.txt /Time/Time/keywords.txt
---- /Time/Time/keywords.txt 2010-01-05 12:02:50.000000000 +0530
-+++ /Time/Time/keywords.txt 2013-03-23 22:36:10.000000000 +0530
+diff -rupN ./Time/Time/keywords.txt ../../arduino-1.5.8/libraries/Time/Time/keywords.txt
+--- ./Time/Time/keywords.txt 2010-01-05 12:02:50.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/keywords.txt 2013-03-23 22:36:10.000000000 +0530
@@ -5,25 +5,25 @@
#######################################
# Datatypes (KEYWORD1)
#######################################
# Instances (KEYWORD2)
#######################################
-diff -rupN /Time/Time/Readme.txt /Time/Time/Readme.txt
---- /Time/Time/Readme.txt 2010-01-11 21:36:24.000000000 +0530
-+++ /Time/Time/Readme.txt 2013-03-23 21:37:54.000000000 +0530
+diff -rupN ./Time/Time/Readme.txt ../../arduino-1.5.8/libraries/Time/Time/Readme.txt
+--- ./Time/Time/Readme.txt 2010-01-11 21:36:24.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Readme.txt 2013-03-23 21:37:54.000000000 +0530
@@ -1,131 +1,131 @@
-Readme file for Arduino Time Library
-
+
+The DS1307RTC library included in the download provides an example of how a time provider
+can use the low level functions to interface with the Time library.
-diff -rupN /Time/Time/Time.cpp /Time/Time/Time.cpp
---- /Time/Time/Time.cpp 2010-11-01 18:02:50.000000000 +0530
-+++ /Time/Time/Time.cpp 2013-03-28 03:19:40.000000000 +0530
+diff -rupN ./Time/Time/Time.cpp ../../arduino-1.5.8/libraries/Time/Time/Time.cpp
+--- ./Time/Time/Time.cpp 2010-11-01 18:02:50.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Time.cpp 2013-03-28 03:19:40.000000000 +0530
@@ -19,6 +19,11 @@
6 Jan 2010 - initial release
12 Feb 2010 - fixed leap year calculation error
+ syncInterval = (uint32_t)interval;
+ nextSyncTime = sysTime + syncInterval;
+}
-diff -rupN /Time/Time/Time.h /Time/Time/Time.h
---- /Time/Time/Time.h 2011-07-22 17:30:06.000000000 +0530
-+++ /Time/Time/Time.h 2014-11-25 18:48:37.000000000 +0530
+diff -rupN ./Time/Time/Time.h ../../arduino-1.5.8/libraries/Time/Time/Time.h
+--- ./Time/Time/Time.h 2011-07-22 17:30:06.000000000 +0530
++++ ../../arduino-1.5.8/libraries/Time/Time/Time.h 2014-11-25 18:48:37.000000000 +0530
@@ -8,12 +8,29 @@
*/
+#endif // __cplusplus
#endif /* _Time_h */
-Binary files /Time/Time/.Time.h.swp and /Time/Time/.Time.h.swp differ
-diff -rupN /TimedAction/TimedAction.h /TimedAction/TimedAction.h
---- /TimedAction/TimedAction.h 2010-10-08 02:57:26.000000000 +0530
-+++ /TimedAction/TimedAction.h 2014-12-16 19:55:41.427804271 +0530
-@@ -30,7 +30,7 @@
- #ifndef TIMEDACTION_H
- #define TIMEDACTION_H
-
--#include "WProgram.h"
-+#include "Arduino.h"
-
- #define NO_PREDELAY 0
-
-@@ -67,4 +67,4 @@ class TimedAction {
- || | 1.1 2009-04-08 - Alexander Brevig : Added an example that demonstrates three arduino examples at once
- || | 1.0 2009-03-23 - Alexander Brevig : Initial Release
- || #
--*/
-\ No newline at end of file
-+*/
+Binary files ./Time/Time/.Time.h.swp and ../../arduino-1.5.8/libraries/Time/Time/.Time.h.swp differ
# As in the source code(C) includes arduino Time library head file(C++)
# It requires compile the .c with g++
if target_os == 'arduino':
- libcoap_env.Replace(CC = env.get('CXX'))
libcoap_env.Replace(CFLAGS = env.get('CXXFLAGS'))
######################################################################
# Build flags
######################################################################
-libcoap_env.PrependUnique(CPPPATH = [
- '../ocsocket/include',
- '../ocmalloc/include',
- '../logger/include',
- '../ocrandom/include',
- '../stack',
- '../../oc_logger/include'
+ libcoap_env.PrependUnique(CPPPATH = [
+ './',
+ env.get('ARDUINO_HOME')+'/',
+ env.get('ARDUINO_HOME')+'/hardware/arduino/avr/cores/arduino',
+ env.get('ARDUINO_HOME')+'/hardware/tools/avr/avr/include/',
+ env.get('ARDUINO_HOME')+'/hardware/arduino/avr/variants/mega',
+ env.get('ARDUINO_HOME')+'/libraries/Time/Time',
+ env.get('ARDUINO_HOME')+'/libraries/TimedAction',
+ env.get('ARDUINO_HOME')+'/hardware/arduino/avr/libraries/SPI',
+ env.get('ARDUINO_HOME')+'/libraries/Ethernet/src/utility',
])
if target_os not in ['arduino', 'windows', 'winrt']:
'coap_list.c',
'resource.c',
'hashkey.c',
- 'str.c',
+ 'str.c',
'option.c',
'async.c',
'subscribe.c',
- 'block.c',
-# '../logger/src/logger.c',
-# '../ocrandom/src/ocrandom.c',
-# '../ocmalloc/src/ocmalloc.c',
-# '../../oc_logger/c/oc_logger.c',
-# '../../oc_logger/c/oc_console_logger.c'
+ 'block.c'
]
-if target_os == 'arduino':
- libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
-else:
- libcoap = libcoap_env.SharedLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
+libcoap = libcoap_env.StaticLibrary('libcoap', libcoap_src, OBJPREFIX='libcoap_')
libcoap_env.InstallTarget(libcoap, 'libcoap')
--- /dev/null
+Import('env')
+
+sample_env= env.Clone()
+root_dir = './../../'
+
+sample_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
+sample_env.PrependUnique(LIBS = ['connectivity_abstraction', 'coap'])
+
+sample_env.PrependUnique(CPPPATH = [root_dir + '/api/'])
+sample_env.AppendUnique(CPPPATH = [root_dir + '/inc/'])
+sample_env.AppendUnique(CPPPATH = [root_dir + '/lib/libcoap-4.1.1/'])
+sample_env.AppendUnique(CPPPATH = [root_dir + 'common/inc/'])
+
+sample_dir = './samples/arduino/'
+arduino_simplecs = sample_env.Program('CASample', 'casample.cpp')
+env.CreateBin('CASample')
+
+i_arduino_simplecs = sample_env.Install(env.get('BUILD_DIR'), arduino_simplecs)
+
+Alias('arduino_simplecs', i_arduino_simplecs)
+sample_env.Default('CASample.hex')
+
+if(sample_env['UPLOAD'] == True):
+ sample_env.Upload(env.get('BUILD_DIR') + '/samples/arduino/' + 'CASample.hex')
--- /dev/null
+##
+# Building sample application
+##
+
+Import('env')
+
+sample_env = env.Clone()
+
+ca_os = sample_env.get('TARGET_OS')
+ca_transport = sample_env.get('TARGET_TRANSPORT')
+secured = sample_env.get('SECURED')
+root_dir = './../../'
+
+
+#####################################################################
+# Source files and Target(s)
+######################################################################
+
+print"Reading ca script %s"%ca_transport
+
+sample_env.PrependUnique(CPPPATH = [root_dir + '/api/'])
+sample_env.AppendUnique(CPPPATH = [root_dir + '/inc/'])
+sample_env.AppendUnique(CPPPATH = [root_dir + '/lib/libcoap-4.1.1/'])
+sample_env.AppendUnique(CPPPATH = [root_dir + 'common/inc/'])
+
+print "Reading sample application build script"
+
+build_dir = sample_env.get('BUILD_DIR')
+sample_dir = './samples/linux/'
+
+secured = sample_env.get('SECURED')
+
+print "Sample secured flag is %s" % secured
+
+sample_src = ['./sample_main.c',]
+print " sample src %s" % sample_src
+#env.StaticLibrary('casample', sample_src)
+
+sample_env.PrependUnique(LIBPATH = [sample_env.get('BUILD_DIR'), '.',])
+sample_env.PrependUnique(RPATH = [sample_env.get('BUILD_DIR'), '.',])
+sample_env.PrependUnique(LIBS = ['connectivity_abstraction', 'coap',])
+
+sample_env.ParseConfig('pkg-config --libs glib-2.0');
+
+if secured == '1':
+ sample_env.AppendUnique(CPPPATH = [root_dir + 'external/inc/'])
+ sample_env.AppendUnique(LIBS = ['tinydtls'])
+ casample =sample_env.Program('casample', [sample_src])
+else:
+ casample =sample_env.Program('casample', [sample_src])
+env.InstallTarget(casample, 'casample')
+
+
+
#include <unistd.h>
#include "cacommon.h"
#include "cainterface.h"
+#ifdef __WITH_DTLS__
#include "ocsecurityconfig.h"
-
+#endif
#define MAX_BUF_LEN 1024
#define MAX_OPT_LEN 16
CABool_t gLocalUnicastPort;
CABool_t gLocalSecurePort;
CAConnectivityType_t gSelectedNwType = CA_ETHERNET;
+const char* gMessageType[] = {"CON", "NON", "ACK", "RESET"};
char get_menu();
void process();
static const char *gNormalInfoData = "{\"oc\":[{\"href\":\"%s\",\"prop\":{\"rt\":[\"core.led\"],"
"\"if\":[\"oc.mi.def\"],\"obs\":1}}]}";
+#ifdef __WITH_DTLS__
static OCDtlsPskCredsBlob *pskCredsBlob = NULL;
void clearDtlsCredentialInfo()
printf("OCGetDtlsPskCredentials OUT\n");
}
+// Internal API. Invoked by OC stack to retrieve credentials from this module
+void CAGetDtlsPskCredentials(OCDtlsPskCredsBlob **credInfo)
+{
+ printf("CAGetDtlsPskCredentials IN\n");
+
+ *credInfo = pskCredsBlob;
+ printf("CAGetDtlsPskCredentials OUT\n");
+}
int32_t SetCredentials()
{
- int32_t ret = 0;
printf("SetCredentials IN\n");
pskCredsBlob = (OCDtlsPskCredsBlob *)malloc(sizeof(OCDtlsPskCredsBlob));
- if (pskCredsBlob)
- {
- memset(pskCredsBlob, 0x0, sizeof(OCDtlsPskCredsBlob));
+ memset(pskCredsBlob, 0x0, sizeof(OCDtlsPskCredsBlob));
+ memcpy(pskCredsBlob->identity, IDENTITY, DTLS_PSK_ID_LEN);
- pskCredsBlob->blobVer = DtlsPskCredsBlobVer_CurrentVersion;
+ pskCredsBlob->num = 1;
- memcpy(pskCredsBlob->identity, IDENTITY, DTLS_PSK_ID_LEN);
+ pskCredsBlob->creds = (OCDtlsPskCreds *)malloc(sizeof(OCDtlsPskCreds) * (pskCredsBlob->num));
- pskCredsBlob->num = 1;
-
- memcpy(pskCredsBlob->creds[0].id, IDENTITY, DTLS_PSK_ID_LEN);
- memcpy(pskCredsBlob->creds[0].psk, RS_CLIENT_PSK, DTLS_PSK_PSK_LEN);
-
- ret = 1;
- }
+ memcpy(pskCredsBlob->creds[0].id, IDENTITY, DTLS_PSK_ID_LEN);
+ memcpy(pskCredsBlob->creds[0].psk, RS_CLIENT_PSK, DTLS_PSK_PSK_LEN);
printf("SetCredentials OUT\n");
- return ret;
+ return 1;
}
+#endif
int main()
{
printf("\t\tsample main\n");
printf("=============================================\n");
+ CAResult_t res;
/*
* Read DTLS PSK credentials from persistent storage and
* set in the OC stack.
*/
+#ifdef __WITH_DTLS__
if (SetCredentials() == 0)
{
printf("SetCredentials failed\n");
return 0;
}
- CAResult_t res = CAInitialize();
+ res = CARegisterDTLSCredentialsHandler(CAGetDtlsPskCredentials);
+ if(res != CA_STATUS_OK)
+ {
+ printf("Set credential handler fail\n");
+ return 0;
+ }
+#endif
+ res = CAInitialize();
if (res != CA_STATUS_OK)
{
printf("CAInitialize fail\n");
{
CADestroyToken(gLastRequestToken);
}
-
+ gLastRequestToken = NULL;
CATerminate();
+#ifdef __WITH_DTLS__
clearDtlsCredentialInfo();
-
+#endif
return 0;
}
{
printf("find resource to %s URI\n", buf);
+ if (gLastRequestToken != NULL)
+ {
+ CADestroyToken(gLastRequestToken);
+ }
+
gLastRequestToken = token;
}
requestData.token = token;
if ('1' == secureRequest[0])
{
- int length = strlen(resourceURI) + 1;
+ int length = strlen(gSecureInfoData) + strlen(resourceURI) + 1;
requestData.payload = (CAPayload_t) malloc(length);
sprintf(requestData.payload, gSecureInfoData, resourceURI, gLocalSecurePort);
}
{
CADestroyToken(token);
}
-
+ if (requestData.payload != NULL)
+ {
+ free(requestData.payload);
+ }
// destroy remote endpoint
CADestroyRemoteEndpoint(endpoint);
printf("=============================================\n");
CAAdvertiseResource(buf, token, headerOpt, (uint8_t) optionNum);
// delete token
- /*
- if (token != NULL)
- {
- CADestroyToken(token);
- }
- */
+ if (token != NULL)
+ {
+ CADestroyToken(token);
+ }
free(headerOpt);
CALocalConnectivity_t *tempInfo = NULL;
uint32_t tempSize = 0;
- if((CAGetNetworkInformation(&tempInfo, &tempSize) != CA_STATUS_OK) ||
- !tempInfo || !tempSize)
+ CAGetNetworkInformation(&tempInfo, &tempSize);
+ if (tempInfo == NULL || tempSize <= 0)
{
printf("network not connected\n");
return;
printf("################## Network Information #######################\n");
printf("network info total size is %d\n\n", tempSize);
+
for (index = 0; index < tempSize; index++)
{
printf("Type: %d\n", tempInfo[index].type);
object->addressInfo.IP.port, object->isSecured);
printf("Data: %s\n", requestInfo->info.payload);
-
+ printf("Message type: %s\n", gMessageType[requestInfo->info.type]);
if (gLastRequestToken != NULL && requestInfo->info.token != NULL
&& (strcmp((char *)gLastRequestToken, requestInfo->info.token) == 0))
{
//endpoint->connectivityType = object->connectivityType;
endpoint->isSecured = CA_TRUE;
object = endpoint;
+
+ free(uri);
}
}
printf("send response with URI\n");
- send_response(object, (requestInfo != NULL) ? &requestInfo->info : NULL);
+ send_response(object, &requestInfo->info);
gReceived = 1;
}
object->addressInfo.IP.port, object->isSecured);
printf("response result : %d\n", responseInfo->result);
printf("Data: %s\n", responseInfo->info.payload);
-
+ printf("Message type: %s\n", gMessageType[responseInfo->info.type]);
if (responseInfo->info.options)
{
uint32_t len = responseInfo->info.numOptions;
}
printf("\n=============================================\n");
+
+ return CA_STATUS_FAILED;
}
--- /dev/null
+##
+# This script includes generic build options:
+# release/debug, target os, target arch, cross toolchain, build environment etc
+##
+import os
+import platform
+
+# Map of host os and allowed target os (host: allowed target os)
+host_target_map = {
+ 'linux': ['linux', 'android', 'arduino', 'yocto', 'tizen'],
+ 'windows': ['windows', 'winrt', 'android', 'arduino', 'tizen'],
+ 'darwin': ['darwin', 'ios', 'android', 'arduino'],
+ }
+
+# Map of os and allowed archs (os: allowed archs)
+os_arch_map = {
+ 'linux': ['x86', 'x86_64', 'arm', 'arm64'],
+ 'android': ['x86', 'x86_64', 'armeabi', 'armeabi-v7a', 'armeabi-v7a-hard', 'arm64-v8a'],
+ 'windows': ['x86', 'amd64', 'arm'],
+ 'winrt': ['arm'],
+ 'darwin': ['i386', 'x86_64'],
+ 'ios': ['i386', 'x86_64', 'armv7', 'armv7s', 'arm64'],
+ 'arduino': ['avr', 'arm'],
+ 'yocto': ['x86', 'x86_64'],
+ 'tizen': ['armv7'],
+ }
+
+host = platform.system().lower()
+
+if not host_target_map.has_key(host):
+ print "\nError: Current system (%s) isn't supported\n" % host
+ Exit(1)
+
+######################################################################
+# Get build options (the optins from command line)
+######################################################################
+target_os = ARGUMENTS.get('TARGET_OS', host).lower() # target os
+
+if target_os not in host_target_map[host]:
+ print "\nError: Unknown target os: %s (Allow values: %s)\n" % (target_os, host_target_map[host])
+ Exit(1)
+
+default_arch = platform.machine()
+if default_arch not in os_arch_map[target_os]:
+ default_arch = os_arch_map[target_os][0].lower()
+
+target_arch = ARGUMENTS.get('TARGET_ARCH', default_arch) # target arch
+
+######################################################################
+# Common build options (release, target os, target arch)
+######################################################################
+help_vars = Variables()
+help_vars.Add(BoolVariable('RELEASE', 'Build for release?', True)) # set to 'no', 'false' or 0 for debug
+help_vars.Add(EnumVariable('TARGET_OS', 'Target platform', host, host_target_map[host]))
+help_vars.Add(ListVariable('TARGET_TRANSPORT', 'Target transport', 'ALL', ['ALL', 'WIFI', 'ETHERNET', 'BT', 'BLE']))
+help_vars.Add(EnumVariable('TARGET_ARCH', 'Target architecture', default_arch, os_arch_map[target_os]))
+help_vars.Add(EnumVariable('SECURED', 'Build with DTLS', '0', allowed_values=('0', '1')))
+
+######################################################################
+# Platform(build target) specific options: SDK/NDK & toolchain
+######################################################################
+targets_support_cc = ['linux', 'arduino', 'tizen']
+
+if target_os in targets_support_cc:
+ # Set cross compile toolchain
+ help_vars.Add('TC_PREFIX', "Toolchain prefix (Generally only be required for cross-compiling)", os.environ.get('TC_PREFIX'))
+ help_vars.Add(PathVariable('TC_PATH',
+ 'Toolchain path (Generally only be required for cross-compiling)',
+ os.environ.get('TC_PATH')))
+
+if target_os in ['android', 'arduino']: # Android/Arduino always uses GNU compiler regardless of the host
+ env = Environment(variables = help_vars,
+ tools = ['gnulink', 'gcc', 'g++', 'ar', 'as']
+ )
+else:
+ env = Environment(variables = help_vars, TARGET_ARCH = target_arch, TARGET_OS = target_os)
+
+Help(help_vars.GenerateHelpText(env))
+
+tc_set_msg = '''
+************************************ Warning **********************************
+* Enviornment variable TC_PREFIX/TC_PATH is set. It will change the default *
+* toolchain, if it isn't what you expect you should unset it, otherwise it may*
+* cause inexplicable errors. *
+*******************************************************************************
+'''
+
+if target_os in targets_support_cc:
+ prefix = env.get('TC_PREFIX')
+ tc_path = env.get('TC_PATH')
+ if prefix:
+ env.Replace(CC = prefix + 'gcc')
+ env.Replace(CXX = prefix + 'g++')
+ env.Replace(AR = prefix + 'ar')
+ env.Replace(AS = prefix + 'as')
+ env.Replace(LINK = prefix + 'ld')
+ env.Replace(RANLIB = prefix + 'ranlib')
+
+ if tc_path:
+ env.PrependENVPath('PATH', tc_path)
+ sys_root = os.path.abspath(tc_path + '/../')
+ env.AppendUnique(CCFLAGS = ['--sysroot=' + sys_root])
+ env.AppendUnique(LINKFLAGS = ['--sysroot=' + sys_root])
+
+ if prefix or tc_path:
+ print tc_set_msg
+
+# Ensure scons be able to change its working directory
+env.SConscriptChdir(1)
+
+# Set the source directory and build directory
+# Source directory: 'dir'
+# Build directory: 'dir'/out/<target_os>/<target_arch>/<release or debug>/
+#
+# You can get the directory as following:
+# env.get('SRC_DIR')
+# env.get('BUILD_DIR')
+
+def __set_dir(env, dir):
+ if not os.path.exists(dir + '/SConstruct'):
+ print '''
+*************************************** Error *********************************
+* The directory(%s) seems isn't a source code directory, no SConstruct file is
+* found. *
+*******************************************************************************
+''' % dir
+ Exit(1)
+
+ if env.get('RELEASE'):
+ build_dir = dir + '/out/' + target_os + '/' + target_arch + '/release/'
+ else:
+ build_dir = dir + '/out/' + target_os + '/' + target_arch + '/debug/'
+ env.VariantDir(build_dir, dir, duplicate=0)
+
+ env.Replace(BUILD_DIR = build_dir)
+ env.Replace(SRC_DIR = dir)
+
+def __src_to_obj(env, src, home = ''):
+ obj = env.get('BUILD_DIR') + src.replace(home, '')
+ if env.get('OBJSUFFIX'):
+ obj += env.get('OBJSUFFIX')
+ return env.Object(obj, src)
+
+def __install(ienv, targets, name):
+ i_n = ienv.Install(env.get('BUILD_DIR'), targets)
+ Alias(name, i_n)
+ env.AppendUnique(TS = [name])
+
+def __append_target(ienv, target):
+ env.AppendUnique(TS = [target])
+
+def __print_targets(env):
+ Help('''
+===============================================================================
+Targets:\n ''')
+ for t in env.get('TS'):
+ Help(t + ' ')
+ Help('''
+\nDefault all targets will be built. You can specify the target to build:
+
+ $ scons [options] [target]
+===============================================================================
+''')
+
+env.AddMethod(__set_dir, 'SetDir')
+env.AddMethod(__print_targets, 'PrintTargets')
+env.AddMethod(__src_to_obj, 'SrcToObj')
+env.AddMethod(__append_target, 'AppendTarget')
+env.AddMethod(__install, 'InstallTarget')
+env.SetDir(env.GetLaunchDir())
+env['ROOT_DIR']=env.GetLaunchDir()
+
+Export('env')
+
+######################################################################
+# Link scons to Yocto cross-toolchain ONLY when target_os is yocto
+######################################################################
+if target_os == "yocto":
+ '''
+ This code injects Yocto cross-compilation tools+flags into scons'
+ build environment in order to invoke the relevant tools while
+ performing a build.
+ '''
+ import os.path
+ try:
+ CC = os.environ['CC']
+ target_prefix = CC.split()[0]
+ target_prefix = target_prefix[:len(target_prefix)-3]
+ tools = {"CC" : target_prefix+"gcc",
+ "CXX" : target_prefix+"g++",
+ "AS" : target_prefix+"as",
+ "LD" : target_prefix+"ld",
+ "GDB" : target_prefix+"gdb",
+ "STRIP" : target_prefix+"strip",
+ "RANLIB" : target_prefix+"ranlib",
+ "OBJCOPY" : target_prefix+"objcopy",
+ "OBJDUMP" : target_prefix+"objdump",
+ "AR" : target_prefix+"ar",
+ "NM" : target_prefix+"nm",
+ "M4" : "m4",
+ "STRINGS": target_prefix+"strings"}
+ PATH = os.environ['PATH'].split(os.pathsep)
+ for tool in tools:
+ if tool in os.environ:
+ for path in PATH:
+ if os.path.isfile(os.path.join(path, tools[tool])):
+ env[tool] = os.path.join(path, os.environ[tool])
+ break
+ except:
+ print "ERROR in Yocto cross-toolchain environment"
+ Exit(1)
+ '''
+ Now reset TARGET_OS to linux so that all linux specific build configurations
+ hereupon apply for the entirety of the build process.
+ '''
+ env['TARGET_OS'] = 'linux'
+ '''
+ We want to preserve debug symbols to allow BitBake to generate both DEBUG and
+ RELEASE packages for OIC.
+ '''
+ env['CCFLAGS'].append('-g')
+ Export('env')
+else:
+ '''
+ If target_os is not Yocto, continue with the regular build process
+ '''
+ # Load config of target os
+ env.SConscript(target_os + '/SConscript')
+
+# Delete the temp files of configuration
+if env.GetOption('clean'):
+ dir = env.get('SRC_DIR')
+
+ if os.path.exists(dir + '/config.log'):
+ Execute(Delete(dir + '/config.log'))
+ Execute(Delete(dir + '/.sconsign.dblite'))
+ Execute(Delete(dir + '/.sconf_temp'))
+
+Return('env')
--- /dev/null
+##
+# The main build script
+#
+##
+
+# Load common build config
+# Load common build config
+SConscript('SConscript')
+
+Import('env')
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+
+print "Given Transport is %s" % transport
+print "Given OS is %s" % target_os
+print "Secured %s" % env.get('SECURED')
+
+if target_os == 'tizen':
+ SConscript('scons/SConscript')
+else:
+ print "Given platform is not supported"
--- /dev/null
+##
+# 'resource' sub-project main build script
+#
+##
+
+Import('env')
+
+target_os = env.get('TARGET_OS')
+transport = env.get('TARGET_TRANSPORT')
+
+OIC_LIB = 'oic'
+root_dir = env.get('ROOT_DIR')
+build_dir = env.get('BUILD_DIR')
+sample_dir = build_dir
+
+env.AppendUnique(CFLAGS = ['-std=c99', '-fPIC', '-D__TIZEN__','-DWITH_POSIX', '-Wall', '-DSLP_SDK_LOG', '-g','-D_GNU_SOURCE','-DTIZEN_DEBUG_ENABLE', '-DTB_LOG','`pkg-config', '--cflags', '--libs','dlog', 'com.oic.ca', 'capi-network-wifi',
+ 'gobject-2.0','glib-2.0`'])
+
+env.Append(LIBPATH=[root_dir +'/lib/tizen/ble/libs/',])
+env.Append(LIBS=[
+ '-lm', '-lpthread', '-lrt', '-ldl', '-lstdc++', '-lgobject-2.0', '-lgio-2.0', '-lglib-2.0', '-lcapi-network-wifi', '-ldlog', '-lcapi-network-bluetooth', '-lconnectivity_abstraction', 'coap',
+])
+
+env.Prepend(RPATH=[root_dir +'/lib/tizen/ble/libs/',])
+if 'ALL' in transport:
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER', 'NO_ETHERNET_ADAPTER','EDR_ADAPTER','LE_ADAPTER','BT_ADAPTER_TEST','BLE_ADAPTER_TEST','WIFI_ADAPTER_TEST'])
+ print "CA Transport is ALL"
+else:
+ if 'BT' in transport:
+ env.AppendUnique(CPPDEFINES = ['EDR_ADAPTER','BT_ADAPTER_TEST'])
+ print "CA Transport is BT"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_EDR_ADAPTER'])
+
+ if 'BLE' in transport:
+ env.AppendUnique(CPPDEFINES = ['LE_ADAPTER','BLE_ADAPTER_TEST'])
+ print "CA Transport is BLE"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_LE_ADAPTER'])
+
+ if 'WIFI' in transport:
+ env.AppendUnique(CPPDEFINES = ['WIFI_ADAPTER','WIFI_ADAPTER_TEST'])
+ print "CA Transport is WIFI"
+ else:
+ env.AppendUnique(CPPDEFINES = ['NO_WIFI_ADAPTER'])
+
+
+
+
+in_sample_src = [sample_dir + '/interfacesample.c']
+ca_sample_src = [sample_dir + '/casample.c']
+
+
+print " interface sample src %s" % in_sample_src
+print " ca sample src %s" % ca_sample_src
+
+env.Program('interface_sample', [in_sample_src,])
+env.Program('ca_sample', [ca_sample_src,])
+
+
*/
static u_mutex gDtlsListMutex = NULL;
+/**
+ * @var gGetCredentialsCallback
+ * @brief callback to get DTLS credentials
+ */
+static CAGetDTLSCredentialsHandler gGetCredentialsCallback = NULL;
+
static eDtlsRet_t CAAdapterNetDtlsEncryptInternal(const stCADtlsAddrInfo_t *dstSession,
uint8_t *data, uint32_t dataLen)
{
return DTLS_FAIL;
}
- int32_t retLen = dtls_write(gCaDtlsContext->dtlsContext, (session_t *)dstSession, data,
+ int32_t retLen = dtls_write(gCaDtlsContext->dtlsContext, (session_t *)dstSession, data,
dataLen);
OIC_LOG_V(DEBUG, NET_DTLS_TAG, "dtls_write retun len [%d]", retLen);
if (0 == retLen)
}
CAFreeCacheMsg(msg);
}
- u_arraylist_free(gCaDtlsContext->cacheList);
+ u_arraylist_free(&gCaDtlsContext->cacheList);
gCaDtlsContext->cacheList = NULL;
u_mutex_unlock(gDtlsListMutex);
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
uint32_t list_length = 0;
u_mutex_lock(gDtlsListMutex);
list_length = u_arraylist_length(gCaDtlsContext->cacheList);
- for (list_index = 0; list_index < list_length; )
+ for (list_index = 0; list_index < list_length;)
{
stCACacheMessage_t *msg = (stCACacheMessage_t *)u_arraylist_get(gCaDtlsContext->cacheList,
list_index);
}
else
{
- OIC_LOG(ERROR, NET_DTLS_TAG, "CAAdapterNetDtlsEncryptInternal failed.");
+ OIC_LOG(ERROR, NET_DTLS_TAG, "u_arraylist_remove failed.");
break;
}
}
OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
int32_t ret = -1;
+
+ VERIFY_NON_NULL_RET(gGetCredentialsCallback, NET_DTLS_TAG, "GetCredential callback", 0);
+
OCDtlsPskCredsBlob *credInfo = NULL;
//Retrieve the credentials blob from security module
- OCGetDtlsPskCredentials(&credInfo);
+ // OCGetDtlsPskCredentials(&credInfo);
+ gGetCredentialsCallback(&credInfo);
- VERIFY_NON_NULL_RET(credInfo, NET_DTLS_TAG, "OCGetDtlsPskCredentials credInfo is NULL", ret);
+ VERIFY_NON_NULL_RET(credInfo, NET_DTLS_TAG, "CAGetDtlsPskCredentials credInfo is NULL", 0);
if ((type == DTLS_PSK_HINT) || (type == DTLS_PSK_IDENTITY))
{
//Check if we have the credentials for the device with which we
//are trying to perform a handshake
int index = 0;
- for (; index < credInfo->num; index++)
+ for (index = 0; index < credInfo->num; index++)
{
if (memcmp(desc, credInfo->creds[index].id, DTLS_PSK_ID_LEN) == 0)
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
}
+void CADTLSSetCredentialsCallback(CAGetDTLSCredentialsHandler credCallback)
+{
+ OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
+ gGetCredentialsCallback = credCallback;
+ OIC_LOG(DEBUG, NET_DTLS_TAG, "OUT");
+}
+
CAResult_t CAAdapterNetDtlsInit()
{
OIC_LOG(DEBUG, NET_DTLS_TAG, "IN");
--- /dev/null
+#######################################################
+# Building BT adapter
+#######################################################
+
+Import('env')
+
+print"Reading bt adapter script"
+
+target_os = env.get('TARGET_OS')
+src_dir = './src/bt_edr_adapter/'
+
+#Source files to build common for all platforms
+if target_os != 'arduino':
+ env.AppendUnique(CA_SRC=[src_dir+'caedradapter.c'])
+
+#Source files to build in Linux platform
+if target_os == 'linux':
+ env.AppendUnique(CA_SRC=[src_dir+'linux/caedradapter.c',
+ ])
+
+#Source files to build in Tizen platform
+if target_os == 'tizen':
+ env.PrependUnique(CPPPATH = [src_dir + 'tizen'])
+ env.AppendUnique(CA_SRC=[src_dir+'tizen/caedrclient.c',
+ src_dir+'tizen/caedrdevicelist.c',
+ src_dir+'tizen/caedrendpoint.c',
+ src_dir+'tizen/caedrnwmonitor.c',
+ src_dir+'tizen/caedrserver.c',
+ src_dir+'tizen/caedrutils.c',
+ ])
+
+#Source files to build in Android platform
+if target_os == 'android':
+ env.AppendUnique(CA_SRC=[src_dir+'android/caedradapter.c',
+ ])
--- /dev/null
+#######################################################
+# Building BLE adapter
+#######################################################
+
+Import('env')
+
+print"Reading ble adapter script"
+
+target_os = env.get('TARGET_OS')
+src_dir = './src/bt_le_adapter/'
+
+#Source files to build common for all platforms
+if target_os != 'arduino':
+ env.AppendUnique(CA_SRC=[src_dir+'caleadapter.c'])
+else:
+ env.AppendUnique(CA_SRC=[src_dir+'caleadapter_singlethread.c'])
+
+#Source files to build in Linux platform
+if target_os == 'linux':
+ env.AppendUnique(CA_SRC=[src_dir+'linux/caleadapter.c',
+ ])
+
+#Source files to build in Tizen platform
+if target_os == 'tizen':
+ env.PrependUnique(CPPPATH = [src_dir + 'tizen'])
+ env.PrependUnique(CFLAGS = ['-I'+ './con/lib/tizen/ble/inc'])
+ env.AppendUnique(CA_SRC=[src_dir+'tizen/cableclient.c',
+ src_dir+'tizen/cableserver.c',
+ src_dir+'tizen/cableutil.c',
+ src_dir+'tizen/cablenwmonitor.c',
+ ])
+
+#Source files to build in Arduino platform
+if target_os == 'arduino':
+ env.PrependUnique(CPPPATH = [src_dir + 'arduino'])
+ env.AppendUnique(CA_SRC=[src_dir+'arduino/cableserver.cpp',
+ src_dir+'arduino/cablenwmonitor.cpp',
+ ])
+
+#Source files to build in Android platform
+if target_os == 'android':
+ env.AppendUnique(CA_SRC=[src_dir+'android/caleadapter.c',
+ src_dir+'android/caleclient.c',
+ src_dir+'android/caleserver.c',
+ ])
#define TAG PCF("CA")
+#ifdef __WITH_DTLS__
+// CAAdapterNetDTLS will register the callback.
+// Taking callback all the way through adapters not the right approach, hence calling here.
+extern void CADTLSSetCredentialsCallback(CAGetDTLSCredentialsHandler credCallback);
+#endif
+
CAResult_t CAInitialize()
{
OIC_LOG_V(DEBUG, TAG, "CAInitialize");
OIC_LOG_V(DEBUG, TAG, "CARegisterHandler");
CASetRequestResponseCallbacks(ReqHandler, RespHandler);
+}
+#ifdef __WITH_DTLS__
+CAResult_t CARegisterDTLSCredentialsHandler(
+ CAGetDTLSCredentialsHandler GetDTLSCredentialsHandler)
+{
+ OIC_LOG(DEBUG, TAG, "CARegisterDTLSCredentialsHandler");
+ CADTLSSetCredentialsCallback(GetDTLSCredentialsHandler);
return CA_STATUS_OK;
}
+#endif //__WITH_DTLS__
-CAResult_t CACreateRemoteEndpoint(const CAURI_t uri,
+CAResult_t CACreateRemoteEndpoint(const CAURI_t uri,
const CAConnectivityType_t connectivityType,CARemoteEndpoint_t **remoteEndpoint)
{
OIC_LOG_V(DEBUG, TAG, "CACreateRemoteEndpoint");
}
CAResult_t CARetransmissionSentData(CARetransmission_t *context,
- const CARemoteEndpoint_t* endpoint,const void* pdu, uint32_t size)
+ const CARemoteEndpoint_t* endpoint, const void* pdu, uint32_t size)
{
if (context == NULL || endpoint == NULL || pdu == NULL)
{
--- /dev/null
+#######################################################
+# Building Ethernet adapter
+#######################################################
+
+Import('env')
+
+print "Reading ethernet adapter script"
+
+target_os = env.get('TARGET_OS')
+inc_files = env.get('CPPPATH')
+src_dir = './src/ethernet_adapter/'
+
+#Source files to build common for all platforms
+if target_os == 'arduino':
+ env.AppendUnique(CA_SRC=[src_dir+'caethernetadapter_singlethread.c'])
+else:
+ env.AppendUnique(CPPPATH=[src_dir+'arduino/'])
+ env.AppendUnique(CA_SRC=[src_dir+'caethernetadapter.c'])
+
+#Source files to build in Linux platform
+if target_os == 'linux':
+ env.AppendUnique(CA_SRC=[src_dir+'linux/caethernetclient.c',
+ src_dir+'linux/caethernetserver.c',
+ src_dir+'linux/caethernetnwmonitor.c',
+ ])
+
+#Source files to build in Arduino platform
+if target_os == 'arduino':
+ env.AppendUnique(CA_SRC=[src_dir+'arduino/caethernetadapterutils.cpp',
+ src_dir+'arduino/caethernetclient.cpp',
+ src_dir+'arduino/caethernetserver.cpp',
+ src_dir+'arduino/caethernetnwmonitor.cpp',
+ ])
\ No newline at end of file
--- /dev/null
+#######################################################
+# Building wifi adapter
+#######################################################
+
+Import('env')
+
+print"Reading wifi adapter script"
+
+target_os = env.get('TARGET_OS')
+src_dir = './src/wifi_adapter/'
+
+#Source files to build common for all platforms
+if target_os != 'arduino':
+ env.AppendUnique(CA_SRC=[src_dir+'cawifiadapter.c'])
+else:
+ env.AppendUnique(CA_SRC=[src_dir+'cawifiadapter_singlethread.c'])
+
+#Source files to build in Linux platform
+if target_os == 'linux':
+ env.AppendUnique(CA_SRC=[src_dir+ 'linux/cawificlient.c',
+ src_dir+'linux/cawifinwmonitor.c',
+ src_dir+'linux/cawifiserver.c',])
+
+#Source files to build in Tizen platform
+if target_os == 'tizen':
+ env.AppendUnique(CA_SRC=[src_dir+ 'tizen/cawificlient.c',
+ src_dir+'tizen/cawifinwmonitor.c',
+ src_dir+'tizen/cawifiserver.c',])
+
+#Source files to build in Arduino platform
+if target_os == 'arduino':
+ env.AppendUnique(CA_SRC=[src_dir+ 'arduino/cawificlient.cpp',
+ src_dir+'arduino/cawifinwmonitor.cpp',
+ src_dir+'arduino/cawifiserver.cpp',])
+
+#Source files to build in Android platform
+if target_os == 'android':
+ env.AppendUnique(CA_SRC=[src_dir+'android/cawificlient.c',
+ src_dir+'android/cawifiserver.c',
+ src_dir+'android/cawifinwmonitor.c',
+ ])
{
OIC_LOG(DEBUG, WIFI_ADAPTER_TAG, "IN");
- /* Start monitoring wifi network */
+ // Start monitoring wifi network
+ // network monitor is yet to be implemented
CAResult_t ret = CAWiFiStartNetworkMonitor();
if (CA_STATUS_OK != ret)
{
}
gStartMulticastServerRequested = true;
+ // network monitor is yet to be implemented
bool retVal = CAWiFiIsConnected();
if (false == retVal)
{
if (CA_STATUS_OK == ret)
{
OIC_LOG(INFO, WIFI_ADAPTER_TAG, "Multicast Server Started Successfully");
+ // iff wifi shield firmware upgrade allows multicast
gIsMulticastServerStarted = true;
}
CAResult_t CAStartWIFIDiscoveryServer()
{
OIC_LOG(DEBUG, WIFI_ADAPTER_TAG, "IN");
- /* Both listening and discovery server are same */
+ // Both listening and discovery server are same
OIC_LOG(DEBUG, WIFI_ADAPTER_TAG, "OUT");
return CAStartWIFIListeningServer();
}
// check return value
TEST(RegisterHandlerTest, TC_05_Positive_01)
{
- EXPECT_EQ(CA_STATUS_OK, CARegisterHandler(request_handler, response_handler));
+ CARegisterHandler(request_handler, response_handler);
}
// CACreateRemoteEndpoint TC
TCT Unit tests for Tizen:
==========================
1. TCT tool should be setup in linux to execute these test cases. Please refer to "CoreAPI Test Manual.pptx" present in this folder.
-2. OIC-Core and InterfaceAPIs should be built first.
+2. OIC-CA package should be built first.
3. Copy liboic to <TCT Directory>/core-api/src.
4. Copy packaging/core-liboic-tests.spec to <TCT Directory>/packaging.
-5. Build oic test case project with "tctbuild build liboic".
-6. Install test framework to device with "tctbuild install liboic".
+5. Build oic test case project with "sudo ./tctbuild build liboic".
+6. Install test framework to device with "sudo ./tctbuild install liboic".
7. Run tct tool with "tct-mgr".
\ No newline at end of file
# ${CAPI_LIB}
#)
PKG_CHECK_MODULES(pkgs REQUIRED
- capi-network-bluetooth capi-network-wifi com.samsung.oicca dlog
+ capi-network-bluetooth capi-network-wifi com.samsung.oicca dlog gobject-2.0 glib-2.0
)
INCLUDE_DIRECTORIES(
${${CAPI_LIB}_INCLUDE_DIRS}
+ /usr/include/glib-2.0
+ /usr/lib/glib-2.0/include
+ /usr/lib/
+ /usr/include/network
)
ADD_DEFINITIONS("-D__TIZEN__")
ADD_EXECUTABLE(${EXEC_NAME} ${EXEC_NAME}.c ${TC_SOURCES})
TARGET_LINK_LIBRARIES(${EXEC_NAME}
- ${${CAPI_LIB}_LIBRARIES} /usr/lib/liboicinterface.a -lm -lpthread -lrt -ldl -lcapi-network-wifi -lcapi-network-bluetooth -ldlog
+ ${${CAPI_LIB}_LIBRARIES} -loicinterface -lm -lpthread -lrt -ldl -lstdc++ -lgobject-2.0 -lgio-2.0 -lglib-2.0 -lcapi-network-wifi -ldlog -lcapi-network-bluetooth
)
INSTALL(PROGRAMS ${EXEC_NAME}
-//#include <glib.h>
-#include "assert.h"
+#include <assert.h>
#include "interfaceHeaders/cacommon.h"
#include "interfaceHeaders/caadapterinterface.h"
#include "interfaceHeaders/caedradapter.h"
+#include "interfaceHeaders/uthreadpool.h"
//& set: Liboic
CALocalConnectivity_t *localBtEndpoint = NULL;
CARemoteEndpoint_t remoteMulticastEndpoint;
CARemoteEndpoint_t remoteEndpoint[10]; /* 10 RemoteEndpoints are currently kept */
-char remoteIPAddress[CA_IPADDR_SIZE] =
- "192.168.1.8"; //Change the Corresponding IP address during testing.
+char remoteIPAddress[CA_IPADDR_SIZE] = "192.168.1.8"; // Change the Corresponding IP address during testing.
char localIPAddress[CA_IPADDR_SIZE] = {0};
-int localPort = -1;
int32_t serverId;
// Global bt Addr. Change this before testing.
char btAddr[CA_MACADDR_SIZE] = "BC:79:AD:E6:BC:F6";
char *serviceUUID = "12341234-1C25-481F-9DFB-59193D238280";
-//static GMainLoop *mainloop;
-//int gMainloopStatus = 0;
-//Hardcoded values to Test
+static u_thread_pool_t gBTThreadPool = NULL;
-char coapData[500] =
- "{\"oc:\[{href\":\"/a/light\",\"ref\":{\"power\":\"20\",\"state\":\"true\"}}\]}";
+// Hardcoded values to Test
+char coapData[500] = "{\"oc:\[{href\":\"/a/light\",\"ref\":{\"power\":\"20\",\"state\":\"true\"}}\]}";
typedef struct ConnectivityHandlerList
{
CAConnectivityHandler_t *gConnectivityHandlers = NULL;
-void storeInterfaceCallbacks(CAConnectivityHandler_t *newHandler)
+void initializeThreadPool(int d)
{
- printf("\nstoreInterfaceCallbacks Entry in Sample");
-#if 0
- newHandler->nextHandler = NULL;
-
- CAConnectivityHandler *tempCAConnectivityHandlers = gCAConnectivityHandlers;
-
- if (!tempCAConnectivityHandlers)
- {
- gCAConnectivityHandlers = newHandler;
- return;
- }
- while (tempCAConnectivityHandlers->nextHandler)
- {
- tempCAConnectivityHandlers = tempCAConnectivityHandlers->nextHandler;
- }
-
- tempCAConnectivityHandlers->nextHandler = newHandler;
-#endif
- printf("\nstoreInterfaceCallbacks Exit in Sample");
+ if (CA_STATUS_OK != u_thread_pool_init(3, &gBTThreadPool))
+ printf("Failed to create thread pool for BT adapter!\n");
}
void interfaceRegisterCallback(CAConnectivityHandler_t handler,
newConnectivityHandler->type = connType;
newConnectivityHandler->handler = handler;
- storeInterfaceCallbacks(newConnectivityHandler);
printf("interfaceRegisterCallback Exit in Sample\n");
}
void requestResponseHandler(CARemoteEndpoint_t *object, void *data)
{
printf("\nrequestResponseHandler Entry in Sample");
- if (object == NULL || data == NULL)
+ if (NULL == object || NULL == data)
{
printf("\nNULL Object");
return;
printf("\nData Received from %s\n", object->addressInfo.BT.btMacAddress);
if (data)
printf("\nReceived Data : %s \n", (char *)data);
- /*
- gMainloopStatus = 1;
- if (mainloop)
- {
- g_main_loop_quit(mainloop);
- mainloop = NULL;
- }
- */
+
printf("\nrequestResponseHandler Exit in Sample");
}
CANetworkStatus_t networkConnectivityState)
{
printf("\nnetworkInterfaceCallback Entry in Sample");
- if (localEndPoint == NULL)
+ if (NULL == localEndPoint)
{
printf("\nNULL Object");
return;
int bt_tc_001_intializeBT_p(void)
{
CAResult_t error = CA_STATUS_FAILED;
+ initializeThreadPool(0);
error = CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler,
- networkInterfaceCallback);
+ networkInterfaceCallback, gBTThreadPool);
assert_eq(error, CA_STATUS_OK);
CATerminateEDR();
return 0;
int bt_tc_002_intializeBT_n(void)
{
CAResult_t error = CA_STATUS_FAILED;
- error = CAInitializeEDR(NULL, NULL, NULL);
+ initializeThreadPool(0);
+ error = CAInitializeEDR(NULL, NULL, NULL, gBTThreadPool);
assert_eq(error, CA_STATUS_INVALID_PARAM);
return 0;
}
int bt_tc_003_getBTInterfaceInformation_p(void)
{
CAResult_t error = CA_STATUS_FAILED;
- //Startup
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ // Startup
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
uint32_t size = 0;
error = CAGetEDRInterfaceInformation(&localBtEndpoint, &size);
int bt_tc_005_startAdapter_p(void)
{
CAResult_t error = CA_STATUS_FAILED;
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
error = CAStartEDR();
assert_eq(error, CA_STATUS_OK);
CAStopEDR();
int ret = -1;
int ref = 0;
- //Startup
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ // Startup
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
CAStartEDR();
CAStartEDRListeningServer();
ret = CASendEDRUnicastData(&endpoint, coapData, strlen(coapData) + 1);
sleep(5);
- //Cleanup
+ // Cleanup
CAStopEDR();
CATerminateEDR();
{
int dataSize = 0;
int ret = -1;
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
ret = CASendEDRUnicastData(NULL, NULL, NULL);
CATerminateEDR();
assert_eq(ret, 0);
{
int dataSize = 0;
int ret = -1;
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
ret = CASendEDRMulticastData(NULL, NULL);
CATerminateEDR();
assert_eq(ret, 0);
{
CAResult_t error = CA_STATUS_FAILED;
int ref = 0;
- //Startup
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ // Startup
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
error = CAStartEDRListeningServer();
assert_eq(error, CA_STATUS_OK);
- //Cleanup
+ // Cleanup
CAStopEDR();
CATerminateEDR();
return 0;
{
CAResult_t error = CA_STATUS_FAILED;
int ref = 0;
- //Startup
- CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ // Startup
+ CAInitializeEDR(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gBTThreadPool);
CAStartEDRListeningServer();
error = CAStopEDR();
assert_eq(error, CA_STATUS_OK);
- //Cleanup
+ // Cleanup
CATerminateEDR();
return 0;
}
#include <string.h>
#include "tct-liboic-core.h"
-int main(int argc, const char *argv[])
+int main(int argc, const char* argv[])
{
int result = -1;
int i;
- if (argc != 2)
- {
+ if (argc != 2) {
printf("Usage: %s <testcase name>\n", argv[0]);
return 2;
}
- for (i = 0; tc_array[i].name; i++)
- {
- if (!strcmp(argv[1], tc_array[i].name))
- {
+ for (i = 0; tc_array[i].name; i++) {
+ if (!strcmp(argv[1], tc_array[i].name)) {
if (tc_array[i].startup)
tc_array[i].startup();
extern int wifi_tc_006_sendWifiUnicastData_n(void);
extern int wifi_tc_007_sendWifiMulticastData_p(void);
extern int wifi_tc_008_sendWifiMulticastData_n(void);
-extern int wifi_tc_009_startWifiServers_p(void);
-extern int wifi_tc_010_startWifiServers_n(void);
-extern int wifi_tc_011_stopWifiServers_p(void);
+extern int wifi_tc_009_startUnicastServer_p(void);
+extern int wifi_tc_010_startUnicastServer_n(void);
+extern int wifi_tc_011_startUnicastServer_n(void);
+extern int wifi_tc_012_startUnicastServer_n(void);
+extern int wifi_tc_013_startMulticastServer_p(void);
+extern int wifi_tc_014_startMulticastServer_n(void);
+extern int wifi_tc_015_startMulticastServer_n(void);
+extern int wifi_tc_016_startMulticastServer_n(void);
+extern int wifi_tc_017_startMulticastServer_n(void);
-testcase tc_array[] =
-{
+testcase tc_array[] = {
{"wifi_tc_001_initializeWifi_p", wifi_tc_001_initializeWifi_p, utc_liboic_startup, utc_liboic_cleanup},
{"wifi_tc_002_initializeWifi_n", wifi_tc_002_initializeWifi_n, utc_liboic_startup, utc_liboic_cleanup},
{"wifi_tc_003_getWIFIInterfaceInformation_p", wifi_tc_003_getWIFIInterfaceInformation_p, utc_liboic_startup, utc_liboic_cleanup},
{"wifi_tc_006_sendWifiUnicastData_n", wifi_tc_006_sendWifiUnicastData_n, utc_liboic_startup, utc_liboic_cleanup},
{"wifi_tc_007_sendWifiMulticastData_p", wifi_tc_007_sendWifiMulticastData_p, utc_liboic_startup, utc_liboic_cleanup},
{"wifi_tc_008_sendWifiMulticastData_n", wifi_tc_008_sendWifiMulticastData_n, utc_liboic_startup, utc_liboic_cleanup},
- {"wifi_tc_009_startWifiServers_p", wifi_tc_009_startWifiServers_p, utc_liboic_startup, utc_liboic_cleanup},
- {"wifi_tc_010_startWifiServers_n", wifi_tc_010_startWifiServers_n, utc_liboic_startup, utc_liboic_cleanup},
- {"wifi_tc_011_stopWifiServers_p", wifi_tc_011_stopWifiServers_p, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_009_startUnicastServer_p", wifi_tc_009_startUnicastServer_p, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_010_startUnicastServer_n", wifi_tc_010_startUnicastServer_n, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_011_startUnicastServer_n", wifi_tc_011_startUnicastServer_n, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_012_startUnicastServer_n", wifi_tc_012_startUnicastServer_n, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_013_startMulticastServer_p", wifi_tc_013_startMulticastServer_p, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_014_startMulticastServer_n", wifi_tc_014_startMulticastServer_n, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_015_startMulticastServer_n", wifi_tc_015_startMulticastServer_n, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_016_startMulticastServer_n", wifi_tc_016_startMulticastServer_n, utc_liboic_startup, utc_liboic_cleanup},
+ {"wifi_tc_017_startMulticastServer_n", wifi_tc_017_startMulticastServer_n, utc_liboic_startup, utc_liboic_cleanup},
{NULL, NULL}
};
-//#include <glib.h>
-#include "assert.h"
-//#include "oic-core/logger.h"
-//#include "oic-core/ocstack.h"
+#include <assert.h>
+#include <stdbool.h>
+#include <unistd.h>
+
#include "interfaceHeaders/cacommon.h"
#include "interfaceHeaders/caadapterinterface.h"
-#include "interfaceHeaders/cawifiethernetadapter.h"
+#include "interfaceHeaders/cawifiadapter.h"
+#include "interfaceHeaders/uthreadpool.h"
-//& set: Liboic
+// & set: Liboic
-//Wifi callbacks
+// Wifi callbacks
-CALocalConnectivity *localWifiEndpoint = NULL;
-CARemoteEndpoint remoteMulticastEndpoint;
-CARemoteEndpoint remoteEndpoint[10]; /* 10 RemoteEndpoints are currently kept */
-char remoteIPAddress[CA_IPADDR_SIZE] =
- "192.168.1.103"; //Change the Corresponding IP address during testing.
+CALocalConnectivity_t* localWifiEndpoint = NULL;
+CARemoteEndpoint_t remoteMulticastEndpoint;
+CARemoteEndpoint_t remoteEndpoint[10]; /* 10 RemoteEndpoints are currently kept */
+char remoteIPAddress[CA_IPADDR_SIZE] = "192.168.1.103"; // Change the Corresponding IP address during testing.
char localIPAddress[CA_IPADDR_SIZE] = {0};
-int localPort = -1;
-int32_t serverId;
-//static GMainLoop *mainloop;
-//int gMainloopStatus = 0;
+static u_thread_pool_t gWiFiThreadPool = NULL;
-//Hardcoded values to Test
-typedef struct ConnectivityHandlerList
-{
- CAConnectivityType type;
- CAConnectivityHandler handler;
- struct ConnectivityHandlerList *nextHandler;
+typedef struct ConnectivityHandlerList {
+ CAConnectivityType_t type;
+ CAConnectivityHandler_t handler;
+ struct ConnectivityHandlerList* nextHandler;
} ConnectivityHandlerList;
-char coapData[500] =
- "{\"oc:\[{href\":\"/a/light\",\"ref\":{\"power\":\"20\",\"state\":\"true\"}}\]}";
+// Hardcoded values to Test
+char coapData[500] = "{\"oc:\[{href\":\"/a/light\",\"ref\":{\"power\":\"20\",\"state\":\"true\"}}\]}";
-#define CA_PORT 5683
+#define CA_PORT 5283
#define CA_MCAST_PORT 5298
/**
#define CA_MULTICAST_IP "224.0.1.187"
-CAConnectivityHandler *gCAConnectivityHandlers = NULL;
+CAConnectivityHandler_t* gCAConnectivityHandlers = NULL;
+
+void initializeThreadPool(int d)
+{
+ if (CA_STATUS_OK != u_thread_pool_init(3, &gWiFiThreadPool))
+ printf("Failed to create thread pool for WiFi adapter!\n");
+}
int interfaceInitializeEndpoint(int d)
{
- int i = 0;
+ int i = 0;
/* As of initializing one endpoint */
for (i = 0; i < 1; i++)
{
remoteEndpoint[i].connectivityType = CA_WIFI;
strncpy(remoteEndpoint[i].addressInfo.IP.ipAddress, remoteIPAddress, CA_IPADDR_SIZE);
- remoteEndpoint[i].addressInfo.IP.port = 5683; /* Send the corresponding port here */
+ remoteEndpoint[i].addressInfo.IP.port = 5283; /* Send the corresponding port here */
}
remoteMulticastEndpoint.connectivityType = CA_WIFI;
}
-void storeInterfaceCallbacks(CAConnectivityHandler *newHandler)
-{
- printf("\nstoreInterfaceCallbacks Entry in Sample");
-#if 0
- newHandler->nextHandler = NULL;
-
- CAConnectivityHandler *tempCAConnectivityHandlers = gCAConnectivityHandlers;
-
- if (!tempCAConnectivityHandlers)
- {
- gCAConnectivityHandlers = newHandler;
- return;
- }
- while (tempCAConnectivityHandlers->nextHandler)
- {
- tempCAConnectivityHandlers = tempCAConnectivityHandlers->nextHandler;
- }
-
- tempCAConnectivityHandlers->nextHandler = newHandler;
-#endif
- printf("\nstoreInterfaceCallbacks Exit in Sample");
-}
-
-/*
-void interfaceRegisterCallback(CAConnectivityHandler handler , CAConnectivityType cType)
-{
- printf("\ninterfaceRegisterCallback Entry in Sample");
- CAConnectivityHandler newCAConnectivityHandler;
- newCAConnectivityHandler.start = handler.start;
- newCAConnectivityHandler.stop = handler.stop;
- newCAConnectivityHandler.startAdapter = handler.startAdapter;
- newCAConnectivityHandler.sendData= handler.sendData;
- newCAConnectivityHandler.sendDataToAll= handler.sendDataToAll;
- newCAConnectivityHandler.statNotifyServer= handler.statNotifyServer;
- newCAConnectivityHandler.sendNotification= handler.sendNotification;
- newCAConnectivityHandler.GetnetInfo= handler.GetnetInfo;
- //newCAConnectivityHandler.cType= cType;
- storeInterfaceCallbacks(&newCAConnectivityHandler);
- printf("\ninterfaceRegisterCallback Exit in Sample");
-}
-*/
-
-void interfaceRegisterCallback(CAConnectivityHandler handler,
- CAConnectivityType connType)
+void interfaceRegisterCallback(CAConnectivityHandler_t handler,
+ CAConnectivityType_t connType)
{
printf("interfaceRegisterCallback Entry in Sample\n");
-// connectivity Handlerlist is not used
-#if 0
- ConnectivityHandlerList *newConnectivityHandler = (ConnectivityHandlerList *) malloc(sizeof(
- ConnectivityHandlerList));
- if (NULL == newConnectivityHandler)
- {
- printf("Memory allocation failed!\n");
- return;
- }
-
+ ConnectivityHandlerList* newConnectivityHandler = (ConnectivityHandlerList*) malloc(sizeof(ConnectivityHandlerList));
newConnectivityHandler->type = connType;
newConnectivityHandler->handler = handler;
- storeInterfaceCallbacks(newConnectivityHandler);
-#endif //#if 0
printf("interfaceRegisterCallback Exit in Sample\n");
}
-void requestResponseHandler(CARemoteEndpoint *object, void *data)
+void requestResponseHandler(CARemoteEndpoint_t* object, void* data)
{
printf("\nrequestResponseHandler Entry in Sample");
- if (object == NULL || data == NULL)
- {
+ if (NULL == object || NULL == data) {
printf("\nNULL Object");
- return;
}
-
if (object->addressInfo.IP.ipAddress)
printf("\nData Received from %s\n", object->addressInfo.IP.ipAddress);
if (data)
- printf("\nReceived Data : %s \n", (char *)data);
- /*
- gMainloopStatus = 1;
- if (mainloop)
- {
- g_main_loop_quit(mainloop);
- mainloop = NULL;
- }
- */
+ printf("\nReceived Data : %s \n", (char*)data);
+
printf("\nrequestResponseHandler Exit in Sample");
}
-void networkInterfaceCallback(CALocalConnectivity *localEndPoint,
- CANetworkStatus networkConnectivityState)
+void networkInterfaceCallback(CALocalConnectivity_t* localEndPoint, CANetworkStatus_t networkConnectivityState)
{
printf("\nnetworkInterfaceCallback Entry in Sample");
- if (localEndPoint == NULL)
- {
+ if (NULL == localEndPoint) {
printf("\nNULL Object");
- return;
}
-
if (localEndPoint->addressInfo.IP.ipAddress)
printf("\n Local Interface Address%s\n", localEndPoint->addressInfo.IP.ipAddress);
}
-
int wifi_tc_001_initializeWifi_p(void)
{
- CAResult error = CA_STATUS_FAILED;
- error = CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler,
- networkInterfaceCallback);
+ CAResult_t error = CA_STATUS_FAILED;
+ initializeThreadPool(0);
+ error = CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
assert_eq(error, CA_STATUS_OK);
+ u_thread_pool_free(gWiFiThreadPool);
return 0;
}
int wifi_tc_002_initializeWifi_n(void)
{
- CAResult error = CA_STATUS_FAILED;
- error = CAInitializeWifi(NULL, NULL, NULL);
- assert_eq(error, CA_STATUS_INVALID_PARAM); //Note: initializeWifi always return OC_STACK_OK
+ CAResult_t error = CA_STATUS_FAILED;
+ initializeThreadPool(0);
+ error = CAInitializeWifi(NULL, NULL, NULL, NULL);
+ assert_eq(error, CA_STATUS_INVALID_PARAM); // Note: initializeWifi always return OC_STACK_OK
+ u_thread_pool_free(gWiFiThreadPool);
return 0;
}
int wifi_tc_003_getWIFIInterfaceInformation_p(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
uint32_t size = 0;
+
+ //Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
assert_eq(error, CA_STATUS_OK);
-
- // Now, check local endpoint information
- //assert_neq(localWifiEndpoint->endpoint_info, NULL);
- strncpy(localIPAddress, localWifiEndpoint->addressInfo.IP.ipAddress, CA_IPADDR_SIZE);
- localPort = localWifiEndpoint->addressInfo.IP.port;
- assert_neq(localPort, -1);
return 0;
}
int wifi_tc_004_getWIFIInterfaceInformation_n(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
uint32_t size = 0;
error = CAGetWIFIInterfaceInformation(NULL, &size);
assert_eq(error, CA_STATUS_INVALID_PARAM);
int wifi_tc_005_sendWifiUnicastData_p(void)
{
uint32_t dataSize;
- CAResult error = CA_STATUS_FAILED;
//Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
- error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- assert_eq(error, CA_STATUS_OK);
-
- localWifiEndpoint->addressInfo.IP.port = 5683;
- //StartWifiAdapter(localWifiEndpoint);
-
+ CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
+ // localWifiEndpoint->addressInfo.IP.port = 5283;
interfaceInitializeEndpoint(0);
dataSize = CASendWIFIUnicastData(&remoteEndpoint[0], coapData, strlen(coapData));
sleep(5);
assert_eq(dataSize, strlen(coapData));
- CATerminateWifi();
+
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_006_sendWifiUnicastData_n(void)
{
int dataSize = 0;
- interfaceInitializeEndpoint(0);
dataSize = CASendWIFIUnicastData(NULL, NULL, NULL);
assert_eq(dataSize, 0);
return 0;
int wifi_tc_007_sendWifiMulticastData_p(void)
{
uint32_t dataSize = 0;
- interfaceInitializeEndpoint(0);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
+
dataSize = CASendWIFIMulticastData(coapData, strlen(coapData));
+ sleep(5);
assert_eq(dataSize, strlen(coapData));
+
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_008_sendWifiMulticastData_n(void)
{
int dataSize = 0;
- interfaceInitializeEndpoint(0);
dataSize = CASendWIFIMulticastData(NULL, NULL);
assert_eq(dataSize, 0);
return 0;
int wifi_tc_009_startUnicastServer_p(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
int16_t unicastPort = CA_PORT;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
- error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
-
- error = CAStartUnicastServer("0.0.0.0", &unicastPort);
+ int32_t serverFd = 0;
+ // error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
+ error = CAWiFiStartUnicastServer("0.0.0.0", &unicastPort, false, false, &serverFd);
assert_eq(error, CA_STATUS_OK);
- //Cleanup
- CAStopUnicastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_010_startUnicastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ CAResult_t error = CA_STATUS_FAILED;
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- assert_eq(error, CA_STATUS_OK);
- error = CAStartUnicastServer(NULL, localWifiEndpoint->addressInfo.IP.port);
+ error = CAWiFiStartUnicastServer(NULL, &localWifiEndpoint->addressInfo.IP.port, false, false, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopUnicastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_011_startUnicastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ CAResult_t error = CA_STATUS_FAILED;
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- assert_eq(error, CA_STATUS_OK);
- error = CAStartUnicastServer(localWifiEndpoint->addressInfo.IP.ipAddress, NULL);
+ error = CAWiFiStartUnicastServer(localWifiEndpoint->addressInfo.IP.ipAddress, NULL, false, false, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopUnicastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_012_startUnicastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ CAResult_t error = CA_STATUS_FAILED;
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- assert_eq(error, CA_STATUS_OK);
- error = CAStartUnicastServer(NULL, NULL);
+ error = CAWiFiStartUnicastServer(NULL, NULL, false, false, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopUnicastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_013_startMulticastServer_p(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
int16_t multicastPort = CA_MCAST_PORT;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- error = CAStartMulticastServer(CA_MULTICAST_IP, "0.0.0.0", &multicastPort);
+ error = CAWiFiStartMulticastServer("0.0.0.0", CA_MULTICAST_IP, multicastPort, &serverFd);
assert_eq(error, CA_STATUS_OK);
- //Cleanup
- CAStopMulticastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_014_startMulticastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
int16_t multicastPort = CA_MCAST_PORT;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- error = CAStartMulticastServer(NULL, "0.0.0.0", &multicastPort);
+ error = CAWiFiStartMulticastServer(NULL, "0.0.0.0", multicastPort, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopMulticastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_015_startMulticastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
int16_t multicastPort = CA_MCAST_PORT;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- error = CAStartMulticastServer(CA_MULTICAST_IP, NULL, &multicastPort);
+ error = CAWiFiStartMulticastServer(NULL, CA_MULTICAST_IP, multicastPort, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopMulticastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_016_startMulticastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
int16_t multicastPort = CA_MCAST_PORT;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- error = CAStartMulticastServer(CA_MULTICAST_IP, "0.0.0.0", NULL);
+ error = CAWiFiStartMulticastServer("0.0.0.0", CA_MULTICAST_IP, NULL, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopMulticastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
int wifi_tc_017_startMulticastServer_n(void)
{
- CAResult error = CA_STATUS_FAILED;
+ CAResult_t error = CA_STATUS_FAILED;
int16_t multicastPort = CA_MCAST_PORT;
- //Startup
- CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback);
+ // Startup
+ initializeThreadPool(0);
+ CAInitializeWifi(interfaceRegisterCallback, requestResponseHandler, networkInterfaceCallback, gWiFiThreadPool);
+ CAStartWIFI();
uint32_t size = 0;
+ int32_t serverFd = 0;
error = CAGetWIFIInterfaceInformation(&localWifiEndpoint, &size);
- error = CAStartMulticastServer(NULL, NULL, NULL);
+ error = CAWiFiStartMulticastServer(NULL, NULL, NULL, NULL, &serverFd);
assert_eq(error, CA_STATUS_INVALID_PARAM);
- //Cleanup
- CAStopMulticastServer();
- CATerminateWifi();
+ // Cleanup
+ CAStopWIFI();
+ u_thread_pool_free(gWiFiThreadPool);
+ CATerminateWIfI();
return 0;
}
samples_env.AppendUnique(LIBS = ['-lpthread'])
samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
samples_env.PrependUnique(LIBS = ['oc', 'm', 'octbstack', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction'])
-
+if env.get('SECURED') == '1':
+ samples_env.AppendUnique(LIBS = ['tinydtls'])
samples_env.ParseConfig('pkg-config --libs glib-2.0');
samples_env.AppendUnique(CPPDEFINES = ['CA_INT', 'TB_LOG'])
samples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
samples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'm', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction'])
+if env.get('SECURED') == '1':
+ samples_env.AppendUnique(LIBS = ['tinydtls'])
+
samples_env.Append(LINKFLAGS = ['-Wl,--no-as-needed'])
samples_env.ParseConfig('pkg-config --libs glib-2.0');
examples_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
examples_env.PrependUnique(LIBS = ['oc', 'octbstack', 'coap', 'coap_csdk', 'oc_logger', 'connectivity_abstraction'])
+if env.get('SECURED') == '1':
+ examples_env.AppendUnique(LIBS = ['tinydtls'])
examples_env.ParseConfig('pkg-config --libs glib-2.0');
sample_env.AppendUnique(LIBS = ['oc', 'oc_logger', 'octbstack', 'coap', 'coap_csdk',
'connectivity_abstraction',
'ppm', 'pmimpl', 'dl'])
-
+if env.get('SECURED') == '1':
+ sample_env.AppendUnique(LIBS = ['tinydtls'])
sample_env.ParseConfig('pkg-config --libs glib-2.0')
######################################################################
linux_sample_env.AppendUnique(LIBS = ['libcoap'])
linux_sample_env.AppendUnique(LIBS = ['liboc_logger'])
linux_sample_env.AppendUnique(LIBS = ['dl'])
+if env.get('SECURED') == '1':
+ linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
linux_sample_env.AppendUnique(LIBS = ['coap'])
linux_sample_env.AppendUnique(LIBS = ['coap_csdk'])
linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
-
+if env.get('SECURED') == '1':
+ linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
######################################################################
linux_sample_env.AppendUnique(LIBS = ['coap'])
linux_sample_env.AppendUnique(LIBS = ['coap_csdk'])
linux_sample_env.AppendUnique(LIBS = ['connectivity_abstraction'])
-
+if lib_env.get('SECURED') == '1':
+ linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
'connectivity_abstraction', 'coap_csdk',
'libcoap', 'liboc_logger', 'dl', 'pthread'])
-
+if env.get('SECURED') == '1':
+ linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
######################################################################
linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
'coap_csdk', 'connectivity_abstraction',
'libcoap', 'liboc_logger', 'dl', 'pthread'])
-
+if env.get('SECURED') == '1':
+ linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
######################################################################
linux_sample_env.AppendUnique(LIBS = ['libTGMSDKLibrary', 'oc', 'octbstack',
'coap_csdk', 'connectivity_abstraction',
'libcoap', 'liboc_logger', 'dl', 'pthread'])
-
+if env.get('SECURED') == '1':
+ linux_sample_env.AppendUnique(LIBS = ['tinydtls'])
linux_sample_env.ParseConfig('pkg-config --libs glib-2.0')
######################################################################