Awa LWM2M C API (0.2.5)  
Classes | Macros | Typedefs | Enumerations | Functions
static.h File Reference

This interface enables an application to be statically embedded within the LWM2M Client and interact with its resources. More...

#include "types.h"
#include "error.h"
Include dependency graph for static.h:

Go to the source code of this file.

Classes

struct  AwaFactoryBootstrapInfo
 Information required to bootstrap the client daemon from a factory configuration. More...
 

Macros

#define BOOTSTRAP_CONFIG_SERVER_URI_SIZE
 Maximum size in characters of Server URI string. More...
 
#define BOOTSTRAP_CONFIG_PUBLIC_KEY_SIZE
 Maximum size in bytes of Public Key / Identity opaque value. More...
 
#define BOOTSTRAP_CONFIG_SERVER_KEY_SIZE
 Maximum size in bytes of Server Key opaque value. More...
 
#define BOOTSTRAP_CONFIG_SECRET_KEY_SIZE
 Maximum size in bytes of Secret Key opaque value. More...
 
#define BOOTSTRAP_CONFIG_BINDING_SIZE
 Maximum length in characters of Binding string. More...
 

Typedefs

typedef struct _AwaStaticClient AwaStaticClient
 Represents an Awa Static Client context, holding the necessary information to initialise the client daemon, define objects and resources, and handle callbacks. More...
 
typedef AwaResult(* AwaStaticClientHandler) (AwaStaticClient *client, AwaOperation operation, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID, AwaResourceID resourceID, AwaResourceInstanceID resourceInstanceID, void **dataPointer, size_t *dataSize, bool *changed)
 A user-specified callback handler for a LWM2M Operation on the specified /O/I/R/i path to an LWM2M entity that will be called whenever a management server performs a LWM2M operation on the specified client, allowing full control of the operation on the target entity as well as the return code to be sent back to the server that performed the operation. More...
 

Enumerations

enum  AwaOperation {
  AwaOperation_CreateObjectInstance,
  AwaOperation_DeleteObjectInstance,
  AwaOperation_Read,
  AwaOperation_Write,
  AwaOperation_Execute,
  AwaOperation_CreateResource,
  AwaOperation_DeleteResource
}
 Supported operations for resource and object handlers defined with AwaStaticClient_DefineResource. More...
 
enum  AwaSecurityMode {
  AwaSecurityMode_PreSharedKey,
  AwaSecurityMode_RawPublicKey,
  AwaSecurityMode_Certificate,
  AwaSecurityMode_NoSec
}
 Supported LWM2M security modes. More...
 
enum  AwaResult {
  AwaResult_Success,
  AwaResult_SuccessCreated,
  AwaResult_SuccessDeleted,
  AwaResult_SuccessChanged,
  AwaResult_SuccessContent,
  AwaResult_BadRequest,
  AwaResult_Unauthorized,
  AwaResult_Forbidden,
  AwaResult_NotFound,
  AwaResult_MethodNotAllowed,
  AwaResult_NotAcceptable,
  AwaResult_InternalError,
  AwaResult_OutOfMemory,
  AwaResult_AlreadyDefined,
  AwaResult_MismatchedDefinition,
  AwaResult_AlreadyCreated,
  AwaResult_Unsupported,
  AwaResult_Unspecified
}
 Supported result codes for handler callbacks. More...
 

Functions

AwaStaticClientAwaStaticClient_New (void)
 Allocate and return a pointer to a new Awa Static Client. More...
 
AwaContentType AwaStaticClient_GetDefaultContentType (void)
 Retrieve default content type to use when a request doesn't specify via accept header a preferred content type. More...
 
void AwaStaticClient_SetDefaultContentType (AwaContentType contentType)
 Set the default content type to use when a request doesn't specify via accept header a preferred content type. More...
 
AwaError AwaStaticClient_SetLogLevel (AwaLogLevel level)
 Set the client log level. More...
 
AwaError AwaStaticClient_SetEndPointName (AwaStaticClient *client, const char *endPointName)
 Set the client endpoint name. More...
 
AwaError AwaStaticClient_SetCoAPListenAddressPort (AwaStaticClient *client, const char *address, int port)
 Set the address and port to listen on for incoming CoAP packets. More...
 
