OC_LOG_V(DEBUG, TAG,
"Received RST, removing all queues associated with Token %d bytes",
CA_MAX_TOKEN_LEN);
- OC_LOG_BUFFER(INFO, TAG, sentToken, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)sentToken, CA_MAX_TOKEN_LEN);
coap_cancel_all_messages(ctx, &sentQueue->remote, (unsigned char *)sentToken,
CA_MAX_TOKEN_LEN);
#else
VERIFY_NON_NULL(pdu);
#ifdef CA_INT
pdu->hdr->token_length = CA_MAX_TOKEN_LEN;
- if (!coap_add_token(pdu, CA_MAX_TOKEN_LEN, *token))
+ if (!coap_add_token(pdu, CA_MAX_TOKEN_LEN, (const unsigned char *)*token))
{
OC_LOG(FATAL, TAG, PCF("coap_add_token failed"));
}
*/
//------------------------------------------------------------------------
#ifdef CA_INT
-ClientCB* GetClientCB(CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri);
+ClientCB* GetClientCB(const CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri);
#else // CA_INT
ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, const unsigned char * requestUri);
#endif // CA_INT
static int TEST_CASE = 0;
static const char * TEST_APP_UNICAST_DISCOVERY_QUERY = "coap://0.0.0.0:5683/oc/core";
static const char * TEST_APP_UNICAST_DEVICE_DISCOVERY_QUERY = "coap://0.0.0.0:5683/oc/core/d";
-static const char * TEST_APP_MULTICAST_DEVICE_DISCOVERY_QUERY = "coap://224.0.1.187:5683/oc/core/d";
+
#ifdef CA_INT
static const char * MULTICAST_DEVICE_DISCOVERY_QUERY = "/oc/core/d";
+#else //CA_INT
+static const char * TEST_APP_MULTICAST_DEVICE_DISCOVERY_QUERY = "coap://224.0.1.187:5683/oc/core/d";
+#endif //CA_INT
+
+#ifdef CA_INT
static const char * MULTICAST_RESOURCE_DISCOVERY_QUERY = "/oc/core";
//The following variable determines the interface (wifi, ethernet etc.)
//to be used for sending unicast messages. Default set to WIFI.
static constexpr unsigned int SLOW_RESPONSE_DELAY_SEC = 5;
static LEDResource LED;
-// This variable determines instance number of the LED resource.
-// Used by POST method to create a new instance of LED resource.
-static unsigned int gCurrLedInstance = 0;
+
static constexpr unsigned int SAMPLE_MAX_NUM_POST_INSTANCE = 2;
static LEDResource gLedInstance[SAMPLE_MAX_NUM_POST_INSTANCE];
OC_LOG(INFO, TAG, PCF("deleting tokens"));
#ifdef CA_INT
CADestroyToken (cbNode->token);
- OC_LOG_BUFFER(INFO, TAG, cbNode->token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)cbNode->token, CA_MAX_TOKEN_LEN);
#else
OC_LOG_BUFFER(INFO, TAG, cbNode->token.token, cbNode->token.tokenLength);
#endif // CA_INT
}
#ifdef CA_INT
-ClientCB* GetClientCB(CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri)
+ClientCB* GetClientCB(const CAToken_t * token, OCDoHandle handle, const unsigned char * requestUri)
#else // CA_INT
ClientCB* GetClientCB(OCCoAPToken * token, OCDoHandle handle, const unsigned char * requestUri)
#endif // CA_INT
LL_FOREACH(cbList, out) {
OC_LOG(INFO, TAG, PCF("comparing tokens"));
#ifdef CA_INT
- OC_LOG_BUFFER(INFO, TAG, *token, CA_MAX_TOKEN_LEN);
- OC_LOG_BUFFER(INFO, TAG, out->token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)*token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, CA_MAX_TOKEN_LEN);
if(memcmp(out->token, *token, CA_MAX_TOKEN_LEN) == 0)
{
return out;
{
#ifdef CA_INT
OC_LOG(INFO, TAG,PCF("comparing tokens"));
- OC_LOG_BUFFER(INFO, TAG, token, CA_MAX_TOKEN_LEN);
- OC_LOG_BUFFER(INFO, TAG, out->token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->token, CA_MAX_TOKEN_LEN);
if((memcmp(out->token, *token, CA_MAX_TOKEN_LEN) == 0))
{
return out;
{
OC_LOG_V(INFO, TAG, PCF("deleting tokens"));
#ifdef CA_INT
- OC_LOG_BUFFER(INFO, TAG, obsNode->token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)obsNode->token, CA_MAX_TOKEN_LEN);
#else
OC_LOG_BUFFER(INFO, TAG, obsNode->token.token, obsNode->token.tokenLength);
#endif
{
#ifdef CA_INT
OC_LOG(INFO, TAG,PCF("comparing tokens"));
- OC_LOG_BUFFER(INFO, TAG, token, CA_MAX_TOKEN_LEN);
- OC_LOG_BUFFER(INFO, TAG, out->requestToken, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)out->requestToken, CA_MAX_TOKEN_LEN);
if(memcmp(out->requestToken, token, CA_MAX_TOKEN_LEN) == 0)
{
return out;
#ifdef CA_INT
#include "cacommon.h"
#include "cainterface.h"
+ #include <arpa/inet.h>
#endif
//TODO: we should allow the server to define this
#define MAX_OBSERVE_AGE (0x2FFFFUL)
-
//-----------------------------------------------------------------------------
// Internal API function
//-----------------------------------------------------------------------------
{
struct sockaddr_in sa;
OCStackResult ret = OC_STACK_INVALID_PARAM;
+
if (!endPoint)
{
OC_LOG(ERROR, TAG, PCF("CA Remote end-point is NULL!"));
snprintf(fullUri, MAX_URI_LENGTH, "coap://%s:%u%s", ipAddress, endPoint->addressInfo.IP.port,
OC_PRESENCE_URI);
- cbNode = GetClientCB(NULL, NULL, fullUri);
+ cbNode = GetClientCB(NULL, NULL, (unsigned char *)fullUri);
if(cbNode)
{
else
{
snprintf(fullUri, MAX_URI_LENGTH, "%s%s", OC_MULTICAST_IP, endPoint->resourceUri);
- cbNode = GetClientCB(NULL, NULL, fullUri);
+ cbNode = GetClientCB(NULL, NULL, (unsigned char *)fullUri);
if(cbNode)
{
multicastPresenceSubscribe = 1;
&(responseInfo->info.options[i]), sizeof(OCHeaderOption));
}
}
- result = cbNode->callBack(cbNode->context,
- cbNode->handle, &response);
- if (result == OC_STACK_DELETE_TRANSACTION)
+ if (cbNode->callBack(cbNode->context,
+ cbNode->handle, &response) == OC_STACK_DELETE_TRANSACTION)
{
FindAndDeleteClientCB(cbNode);
}
}
OC_LOG_V(INFO, TAG, "HandleCARequests: CA token length = %d", CA_MAX_TOKEN_LEN);
- OC_LOG_BUFFER(INFO, TAG, requestInfo->info.token, CA_MAX_TOKEN_LEN);
+ OC_LOG_BUFFER(INFO, TAG, (const uint8_t *)requestInfo->info.token, CA_MAX_TOKEN_LEN);
serverRequest.requestToken = (CAToken_t)OCMalloc(CA_MAX_TOKEN_LEN+1);
// Module Name
// TODO-CA: CA is including non-vendor header options as well, like observe.
// Need to filter those out
GetObserveHeaderOption(&serverRequest.observationOption,
- requestInfo->info.options, &(requestInfo->info.numOptions));
+ requestInfo->info.options, (uint8_t *)&(requestInfo->info.numOptions));
if (requestInfo->info.numOptions > MAX_HEADER_OPTIONS)
{
OC_LOG(ERROR, TAG,
public:
/// Constructor
- RoomResource(): m_roomName("John's Room"), m_lightState(false),
- m_lightColor(0), m_fanState(false), m_fanSpeed(0)
+ RoomResource(): m_roomName("John's Room"), m_roomHandle(nullptr), m_lightState(false),
+ m_lightColor(0),m_lightHandle(nullptr), m_fanState(false), m_fanSpeed(0),
+ m_fanHandle(nullptr)
{
m_lightUri = "/a/light"; // URI of the resource
m_lightTypes.push_back("core.light"); // resource type name. In this case, it is light
cv.wait(lock);
}
- catch(OCException e)
+ catch(OCException &e)
{
std::cout << "Exception in main: " << e.what();
}
public:
/// Constructor
LightResource()
- :m_name("John's light"), m_state(false), m_power(0), m_lightUri("/a/light") {
+ :m_name("John's light"), m_state(false), m_power(0), m_lightUri("/a/light"),
+ m_resourceHandle(nullptr) {
// Initialize representation
m_lightRep.setUri(m_lightUri);
break;
case 4:
isSlowResponse = true;
+ break;
default:
break;
}
std::unique_lock<std::mutex> lock(blocker);
cv.wait(lock);
}
- catch(OCException e)
+ catch(OCException &e)
{
- //log(e.what());
+ std::cout << "OCException in main : " << e.what() << endl;
}
// No explicit call to stop the platform.
static const char RESOURCE_UNREG_FAILED[] = "Unregistering resource failed";
static const char OPTION_ID_RANGE_INVALID[] =
"Error: OptionID valid only from 2048 to 3000 inclusive.";
-
static const char NO_ERROR[] = "No Error";
static const char RESOURCE_CREATED[] = "Resource Created";
static const char RESOURCE_DELETED[] = "Resource Deleted";
static const char INVALID_JSON_ARRAY_DEPTH[] = "Max JSON Array Depth exceeded";
static const char INVALID_JSON_TYPE_TAG[] = "Invalid JSON Type Tag";
static const char INVALID_ATTRIBUTE[] = "Invalid Attribute: ";
+ static const char INVALID_DEVICE_INFO[] = "Invalid Device Information";
+
}
namespace Error
return OC::Exception::INVALID_REQUEST_HANDLE;
case OC_STACK_ERROR:
return OC::Exception::GENERAL_FAULT;
+ case OC_STACK_INVALID_DEVICE_INFO:
+ return OC::Exception::INVALID_DEVICE_INFO;
+ case OC_STACK_INVALID_JSON:
+ return OC::Exception::INVALID_REPRESENTATION;
}
return OC::Exception::UNKNOWN_ERROR;
const std::vector<std::string>& resourceTypes,
const std::vector<std::string>& interfaces)
: m_clientWrapper(clientWrapper), m_uri(uri), m_resourceId(serverId, m_uri),
+ m_host(host),
m_connectivityType(connectivityType),
- m_host(host), m_isObservable(observable),
+ m_isObservable(observable),
m_isCollection(false), m_resourceTypes(resourceTypes), m_interfaces(interfaces),
m_observeHandle(nullptr)
{