+#******************************************************************
+#
+# Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
+#
##
# This script includes arduino specific config for oic-resource
##
-Import('env', 'TARGET_CPU_ARCH', 'ARDUINO_HOME')
-
-# 'NET' build option
-if env.get('NET') is None:
- vars = Variables()
- vars.Add(EnumVariable('NET', 'Network connection type', 'Ethernet', ['Ethernet', 'Wifi']))
- vars.Update(env)
- Help(vars.GenerateHelpText(env))
-
-env.AppendUnique(CPPPATH = [
- ARDUINO_HOME + '/libraries/Ethernet/src',
- ARDUINO_HOME + '/libraries/Ethernet/src/utility',
- ARDUINO_HOME + '/libraries/WiFi/src',
- ARDUINO_HOME + '/libraries/WiFi/src/utility',
- ARDUINO_HOME + '/libraries/Time/',
- ])
-
-if TARGET_CPU_ARCH == 'arm':
- # Include path
- env.AppendUnique(CPPPATH = [
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/USB',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/avr',
- 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',
- ARDUINO_HOME + '/hardware/arduino/sam/variants/arduino_due_x',
- ARDUINO_HOME + '/hardware/arduino/sam/libraries/SPI',
- ])
-
- # Compiler/Linker flags
- env.AppendUnique(CXXFLAGS = ['-ffunction-sections', '-fdata-sections', '-nostdlib',
- '--param', 'max-inline-insns-single=500', '-fno-rtti', '-fno-exceptions',
- '-mcpu=cortex-m3', '-mthumb'
- ])
- env.AppendUnique(CPPDEFINES = ['printf=iprintf', 'F_CPU=84000000L', 'ARDUINO=157',
- 'ARDUINO_SAM_DUE', 'ARDUINO_ARCH_SAM', '__SAM3X8E__', 'USB_VID=0x2341',
- 'USB_PID=0x003e', 'USBCON', 'DUSB_MANUFACTURER="Unknown"', 'WITH_ARDUINO',
- ])
-
- # Source
- ARDUINO_SRC = []
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/*.c'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/*.cpp'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/avr/*.c'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/USB/*.cpp'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/variants/arduino_due_x/*.cpp'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/hardware/arduino/sam/libraries/SPI/*.cpp'))
-else:
- # Include path
- env.AppendUnique(CPPPATH = [
- ARDUINO_HOME + '/hardware/arduino/avr/cores/arduino',
- ARDUINO_HOME + '/hardware/arduino/avr/libraries/SPI',
- ARDUINO_HOME + '/hardware/arduino/avr/variants/mega',
- ])
-
- # Compiler/Linker flags
- env.AppendUnique(CXXFLAGS = ['-mmcu=atmega2560', '-MMD', '-std=c++0x',
- '-Wno-write-strings', '-ffunction-sections', '-fdata-sections',
- '-fno-exceptions', '-felide-constructors'
- ])
- env.AppendUnique(CPPDEFINES = ['F_CPU=16000000L', 'ARDUINO=156', 'ARDUINO_AVR_MEGA2560',
- 'ARDUINO_ARCH_AVR', 'WITH_ARDUINO', 'ATMEGA2560'
- ])
-
- # Source
- ARDUINO_SRC = [
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/WInterrupts.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/wiring.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/wiring_digital.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/main.cpp',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/Stream.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/WMath.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/WString.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/HardwareSerial.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/Print.c',
- ARDUINO_HOME + '/hardware/arduino/sam/cores/arduino/IPAddress.c',
- ARDUINO_HOME + '/hardware/arduino/avr/libraries/SPI/SPI.cpp',
- ]
-
-if env.get('NET') == 'Ethernet':
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/Ethernet/src/*.cpp'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/Ethernet/src/utility/*.cpp'))
-else:
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/WiFi/src/*.cpp'))
- ARDUINO_SRC.extend(Glob(ARDUINO_HOME + '/libraries/WiFi/src/utility/*.cpp'))
-
-Export('ARDUINO_SRC')
\ No newline at end of file
+Import('env')
+
+# Add 'SHIELD' build option, let user select board network connection type
+vars = Variables()
+if 'IP' in env.get('TARGET_TRANSPORT'):
+ vars.Add(EnumVariable('SHIELD', 'Network connection type', 'WIFI', ['ETH', 'WIFI']))
+elif 'BLE' in env.get('TARGET_TRANSPORT'):
+ vars.Add(EnumVariable('SHIELD', 'Network connection type', 'RBL_NRF8001', ['RBL_NRF8001']))
+vars.Update(env)
+Help(vars.GenerateHelpText(env))
+
+env.ImportLib('SPI')
+if 'ETH' in env.get('SHIELD'):
+ env.ImportLib('Ethernet')
+ env.AppendUnique(CPPDEFINES = ['ARDUINOETH'])
+if 'WIFI' in env.get('SHIELD'):
+ env.ImportLib('WiFi')
+ env.AppendUnique(CPPDEFINES = ['ARDUINOWIFI'])
+if 'RBL_NRF8001' in env.get('SHIELD'):
+ env.ImportLib('BLE')
+ env.ImportLib('RBL_nRF8001')
+
+env.ImportLib('Time/Time')
+# we have variety of macros for arduino!!
+env.AppendUnique(CPPDEFINES = ['WITH_ARDUINO', '__ARDUINO__'])
+# Set device name to __OIC_DEVICE_NAME__
+env.AppendUnique(CPPDEFINES = ['-D__OIC_DEVICE_NAME__=' + "\'\"" + env.get('DEVICE_NAME') + "\"\'"])
+if env.get('LOGGING'):
+ env.AppendUnique(CPPDEFINES = ['TB_LOG'])