AwaError AwaStaticClient_SetBootstrapServerURI (AwaStaticClient *client, const char *bootstrapServerURI)
 Set the network location of a trusted LWM2M Bootstrap server, in the URI format: "coap://[address]:[port]". More...
 
AwaError AwaStaticClient_SetFactoryBootstrapInformation (AwaStaticClient *client, const AwaFactoryBootstrapInfo *factoryBootstrapInformation)
 Configure factory bootstrap by supplying LWM2M Server Bootstrap Information to register with a LWM2M server. More...
 
void AwaStaticClient_SetCertificate (AwaStaticClient *client, const uint8_t *certificate, int certificateLength, AwaCertificateFormat format)
 Configure default certificate to use when Awa Static Client connects to a secure Server/Bootstrap. More...
 
void AwaStaticClient_SetPSK (AwaStaticClient *client, const char *identity, const uint8_t *key, int keyLength)
 Configure default PSK to use when Awa Static Client connects to a secure Server/Bootstrap. More...
 
AwaError AwaStaticClient_SetApplicationContext (AwaStaticClient *client, void *context)
 Set a user-specified application context which is accessible to any defined callback handler owned by the Awa Static Client with AwaStaticClient_GetApplicationContext. More...
 
void * AwaStaticClient_GetApplicationContext (AwaStaticClient *client)
 Retrieve a user-specified application context as a void pointer. More...
 
AwaClientRegistrationStatus AwaStaticClient_GetRegistrationStatus (AwaStaticClient *client)
 Retrieve register status for the Awa Static Client. More...
 
AwaError AwaStaticClient_Init (AwaStaticClient *client)
 Initialise an Awa Static client. More...
 
void AwaStaticClient_Free (AwaStaticClient **client)
 Free an Awa Static Client. More...
 
AwaError AwaStaticClient_DefineObject (AwaStaticClient *client, AwaObjectID objectID, const char *objectName, uint16_t minimumInstances, uint16_t maximumInstances)
 Define a new custom LWM2M object. More...
 
AwaError AwaStaticClient_SetObjectOperationHandler (AwaStaticClient *client, AwaObjectID objectID, AwaStaticClientHandler handler)
 Set the Object Operation handler function, to be called by the LWM2M Client when object instances are created or deleted. More...
 
AwaError AwaStaticClient_DefineResource (AwaStaticClient *client, AwaObjectID objectID, AwaResourceID resourceID, const char *resourceName, AwaResourceType resourceType, uint16_t minimumInstances, uint16_t maximumInstances, AwaResourceOperations operations)
 Define a new resource as part of a defined object. More...
 
AwaError AwaStaticClient_SetResourceOperationHandler (AwaStaticClient *client, AwaObjectID objectID, AwaResourceID resourceID, AwaStaticClientHandler handler)
 Set a user-specified callback handler that will be called whenever a LWM2M operation on the resource is performed. More...
 
AwaError AwaStaticClient_SetResourceStorageWithPointer (AwaStaticClient *client, AwaObjectID objectID, AwaResourceID resourceID, void *dataPointer, size_t dataElementSize, size_t dataStepSize)
 Set a resource's storage with a pointer to the resource's data, leaving handling of the resource to the LWM2M Client. More...
 
AwaError AwaStaticClient_SetResourceStorageWithPointerArray (AwaStaticClient *client, AwaObjectID objectID, AwaResourceID resourceID, void *dataPointers[], size_t dataElementSize)
 Set a resource's storage with an array of pointers to non-contiguous data, where each piece of data stores the resource for a single instance of its object. More...
 
int AwaStaticClient_Process (AwaStaticClient *client)
 Process the Awa Static Client. More...
 
const void * AwaStaticClient_GetResourceInstancePointer (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID, AwaResourceID resourceID, AwaResourceInstanceID resourceInstanceID, size_t *resourceSize)
 Retrieve a pointer to a resource instance's data, when defined with AwaStaticClient_SetResourceStorageWithPointer or AwaStaticClient_SetResourceStorageWithPointerArray. More...
 
AwaError AwaStaticClient_CreateResource (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID, AwaResourceID resourceID)
 Create an optional resource within the specified object instance. More...
 
AwaError AwaStaticClient_DeleteResource (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID, AwaResourceID resourceID)
 Delete an optional resource within the specified object instance. More...
 
