Soletta™ Framework
|
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... | |
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.
#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.
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:
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.
key_ | Field's key. |
value_ | The boolean value of this field. |
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.
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.
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.
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.
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.
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.
key_ | Field's key. |
value_ | The signed int value of this field. |
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.
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.
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.
key_ | Field's key. |
value_ | The unsigned int value of this field. |
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().
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.
typedef struct sol_oic_map_reader sol_oic_map_reader |
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.
parser | Internal Pointer. Not to be used. |
ptr | Internal Pointer. Not to be used. |
remaining | Internal information. Not to be used. |
extra | Internal information. Not to be used. |
type | Internal information. Not to be used. |
flags | Internal information. Not to be used. |
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().
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().
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.
typedef struct sol_oic_repr_field sol_oic_repr_field |
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().
Information about a client request.
Information about a server response.
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. |
enum sol_oic_map_type |
Used in sol_oic_map_writer to state if the map has a content or not.
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. |
enum sol_oic_repr_type |
field type of sol_oic_repr_field structure.
Flags to set when adding a new resource to a server.
Multiple flags can be set, just connect them using the | operator.
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.
oic_map_writer | The sol_oic_map_writer in which the element will be added. |
repr | The element |
0
on success, error code (always negative) otherwise.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.
oic_map_writer | The map to get the type from. |
type | A pointer to an enum to be filled with oic_map_writer type. |
-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.
map | The sol_oic_map_reader element to be used to initialize the iterator. |
iterator | Iterator to be initialized so it can be used by sol_oic_map_loop_next() to visit map elements. |
repr | Initialize this element to be used by sol_oic_map_loop_next() to hold map elements. |
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.
repr | The value of next element from iterator |
iterator | The sol_oic_map_reader iterator initialized by sol_oic_map_loop_init function. |
reason | SOL_OIC_MAP_LOOP_ERROR if an error occurred. SOL_OIC_MAP_LOOP_OK otherwise. |
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.
oic_map_writer | The map to set the type. |
type | The new type of oic_map_writer. |
0
on success, error code (always negative) otherwise.
|
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.
pkt | The 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.
field | the field to be cleared. |
Referenced by user_handle_put().