easy_setup_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
if target_os not in ['linux', 'arduino']:
easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'connectivity_abstraction', 'gnustl_shared'])
+ if not env.get('RELEASE'):
+ easy_setup_env.AppendUnique(LIBS = ['log'])
else:
easy_setup_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction'])
-
- if not env.get('RELEASE'):
- easy_setup_env.AppendUnique(LIBS = ['log'])
-
if target_os == 'arduino':
easy_setup_env.AppendUnique(CPPPATH = [
env.get('SRC_DIR') + '/resource/csdk/stack/include',
env.get('SRC_DIR') + '/resource/csdk/logger/include',
env.get('SRC_DIR') + '/resource/csdk/security/include',
- env.get('SRC_DIR') + '/extlibs/cjson'
- ])
+ env.get('SRC_DIR') + '/extlibs/cjson',
+ 'sdk/common',
+ 'sdk/mediator/inc'])
######################################################################
# Source files and Targets
if target_os == 'android':
- es_sdk_shared = easy_setup_env.SharedLibrary('libESSDK',
- ['sdk/src/easysetupmgr.cpp',
- 'sdk/src/camutex_pthreads.c',
- 'sdk/src/provisioninghandler.cpp'])
+ es_sdk_shared = easy_setup_env.StaticLibrary('libESSDK',
+ ['sdk/mediator/src/easysetupmgr.cpp',
+ 'sdk/mediator/src/camutex_pthreads.c',
+ 'sdk/mediator/src/provisioninghandler.cpp'])
easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
if target_os == 'linux':
es_sdk_shared = easy_setup_env.SharedLibrary('ESSDKLibrary',
- ['sdk/src/easysetupmgr.cpp',
- 'sdk/src/camutex_pthreads.c',
- 'sdk/src/provisioninghandler.cpp'])
+ ['sdk/mediator/src/easysetupmgr.cpp',
+ 'sdk/mediator/src/camutex_pthreads.c',
+ 'sdk/mediator/src/provisioninghandler.cpp'])
easy_setup_env.InstallTarget(es_sdk_shared, 'libESSDK')
#Go to build sample apps
env.get('SRC_DIR') + '/resource/csdk/logger/include',
env.get('SRC_DIR') + '/resource/csdk/security/include',
env.get('SRC_DIR') + '/extlibs/cjson',
- env.get('SRC_DIR') + '/service/easy-setup/sdk/inc'
- ])
+ env.get('SRC_DIR') + '/service/easy-setup/sdk/mediator/inc',
+ env.get('SRC_DIR') + '/service/easy-setup/sdk/common'])
richclient_env.PrependUnique(LIBS = ['oc', 'octbstack', 'oc_logger', 'pthread', 'connectivity_abstraction', 'coap', 'ESSDKLibrary'])
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<classpath>\r
- <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>\r
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>\r
- <classpathentry exported="true" kind="con" path="com.android.ide.eclipse.adt.DEPENDENCIES"/>\r
- <classpathentry kind="src" path="src"/>\r
- <classpathentry kind="src" path="gen"/>\r
- <classpathentry kind="output" path="bin/classes"/>\r
-</classpath>\r
+++ /dev/null
-<?xml version="1.0" encoding="UTF-8"?>\r
-<projectDescription>\r
- <name>EasySetupCore</name>\r
- <comment></comment>\r
- <projects>\r
- </projects>\r
- <buildSpec>\r
- <buildCommand>\r
- <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>org.eclipse.jdt.core.javabuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- <buildCommand>\r
- <name>com.android.ide.eclipse.adt.ApkBuilder</name>\r
- <arguments>\r
- </arguments>\r
- </buildCommand>\r
- </buildSpec>\r
- <natures>\r
- <nature>com.android.ide.eclipse.adt.AndroidNature</nature>\r
- <nature>org.eclipse.jdt.core.javanature</nature>\r
- </natures>\r
-</projectDescription>\r
+++ /dev/null
-LOCAL_PATH := $(call my-dir)
-
-ifeq ($(strip $(ANDROID_NDK)),)
-$(error ANDROID_NDK is not set!)
-endif
-
-$(warning "Current path" $(LOCAL_PATH))
-$(info TC_PREFIX=$(TOOLCHAIN_PREFIX))
-$(info CFLAGS=$(TARGET_CFLAGS))
-$(info CXXFLAGS=$(TARGET_CXXFLAGS) $(TARGET_NO_EXECUTE_CFLAGS))
-$(info CPPFLAGS=$(TARGET_CPPFLAGS))
-$(info CPPPATH=$(TARGET_C_INCLUDES) $(__ndk_modules.$(APP_STL).EXPORT_C_INCLUDES))
-$(info SYSROOT=$(SYSROOT_LINK))
-$(info LDFLAGS=$(TARGET_LDFLAGS) $(TARGET_NO_EXECUTE_LDFLAGS) $(TARGET_NO_UNDEFINED_LDFLAGS) $(TARGET_RELRO_LDFLAGS))
-$(info TC_VER=$(TOOLCHAIN_VERSION))
-$(info PLATFORM=$(APP_PLATFORM))
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../dep/android/$(TARGET_ARCH_ABI)/usr/lib
-LOCAL_MODULE := libandroid-boost_system
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libboost_system.a
-include $(PREBUILT_STATIC_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/debug
-LOCAL_MODULE := android-oc_logger
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc_logger.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/debug
-LOCAL_MODULE := android-octbstack
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/debug
-LOCAL_MODULE := android-oc
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboc.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/debug
-LOCAL_MODULE := android-connectivity_abstraction
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../android/android_api/base/libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := android-ocstack-jni
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libocstack-jni.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../android/android_api/base/libs/$(TARGET_ARCH_ABI)
-LOCAL_MODULE := android-ca-interface
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libca-interface.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-OIC_LIB_PATH := ../../../../../out/android/$(TARGET_ARCH_ABI)/debug
-LOCAL_MODULE := android-easysetup
-LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libESSDK.so
-include $(PREBUILT_SHARED_LIBRARY)
-
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := easysetup-jni
-
-#Add Pre processor definitions
-DEFINE_FLAG = -DWITH_POSIX -D__ANDROID__
-
-#Add Debug flags here
-DEBUG_FLAG = -DTB_LOG
-
-BUILD_FLAG = $(DEFINE_FLAG) $(DEBUG_FLAG)
-
-LOCAL_CPPFLAGS = $(BUILD_FLAG)
-LOCAL_CPPFLAGS += -std=c++0x -frtti -fexceptions
-
-$(info CPPFLAGSUPDATED=$(LOCAL_CPPFLAGS))
-
-NDK_ROOT := /home/madan/android-ndk-r10d
-
-LOCAL_C_INCLUDES := $(LOCAL_PATH) \
- $(LOCAL_PATH)/jniutil/inc \
- $(LOCAL_PATH)/../../../../../service/easy-setup/sdk/inc \
- $(LOCAL_PATH)/../../../../../resource/csdk/logger/include \
- $(LOCAL_PATH)/../../../../../resource/csdk/connectivity/common/inc \
- $(LOCAL_PATH)/../../../../../resource/include \
- $(LOCAL_PATH)/../../../../../resource/oc_logger/include \
- $(LOCAL_PATH)/../../../../../resource/csdk/ocmalloc/include \
- $(LOCAL_PATH)/../../../../../resource/csdk/connectivity/api \
- $(LOCAL_PATH)/../../../../../resource/csdk/stack/include \
- $(LOCAL_PATH)/../../../../../resource/csdk/logger/include \
- $(LOCAL_PATH)/../../../../../resource/csdk/security/include \
- $(LOCAL_PATH)/../../../../../extlibs/cjson \
- $(LOCAL_PATH)/../../../../../extlibs/boost/boost_1_58_0 \
- $(LOCAL_PATH)/../../../../../extlibs/timer \
- $(LOCAL_PATH)/../../../../../android/android_api/base/jni \
- $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include \
- $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include \
-
-LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/jni_easy_setup.cpp))
-LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/jniutil/src/*.cpp))
-
-LOCAL_LDLIBS := -llog
-LOCAL_LDLIBS += -L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)
-LOCAL_SHARED_LIBRARIES := android-easysetup
-LOCAL_STATIC_LIBRARIES := android-boost_system
-
-include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-// Do not remove the include below
-#include "Arduino.h"
-
-#include "logger.h"
-#include "ocstack.h"
-#include <string.h>
-
-#ifdef ARDUINOWIFI
-// Arduino WiFi Shield
-#include <SPI.h>
-#include <WiFi.h>
-#include <WiFiUdp.h>
-#else
-// Arduino Ethernet Shield
-#include <EthernetServer.h>
-#include <Ethernet.h>
-#include <Dns.h>
-#include <EthernetClient.h>
-#include <util.h>
-#include <EthernetUdp.h>
-#include <Dhcp.h>
-#endif
-
-#include "common.h"
-
-#ifndef ES_NETWORK_HANDLER_H_
-#define ES_NETWORK_HANDLER_H_
-
-#define MAXSSIDLEN 33
-#define MAXNETCREDLEN 20
-#define MAXNUMTYPE 5
-#define MAXADDRLEN 15
-
-typedef void (*NetworkEventCallback)(ES_RESULT);
-
-enum NetworkType
-{
- ES_WIFI = 1, ES_BT = 2, ES_BLE = 3, ES_ZIGBEE = 4, ES_ETH = 5
-};
-
-typedef struct NETWORKINFO
-{
- NetworkType type;
-
- // for WiFI
- IPAddress ipaddr;
- char ssid[MAXSSIDLEN];
-
- // for BT, BLE
- byte mac[6];
-} NetworkInfo;
-
-ES_RESULT ConnectToWiFiNetworkForOnboarding(char *ssid, char *pass, NetworkEventCallback);
-int getCurrentNetworkInfo(NetworkType targetType, NetworkInfo *info);
-
-#endif
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2014 Samsung Electronics 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.
-//
-//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
-
-#include "networkHandler.h"
-
-PROGMEM const char TAG[] = "ArduinoServer";
-
-int findNetwork(char *ssid);
-int ConnectToNetwork(char *ssid, char *pass);
-void printEncryptionType(int thisType);
-
-// Arduino WiFi Shield
-// Note : Arduino WiFi Shield currently does NOT support multicast and therefore
-// this server will NOT be listening on 224.0.1.187 multicast address.
-
-static const char ARDUINO_WIFI_SHIELD_UDP_FW_VER[] = "1.1.0";
-
-IPAddress myIP;
-
-ES_RESULT ConnectToWiFiNetworkForOnboarding(char *ssid, char *pass, NetworkEventCallback cb)
-{
- char *fwVersion;
- int status = WL_IDLE_STATUS;
- int res;
-
- // check for the presence of the shield:
- if (WiFi.status() == WL_NO_SHIELD)
- {
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
- return ES_ERROR;
- }
-
- // Verify that WiFi Shield is running the firmware with all UDP fixes
- fwVersion = WiFi.firmwareVersion();
- OC_LOG_V(INFO, TAG, "WiFi Shield Firmware version %s", fwVersion);
- if (strncmp(fwVersion, ARDUINO_WIFI_SHIELD_UDP_FW_VER, sizeof(ARDUINO_WIFI_SHIELD_UDP_FW_VER))
- != 0)
- {
- OC_LOG(DEBUG, TAG, PCF("!!!!! Upgrade WiFi Shield Firmware version !!!!!!"));
- return ES_ERROR;
- }
-
- while (findNetwork(ssid) == 0) // found
- {
- delay(2000);
- }
-
- if (cb != NULL)
- {
- cb(ES_NETWORKFOUND);
- }
-
- if (WiFi.status() == WL_CONNECTED)
- WiFi.disconnect();
-
- res = ConnectToNetwork(ssid, pass);
-
- if (res == 0)
- {
- return ES_NETWORKCONNECTED;
- }
- else
- {
- return ES_NETWORKNOTCONNECTED;
- }
-}
-
-int findNetwork(char *ssid)
-{
- int res = 0;
- // scan for nearby networks:
- Serial.println("** Scan Networks **");
- int numSsid = WiFi.scanNetworks();
- if (numSsid == -1)
- {
- Serial.println("Couldn't get a wifi connection");
-
- return res;
- }
-
- // print the list of networks seen:
- Serial.print("number of available networks:");
- Serial.println(numSsid);
-
- // print the network number and name for each network found:
- for (int thisNet = 0; thisNet < numSsid; thisNet++)
- {
- Serial.print(thisNet);
- Serial.print(") ");
- Serial.print(WiFi.SSID(thisNet));
- Serial.print("\tEncryption: ");
- printEncryptionType(WiFi.encryptionType(thisNet));
-
- if (strcmp(WiFi.SSID(thisNet), ssid) == 0)
- {
- res = 1;
- }
- }
-
- return res;
-}
-
-int ConnectToNetwork(char *ssid, char *pass)
-{
- int status = WL_IDLE_STATUS;
- //IPAddress desiredIP(192, 168, 43, 2);
- //IPAddress desiredIP(192, 168, 0, 115);
-
- //WiFi.config(desiredIP);
-
- // attempt to connect to Wifi network:
- while (status != WL_CONNECTED)
- {
- OC_LOG_V(INFO, TAG, "Attempting to connect to SSID: %s", ssid);
-
- status = WiFi.begin(ssid, pass);
-
- // wait 10 seconds for connection:
- delay(10000);
- }
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
-
- myIP = WiFi.localIP();
- OC_LOG_V(INFO, TAG, "IP Address: %d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
-
- char buf[50];
- sprintf(buf, "IP Address: %d.%d.%d.%d", myIP[0], myIP[1], myIP[2], myIP[3]);
- Serial.println(buf);
-
- return 0;
-}
-
-int getCurrentNetworkInfo(NetworkType targetType, NetworkInfo *info)
-{
- if (targetType == ES_WIFI && WiFi.status() == WL_CONNECTED)
- {
- info->type = ES_WIFI;
- info->ipaddr = WiFi.localIP();
- strcpy(info->ssid, WiFi.SSID());
-
- return 0;
- }
-
- return -1;
-}
-
-void printEncryptionType(int thisType)
-{
- // read the encryption type and print out the name:
- switch (thisType)
- {
- case ENC_TYPE_WEP:
- Serial.println("WEP");
- break;
- case ENC_TYPE_TKIP:
- Serial.println("WPA");
- break;
- case ENC_TYPE_CCMP:
- Serial.println("WPA2");
- break;
- case ENC_TYPE_NONE:
- Serial.println("None");
- break;
- case ENC_TYPE_AUTO:
- Serial.println("Auto");
- break;
- }
-}
#ifndef ES_COMMON_H_
#define ES_COMMON_H_
+#include "ocstack.h"
+#include "octypes.h"
+
+// Defines
+#define OIC_STRING_MAX_VALUE 100
+#define IPV4_ADDR_SIZE 16
+#define IP_PORT 6298
+#define NET_WIFI_SSID_SIZE 16
+#define NET_WIFI_PWD_SIZE 16
+
+/**
+ * @brief Mac address length for BT port
+ */
+#define NET_MACADDR_SIZE 18
+
+//The following variable determines the interface (wifi, ethernet etc.)
+//to be used for sending unicast messages. Default set to Ethernet.
+static OCConnectivityType OC_CONNTYPE = OC_IPV4;
+
+static const char * UNICAST_PROVISIONING_QUERY = "coap://%s:%d/oic/res?rt=oic.prov";
+static const char * OIC_PROVISIONING_URI = "/oic/prov";
+
typedef enum
{
ES_ERROR = -1,
ES_RECVTRIGGEROFPROVRES,
} ES_RESULT;
+
+/**
+ * Provisioning Device Status
+ */
+typedef struct {
+ /// Address of remote server
+ OCDevAddr * addr;
+ /// Indicates adaptor type on which the response was received
+ OCConnectivityType connType;
+} ProvDeviceInfo;
+
+/**
+ * Provosioning Status
+ */
+typedef enum {
+ DEVICE_PROVISIONED = 0, DEVICE_NOT_PROVISIONED
+} ProvStatus;
+
+/**
+ * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
+ */
+typedef struct {
+ // Provisioning Status
+ ProvStatus provStatus;
+ // Provisioning Device Info
+ ProvDeviceInfo provDeviceInfo;
+} ProvisioningInfo;
+
+/**
+ * @brief Network information of the Enroller
+ */
+typedef union
+{
+ /**
+ * @brief BT Mac Information
+ */
+ struct
+ {
+ char btMacAddress[NET_MACADDR_SIZE]; /**< BT mac address **/
+ } BT;
+
+ /**
+ * @brief LE MAC Information
+ */
+ struct
+ {
+ char leMacAddress[NET_MACADDR_SIZE]; /**< BLE mac address **/
+ } LE;
+
+ /**
+ * @brief IP Information
+ */
+ struct
+ {
+ char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enroller**/
+ char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
+ char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
+ } WIFI;
+} EnrolleeInfo_t;
+
+
+/**
+ * @brief Network Information
+ */
+typedef struct
+{
+ EnrolleeInfo_t netAddressInfo; /**< Enroller Network Info**/
+ OCConnectivityType connType; /**< Connectivity Type**/
+ bool isSecured; /**< Secure connection**/
+} EnrolleeNWProvInfo_t;
+
+/**
+ * Client applications implement this callback to consume responses received from Servers.
+ */
+typedef void (*OCProvisioningStatusCB)(ProvisioningInfo provInfo);
+
#endif
+++ /dev/null
-//******************************************************************
-//
-// Copyright 2015 Samsung Electronics 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 __EASY_CONNECT_COMMON_H_
-#define __EASY_CONNECT_COMMON_H_
-
-#include "ocstack.h"
-#include "octypes.h"
-
-// Defines
-#define OIC_STRING_MAX_VALUE 100
-#define IPV4_ADDR_SIZE 16
-#define IP_PORT 6298
-#define NET_WIFI_SSID_SIZE 16
-#define NET_WIFI_PWD_SIZE 16
-
-/**
- * @brief Mac address length for BT port
- */
-#define NET_MACADDR_SIZE 18
-
-//The following variable determines the interface (wifi, ethernet etc.)
-//to be used for sending unicast messages. Default set to Ethernet.
-static OCConnectivityType OC_CONNTYPE = OC_IPV4;
-
-static const char * UNICAST_PROVISIONING_QUERY = "coap://%s:%d/oic/res?rt=oic.prov";
-static const char * OIC_PROVISIONING_URI = "/oic/prov";
-
-/**
- * Provisioning Device Status
- */
-typedef struct {
- /// Address of remote server
- OCDevAddr * addr;
- /// Indicates adaptor type on which the response was received
- OCConnectivityType connType;
-} ProvDeviceInfo;
-
-/**
- * Provosioning Status
- */
-typedef enum {
- DEVICE_PROVISIONED = 0, DEVICE_NOT_PROVISIONED
-} ProvStatus;
-
-/**
- * Response from queries to remote servers. Queries are made by calling the @ref OCDoResource API.
- */
-typedef struct {
- // Provisioning Status
- ProvStatus provStatus;
- // Provisioning Device Info
- ProvDeviceInfo provDeviceInfo;
-} ProvisioningInfo;
-
-/**
- * @brief Network information of the Enroller
- */
-typedef union
-{
- /**
- * @brief BT Mac Information
- */
- struct
- {
- char btMacAddress[NET_MACADDR_SIZE]; /**< BT mac address **/
- } BT;
-
- /**
- * @brief LE MAC Information
- */
- struct
- {
- char leMacAddress[NET_MACADDR_SIZE]; /**< BLE mac address **/
- } LE;
-
- /**
- * @brief IP Information
- */
- struct
- {
- char ipAddress[IPV4_ADDR_SIZE]; /**< IP Address of the Enroller**/
- char ssid[NET_WIFI_SSID_SIZE]; /**< ssid of the Enroller**/
- char pwd[NET_WIFI_PWD_SIZE]; /**< pwd of the Enroller**/
- } WIFI;
-} EnrolleeInfo_t;
-
-
-/**
- * @brief Network Information
- */
-typedef struct
-{
- EnrolleeInfo_t netAddressInfo; /**< Enroller Network Info**/
- OCConnectivityType connType; /**< Connectivity Type**/
- bool isSecured; /**< Secure connection**/
-} EnrolleeNWProvInfo_t;
-
-/**
- * Client applications implement this callback to consume responses received from Servers.
- */
-typedef void (*OCProvisioningStatusCB)(ProvisioningInfo provInfo);
-
-#endif
-
// Load Easy Setup JNI interface\r
System.loadLibrary("gnustl_shared");\r
System.loadLibrary("octbstack");\r
- System.loadLibrary("oc");\r
System.loadLibrary("connectivity_abstraction");\r
- System.loadLibrary("ca-interface");\r
- System.loadLibrary("ESSDK");\r
System.loadLibrary("easysetup-jni");\r
}\r
\r
--- /dev/null
+LOCAL_PATH := $(call my-dir)
+
+ifeq ($(strip $(ANDROID_NDK)),)
+$(error ANDROID_NDK is not set!)
+endif
+
+$(warning "Current path" $(LOCAL_PATH))
+$(info TC_PREFIX=$(TOOLCHAIN_PREFIX))
+$(info CFLAGS=$(TARGET_CFLAGS))
+$(info CXXFLAGS=$(TARGET_CXXFLAGS) $(TARGET_NO_EXECUTE_CFLAGS))
+$(info CPPFLAGS=$(TARGET_CPPFLAGS))
+$(info CPPPATH=$(TARGET_C_INCLUDES) $(__ndk_modules.$(APP_STL).EXPORT_C_INCLUDES))
+$(info SYSROOT=$(SYSROOT_LINK))
+$(info LDFLAGS=$(TARGET_LDFLAGS) $(TARGET_NO_EXECUTE_LDFLAGS) $(TARGET_NO_UNDEFINED_LDFLAGS) $(TARGET_RELRO_LDFLAGS))
+$(info TC_VER=$(TOOLCHAIN_VERSION))
+$(info PLATFORM=$(APP_PLATFORM))
+
+include $(CLEAR_VARS)
+OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug
+LOCAL_MODULE := android-octbstack
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/liboctbstack.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug
+LOCAL_MODULE := android-connectivity_abstraction
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libconnectivity_abstraction.so
+include $(PREBUILT_SHARED_LIBRARY)
+
+include $(CLEAR_VARS)
+OIC_LIB_PATH := ../../../../../../out/android/$(TARGET_ARCH_ABI)/debug
+LOCAL_MODULE := android-easysetup
+LOCAL_SRC_FILES := $(OIC_LIB_PATH)/libESSDK.a
+include $(PREBUILT_STATIC_LIBRARY)
+
+include $(CLEAR_VARS)
+
+LOCAL_MODULE := easysetup-jni
+
+#Add Pre processor definitions
+DEFINE_FLAG = -DWITH_POSIX -D__ANDROID__
+
+#Add Debug flags here
+DEBUG_FLAG = -DTB_LOG
+
+BUILD_FLAG = $(DEFINE_FLAG) $(DEBUG_FLAG)
+
+LOCAL_CPPFLAGS = $(BUILD_FLAG)
+LOCAL_CPPFLAGS += -std=c++0x -frtti -fexceptions
+
+$(info CPPFLAGSUPDATED=$(LOCAL_CPPFLAGS))
+
+NDK_ROOT := /home/madan/android-ndk-r10d
+
+LOCAL_C_INCLUDES := $(LOCAL_PATH) \
+ $(LOCAL_PATH)/jniutil/inc \
+ $(LOCAL_PATH)/../../../../../../service/easy-setup/sdk/mediator/inc \
+ $(LOCAL_PATH)/../../../../../../service/easy-setup/sdk/common \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/logger/include \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/connectivity/common/inc \
+ $(LOCAL_PATH)/../../../../../../resource/include \
+ $(LOCAL_PATH)/../../../../../../resource/oc_logger/include \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/ocmalloc/include \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/connectivity/api \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/stack/include \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/logger/include \
+ $(LOCAL_PATH)/../../../../../../resource/csdk/security/include \
+ $(LOCAL_PATH)/../../../../../../extlibs/cjson \
+ $(LOCAL_PATH)/../../../../../../extlibs/boost/boost_1_58_0 \
+ $(LOCAL_PATH)/../../../../../../extlibs/timer \
+ $(LOCAL_PATH)/../../../../../../android/android_api/base/jni \
+ $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/include \
+ $(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include \
+
+LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/jni_easy_setup.cpp))
+LOCAL_SRC_FILES += $(patsubst $(LOCAL_PATH)/%, %, $(wildcard $(LOCAL_PATH)/jniutil/src/*.cpp))
+
+LOCAL_LDLIBS := -llog
+LOCAL_LDLIBS += -L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)
+LOCAL_SHARED_LIBRARIES := android-easysetup
+LOCAL_SHARED_LIBRARIES += android-connectivity_abstraction
+LOCAL_SHARED_LIBRARIES += android-octbstack
+
+include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
APP_STL := gnustl_shared
+APP_PLATFORM = android-21
NDK_TOOLCHAIN_VERSION := 4.8
#include "logger.h"
#include "ocstack.h"
#include "octypes.h"
-#include "easysetupcommon.h"
+#include "common.h"
+
+#include "provisioninghandler.h"
+
//-----------------------------------------------------------------------------
// Defines
--- /dev/null
+//******************************************************************
+//
+// Copyright 2015 Samsung Electronics 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 __PROVISIONING_HANDLER_H_
+#define __PROVISIONING_HANDLER_H_
+
+#include "logger.h"
+#include "ocstack.h"
+#include "common.h"
+
+//-----------------------------------------------------------------------------
+// Defines
+//-----------------------------------------------------------------------------
+#define TAG "provisioninghandler"
+#define DEFAULT_CONTEXT_VALUE 0x99
+#ifndef MAX_LENGTH_IPv4_ADDR
+#define MAX_LENGTH_IPv4_ADDR 16
+#endif
+
+//-----------------------------------------------------------------------------
+// Typedefs
+//-----------------------------------------------------------------------------
+
+/**
+ * List of methods that can be inititated from the client
+ */
+OCStackResult InitProvisioningHandler();
+
+OCStackResult TerminateProvisioningHandler();
+
+void listeningFunc(void*);
+
+OCStackApplicationResult ProvisionEnrolleeResponse(void* ctx, OCDoHandle handle,
+ OCClientResponse * clientResponse);
+
+OCStackResult ProvisionEnrollee(OCQualityOfService qos, const char* query);
+
+OCStackApplicationResult GetProvisioningStatusResponse(void* ctx,
+ OCDoHandle handle, OCClientResponse * clientResponse);
+
+OCStackResult InvokeOCDoResource(const char* query, OCMethod method,
+ OCQualityOfService qos, OCClientResponseHandler cb, const char* request,
+ OCHeaderOption * options, uint8_t numOptions);
+
+OCStackResult GetProvisioningStatus(OCQualityOfService qos, const char* query);
+
+OCStackResult StartProvisioningProcess(const EnrolleeNWProvInfo_t *netInfo,
+ OCProvisioningStatusCB provisioningStatusCallback);
+
+
+void StopProvisioningProcess();
+
+OCStackApplicationResult SubscribeProvPresenceCallback(void* ctx, OCDoHandle handle,
+ OCClientResponse* clientResponse);
+
+OCStackResult SubscribeProvPresence(OCQualityOfService qos, const char* requestURI);
+
+OCStackApplicationResult FindProvisioningResourceResponse(void* ctx,
+ OCDoHandle handle, OCClientResponse * clientResponse);
+
+OCStackResult FindProvisioningResource(OCQualityOfService qos,
+ const char* requestURI);
+
+//Invoke Provisioning Status Callback
+void PrepareProvisioingStatusCB(ProvisioningInfo *provInfo,
+ OCClientResponse * clientResponse, ProvStatus provStatus);
+
+#endif
+
#include <sstream>
#include "easysetupmgr.h"
-#include "provisioninghandler.h"
//Use ipv4addr for both InitDiscovery and InitDeviceDiscovery
char ipv4addr[IPV4_ADDR_SIZE] = { 0 };