AwaError AwaStaticClient_CreateObjectInstance (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID)
 Create an object instance within the specified object. More...
 
AwaError AwaStaticClient_DeleteObjectInstance (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID)
 Delete an object instance within the specified object. More...
 
AwaError AwaStaticClient_ResourceChanged (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID, AwaResourceID resourceID)
 Mark the specified resource as changed, in order for the Awa Static Client to send notifications to all LWM2M servers observing that resource. More...
 
AwaError AwaStaticClient_ObjectInstanceChanged (AwaStaticClient *client, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID)
 Mark the specified object instance as changed, in order for the Awa Static Client to send notifications to all LWM2M servers observing that object instance. More...
 

Detailed Description

This interface enables an application to be statically embedded within the LWM2M Client and interact with its resources.

The Client hosts resources within a data model based on Objects, Object Instances and Resources. Please consult the LWM2M specification for details of this model.

A Management Application may interact with the Client via LWM2M, accessing the same resources. Therefore it is essential that both the Client Application and Management Application are aware of the same data model and have definitions for the same objects and resources.

It is recommended that OMA registered IDs are used for objects that conform to registered LWM2M objects such as IPSO objects.

Macro Definition Documentation

#define BOOTSTRAP_CONFIG_SERVER_URI_SIZE

Maximum size in characters of Server URI string.

#define BOOTSTRAP_CONFIG_PUBLIC_KEY_SIZE

Maximum size in bytes of Public Key / Identity opaque value.

#define BOOTSTRAP_CONFIG_SERVER_KEY_SIZE

Maximum size in bytes of Server Key opaque value.

#define BOOTSTRAP_CONFIG_SECRET_KEY_SIZE

Maximum size in bytes of Secret Key opaque value.

#define BOOTSTRAP_CONFIG_BINDING_SIZE

Maximum length in characters of Binding string.

Typedef Documentation

typedef struct _AwaStaticClient AwaStaticClient

Represents an Awa Static Client context, holding the necessary information to initialise the client daemon, define objects and resources, and handle callbacks.

typedef AwaResult(* AwaStaticClientHandler) (AwaStaticClient *client, AwaOperation operation, AwaObjectID objectID, AwaObjectInstanceID objectInstanceID, AwaResourceID resourceID, AwaResourceInstanceID resourceInstanceID, void **dataPointer, size_t *dataSize, bool *changed)

A user-specified callback handler for a LWM2M Operation on the specified /O/I/R/i path to an LWM2M entity that will be called whenever a management server performs a LWM2M operation on the specified client, allowing full control of the operation on the target entity as well as the return code to be sent back to the server that performed the operation.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]operationThe requested operation to perform on the entity.
[in]objectIDIdentifies the object for which the query is targeted.
[in]objectInstanceIDIdentifies the object instance for which the query is targeted, or AWA_INVALID_ID if the request is on an object.
[in]resourceIDIdentifies the resource for which the query is targeted, or AWA_INVALID_ID if the request is on an object instance or object.
[in]resourceInstanceIDIdentifies the resource instance for which the query is targeted, or AWA_INVALID_ID if the request is on a single-instance resource, object instance or object.
[in,out]dataPointerA pointer to a void pointer containing data for the requested resource to be read or modified.
[in,out]dataSizeA pointer to an unsigned integer containing the length of the requested resource.
[out]changedSet by the handler to indicate whether the resource's value has been changed by the handler If set to true, a notification will be sent when possible to any observers of the target object, object instance or resource.
Returns
AwaResult_SuccessCreated on a successful create object instance or resource operation.
AwaResult_SuccessDeleted on a successful delete object instance or resource operation.
AwaResult_SuccessContent on a successful read operation.
AwaResult_SuccessChanged on a successful write or execute operation.
Various errors on failure.

Enumeration Type Documentation

Supported operations for resource and object handlers defined with AwaStaticClient_DefineResource.

Enumerator
AwaOperation_CreateObjectInstance 

indicates a request to create an object instance

AwaOperation_DeleteObjectInstance 

indicates a request to delete an object instance

AwaOperation_Read 

indicates a request to read from a resource

AwaOperation_Write 

indicates a request to write to a resource

AwaOperation_Execute 

indicates a request to write to a resource

