timelib_dir = arduinolib_dir + '/libraries/Time'
if not os.path.exists(timelib_dir):
- timelib_zip_file = src_dir + '/extlibs/arduino/Time.zip'
- timelib_url = 'http://playground.arduino.cc/uploads/Code/Time.zip'
- # Install Arduino Time library
- # If the zip file is not already present, download it
- os.mkdir(timelib_dir)
- os.chdir(timelib_dir)
- if not os.path.exists(timelib_zip_file):
- timelib_zip = env.Download(timelib_zip_file, timelib_url)
- else:
- timelib_zip = timelib_zip_file
+ if WhereIs('dos2unix') is not None:
+ timelib_zip_file = src_dir + '/extlibs/arduino/Time.zip'
+ timelib_url = 'http://playground.arduino.cc/uploads/Code/Time.zip'
+ # Install Arduino Time library
+ # If the zip file is not already present, download it
+ os.mkdir(timelib_dir)
+ os.chdir(timelib_dir)
+ if not os.path.exists(timelib_zip_file):
+ timelib_zip = env.Download(timelib_zip_file, timelib_url)
+ else:
+ timelib_zip = timelib_zip_file
- # Unzip the lib
- print 'Unzipping Arduino Time lib...'
- env.UnpackAll(timelib_dir + '/Time', timelib_zip)
+ # Unzip the lib
+ print 'Unzipping Arduino Time lib...'
+ env.UnpackAll(timelib_dir + '/Time', timelib_zip)
- # Apply patches to ARDUINO_HOME directory.
- os.chdir(arduinolib_dir)
- print 'Patching Arduino libraries...'
- os.system("find ./libraries/Time/Time/DateStrings.cpp -type f -exec dos2unix {} \;")
- os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_libraries.patch --directory=" + arduinolib_dir)
+ # Apply patches to ARDUINO_HOME directory.
+ os.chdir(arduinolib_dir)
+ print 'Patching Arduino libraries...'
- # Remove downloaded file
- os.remove(timelib_zip_file)
+ os.system("find ./libraries/Time/Time/DateStrings.cpp -type f -exec dos2unix {} \;")
+ os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_libraries.patch --directory=" + arduinolib_dir)
+
+ # Remove downloaded file
+ os.remove(timelib_zip_file)
+ else:
+ print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
+ print 'You may likely retrieve this package as follows:'
+ print ' sudo apt-get install dos2unix'
+ print ' or'
+ print ' sudo yum install dos2unix'
+ exit(1)
redbearlib_dir = arduinolib_dir + '/libraries/RBL_nRF8001'
if not os.path.exists(redbearlib_dir):
- redbearlib_zip_file = src_dir + '/extlibs/arduino/25643e7b1b7da3740406325a471e3faa4b948747.zip'
- redbearlib_url = 'https://github.com/RedBearLab/nRF8001/archive/25643e7b1b7da3740406325a471e3faa4b948747.zip'
- if not os.path.exists(redbearlib_zip_file):
- redbearlib_zip = env.Download(redbearlib_zip_file, redbearlib_url)
- else:
- redbearlib_zip = redbearlib_zip_file
+ if WhereIs('dos2unix') is not None:
+ redbearlib_zip_file = src_dir + '/extlibs/arduino/25643e7b1b7da3740406325a471e3faa4b948747.zip'
+ redbearlib_url = 'https://github.com/RedBearLab/nRF8001/archive/25643e7b1b7da3740406325a471e3faa4b948747.zip'
+ if not os.path.exists(redbearlib_zip_file):
+ redbearlib_zip = env.Download(redbearlib_zip_file, redbearlib_url)
+ else:
+ redbearlib_zip = redbearlib_zip_file
+
+ # Unzip the lib
+ print 'Unzipping Red Bear lib...'
+ os.chdir(arduinolib_dir + '/libraries')
+ env.UnpackAll(redbearlib_dir, redbearlib_zip)
- # Unzip the lib
- print 'Unzipping Red Bear lib...'
- os.chdir(arduinolib_dir + '/libraries')
- env.UnpackAll(redbearlib_dir, redbearlib_zip)
+ # Because the way Red Bear lib is distributed... All Red Bear source files must be moved up a few directories.
+ shutil.move('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747/Arduino/libraries/RBL_nRF8001/', '.')
+ shutil.rmtree('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747')
- # Because the way Red Bear lib is distributed... All Red Bear source files must be moved up a few directories.
- shutil.move('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747/Arduino/libraries/RBL_nRF8001/', '.')
- shutil.rmtree('nRF8001-25643e7b1b7da3740406325a471e3faa4b948747')
+ # Apply Red Bear patches
+ print 'Patching Red Bear library...'
+ os.chdir(arduinolib_dir + '/libraries/RBL_nRF8001/')
- # Apply Red Bear patches
- print 'Patching Red Bear library...'
- os.chdir(arduinolib_dir + '/libraries/RBL_nRF8001/')
- os.system("find . -type f -exec dos2unix {} \;")
- os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/RBL_nRF8001.patch")
+ os.system("find . -type f -exec dos2unix {} \;")
+ os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/RBL_nRF8001.patch")
- # Remove downloaded file
- os.remove(redbearlib_zip_file)
+ # Remove downloaded file
+ os.remove(redbearlib_zip_file)
+ else:
+ print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
+ print 'You may likely retrieve this package as follows:'
+ print ' sudo apt-get install dos2unix'
+ print ' or'
+ print ' sudo yum install dos2unix'
+ exit(1)
nordiclib_dir = arduinolib_dir + '/libraries/BLE'
if not os.path.exists(nordiclib_dir):
- nordiclib_zip_file = src_dir + '/extlibs/arduino/ble-sdk-arduino-0.9.5.beta.zip'
- nordiclib_url = 'https://github.com/NordicSemiconductor/ble-sdk-arduino/archive/0.9.5.beta.zip'
- if not os.path.exists(nordiclib_zip_file):
- nordiclib_zip = env.Download(nordiclib_zip_file, nordiclib_url)
- else:
- nordiclib_zip = nordiclib_zip_file
-
- # Unzip the lib
- print 'Unzipping Nordic lib...'
- os.chdir(arduinolib_dir + '/libraries')
- env.UnpackAll(nordiclib_dir, nordiclib_zip)
-
- # Because the way Nordic lib is distributed... All Nordic source files must be moved up a few directories.
- shutil.move('ble-sdk-arduino-0.9.5.beta/libraries/BLE/', '.')
- shutil.rmtree('ble-sdk-arduino-0.9.5.beta')
-
- # Apply Nordic lib patches
- print 'Patching Nordic library...'
- os.chdir(arduinolib_dir + '/libraries/BLE/')
- os.system("find . -type f -exec dos2unix {} \;")
- os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_due_ble.patch")
+ if WhereIs('dos2unix') is not None:
+ nordiclib_zip_file = src_dir + '/extlibs/arduino/ble-sdk-arduino-0.9.5.beta.zip'
+ nordiclib_url = 'https://github.com/NordicSemiconductor/ble-sdk-arduino/archive/0.9.5.beta.zip'
+ if not os.path.exists(nordiclib_zip_file):
+ nordiclib_zip = env.Download(nordiclib_zip_file, nordiclib_url)
+ else:
+ nordiclib_zip = nordiclib_zip_file
+
+ # Unzip the lib
+ print 'Unzipping Nordic lib...'
+ os.chdir(arduinolib_dir + '/libraries')
+ env.UnpackAll(nordiclib_dir, nordiclib_zip)
+
+ # Because the way Nordic lib is distributed... All Nordic source files must be moved up a few directories.
+ shutil.move('ble-sdk-arduino-0.9.5.beta/libraries/BLE/', '.')
+ shutil.rmtree('ble-sdk-arduino-0.9.5.beta')
+
+ # Apply Nordic lib patches
+ print 'Patching Nordic library...'
+ os.chdir(arduinolib_dir + '/libraries/BLE/')
+
+ os.system("find . -type f -exec dos2unix {} \;")
+ os.system("patch -p1 < " + src_dir + "/resource/csdk/connectivity/lib/arduino/arduino_due_ble.patch")
- # Remove downloaded file
- os.remove(nordiclib_zip_file)
+ # Remove downloaded file
+ os.remove(nordiclib_zip_file)
+ else:
+ print 'Please manually install package dos2unix. The build process will end now. Your Action Required: Install package manually, then restart build process.'
+ print 'You may likely retrieve this package as follows:'
+ print ' sudo apt-get install dos2unix'
+ print ' or'
+ print ' sudo yum install dos2unix'
+ exit(1)
# Set the ARDUINO_HOME
env.Replace(ARDUINO_HOME = arduinolib_dir)
if (NULL == headerOpt)
{
LOGE("Memory allocation failed");
+ // destroy remote endpoint
+ CADestroyEndpoint(endpoint);
return;
}
if (0 < securePort) //Set the remote endpoint secure details and send response
{
LOGI("This is secure resource...");
- char *uri = NULL;
- uint32_t length = 0;
-
- length = COAPS_PREFIX_LEN; //length of "coaps://"
- // length of "ipaddress:port"
- length += strlen(object->addr) + PORT_LENGTH;
- length += strlen(requestInfo->info.resourceUri) + 1;
-
- uri = calloc(1, sizeof(char) * length);
- if (!uri)
- {
- LOGE("Failed to create new uri");
- free(uri);
- return;
- }
- sprintf(uri, "%s%s:%d/%s", COAPS_PREFIX, object->addr,
- securePort, requestInfo->info.resourceUri);
CAEndpoint_t *endpoint = NULL;
if (CA_STATUS_OK != CACreateEndpoint(CA_SECURE,
object->adapter, object->addr, securePort, &endpoint))
{
LOGE("Failed to create duplicate of remote endpoint!");
- free(uri);
return;
}
object = endpoint;
-
- free(uri);
}
}
}
{
printf("This is secure resource...\n");
- //length of "coaps://"
- size_t length = COAPS_PREFIX_LEN;
-
- // length of "ipaddress:port"
- length += strlen(object->addr) + PORT_LENGTH;
- length += 1;
-
- char *uri = calloc(1, sizeof(char) * length);
- if (!uri)
- {
- printf("Failed to create new uri\n");
- return;
- }
- sprintf(uri, "%s%s:%d/", COAPS_PREFIX, object->addr,
- object->port);
-
CAEndpoint_t *endpoint = NULL;
if (CA_STATUS_OK != CACreateEndpoint(0, object->adapter, object->addr,
object->port, &endpoint))
{
printf("Failed to create duplicate of remote endpoint!\n");
- free(uri);
return;
}
endpoint->flags = CA_SECURE;
object = endpoint;
-
- free(uri);
}
}
{
printf("This is secure resource...\n");
- //length of "coaps://"
- size_t length = sizeof(SECURE_COAPS_PREFIX) - 1;
-
- // length of "ipaddress:port"
- length += strlen(object->addr) + PORT_LENGTH;
- length += 1;
-
- printf("%s%s:%d/", SECURE_COAPS_PREFIX, object->addr,
- object->port);
-
CAEndpoint_t *endpoint = NULL;
if (CA_STATUS_OK != CACreateEndpoint(0, object->adapter, object->addr,
object->port, &endpoint))
CAGlobals_t caglobals;
-#define TAG "CA"
+#define TAG "CA_CONN_MGR"
static bool g_isInitialized = false;
#include "cathreadpool.h"
#include "caipadapter.h"
-#define TAG "CA"
+#define TAG "CA_INTRFC_CNTRLR"
#define CA_MEMORY_ALLOC_CHECK(arg) {if (arg == NULL) \
{OIC_LOG(ERROR, TAG, "memory error");goto memory_error_exit;} }
#include "oic_string.h"
#include "canetworkconfigurator.h"
-#define TAG PCF("CA")
+#define TAG PCF("CA_MSG_HNDLR")
#define SINGLE_HANDLE
#define MAX_THREAD_POOL_SIZE 20
if (SEND_TYPE_UNICAST == type)
{
+ OIC_LOG(DEBUG,TAG,"Unicast message");
if (NULL != data->requestInfo)
{
OIC_LOG(DEBUG, TAG, "requestInfo is available..");
else
{
OIC_LOG(DEBUG, TAG, "request info, response info is empty");
+ return;
}
// interface controller function call.
coap_delete_pdu(pdu);
}
+ else
+ {
+ OIC_LOG_V(ERROR,TAG,"Failed to generate unicast PDU");
+ return;
+ }
}
else if (SEND_TYPE_MULTICAST == type)
{
- OIC_LOG(DEBUG, TAG, "both requestInfo & responseInfo is not available");
+ OIC_LOG(DEBUG,TAG,"Multicast message");
+ if (NULL != data->requestInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "requestInfo is available..");
+ CAInfo_t *info = &data->requestInfo->info;
- CAInfo_t *info = &data->requestInfo->info;
+ info->options = data->options;
+ info->numOptions = data->numOptions;
- info->options = data->options;
- info->numOptions = data->numOptions;
+ pdu = CAGeneratePDU(CA_GET, info);
+ if (NULL != pdu)
+ {
+ CALogPDUInfo(pdu);
- pdu = CAGeneratePDU(CA_GET, info);
- if (NULL != pdu)
- {
- CALogPDUInfo(pdu);
+ res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+ if (CA_STATUS_OK != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+ coap_delete_pdu(pdu);
+ return;
+ }
- res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
- if (CA_STATUS_OK != res)
- {
- OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
coap_delete_pdu(pdu);
- return;
}
-
- coap_delete_pdu(pdu);
+ else
+ {
+ OIC_LOG_V(ERROR,TAG,"Failed to generate multicast PDU");
+ }
+ }
+ else
+ {
+ OIC_LOG_V(ERROR, TAG, "request info is empty");
}
}
if (SEND_TYPE_UNICAST == type)
{
+ OIC_LOG(DEBUG,TAG,"Unicast Message");
coap_pdu_t *pdu = NULL;
if (NULL != data->requestInfo)
else
{
OIC_LOG(DEBUG, TAG, "request info, response info is empty");
+ return;
}
// interface controller function call.
coap_delete_pdu(pdu);
}
+ else
+ {
+ OIC_LOG_V(ERROR,TAG,"Failed to Generate Unicast PDU");
+ return;
+ }
}
else if (SEND_TYPE_MULTICAST == type)
{
- OIC_LOG(DEBUG, TAG, "both requestInfo & responseInfo is not available");
+ OIC_LOG(DEBUG,TAG,"Multicast Message");
+ if (NULL != data->requestInfo)
+ {
+ OIC_LOG(DEBUG, TAG, "reqInfo avlbl");
- CAInfo_t *info = &data->requestInfo->info;
+ CAInfo_t *info = &data->requestInfo->info;
- info->options = data->options;
- info->numOptions = data->numOptions;
+ info->options = data->options;
+ info->numOptions = data->numOptions;
- coap_pdu_t *pdu = (coap_pdu_t *)CAGeneratePDU(CA_GET, info);
+ coap_pdu_t *pdu = (coap_pdu_t *)CAGeneratePDU(CA_GET, info);
- if (NULL != pdu)
- {
- CALogPDUInfo(pdu);
- res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
- if(CA_STATUS_OK != res)
+ if (NULL != pdu)
{
- OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+ CALogPDUInfo(pdu);
+ res = CASendMulticastData(data->remoteEndpoint, pdu->hdr, pdu->length);
+ if(CA_STATUS_OK != res)
+ {
+ OIC_LOG_V(ERROR, TAG, "send failed:%d", res);
+ coap_delete_pdu(pdu);
+ return;
+ }
coap_delete_pdu(pdu);
- return;
}
- coap_delete_pdu(pdu);
+ else
+ {
+ OIC_LOG(ERROR,TAG,"Failed to Generate Multicast PDU");
+ }
+ }
+ else
+ {
+ OIC_LOG(ERROR,TAG,"requestInfo is empty");
}
}
#include "uarraylist.h"
#include "logger.h"
-#define TAG "CANW"
+#define TAG "CA_NW_CONFIG"
static u_arraylist_t *g_selectedNetworkList = NULL;
static uint32_t NETWORK_IP = CA_ADAPTER_IP;
#define HAVE_SRANDOM 1
#endif
-#define TAG "CA"
+#define TAG "CA_PRTCL_MSG"
/**
* @def VERIFY_NON_NULL_RET
#include "oic_malloc.h"
#include "logger.h"
-#define TAG PCF("CA")
+#define TAG PCF("CA_QING")
static void CAQueueingThreadBaseRoutine(void *threadValue)
{
#include "oic_malloc.h"
#include "logger.h"
-#define TAG "CA"
+#define TAG "CA_RETRANS"
typedef struct
{
{
discoveryResult = OC_STACK_NO_MEMORY;
}
+ else
+ {
+ discoveryResult = OC_STACK_OK;
+ }
}
else if (virtualUriInRequest == OC_PLATFORM_URI)
{
- OCPlatformPayload* payload = OCPlatformPayloadCreate(
+ payload = (OCPayload*)OCPlatformPayloadCreate(
OC_RSRVD_PLATFORM_URI,
&savedPlatformInfo);
if (!payload)
{
discoveryResult = OC_STACK_NO_MEMORY;
}
+ else
+ {
+ discoveryResult = OC_STACK_OK;
+ }
}
#ifdef WITH_PRESENCE
ISSMResource(const std::string &n, const std::string &t) :
name(n), type(t)
{
- location = SENSOR_LOCATION_LOCAL;
+ location = SENSOR_LOCATION_LOCAL;
}
SENSOR_LOCATION location;
std::string name;
std::string type;
std::string friendlyName;
std::string ip;
+ int connectivityType;
std::vector<std::string> inputList;
std::vector<std::map<std::string, std::string> > outputProperty;
};
******************************************************************/
#include "ResourceFinder.h"
+OCConnectivityType g_connectivityType = CT_DEFAULT;
+
SSMRESULT CResourceFinder::finalConstruct()
{
SSMRESULT res = SSM_E_FAIL;
switch (result)
{
case OC_STACK_OK:
- requestURI << "coap://" << hostAddress << "/oc/core?rt=SSManager.Sensor";
+ requestURI << "coap://" << hostAddress << OC_RSRVD_WELL_KNOWN_URI << "?rt=SSManager.Sensor";
- ret = OC::OCPlatform::findResource("", requestURI.str(), CT_DEFAULT,
+ ret = OC::OCPlatform::findResource("", requestURI.str(), g_connectivityType,
std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
if (ret != OC_STACK_OK)
case OC_STACK_PRESENCE_TIMEOUT:
break;
- case OC_STACK_VIRTUAL_DO_NOT_HANDLE:
+ case OC_STACK_PRESENCE_DO_NOT_HANDLE:
break;
default:
std::ostringstream multicastPresenceURI;
multicastPresenceURI << "coap://" << OC_MULTICAST_PREFIX;
- ret = OC::OCPlatform::findResource("", requestURI.str(), CT_DEFAULT,
+ ret = OC::OCPlatform::findResource("", requestURI.str(), g_connectivityType,
std::bind(&CResourceFinder::onResourceFound, this, std::placeholders::_1));
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
ret = OC::OCPlatform::subscribePresence(m_multicastPresenceHandle, multicastPresenceURI.str(),
- "SSManager.Sensor", CT_DEFAULT, std::bind(&CResourceFinder::presenceHandler, this,
+ "SSManager.Sensor", g_connectivityType, std::bind(&CResourceFinder::presenceHandler, this,
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
if (ret != OC_STACK_OK)
pResourceHandler = new OICResourceHandler();
res = pResourceHandler->initHandler(*pResource, this);
- if(res != SSM_S_OK)
+ if (res != SSM_S_OK)
{
SAFE_DELETE(pResourceHandler);
SSM_CLEANUP_ASSERT(res);
m_mapResourcePresenceHandles.end())
{
ret = OC::OCPlatform::subscribePresence(presenceHandle, ((ISSMResource *)pMessage[1])->ip,
- "SSManager.Sensor", CT_DEFAULT, std::bind(&CResourceFinder::presenceHandler, this,
- std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
+ "SSManager.Sensor", (OCConnectivityType)(((ISSMResource *)pMessage[1])->connectivityType),
+ std::bind(&CResourceFinder::presenceHandler, this, std::placeholders::_1, std::placeholders::_2,
+ std::placeholders::_3));
if (ret != OC_STACK_OK)
SSM_CLEANUP_ASSERT(SSM_E_FAIL);
m_pResourceFinderEvent->onResourceFound((ISSMResource *)pMessage[1]);
- if (ret != OC_STACK_OK)
- SSM_CLEANUP_ASSERT(SSM_E_FAIL);
-
break;
case RESOURCE_DISCOVER_UNINSTALL_RESOURCE:
}
void onGetResourceProfile(const OC::HeaderOptions &headerOptions,
- const OC::OCRepresentation &representation, const int &eCode)
+ const OC::OCRepresentation &representation, const int eCode)
{
//unpack attributeMap
m_SSMResource.name = m_pResource->host() + m_pResource->uri();
m_SSMResource.type = m_pResource->uri().substr(1);
m_SSMResource.ip = m_pResource->host();
+ m_SSMResource.connectivityType = m_pResource->connectivityType();
//bind default properties
outputProperty["name"] = "lifetime";
printf("Running thing as %s\n", m_resourceUri.c_str());
m_resourceRep.setUri(m_resourceUri);
- m_resourceRep.setResourceTypes(m_resourceTypes);
- m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
}
~TemphumidResource()
printf("Running thing as %s\n", m_resourceUri.c_str());
m_resourceRep.setUri(m_resourceUri);
- m_resourceRep.setResourceTypes(m_resourceTypes);
- m_resourceRep.setResourceInterfaces(m_resourceInterfaces);
}
~TemphumidResource()