Soletta™ Framework
Framework for making IoT devices

Full online documentation | C API Index
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Modules | Data Structures | Macros | Typedefs | Enumerations | Functions
Open Interconnect Consortium

Implementation of the protocol defined by Open Interconnect Consortium (OIC - http://openinterconnect.org/) More...

Modules

 OIC Client
 Routines to create clients talking the OIC protocol.
 
 OIC Server
 Routines to create servers talking the OIC protocol.
 

Data Structures

struct  sol_oic_device_info
 Structure containing all fields that are retrieved by sol_oic_client_get_server_info() and sol_oic_client_get_server_info_by_addr(). More...
 
struct  sol_oic_map_reader
 Handler for an OIC packet map reader. More...
 
struct  sol_oic_platform_info
 Structure containing all fields that are retrieved by sol_oic_client_get_platform_info() and sol_oic_client_get_platform_info_by_addr(). More...
 
struct  sol_oic_repr_field
 Structure to keep a single oic-map's field. More...
 

Macros

#define SOL_OIC_MAP_LOOP(map_, current_, iterator_, end_reason_)
 Macro to be used to loop through all elements from a sol_oic_map_reader. More...
 
#define SOL_OIC_REPR_BOOL(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_BOOL, .v_boolean = !!(value_))
 Helper macro to create a boolean sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_BYTE_STRING(key_, value_, len_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_BYTE_STRING, .v_slice = SOL_STR_SLICE_STR((value_), (len_)))
 Helper macro to create a byte string sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_DOUBLE(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_DOUBLE, .v_double = (value_))
 Helper macro to create a double-precision float sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_FIELD(key_, type_,...)   (struct sol_oic_repr_field){.type = (type_), .key = (key_), { __VA_ARGS__ } }
 Helper macro to create a sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_FLOAT(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_FLOAT, .v_float = (value_))
 Helper macro to create a single-precision float number sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_HALF_FLOAT(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_HALF_FLOAT, .v_voidptr = (void *)(value_))
 Helper macro to create a half-precision float number sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_INT(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_INT, .v_int = (value_))
 Helper macro to create a signed integer sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_SIMPLE(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_SIMPLE, .v_simple = (value_))
 Helper macro to create a simple integer sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_TEXT_STRING(key_, value_, len_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_TEXT_STRING, .v_slice = SOL_STR_SLICE_STR((value_), (len_)))
 Helper macro to create a text string sol_oic_repr_field. More...
 
#define SOL_OIC_REPR_UINT(key_, value_)   SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_UINT, .v_uint = (value_))
 Helper macro to create an unsigned integer sol_oic_repr_field. More...
 

Typedefs

typedef struct sol_oic_device_info sol_oic_device_info
 Structure containing all fields that are retrieved by sol_oic_client_get_server_info() and sol_oic_client_get_server_info_by_addr(). More...
 
typedef struct sol_oic_map_reader sol_oic_map_reader
 Handler for an OIC packet map reader. More...
 
typedef struct sol_oic_map_writer sol_oic_map_writer
 Opaque handler for an OIC packet map writer. More...
 
typedef struct
sol_oic_platform_info 
sol_oic_platform_info
 Structure containing all fields that are retrieved by sol_oic_client_get_platform_info() and sol_oic_client_get_platform_info_by_addr(). More...
 
typedef struct sol_oic_repr_field sol_oic_repr_field
 Structure to keep a single oic-map's field. More...
 
typedef struct sol_oic_request sol_oic_request
 Information about a client request. More...
 
typedef struct sol_oic_response sol_oic_response
 Information about a server response. More...
 

Enumerations

enum  sol_oic_map_loop_reason { SOL_OIC_MAP_LOOP_OK = 0, SOL_OIC_MAP_LOOP_ERROR }
 Possible reasons a SOL_OIC_MAP_LOOP was terminated. More...
 
enum  sol_oic_map_type { SOL_OIC_MAP_NO_CONTENT, SOL_OIC_MAP_CONTENT }
 Used in sol_oic_map_writer to state if the map has a content or not. More...
 
enum  sol_oic_repr_type {
  SOL_OIC_REPR_TYPE_UINT, SOL_OIC_REPR_TYPE_INT, SOL_OIC_REPR_TYPE_SIMPLE, SOL_OIC_REPR_TYPE_TEXT_STRING,
  SOL_OIC_REPR_TYPE_BYTE_STRING, SOL_OIC_REPR_TYPE_HALF_FLOAT, SOL_OIC_REPR_TYPE_FLOAT, SOL_OIC_REPR_TYPE_DOUBLE,
  SOL_OIC_REPR_TYPE_BOOL, SOL_OIC_REPR_TYPE_UNSUPPORTED
}
 field type of sol_oic_repr_field structure. More...
 
enum  sol_oic_resource_flag {
  SOL_OIC_FLAG_NONE = 0, SOL_OIC_FLAG_DISCOVERABLE = 1 << 0, SOL_OIC_FLAG_OBSERVABLE = 1 << 1, SOL_OIC_FLAG_ACTIVE = 1 << 2,
  SOL_OIC_FLAG_SLOW = 1 << 3, SOL_OIC_FLAG_SECURE = 1 << 4, SOL_OIC_FLAG_DISCOVERABLE_EXPLICIT = 1 << 5
}
 Flags to set when adding a new resource to a server. More...
 

Functions

int sol_oic_map_append (struct sol_oic_map_writer *oic_map_writer, struct sol_oic_repr_field *repr)
 Append an element to oic_map_writer. More...
 
int sol_oic_map_get_type (struct sol_oic_map_writer *oic_map_writer, enum sol_oic_map_type *type)
 get current oic_map_writer type. More...
 
enum sol_oic_map_loop_reason sol_oic_map_loop_init (const struct sol_oic_map_reader *map, struct sol_oic_map_reader *iterator, struct sol_oic_repr_field *repr)
 Initialize an iterator to loop through elements of map. More...
 
bool sol_oic_map_loop_next (struct sol_oic_repr_field *repr, struct sol_oic_map_reader *iterator, enum sol_oic_map_loop_reason *reason)
 Get the next element from iterator. More...
 
int sol_oic_map_set_type (struct sol_oic_map_writer *oic_map_writer, enum sol_oic_map_type type)
 set current oic_map_writer type. More...
 
static void sol_oic_payload_debug (struct sol_coap_packet *pkt)
 Print the decoded cbor content of pkt. More...
 
void sol_oic_repr_field_clear (struct sol_oic_repr_field *field)
 Release memory from field. More...
 

Detailed Description

Implementation of the protocol defined by Open Interconnect Consortium (OIC - http://openinterconnect.org/)

It's a common communication framework based on industry standard technologies to wirelessly connect and intelligently manage the flow of information among devices, regardless of form factor, operating system or service provider.

Both client and server sides are covered by this module.

Macro Definition Documentation

#define SOL_OIC_MAP_LOOP (   map_,
  current_,
  iterator_,
  end_reason_ 
)
Value:
for (end_reason_ = sol_oic_map_loop_init(map_, iterator_, current_); \
end_reason_ == SOL_OIC_MAP_LOOP_OK && \
sol_oic_map_loop_next(current_, iterator_, &end_reason_);)
enum sol_oic_map_loop_reason sol_oic_map_loop_init(const struct sol_oic_map_reader *map, struct sol_oic_map_reader *iterator, struct sol_oic_repr_field *repr)
Initialize an iterator to loop through elements of map.
Success termination.
Definition: sol-oic.h:467
bool sol_oic_map_loop_next(struct sol_oic_repr_field *repr, struct sol_oic_map_reader *iterator, enum sol_oic_map_loop_reason *reason)
Get the next element from iterator.

Macro to be used to loop through all elements from a sol_oic_map_reader.

Parameters
map_A pointer to the struct sol_oic_map_reader to be looped
current_A pointer to a struct sol_oic_repr_field to be filled with the current element data.
iterator_A pointer to a struct sol_oic_map_reader to be used as an iterator
end_reason_A pointer to a enum sol_oic_map_loop_reason to be filled with the reason this loop has terminated.

Example to read data from a struct sol_oic_map_reader using this macro:

struct sol_oic_repr_field field;
enum sol_oic_map_loop_reason end_reason;
struct sol_oic_map_reader iterator;
SOL_OIC_MAP_LOOP(map_reader, &field, &iterator, end_reason) {
{
// do something
}
if (end_reason != SOL_OIC_MAP_LOOP_OK)
// Error handling
Note
: If you add a break or a return statement in SOL_OIC_MAP_LOOP, it is necessary to release the current_ memory using sol_oic_repr_field_clear().
See Also
sol_oic_map_reader
sol_oic_map_loop_init
sol_oic_map_loop_next
Examples:
/src/samples/coap/iotivity-test-client.c, /src/samples/coap/oic-client.c, and /src/samples/coap/oic-server.c.

Referenced by fill_info(), got_get_response(), print_response(), and user_handle_put().

#define SOL_OIC_REPR_BOOL (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_BOOL, .v_boolean = !!(value_))

Helper macro to create a boolean sol_oic_repr_field.

Parameters
key_Field's key.
value_The boolean value of this field.
Examples:
/src/samples/coap/iotivity-test-client.c, and /src/samples/coap/oic-server.c.

Referenced by put_fill_repr_map(), and user_handle_get().

#define SOL_OIC_REPR_BYTE_STRING (   key_,
  value_,
  len_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_BYTE_STRING, .v_slice = SOL_STR_SLICE_STR((value_), (len_)))

Helper macro to create a byte string sol_oic_repr_field.

Parameters
key_Field's key.
value_A pointer to the string to be set as the string value of this field.
len_The length of the string pointed by value.
#define SOL_OIC_REPR_DOUBLE (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_DOUBLE, .v_double = (value_))

Helper macro to create a double-precision float sol_oic_repr_field.

Parameters
key_Field's key.
value_The value of the float number.
#define SOL_OIC_REPR_FIELD (   key_,
  type_,
  ... 
)    (struct sol_oic_repr_field){.type = (type_), .key = (key_), { __VA_ARGS__ } }