AwaOperation_CreateResource 

indicates a request to create a resource

AwaOperation_DeleteResource 

indicates a request to delete a resource

Supported LWM2M security modes.

See the LWM2M specification for details.

Enumerator
AwaSecurityMode_PreSharedKey 

indicates Pre-Shared Key security mode (PSK)

AwaSecurityMode_RawPublicKey 

indicates Raw Public Key security mode (RPK)

AwaSecurityMode_Certificate 

indicates Certificate-based security mode

AwaSecurityMode_NoSec 

indicates No Security mode

enum AwaResult

Supported result codes for handler callbacks.

Enumerator
AwaResult_Success 

indicates the requested operation completed successfully

AwaResult_SuccessCreated 

indicates the requested target was created successfully

AwaResult_SuccessDeleted 

indicates the requested target was deleted successfully

AwaResult_SuccessChanged 

indicates a successful write to a resource

AwaResult_SuccessContent 

indicates a successful read from a resource

AwaResult_BadRequest 

indicates an invalid argument or request to create an entity that already exists

AwaResult_Unauthorized 

indicates an attempt to call the requested operation with insufficient authorisation

AwaResult_Forbidden 

indicates a request to create an object instance

AwaResult_NotFound 

indicates the specified object, object instance or resource does not exist

AwaResult_MethodNotAllowed 

indicates the requested operation is not allowed for the specified target

AwaResult_NotAcceptable 

indicates a requested accept-header was not acceptable by the client daemon

AwaResult_InternalError 

indicates the handler failed internally while processing a request

AwaResult_OutOfMemory 

indicates the handler did not have sufficient memory to service the requested operation

AwaResult_AlreadyDefined 

indicates an attempt to define an already defined object or resource

AwaResult_MismatchedDefinition 

indicates an attempt to define an object that does not match the existing definition

AwaResult_AlreadyCreated 

indicates an attempt to create an existing resource or object instance

AwaResult_Unsupported 

indicates the requested operation is not supported by the called handler

AwaResult_Unspecified 

indicates the requested operation was ignored by the called handler

Function Documentation

AwaStaticClient* AwaStaticClient_New ( void  )

Allocate and return a pointer to a new Awa Static Client.

The new client can be used to define custom objects, resources and callback handlers, and respond to LWM2M operations.

The Awa Static Client is owned by the caller and should eventually be freed with AwaStaticClient_Free.

Returns
A pointer to a newly allocated Awa Static Client instance.
NULL on failure.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
AwaContentType AwaStaticClient_GetDefaultContentType ( void  )

Retrieve default content type to use when a request doesn't specify via accept header a preferred content type.

The default is initially AwaContentType_ApplicationPlainText.

Returns
The default content type
void AwaStaticClient_SetDefaultContentType ( AwaContentType  contentType)

Set the default content type to use when a request doesn't specify via accept header a preferred content type.

Parameters
[in]contentTypeThe default contentType eg AwaContentType_ApplicationOmaLwm2mTLV.
AwaError AwaStaticClient_SetLogLevel ( AwaLogLevel  level)

Set the client log level.

This function is not tied to an AwaStaticClient and has global effect. Only messages with level equal to or less than the current log level will be displayed in the log.

This function can be called at any time.

Parameters
[in]levelA valid log level.
Returns
AwaError_Success on success.
AwaError_LogLevelInvalid if an invalid log level is specified.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_SetEndPointName ( AwaStaticClient client,
const char *  endPointName 
)

Set the client endpoint name.

This is the unique ID used to identify the client from any server the client has registered with.

This function must be called, and before calling AwaStaticClient_Init.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]endPointNameThe unique endpoint name to identify this client.
Returns
AwaError_Success on success.
AwaError_OperationInvalid if the client has already been initialised.
AwaError_StaticClientInvalid if the client is NULL.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_SetCoAPListenAddressPort ( AwaStaticClient client,
const char *  address,
int  port 
)

Set the address and port to listen on for incoming CoAP packets.

IPv4 and IPv6 addresses are valid. It must be the address of a local interface. Only local DNS names are valid.

Address "Any" (0.0.0.0 for IPv4, :: for IPv6) is valid.

