Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes for compiler errors and some build improvements around contiki in preparation for RIOT support #302

Merged
merged 5 commits into from
Jan 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions api/include/awa/static.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ typedef AwaResult (*AwaStaticClientHandler)(AwaStaticClient * client, AwaOperati
* @return A pointer to a newly allocated Awa Static Client instance.
* @return NULL on failure.
*/
AwaStaticClient * AwaStaticClient_New();
AwaStaticClient * AwaStaticClient_New(void);

/**
* @brief Retrieve default content type to use when a request doesn't specify via accept header a preferred content type.
Expand All @@ -227,7 +227,7 @@ AwaStaticClient * AwaStaticClient_New();
*
* @return The default content type
*/
AwaContentType AwaStaticClient_GetDefaultContentType();
AwaContentType AwaStaticClient_GetDefaultContentType(void);

/**
* @brief Set the default content type to use when a request doesn't specify via accept header a preferred content type.
Expand Down
9 changes: 0 additions & 9 deletions core/src/client/Makefile.client
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,5 @@ client_src = \
lwm2m_client_core.c \
lwm2m_acl_object.c \
lwm2m_server_object.c \
lwm2m_serdes.c \
lwm2m_tlv.c \
lwm2m_opaque.c \
lwm2m_plaintext.c \
lwm2m_prettyprint.c \
lwm2m_tree_builder.c \
lwm2m_object_tree.c \
lwm2m_observers.c \
lwm2m_static.c


17 changes: 17 additions & 0 deletions core/src/client/lwm2m_bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ static void SendBootStrapRequest(Lwm2mContextType * context, int shortServerID)

static void HandleBootstrapResponse(void * ctxt, AddressType* address, const char * responsePath, int responseCode, AwaContentType contentType, char * payload, size_t payloadLen)
{
(void)address;
(void)responsePath;
(void)contentType;
(void)payload;
(void)payloadLen;
Lwm2mContextType * context = ctxt;

if (responseCode == AwaResult_SuccessChanged)
Expand All @@ -94,6 +99,7 @@ static void HandleBootstrapResponse(void * ctxt, AddressType* address, const cha

static bool BootStrapFromSmartCard(Lwm2mContextType * context)
{
(void)context;
// not implemented

Lwm2m_Debug("Lwm2m_BootstrapFromSmartCard\n");
Expand All @@ -111,6 +117,14 @@ static bool BootStrapFromFactory(Lwm2mContextType * context)
static int BootStrapPost(void * ctxt, AddressType * addr, const char * path, const char * query, AwaContentType contentType,
const char * requestContent, size_t requestContentLen, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)addr;
(void)path;
(void)query;
(void)contentType;
(void)requestContent;
(void)requestContentLen;
(void)responseContent;
(void)responseContentLen;
Lwm2mContextType * context = (Lwm2mContextType *)ctxt;
Lwm2mBootStrapState state = Lwm2mCore_GetBootstrapState(context);

Expand Down Expand Up @@ -146,6 +160,9 @@ static int BootstrapEndpointHandler(int type, void * ctxt, AddressType * addr,
AwaContentType contentType, const char * requestContent, size_t requestContentLen,
AwaContentType * responseContentType, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)token;
(void)tokenLength;

switch (type)
{
case COAP_PUT_REQUEST: // no break
Expand Down
34 changes: 32 additions & 2 deletions core/src/client/lwm2m_client_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ static int DeserialiseOIR(Lwm2mTreeNode ** dest, AwaContentType contentType, Lwm
return len;
}

AwaContentType Lwm2mCore_GetDefaultContentType()
AwaContentType Lwm2mCore_GetDefaultContentType(void)
{
return defaultContentType;
}
Expand Down Expand Up @@ -1383,6 +1383,7 @@ void Lwm2mCore_GetObjectList(Lwm2mContextType * context, char * altPath, char *
static int HandleNotification(void * ctxt, AddressType * addr, int sequence, const char * token, int tokenLength, ObjectIDType objectID,
ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID, AwaContentType contentType, void * ContextData)
{
(void)ContextData;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int oir[3];
ObjectInstanceResourceKey key =
Expand Down Expand Up @@ -1423,6 +1424,9 @@ static int HandleObserveRequest(void * ctxt, AddressType * addr, const char * pa
AwaContentType contentType, const char * requestContent, size_t requestContentLen, AwaContentType * responseContentType,
char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)query;
(void)requestContent;
(void)requestContentLen;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int matches;
int oir[3] =
Expand Down Expand Up @@ -1470,6 +1474,9 @@ static int HandleCancelObserveRequest(void * ctxt, AddressType * addr, const cha
const char * requestContent, size_t requestContentLen, AwaContentType * responseContentType, char * responseContent,
size_t * responseContentLen, int * responseCode)
{
(void)query;
(void)requestContent;
(void)requestContentLen;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int matches;
int oir[3] =
Expand Down Expand Up @@ -1516,6 +1523,9 @@ static int HandleGetRequest(void * ctxt, AddressType * addr, const char * path,
const char * requestContent, size_t requestContentLen, AwaContentType * responseContentType, char * responseContent,
size_t * responseContentLen, int * responseCode)
{
(void)query;
(void)requestContent;
(void)requestContentLen;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int len = 0;
int matches;
Expand Down Expand Up @@ -1559,6 +1569,10 @@ static int HandleGetRequest(void * ctxt, AddressType * addr, const char * path,
static int HandlePostRequest(void * ctxt, AddressType * addr, const char * path, const char * query, AwaContentType contentType,
const char * requestContent, int requestContentLen, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)query;
(void)requestContent;
(void)requestContentLen;
(void)responseContent;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int len = -1;
int matches;
Expand Down Expand Up @@ -1693,6 +1707,10 @@ static int HandlePostRequest(void * ctxt, AddressType * addr, const char * path,
static int HandleWriteAttributesRequest(void * ctxt, AddressType * addr, const char * path, const char * query, AwaContentType contentType,
const char * requestContent, size_t requestContentLen, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)contentType;
(void)requestContent;
(void)requestContentLen;
(void)responseContent;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int oir[3] =
{ -1, -1, -1 };
Expand Down Expand Up @@ -1990,6 +2008,9 @@ static void PrepareObjectForReplace(Lwm2mContextType * context, ObjectIDType obj
static int HandlePutRequest(void * ctxt, AddressType * addr, const char * path, const char * query, AwaContentType contentType,
const char * requestContent, size_t requestContentLen, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)addr;
(void)query;
(void)responseContent;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int matches;
int oir[3] =
Expand Down Expand Up @@ -2083,6 +2104,9 @@ static int HandlePutRequest(void * ctxt, AddressType * addr, const char * path,
static int HandleBootstrapPutRequest(void * ctxt, AddressType * addr, const char * path, const char * query, AwaContentType contentType,
const char * requestContent, size_t requestContentLen, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)addr;
(void)query;
(void)responseContent;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int matches;
int oir[3] =
Expand Down Expand Up @@ -2138,6 +2162,11 @@ static int HandleBootstrapPutRequest(void * ctxt, AddressType * addr, const char
static int HandleDeleteRequest(void * ctxt, AddressType * addr, const char * path, const char * query, AwaContentType contentType,
const char * requestContent, size_t requestContentLen, char * responseContent, size_t * responseContentLen, int * responseCode)
{
(void)query;
(void)contentType;
(void)requestContent;
(void)requestContentLen;
(void)responseContent;
Lwm2mContextType * context = (Lwm2mContextType *) ctxt;
int oir[3] =
{ -1, -1, -1 };
Expand Down Expand Up @@ -2265,6 +2294,7 @@ int Lwm2mCore_SetEndPointClientName(Lwm2mContextType * context, const char * end

int Lwm2mCore_GetEndPointClientName(Lwm2mContextType * context, char * buffer, int len)
{
(void)len;
strcpy(buffer, context->EndPointName);
return strlen(buffer);
}
Expand Down Expand Up @@ -2377,7 +2407,7 @@ bool Lwm2mCore_GetUseFactoryBootstrap(Lwm2mContextType * context)
return context->UseFactoryBootstrap;
}

Lwm2mContextType * Lwm2mCore_New()
Lwm2mContextType * Lwm2mCore_New(void)
{
Lwm2mContextType * context = &Lwm2mContext;

Expand Down
4 changes: 2 additions & 2 deletions core/src/client/lwm2m_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ extern "C" {
extern ResourceOperationHandlers defaultResourceOperationHandlers;
extern ObjectOperationHandlers defaultObjectOperationHandlers;

Lwm2mContextType * Lwm2mCore_New();
Lwm2mContextType * Lwm2mCore_New(void);
void Lwm2mCore_SetCoapInfo(Lwm2mContextType * context, CoapInfo * coap);
CoapInfo * Lwm2mCore_GetCoapInfo(Lwm2mContextType * context);
void * Lwm2mCore_GetApplicationContext(Lwm2mContextType * context);
Expand All @@ -65,7 +65,7 @@ Lwm2mContextType * Lwm2mCore_Init(CoapInfo * coap, char * endPointName);

#if LWM2M_CLIENT

AwaContentType Lwm2mCore_GetDefaultContentType();
AwaContentType Lwm2mCore_GetDefaultContentType(void);
void Lwm2mCore_SetDefaultContentType(AwaContentType contentType);

#endif
Expand Down
1 change: 1 addition & 0 deletions core/src/client/lwm2m_object_tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,7 @@ int Lwm2mObjectTree_DeleteResourceInstance(Lwm2mObjectTree * objectTree, ObjectI

int Lwm2mObjectTree_InitIterator(Lwm2mObjectTreeIterator * iterator, Lwm2mObjectTree * objectTree, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID, ResourceInstanceIDType resourceInstanceID)
{
(void)objectTree;
iterator->ObjectID = objectID;
iterator->ObjectInstanceID = objectInstanceID;
iterator->ResourceID = resourceID;
Expand Down
12 changes: 12 additions & 0 deletions core/src/client/lwm2m_registration.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ static void SendRegisterRequest(Lwm2mContextType * context, Lwm2mServerType * se

static void HandleRegisterResponse(void * ctxt, AddressType * address, const char * responsePath, int responseCode, AwaContentType contentType, char * payload, size_t payloadLen)
{
(void)contentType;
(void)payload;
(void)payloadLen;
Lwm2mServerType * server = ctxt;

if (responseCode == 201)
Expand Down Expand Up @@ -212,6 +215,10 @@ static void SendRegistrationUpdate(Lwm2mContextType * context, Lwm2mServerType *

static void HandleRegisterUpdateResponse(void * ctxt, AddressType * address, const char * responsePath, int responseCode, AwaContentType contentType, char * payload, size_t payloadLen)
{
(void)address;
(void)contentType;
(void)payload;
(void)payloadLen;
Lwm2mServerType * server = ctxt;
Lwm2m_Debug("Registration Update Response %s %d\n", responsePath, responseCode);

Expand Down Expand Up @@ -253,6 +260,11 @@ static void Deregister(Lwm2mContextType * context, Lwm2mServerType * server)

static void HandleDeregisterResponse(void * ctxt, AddressType* address, const char * responsePath, int responseCode, AwaContentType contentType, char * payload, size_t payloadLen)
{
(void)address;
(void)responsePath;
(void)contentType;
(void)payload;
(void)payloadLen;
Lwm2mServerType * server = ctxt;
if (responseCode == 202)
{
Expand Down
17 changes: 14 additions & 3 deletions core/src/client/lwm2m_security_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,17 +184,23 @@ static ResourceOperationHandlers securityResourceOperationHandlers =

static int Lwm2mSecurity_ObjectCreateInstanceHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID)
{
(void)objectID;
return (AddSecurityInfo(context, objectInstanceID) != NULL) ? objectInstanceID : -1;
}

static int Lwm2mSecurity_CreateOptionalResourceHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID)
{
(void)context;
(void)objectID;
(void)objectInstanceID;
(void)resourceID;
// No action
return 0;
}

static int Lwm2mSecurity_DeleteObjectInstance(Lwm2mContextType * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID)
{
(void)objectID;
int result = -1;
LWM2MSecurityInfo * info = GetSecurityInfo(context, objectInstanceID);
if (info != NULL)
Expand All @@ -213,6 +219,7 @@ static int Lwm2mSecurity_DeleteObjectInstance(Lwm2mContextType * context, Object

static int Lwm2mSecurity_ObjectDeleteHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID, ResourceInstanceIDType resourceInstanceID)
{
(void)resourceInstanceID;
// 8.2.2 Delete operation MAY target to “/” URI to delete all the existing Object Instances except LWM2M
// Bootstrap Server Account in the LWM2M Client.

Expand Down Expand Up @@ -244,6 +251,8 @@ static int Lwm2mSecurity_ObjectDeleteHandler(void * context, ObjectIDType object
static int Lwm2mSecurity_ResourceReadHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID,
ResourceInstanceIDType resourceInstanceID, const void ** buffer, size_t * bufferLen)
{
(void)objectID;
(void)resourceInstanceID;
LWM2MSecurityInfo * security = GetSecurityInfo(context, objectInstanceID);

if (security != NULL)
Expand Down Expand Up @@ -336,6 +345,8 @@ static void WarnOfInsufficientData(size_t dest_size, size_t src_size)
static int Lwm2mSecurity_ResourceWriteHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID,
ResourceInstanceIDType resourceInstanceID, uint8_t * srcBuffer, size_t srcBufferLen, bool * changed)
{
(void)objectID;
(void)resourceInstanceID;
int result = -1;
LWM2MSecurityInfo * security = GetSecurityInfo(context, objectInstanceID);

Expand All @@ -349,7 +360,7 @@ static int Lwm2mSecurity_ResourceWriteHandler(void * context, ObjectIDType objec
memset(security->ServerURI, 0, sizeof(security->ServerURI));
memcpy(security->ServerURI, srcBuffer, srcBufferLen);
// Recalculate socket address from URI
security->AddressResolved = coap_ResolveAddressByURI(security->ServerURI, &security->address);
security->AddressResolved = coap_ResolveAddressByURI((unsigned char *)security->ServerURI, &security->address);
result = srcBufferLen;
}
else
Expand Down Expand Up @@ -547,14 +558,14 @@ bool Lwm2mCore_IsNetworkAddressRevolved(Lwm2mContextType * context, int shortSer
{
if (!security->AddressResolved)
{
security->AddressResolved = coap_ResolveAddressByURI(security->ServerURI, &security->address);
security->AddressResolved = coap_ResolveAddressByURI((unsigned char *)security->ServerURI, &security->address);
}
result = security->AddressResolved;
}
return result;
}

int Lwm2m_GetClientHoldOff(Lwm2mContextType * context, int shortServerID, int32_t * clientHoldOff)
int Lwm2m_GetClientHoldOff(Lwm2mContextType * context, int shortServerID, uint32_t * clientHoldOff)
{
int result = -1;
LWM2MSecurityInfo * security = GetSecurityInfoForShortServerID(context, shortServerID);
Expand Down
2 changes: 1 addition & 1 deletion core/src/client/lwm2m_security_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void Lwm2m_RegisterSecurityObject(Lwm2mContextType * context);
void Lwm2m_PopulateSecurityObject(Lwm2mContextType * context, const char * bootStrapServer);

int Lwm2m_GetServerURI(Lwm2mContextType * context, int shortServerID, char * buffer, int len);
int Lwm2m_GetClientHoldOff(Lwm2mContextType * context, int shortServerID, int32_t * clientHoldOff);
int Lwm2m_GetClientHoldOff(Lwm2mContextType * context, int shortServerID, uint32_t * clientHoldOff);

bool Lwm2mCore_IsNetworkAddressRevolved(Lwm2mContextType * context, int shortServerID);

Expand Down
19 changes: 19 additions & 0 deletions core/src/client/lwm2m_server_object.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,17 @@ static Lwm2mServerType * AddServerObject(Lwm2mContextType * context, int serverO

static int Lwm2mServer_ObjectCreateInstanceHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID)
{
(void)objectID;
Lwm2m_Debug("Creating server object instance\n");
return (AddServerObject(context, objectInstanceID) != NULL) ? objectInstanceID : -1;
}

static int Lwm2mServer_CreateOptionalResourceHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID)
{
(void)context;
(void)objectID;
(void)objectInstanceID;
(void)resourceID;
// No action
return 0;
}
Expand All @@ -136,12 +141,18 @@ static int RemoveServerObject(Lwm2mContextType * context, int objectInstanceID)

static int Lwm2mServer_ObjectDeleteHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID, ResourceInstanceIDType resourceInstanceID)
{
(void)objectID;
(void)resourceID;
(void)resourceInstanceID;
return RemoveServerObject(context, objectInstanceID);
}

static int Lwm2mServer_ResourceReadHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID,
ResourceInstanceIDType resourceInstanceID, const void ** buffer, size_t * bufferLen)
{
(void)objectID;
(void)resourceInstanceID;

Lwm2mServerType * server = GetServerObjectByObjectInstanceID(context, objectInstanceID);
if (server != NULL)
{
Expand Down Expand Up @@ -205,6 +216,9 @@ static void WarnOfInsufficientData(size_t dest_size, size_t src_size)
static int Lwm2mServer_ResourceWriteHandler(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID,
ResourceInstanceIDType resourceInstanceID, uint8_t * srcBuffer, size_t srcBufferLen, bool * changed)
{
(void)objectID;
(void)resourceInstanceID;

int result = -1;

// FIXME: this server entry needs to be created when the server objects are written.
Expand Down Expand Up @@ -299,6 +313,11 @@ static int Lwm2mServer_ResourceWriteHandler(void * context, ObjectIDType objectI

static int executeRegistrationUpdateTrigger(void * context, ObjectIDType objectID, ObjectInstanceIDType objectInstanceID, ResourceIDType resourceID, uint8_t * inValueBuffer, size_t inValueBufferLen)
{
(void)objectID;
(void)resourceID;
(void)inValueBuffer;
(void)inValueBufferLen;

Lwm2m_Debug("Registration Update triggered for server %d\n", objectInstanceID);
Lwm2mCore_SetServerUpdateRegistration(context, objectInstanceID);
return 0;
Expand Down
Loading