Helper macro to create a sol_oic_repr_field.

Parameters
key_Field's key.
type_Field's type.
...Extra structure initialization commands.
#define SOL_OIC_REPR_FLOAT (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_FLOAT, .v_float = (value_))

Helper macro to create a single-precision float number sol_oic_repr_field.

Parameters
key_Field's key.
value_The value of the float number.
#define SOL_OIC_REPR_HALF_FLOAT (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_HALF_FLOAT, .v_voidptr = (void *)(value_))

Helper macro to create a half-precision float number sol_oic_repr_field.

Parameters
key_Field's key.
value_The value of the float number.
#define SOL_OIC_REPR_INT (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_INT, .v_int = (value_))

Helper macro to create a signed integer sol_oic_repr_field.

Parameters
key_Field's key.
value_The signed int value of this field.
Examples:
/src/samples/coap/iotivity-test-client.c, and /src/samples/coap/oic-server.c.

Referenced by post_fill_repr_map(), put_fill_repr_map(), and user_handle_get().

#define SOL_OIC_REPR_SIMPLE (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_SIMPLE, .v_simple = (value_))

Helper macro to create a simple integer sol_oic_repr_field.

Parameters
key_Field's key.
value_The 8-bit integer value of this field.
#define SOL_OIC_REPR_TEXT_STRING (   key_,
  value_,
  len_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_TEXT_STRING, .v_slice = SOL_STR_SLICE_STR((value_), (len_)))