This function must be called, and before calling AwaStaticClient_Init.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]addressIP address to listen on.
[in]portPort number to listen on.
Returns
AwaError_Success on success.
AwaError_OperationInvalid if the client has already been initialised.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_SetBootstrapServerURI ( AwaStaticClient client,
const char *  bootstrapServerURI 
)

Set the network location of a trusted LWM2M Bootstrap server, in the URI format: "coap://[address]:[port]".

The client will connect to the bootstrap server to obtain the LWM2M Server Bootstrap Information.

[address] can be an IPv4 or IPv6 address, or a resolvable DNS name.

This function must be called, and before calling AwaStaticClient_Init.

If AwaStaticClient_SetFactoryBootstrapInformation is called, bootstrapServerURI is ignored. However if the factory bootstrap information results in a failed registration, bootstrapServerURI will be used to do a client-initiated bootstrap.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]bootstrapServerURINetwork location of bootstrap server.
Returns
AwaError_Success on success.
AwaError_OperationInvalid if the client has already been initialised.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_SetFactoryBootstrapInformation ( AwaStaticClient client,
const AwaFactoryBootstrapInfo factoryBootstrapInformation 
)

Configure factory bootstrap by supplying LWM2M Server Bootstrap Information to register with a LWM2M server.

This function is optional. It should only be called after AwaStaticClient_Init and before AwaStaticClient_Process.

It may be called multiple times to set additional LWM2M servers.

If this factory bootstrap information results in a failed registration, bootstrapServerURI set by AwaStaticClient_SetBootstrapServerURI will be used to do a client-initiated bootstrap.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]factoryBootstrapInformationA pointer to valid Factory Bootstrap information.
Returns
AwaError_Success on success.
AwaError_OperationInvalid if the client has already been initialised.
AwaError_StaticClientInvalid if client is NULL.
void AwaStaticClient_SetCertificate ( AwaStaticClient client,
const uint8_t *  certificate,
int  certificateLength,
AwaCertificateFormat  format 
)

Configure default certificate to use when Awa Static Client connects to a secure Server/Bootstrap.

This function is optional. It should only be called after AwaStaticClient_Init and before AwaStaticClient_Process.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]certificateA pointer to a certificate which is in format.
[in]certificateLengthSize of certificate.
[in]formatWhether certificate is in either ASN1 or PEM format.
void AwaStaticClient_SetPSK ( AwaStaticClient client,
const char *  identity,
const uint8_t *  key,
int  keyLength 
)

Configure default PSK to use when Awa Static Client connects to a secure Server/Bootstrap.

This function is optional. It should only be called after AwaStaticClient_Init and before AwaStaticClient_Process.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]identityA pointer to a NULL terminated string to identify client key.
[in]keyA pointer to shared key.
[in]keyLengthSize of key
AwaError AwaStaticClient_SetApplicationContext ( AwaStaticClient client,
void *  context 
)

Set a user-specified application context which is accessible to any defined callback handler owned by the Awa Static Client with AwaStaticClient_GetApplicationContext.

The handler should cast this pointer to the correct type.

This function can be called at any time.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]contextA pointer to user-specified data.
Returns
AwaError_Success on success.
AwaError_StaticClientInvalid if client is NULL.
void* AwaStaticClient_GetApplicationContext ( AwaStaticClient client)

Retrieve a user-specified application context as a void pointer.

This pointer is associated with the Awa Static Client with AwaStaticClient_SetApplicationContext. The returned pointer should be cast to the correct type.

This function can be called at any time.

Parameters
[in]clientA pointer to a valid Awa Static Client.
Returns
A pointer to the user-specified application context if it exists.
NULL if client is NULL, or no application context was set by the user.
AwaClientRegistrationStatus AwaStaticClient_GetRegistrationStatus ( AwaStaticClient client)

Retrieve register status for the Awa Static Client.

This function should only be called after AwaStaticClient_Init.

Parameters
[in]clientA pointer to a valid Awa Static Client.
Returns
Client registration status.
AwaError AwaStaticClient_Init ( AwaStaticClient client)

Initialise an Awa Static client.

This function can only be called once all information required for the client to connect to a LWM2M server has been set.

This function should only be called once for each Awa Static Client.

Before calling this function, the following functions must be called:

After calling this function, the following functions may be called before calling AwaStaticClient_Process:

