Wirepas SDK
shared_appconfig.h File Reference

Go to the source code of this file.

Typedefs

typedef void(* shared_app_config_received_cb_f) (uint16_t type, uint8_t length, uint8_t *value_p)
 The app config type reception callback. More...
 

Functions

shared_app_config_res_e Shared_Appconfig_init (void)
 Initialize the shared app config library. More...
 
shared_app_config_res_e Shared_Appconfig_addFilter (shared_app_config_filter_t *filter, uint16_t *filter_id)
 Add a new app config type filter to the list. If the item is already in the list it is only updated. More...
 
shared_app_config_res_e Shared_Appconfig_removeFilter (uint16_t filter_id)
 Remove a received packet item from the list. Removed item fields are all set to 0. More...
 
shared_app_config_res_e Shared_Appconfig_setAppConfig (const uint8_t *bytes)
 Set a new app config. More...
 
shared_app_config_res_e Shared_Appconfig_notifyAppConfig (const uint8_t *bytes)
 Notify other modules of a new app config received. More...
 

Data Structures

struct  shared_app_config_filter_t
 Structure holding all parameters for app config type filtering. More...
 

Enumerations

enum  shared_app_config_res_e {
  SHARED_APP_CONFIG_RES_OK = 0, SHARED_APP_CONFIG_RES_NO_FILTER = 1, SHARED_APP_CONFIG_RES_INVALID_PARAM = 2, SHARED_APP_CONFIG_RES_INVALID_FILTER = 3,
  SHARED_APP_CONFIG_RES_UNINITIALIZED = 4, SHARED_APP_CONFIG_RES_INVALID_ROLE = 5
}
 List of return code. More...
 

Macros

#define SHARED_APP_CONFIG_ALL_TYPE_FILTER   0xFFFF
 Value to use to receive all types. More...
 
#define SHARED_APP_CONFIG_INCOMPATIBLE_FILTER   0xFFFE
 Value to use to receive incompatible raw app_config Ie, if the app config is not recognized by this library, the complete raw app config is sent to registered modules. More...
 

Typedef Documentation

◆ shared_app_config_received_cb_f

typedef void(* shared_app_config_received_cb_f) (uint16_t type, uint8_t length, uint8_t *value_p)

The app config type reception callback.

This is the callback called when a new app config is received and a matching type is present in the content.

Parameters
typeThe type that match the filtering
lengthThe length of this TLV entry.
value_pPointer to the value of the TLV

Definition at line 59 of file shared_appconfig.h.

Function Documentation

◆ Shared_Appconfig_addFilter()

shared_app_config_res_e Shared_Appconfig_addFilter ( shared_app_config_filter_t filter,
uint16_t *  filter_id 
)

Add a new app config type filter to the list. If the item is already in the list it is only updated.

Parameters
filterNew filter (type + cb)
filter_idFilter id to be used with Shared_Appconfig_removeTypeReceivedCb. Set only if return code is SHARED_APP_CONFIG_RES_OK
Returns
SHARED_APP_CONFIG_RES_OK if ok. See shared_app_config_res_e for other result codes.
Examples
appconfig/app.c.

◆ Shared_Appconfig_init()

shared_app_config_res_e Shared_Appconfig_init ( void  )

Initialize the shared app config library.

Note
This function is automatically called if library is enabled.
If Shared app config module is used in application, the lib_data->setNewAppConfigCb() function offered by data library MUST NOT be used outside of this module.
Returns
SHARED_APP_CONFIG_RES_OK.

◆ Shared_Appconfig_notifyAppConfig()

shared_app_config_res_e Shared_Appconfig_notifyAppConfig ( const uint8_t *  bytes)

Notify other modules of a new app config received.

Parameters
bytesPointer to app config to notify.
Returns
SHARED_APP_CONFIG_RES_OK if ok. See shared_app_config_res_e for other result codes.
Note
This function must be used very carefully and is only needed on systems where the app config is received from a different path (like DA nodes)

◆ Shared_Appconfig_removeFilter()

shared_app_config_res_e Shared_Appconfig_removeFilter ( uint16_t  filter_id)