Helper macro to create a text string sol_oic_repr_field.

Parameters
key_Field's key.
value_A pointer to the string to be set as the string value of this field.
len_The length of the string pointed by value.
#define SOL_OIC_REPR_UINT (   key_,
  value_ 
)    SOL_OIC_REPR_FIELD(key_, SOL_OIC_REPR_TYPE_UINT, .v_uint = (value_))

Helper macro to create an unsigned integer sol_oic_repr_field.

Parameters
key_Field's key.
value_The unsigned int value of this field.

Typedef Documentation

Structure containing all fields that are retrieved by sol_oic_client_get_server_info() and sol_oic_client_get_server_info_by_addr().

It's open to the API user to bypass the need for getters for everything, but all callbacks returning an instance do so with a const modifier. The user must never change these fields, ever.

Handler for an OIC packet map reader.

This structure is used in callback parameters so users can read fields from an OIC packet using SOL_OIC_MAP_LOOP.

Parameters
parserInternal Pointer. Not to be used.
ptrInternal Pointer. Not to be used.
remainingInternal information. Not to be used.
extraInternal information. Not to be used.
typeInternal information. Not to be used.
flagsInternal information. Not to be used.
Note
Fields from this structure are not expected to be accessed by clients. They are exposed only to make it possible for stack variable declarations of it.
See Also
SOL_OIC_MAP_LOOP.