Parameters
[in]clientA pointer to a valid Awa Static Client.
Returns
AwaError_Success on successful initialisation of the Awa Static Client.
AwaError_StaticClientNotConfigured if the client's endpoint name, bootstrap configuration or CoAP listen information has not been set.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
void AwaStaticClient_Free ( AwaStaticClient **  client)

Free an Awa Static Client.

This function will close any connected sockets and free any allocated memory.

The pointer will be set to NULL. Copies of the pointer to the Awa Static Client should not be used after this call.

Parameters
[in,out]clientA pointer to an Awa Static Client pointer that will be set to NULL.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_DefineObject ( AwaStaticClient client,
AwaObjectID  objectID,
const char *  objectName,
uint16_t  minimumInstances,
uint16_t  maximumInstances 
)

Define a new custom LWM2M object.

By default, the LWM2M Client will handle instance operations such as delete and create. Use AwaStaticClient_SetObjectOperationHandler to override this default behaviour with a specified handler.

This function may only be called after a successful call to AwaStaticClient_Init.

Note
In order for an LWM2M server to perform operations on the defined object, a matching object must be defined on the LWM2M server.
Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectNameA human-friendly name for the new object.
[in]objectIDAn ID that uniquely identifies the object.
[in]minimumInstancesThe minimum number of instances of this object that must exist at any time. Must be less than or equal to maximumInstances.
[in]maximumInstancesThe maximum number of instances of this object that must exist at any time. Must be greater than zero.
Returns
AwaError_Success on success.
AwaError_DefinitionInvalid if objectName is invalid or objectID is out of range, or minimumInstances or maximumInstances are invalid.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_SetObjectOperationHandler ( AwaStaticClient client,
AwaObjectID  objectID,
AwaStaticClientHandler  handler 
)

Set the Object Operation handler function, to be called by the LWM2M Client when object instances are created or deleted.

The target object must be defined with AwaStaticClient_DefineObject.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDAn ID that uniquely identifies the defined object for which the handler will be associated.
[in]handlerA user-specified callback handler.
Returns
AwaError_Success on success.
AwaError_DefinitionInvalid if objectID is invalid.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial3.c.
AwaError AwaStaticClient_DefineResource ( AwaStaticClient client,
AwaObjectID  objectID,
AwaResourceID  resourceID,
const char *  resourceName,
AwaResourceType  resourceType,
uint16_t  minimumInstances,
uint16_t  maximumInstances,
AwaResourceOperations  operations 
)

Define a new resource as part of a defined object.

By default, the LWM2M Client will handle resource operations. Use AwaStaticClient_SetResourceOperationHandler, AwaStaticClient_SetResourceStorageWithPointer or AwaStaticClient_SetResourceStorageWithPointerArray to configure whether operations are handled by the user, or directed to operate on static memory.

This function may only be called after a successful call to AwaStaticClient_Init, and the target object must be defined.

Note
In order for an LWM2M server to perform operations on the defined resource, a matching object with resources must be defined on the LWM2M server.
Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]resourceNameA human-friendly name for the new resource.
[in]objectIDAn ID that uniquely identifies the defined object which will contain the new resource.
[in]resourceIDAn ID that uniquely identifies the new resource within the object.
[in]resourceTypeThe type of the new resource.
[in]minimumInstancesThe minimum number of instances of this resource that must exist at any time. Must be less than or equal to maximumInstances.
[in]maximumInstancesThe maximum number of instances of this resource that must exist at any time. Must be greater than zero.
[in]operationsThe allowed LWM2M operations on the new resource.
Returns
AwaError_Success on success.
AwaError_DefinitionInvalid if resourceName is invalid, or objectID or resourceID is out of range, or minimumInstances or maximumInstances are invalid.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_SetResourceOperationHandler ( AwaStaticClient client,
AwaObjectID  objectID,
AwaResourceID  resourceID,
AwaStaticClientHandler  handler 
)

Set a user-specified callback handler that will be called whenever a LWM2M operation on the resource is performed.

The target resource must be defined with AwaStaticClient_DefineResource before this function is called.