Remove a received packet item from the list. Removed item fields are all set to 0.

Parameters
filter_idfilter to remove.
Returns
SHARED_APP_CONFIG_RES_OK if ok. See shared_app_config_res_e for other result codes.

◆ Shared_Appconfig_setAppConfig()

shared_app_config_res_e Shared_Appconfig_setAppConfig ( const uint8_t *  bytes)

Set a new app config.

Parameters
bytesPointer to app config data to write.
Returns
SHARED_APP_CONFIG_RES_OK if ok. See shared_app_config_res_e for other result codes.
Note
This function must be used on the node that set the app config (sink) in order for other local modules to be notified by the change. In fact, stack itself will not trigger an app config changed callback on the node that change it.

Data Structure Documentation

◆ shared_app_config_filter_t

struct shared_app_config_filter_t

Structure holding all parameters for app config type filtering.

Examples
appconfig/app.c.

Definition at line 64 of file shared_appconfig.h.

Data Fields
bool call_cb_always

If set to true, the cb will be called everytime an app_config is received, even if the type is not present. If it happens, cb will have length set to 0 and value_p set to NULL

shared_app_config_received_cb_f cb

Will be called when the received app_config contains a matching type If the type is SHARED_APP_CONFIG_ALL_TYPE_FILTER the callback will be called multiple times

uint16_t type

Type for this filter. valid range [0;(2^16-1)], -1: to receive all types

Enumeration Type Documentation

◆ shared_app_config_res_e

List of return code.

Enumerator
SHARED_APP_CONFIG_RES_OK 

Operation is successful

SHARED_APP_CONFIG_RES_NO_FILTER 

No more filter available

SHARED_APP_CONFIG_RES_INVALID_PARAM 

Invalid Param

SHARED_APP_CONFIG_RES_INVALID_FILTER 

Trying to remove a filter that doesn't exist

SHARED_APP_CONFIG_RES_UNINITIALIZED 

Using the library without previous initialization

SHARED_APP_CONFIG_RES_INVALID_ROLE 

Invalid node role (not a sink)

Definition at line 15 of file shared_appconfig.h.

Macro Definition Documentation

◆ SHARED_APP_CONFIG_ALL_TYPE_FILTER

#define SHARED_APP_CONFIG_ALL_TYPE_FILTER   0xFFFF

Value to use to receive all types.

Note
Callback will also be called with type SHARED_APP_CONFIG_INCOMPATIBLE_FILTER if app config doesn't follow Wirepas TLV format
Examples
appconfig/app.c.

Definition at line 36 of file shared_appconfig.h.

◆ SHARED_APP_CONFIG_INCOMPATIBLE_FILTER

#define SHARED_APP_CONFIG_INCOMPATIBLE_FILTER   0xFFFE

Value to use to receive incompatible raw app_config Ie, if the app config is not recognized by this library, the complete raw app config is sent to registered modules.

Examples
appconfig/app.c.

Definition at line 43 of file shared_appconfig.h.

SHARED_APP_CONFIG_RES_NO_FILTER
@ SHARED_APP_CONFIG_RES_NO_FILTER
Definition: shared_appconfig.h:20
SHARED_APP_CONFIG_RES_OK
@ SHARED_APP_CONFIG_RES_OK
Definition: shared_appconfig.h:18
SHARED_APP_CONFIG_RES_INVALID_PARAM
@ SHARED_APP_CONFIG_RES_INVALID_PARAM
Definition: shared_appconfig.h:22
SHARED_APP_CONFIG_RES_INVALID_FILTER
@ SHARED_APP_CONFIG_RES_INVALID_FILTER
Definition: shared_appconfig.h:24
shared_app_config_res_e
shared_app_config_res_e
List of return code.
Definition: shared_appconfig.h:15
SHARED_APP_CONFIG_RES_INVALID_ROLE
@ SHARED_APP_CONFIG_RES_INVALID_ROLE
Definition: shared_appconfig.h:28
SHARED_APP_CONFIG_RES_UNINITIALIZED
@ SHARED_APP_CONFIG_RES_UNINITIALIZED
Definition: shared_appconfig.h:26