Opaque handler for an OIC packet map writer.

This structure is used in callback parameters so users can add fields to an OIC packet using sol_oic_map_append().

See Also
sol_oic_server_notify()
sol_oic_client_resource_request()

Structure containing all fields that are retrieved by sol_oic_client_get_platform_info() and sol_oic_client_get_platform_info_by_addr().

It's open to the API user to bypass the need for getters for everything, but all callbacks returning an instance do so with a const modifier. The user must never change these fields, ever.

Structure to keep a single oic-map's field.

Use this structure to read fields using a sol_oic_map_reader and macro SOL_OIC_MAP_LOOP() or to write fields using a sol_oic_map_writer and function sol_oic_map_append().

See Also
sol_oic_map_append()
SOL_OIC_MAP_LOOP()

Information about a client request.

See Also
sol_oic_server_send_response

Information about a server response.

See Also
sol_oic_server_send_response

Enumeration Type Documentation

Possible reasons a SOL_OIC_MAP_LOOP was terminated.

Enumerator
SOL_OIC_MAP_LOOP_OK 

Success termination.

Everything was OK.

SOL_OIC_MAP_LOOP_ERROR 

Loop was terminated because an error occurred.

Not all elements were visited.

Used in sol_oic_map_writer to state if the map has a content or not.

See Also
sol_oic_map_set_type()
sol_oic_map_get_type()
Enumerator
SOL_OIC_MAP_NO_CONTENT 

Map with no content.

When an OIC map is used to create a packet and its type is SOL_OIC_MAP_NO_CONTENT, no payload will be added to the packet.

SOL_OIC_MAP_CONTENT 

Map with content.

When an OIC map is used to create a packet and its type is SOL_OIC_MAP_CONTENT, a payload will be created and elements from the map will be added to payload. If the map contains no elements, an empty map will be added to payload.

field type of sol_oic_repr_field structure.

Enumerator
SOL_OIC_REPR_TYPE_UINT 
SOL_OIC_REPR_TYPE_INT 

Unsigned int type.

SOL_OIC_REPR_TYPE_SIMPLE 

Signed int type.

SOL_OIC_REPR_TYPE_TEXT_STRING 

Unsigned 8-bit integer type.

SOL_OIC_REPR_TYPE_BYTE_STRING 

String with text type.

SOL_OIC_REPR_TYPE_HALF_FLOAT 

String with bytes type.

SOL_OIC_REPR_TYPE_FLOAT 

Half-precision float number type.

SOL_OIC_REPR_TYPE_DOUBLE 

Single-precision float number type.

SOL_OIC_REPR_TYPE_BOOL 

Double-precision float number type.

SOL_OIC_REPR_TYPE_UNSUPPORTED 

Boolean precision type.

Unsupported type.

Flags to set when adding a new resource to a server.

Multiple flags can be set, just connect them using the | operator.

See Also
sol_oic_server_register_resource()
Enumerator
SOL_OIC_FLAG_NONE 

No flag is set.

The device is non-discoverable and non-observable

SOL_OIC_FLAG_DISCOVERABLE 

The resource is discoverable by clients.

SOL_OIC_FLAG_OBSERVABLE 

The resource is observable.

Clients can request observable resources to be notified when a the resource status has changes.

SOL_OIC_FLAG_ACTIVE 

The resource is active.

Devices are set as inactive when they are uninitialized, marked for deletion or already deleted.