Note
This function overrides the effect of AwaStaticClient_SetResourceStorageWithPointer and AwaStaticClient_SetResourceStorageWithPointerArray.
Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDAn ID that uniquely identifies the defined object that contains the defined resource.
[in]resourceIDAn ID that uniquely identifies the defined resource within the object.
[in]handlerA user-specified callback handler.
Returns
AwaError_Success on success.
AwaError_DefinitionInvalid if objectID or resourceID is invalid or out of range.
AwaError_StaticClientInvalid if client is NULL.
Examples:
static-client-tutorial3.c.
AwaError AwaStaticClient_SetResourceStorageWithPointer ( AwaStaticClient client,
AwaObjectID  objectID,
AwaResourceID  resourceID,
void *  dataPointer,
size_t  dataElementSize,
size_t  dataStepSize 
)

Set a resource's storage with a pointer to the resource's data, leaving handling of the resource to the LWM2M Client.

The resource's value within any of its instances may be directly modified at any time, however AwaStaticClient_ResourceChanged should be called to allow notifications to be sent to any observing LWM2M servers.

The target resource must be defined with AwaStaticClient_DefineResource before this function is called.

Note
This function overrides the effect of AwaStaticClient_SetResourceOperationHandler and AwaStaticClient_SetResourceStorageWithPointerArray.
Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDAn ID that uniquely identifies the defined object that contains the defined resource.
[in]resourceIDAn ID that uniquely identifies the defined resource within the object.
[in]dataPointerA pointer to the resource's data.
[in]dataElementSizeThe size in bytes of the resource's data. Must be greater than or equal to 1.
[in]dataStepSizeThe step size in bytes between the resource's data per object instance.
Returns
AwaError_Success on success.
AwaError_DefinitionInvalid if objectID or resourceID is invalid is out of range, or dataPointers is NULL, or dataElementSize is less than 1.
AwaError_StaticClientInvalid if the client is NULL.
Examples:
static-client-tutorial2.c.
AwaError AwaStaticClient_SetResourceStorageWithPointerArray ( AwaStaticClient client,
AwaObjectID  objectID,
AwaResourceID  resourceID,
void *  dataPointers[],
size_t  dataElementSize 
)

Set a resource's storage with an array of pointers to non-contiguous data, where each piece of data stores the resource for a single instance of its object.

Handling of the resource is left to the LWM2M Client. The resource's value within any of its instances may be directly modified at any time, however AwaStaticClient_ResourceChanged should be called to allow notifications to be sent to any observing LWM2M servers.

The target resource must be defined with AwaStaticClient_DefineResource before this function is called.

Note
This function overrides the effect of AwaStaticClient_SetResourceOperationHandler and AwaStaticClient_SetResourceStorageWithPointer.
Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDAn ID that uniquely identifies the defined object that contains the defined resource.
[in]resourceIDAn ID that uniquely identifies the defined resource within the object.
[in]dataPointersAn array of pointers, each containing the location of the resource's data for a single object instance.
[in]dataElementSizeThe size in bytes of the resource's data. Must be greater than or equal to 1.
Returns
AwaError_Success on success.
AwaError_DefinitionInvalid if objectID or resourceID is invalid or out of range, or dataPointers is NULL, or dataElementSize is less than 1.
AwaError_StaticClientInvalid if the client is NULL.
int AwaStaticClient_Process ( AwaStaticClient client)

Process the Awa Static Client.

This is the main process function which in turn processes the LWM2M Client core, updating the LWM2M state machine, handling any incoming CoAP messages, and sending notifications and registration updates to servers.

A successful call to AwaStaticClient_Init must precede a call to this function.

This function needs to be called regularly, usually as part of a loop, and returns the time to wait before calling again.

Parameters
[in]clientA pointer to a valid Awa Static Client.
Returns
The time until this function should next be called, in milliseconds.
Examples:
static-client-tutorial1.c, static-client-tutorial2.c, and static-client-tutorial3.c.
const void* AwaStaticClient_GetResourceInstancePointer ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID,
AwaResourceID  resourceID,
AwaResourceInstanceID  resourceInstanceID,
size_t *  resourceSize 
)

Retrieve a pointer to a resource instance's data, when defined with AwaStaticClient_SetResourceStorageWithPointer or AwaStaticClient_SetResourceStorageWithPointerArray.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDThe ID of the object for the specified resource instance.
[in]objectInstanceIDThe ID of the object instance for the specified resource instance.
[in]resourceIDThe ID of the resource for the specified resource instance.
[in]resourceInstanceIDThe ID of the resource instance.
[out]resourceSizeThe size of the resource instance.
Returns
A pointer to the resource instance's data, if it exists.
NULL if client is NULL or uninitialised, or the resource instance does not exist for the specified object, object instance, resource and resource instance IDs.
AwaError AwaStaticClient_CreateResource ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID,
AwaResourceID  resourceID 
)

