if target_os == 'darwin':
target_path = 'linux'
- env.SConscript('./samples/' + target_path + '/SConscript')
+ #env.SConscript('./samples/' + target_path + '/SConscript')
elif target_os in ['android']:
env.SConscript('./samples/' + target_os + '/SConscript')
# Build notification manager project
SConscript('notification-manager/SConscript')
-if target_os in ['arduino','android', 'linux']:
- SConscript('easy-setup/SConscript')
-
# Build resource-encapsulation project
if target_os not in ['tizen']:
SConscript('resource-encapsulation/SConscript')
+
+if target_os in ['arduino','android', 'linux']:
+ SConscript('easy-setup/SConscript')
+
+
#include "easysetup.h"
-const char *getResult(OCStackResult result);
+#define TAG "TS"
-PROGMEM const char TAG[] = "ThinServer";
+const char *getResult(OCStackResult result);
char ssid[] = "EasySetup123";
char passwd[] = "EasySetup123";
// Add your initialization code here
// Note : This will initialize Serial port on Arduino at 115200 bauds
OC_LOG_INIT();
- OC_LOG(DEBUG, TAG, PCF("OCServer is starting..."));
+ OC_LOG(DEBUG, TAG, "OCServer is starting...");
if(InitEasySetup(ES_WIFI, ssid, passwd, EventCallbackInApp) == ES_ERROR)
{
// Give CPU cycles to OCStack to perform send/recv and other OCStack stuff
if (OCProcess() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack process error"));
+ OC_LOG(ERROR, TAG, "OCStack process error");
return;
}
}
#include "networkHandler.h"
-#define TAG PCF("ES_NH")
+#define TAG "ES_NH"
int findNetwork(const char *ssid);
int ConnectToNetwork(const char *ssid, const char *pass);
// check for the presence of the shield:
if (WiFi.status() == WL_NO_SHIELD)
{
- OC_LOG(ERROR, TAG, PCF("WiFi shield not present"));
+ OC_LOG(ERROR, TAG, "WiFi shield not present");
return ES_ERROR;
}
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 !!!!!!"));
+ OC_LOG(DEBUG, TAG, "!!!!! Upgrade WiFi Shield Firmware version !!!!!!");
//return ES_ERROR;
}
- OC_LOG_V(INFO, TAG, PCF("Finding SSID: %s"), ssid);
+ OC_LOG_V(INFO, TAG, "Finding SSID: %s", ssid);
while (findNetwork(ssid) == 0) // found
{
// attempt to connect to Wifi network:
while (status != WL_CONNECTED)
{
- OC_LOG_V(INFO, TAG, PCF("Attempting to connect to SSID: %s"), ssid);
+ OC_LOG_V(INFO, TAG, "Attempting to connect to SSID: %s", ssid);
status = WiFi.begin((char *) ssid, (char *) pass);
// wait 10 seconds for connection:
delay(10000);
}
- OC_LOG(DEBUG, TAG, PCF("Connected to wifi"));
+ OC_LOG(DEBUG, TAG, "Connected to wifi");
myIP = WiFi.localIP();
- OC_LOG_V(INFO, TAG, PCF("IP Address: %d.%d.%d.%d"), myIP[0], myIP[1], myIP[2], myIP[3]);
+ 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]);
// Do not remove the include below
#include "Arduino.h"
-#include "logger.h"
-#include "ocstack.h"
#include <string.h>
-
-#include "common.h"
+#include "ocstack.h"
#include "networkHandler.h"
-#include "resourceHandler.h"
typedef void (*EventCallback)(ESResult);
//-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#include "easysetup.h"
-#include "ocstack.h"
-#define TAG PCF("ES")
+#include "logger.h"
+#include "resourceHandler.h"
+
+#define TAG "ES"
int g_eventflag = 0;
int g_cnt = 0;
if(TerminateEasySetup() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Terminating stack failed"));
+ OC_LOG(ERROR, TAG, "Terminating stack failed");
return;
}
if(ConnectToWiFiNetwork(ssid, passwd, EventCallbackInOnboarding) != ES_NETWORKCONNECTED)
{
- OC_LOG(ERROR, TAG, PCF("ConnectToWiFiNetwork Failed"));
+ OC_LOG(ERROR, TAG, "ConnectToWiFiNetwork Failed");
return ES_ERROR;
}
else{
- OC_LOG(INFO, TAG, PCF("ConnectToWiFiNetwork Success"));
+ OC_LOG(INFO, TAG, "ConnectToWiFiNetwork Success");
return ES_OK;
}
}
{
if(FindNetworkForOnboarding(networkType, ssid, passwd, cb) != ES_OK)
{
- OC_LOG(ERROR, TAG, PCF("OnBoarding Failed"));
+ OC_LOG(ERROR, TAG, "OnBoarding Failed");
return ES_ERROR;
}
// Initialize the OC Stack in Server mode
if (OCInit(NULL, 0, OC_SERVER) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack init error"));
+ OC_LOG(ERROR, TAG, "OCStack init error");
return ES_ERROR;
}
else
{
- OC_LOG(DEBUG, TAG, PCF("OCStack init success"));
+ OC_LOG(DEBUG, TAG, "OCStack init success");
return ES_OK;
}
}
{
if(OCStop() != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("OCStack stop failed"));
+ OC_LOG(ERROR, TAG, "OCStack stop failed");
return ES_ERROR;
}
else
{
- OC_LOG(ERROR, TAG, PCF("OCStack stop success"));
+ OC_LOG(ERROR, TAG, "OCStack stop success");
return ES_OK;
}
}
#include "resourceHandler.h"
#include "ocpayload.h"
-#define TAG PCF("ES_RH")
+#define TAG "ES_RH"
ProvResource g_prov;
NetResource g_net;
OCStackResult res = OCCreateResource(&g_prov.handle, "oic.prov", OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_PROV, OCEntityHandlerCb,NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
- OC_LOG_V(INFO, TAG, PCF("Created Prov resource with result: %s"), getResult(res));
+ OC_LOG_V(INFO, TAG, "Created Prov resource with result: %s", getResult(res));
return res;
}
netInfo.ipaddr[3]);
sprintf(g_net.cnn, "%s", netInfo.ssid);
- OC_LOG_V(INFO, TAG, PCF("SSID: %s"), g_net.cnn);
- OC_LOG_V(INFO, TAG, PCF("IP Address: %s"), g_net.ipaddr);
+ OC_LOG_V(INFO, TAG, "SSID: %s", g_net.cnn);
+ OC_LOG_V(INFO, TAG, "IP Address: %s", g_net.ipaddr);
OCStackResult res = OCCreateResource(&g_net.handle, "oic.net", OC_RSRVD_INTERFACE_DEFAULT,
OC_RSRVD_ES_URI_NET, OCEntityHandlerCb,NULL, OC_DISCOVERABLE | OC_OBSERVABLE);
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if(!ehRequest)
{
- OC_LOG(ERROR, TAG, PCF("Request is Null"));
+ OC_LOG(ERROR, TAG, "Request is Null");
return ehResult;
}
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OC_LOG(ERROR, TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload *getResp = constructResponse(ehRequest);
if(!getResp)
{
- OC_LOG(ERROR, TAG, PCF("constructResponse failed"));
+ OC_LOG(ERROR, TAG, "constructResponse failed");
return OC_EH_ERROR;
}
OCEntityHandlerResult ehResult=OC_EH_ERROR;
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OC_LOG(ERROR, TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload* input = (OCRepPayload*)(ehRequest->payload);
if(!input)
{
- OC_LOG_V(ERROR, TAG, PCF("Failed to parse"));
+ OC_LOG(ERROR, TAG, "Failed to parse");
return ehResult;
}
OCRepPayload *getResp = constructResponse(ehRequest);
if(!getResp)
{
- OC_LOG(ERROR, TAG, PCF("constructResponse failed"));
+ OC_LOG(ERROR, TAG, "constructResponse failed");
return OC_EH_ERROR;
}
OCEntityHandlerResult ehResult = OC_EH_ERROR;
if(!ehRequest)
{
- OC_LOG(ERROR, TAG, PCF("Request is Null"));
+ OC_LOG(ERROR, TAG, "Request is Null");
return ehResult;
}
if(ehRequest->payload && ehRequest->payload->type != PAYLOAD_TYPE_REPRESENTATION)
{
- OC_LOG(ERROR, TAG, PCF("Incoming payload not a representation"));
+ OC_LOG(ERROR, TAG, "Incoming payload not a representation");
return ehResult;
}
OCRepPayload* input = (OCRepPayload*)(ehRequest->payload);
if(!input)
{
- OC_LOG_V(ERROR, TAG, PCF("Failed to parse") );
+ OC_LOG(ERROR, TAG, "Failed to parse");
return ehResult;
}
char* tr;
OCRepPayload* payload = OCRepPayloadCreate();
if(!payload)
{
- OC_LOG(ERROR, TAG, PCF("Failed to allocate Payload"));
+ OC_LOG(ERROR, TAG, "Failed to allocate Payload");
return NULL;
}
{
if (OC_REST_GET == entityHandlerRequest->method)
{
- OC_LOG_V(INFO, TAG, PCF("Received GET request"));
+ OC_LOG(INFO, TAG, "Received GET request");
ehRet = ProcessGetRequest(entityHandlerRequest, &payload);
}
else if (OC_REST_PUT == entityHandlerRequest->method)
{
- OC_LOG_V(INFO, TAG, PCF("Received PUT request"));
+ OC_LOG(INFO, TAG, "Received PUT request");
if (g_prov.handle != NULL && entityHandlerRequest->resource == g_prov.handle)
{
// Send the response
if (OCDoResponse(&response) != OC_STACK_OK)
{
- OC_LOG(ERROR, TAG, PCF("Error sending response"));
+ OC_LOG(ERROR, TAG, "Error sending response");
ehRet = OC_EH_ERROR;
}
}