SOL_OIC_FLAG_SLOW 

The resource is slow.

Delays in response from slow resource is expected when processing requests.

SOL_OIC_FLAG_SECURE 

The resource is secure.

Connection established with a secure devices is secure.

SOL_OIC_FLAG_DISCOVERABLE_EXPLICIT 

The resource is discoverable by clients only if request contains an explicity query.

Function Documentation

int sol_oic_map_append ( struct sol_oic_map_writer oic_map_writer,
struct sol_oic_repr_field repr 
)

Append an element to oic_map_writer.

Parameters
oic_map_writerThe sol_oic_map_writer in which the element will be added.
reprThe element
Returns
0 on success, error code (always negative) otherwise.
See Also
sol_oic_server_notify()
sol_oic_client_resource_request()
Note
As this function adds elements to oic_map_writer, it will update its type to SOL_OIC_MAP_CONTENT when needed.
Examples:
/src/samples/coap/iotivity-test-client.c, and /src/samples/coap/oic-server.c.

Referenced by post_fill_repr_map(), put_fill_repr_map(), and user_handle_get().

int sol_oic_map_get_type ( struct sol_oic_map_writer oic_map_writer,
enum sol_oic_map_type type 
)

get current oic_map_writer type.

Parameters
oic_map_writerThe map to get the type from.
typeA pointer to an enum to be filled with oic_map_writer type.
Returns
-EINVAL if any param is NULL. 0 otherwise.
enum sol_oic_map_loop_reason sol_oic_map_loop_init ( const struct sol_oic_map_reader map,
struct sol_oic_map_reader iterator,
struct sol_oic_repr_field repr 
)

Initialize an iterator to loop through elements of map.

Parameters
mapThe sol_oic_map_reader element to be used to initialize the iterator.
iteratorIterator to be initialized so it can be used by sol_oic_map_loop_next() to visit map elements.
reprInitialize this element to be used by sol_oic_map_loop_next() to hold map elements.
Returns
SOL_OIC_MAP_LOOP_OK if initialization was a success or SOL_OIC_MAP_LOOP_ERROR if initialization failed.
Note
Prefer using SOL_OIC_MAP_LOOP instead of calling this function directly.
See Also
sol_oic_map_reader
bool sol_oic_map_loop_next ( struct sol_oic_repr_field repr,
struct sol_oic_map_reader iterator,
enum sol_oic_map_loop_reason reason 
)

Get the next element from iterator.

Parameters
reprThe value of next element from iterator
iteratorThe sol_oic_map_reader iterator initialized by sol_oic_map_loop_init function.
reasonSOL_OIC_MAP_LOOP_ERROR if an error occurred. SOL_OIC_MAP_LOOP_OK otherwise.
Returns
false if one error occurred or if there is no more elements to read from iterator. true otherwise.
Note
Prefer using SOL_OIC_MAP_LOOP instead of calling this function directly.
See Also
sol_oic_map_reader
int sol_oic_map_set_type ( struct sol_oic_map_writer oic_map_writer,
enum sol_oic_map_type  type 
)

set current oic_map_writer type.

Use this function if you want to change oic_map_writer type to SOL_OIC_MAP_CONTENT without adding elements to it. This will force OIC to create a payload in packet with an empty list if map is empty. Trying to change from SOL_OIC_MAP_CONTENT to SOL_OIC_MAP_NO_CONTENT will fail if elements were already added to oic_map_writer.

Parameters
oic_map_writerThe map to set the type.
typeThe new type of oic_map_writer.
Returns
0 on success, error code (always negative) otherwise.
static void sol_oic_payload_debug ( struct sol_coap_packet pkt)
inlinestatic

Print the decoded cbor content of pkt.

Checks if pkt is an OIC packet with cbor content in payload and prints it in a human readable way.

Used only for debug purposes.

Parameters
pktThe packet to be debuged.
void sol_oic_repr_field_clear ( struct sol_oic_repr_field field)

Release memory from field.

Release any memory that is hold by field, but not free field variable.

Parameters
fieldthe field to be cleared.
Examples:
/src/samples/coap/oic-server.c.

Referenced by user_handle_put().