Create an optional resource within the specified object instance.

For a resource registered with a handler this will invoke a callback with the AwaOperation_CreateResource.

For a resource registered by pointer this will create the resource. For a multi-instance resource, the number of resource instances created will be the maximum defined.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDThe ID of the object for the specified resource.
[in]objectInstanceIDThe ID of the object instance for the specified resource.
[in]resourceIDThe ID of the optional resource to create.
Returns
AwaError_Success if the resource is created successfully.
AwaError_CannotCreate if the resource already exists, or no resource is defined for the specified object, object instance and resource ID.
AwaError_StaticClientInvalid if client is NULL or uninitialised.
Examples:
static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_DeleteResource ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID,
AwaResourceID  resourceID 
)

Delete an optional resource within the specified object instance.

For a resource registered with a handler this will invoke a callback with the AwaOperation_DeleteResource.

For a resource registered by pointer this will delete the resource.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDThe ID of the object for the specified resource.
[in]objectInstanceIDThe ID of the object instance for the specified resource.
[in]resourceIDThe ID of the optional resource to delete.
Returns
AwaError_Success if the resource is created successfully.
AwaError_CannotCreate if the resource already exists, or no resource is defined for the specified object, object instance and resource ID.
AwaError_StaticClientInvalid if client is NULL or uninitialised.
AwaError AwaStaticClient_CreateObjectInstance ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID 
)

Create an object instance within the specified object.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDThe ID of the object for the specified object instance.
[in]objectInstanceIDThe ID of the object instance to create.
Returns
AwaError_Success if the object instance is created successfully.
AwaError_CannotCreate if the object instance already exists, the object already contains a maximum number of object instances, or if no object is defined for the specified object ID.
AwaError_StaticClientInvalid if client is NULL or uninitialised.
Examples:
static-client-tutorial2.c, and static-client-tutorial3.c.
AwaError AwaStaticClient_DeleteObjectInstance ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID 
)

Delete an object instance within the specified object.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDThe ID of the object for the specified object instance.
[in]objectInstanceIDThe ID of the object instance to delete.
Returns
AwaError_Success if the object instance is created successfully.
AwaError_CannotCreate if the object instance already exists, the object already contains a maximum number of object instances, or if no object is defined for the specified object ID.
AwaError_StaticClientInvalid if client is NULL or uninitialised.
AwaError AwaStaticClient_ResourceChanged ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID,
AwaResourceID  resourceID 
)

Mark the specified resource as changed, in order for the Awa Static Client to send notifications to all LWM2M servers observing that resource.

  • Parameters
    [in]clientA pointer to a valid Awa Static Client.
    [in]objectIDThe ID of the object containing the specified resource.
    [in]objectInstanceIDThe ID of the object instance containing the specified resource.
    [in]resourceIDThe ID of the resource to mark as changed.
    Returns
    AwaError_Success if the specified resource exists and was successfully marked as changed.
    AwaError_DefinitionInvalid if no resource exists for the specified object, object instance and resource IDs.
    AwaError_StaticClientInvalid if client is NULL or uninitialised.
Examples:
static-client-tutorial2.c.
AwaError AwaStaticClient_ObjectInstanceChanged ( AwaStaticClient client,
AwaObjectID  objectID,
AwaObjectInstanceID  objectInstanceID 
)

Mark the specified object instance as changed, in order for the Awa Static Client to send notifications to all LWM2M servers observing that object instance.

This function should also be called when a resource is created or deleted in an object instance.

Parameters
[in]clientA pointer to a valid Awa Static Client.
[in]objectIDThe ID of the object for the specified object instance.
[in]objectInstanceIDThe ID of the object instance to mark as changed.
Returns
AwaError_Success if the specified resource exists and was successfully marked as changed.
AwaError_DefinitionInvalid if no resource exists for the specified object, object instance and resource IDs.
AwaError_StaticClientInvalid if client is NULL or uninitialised.