nRF5 SDK for Mesh v5.0.0
Data Structures | Macros | Typedefs | Functions
Generic OnOff server model interface

Data Structures

struct  generic_onoff_server_state_cbs_t
 Transaction callbacks for the OnOff state. More...
 
struct  generic_onoff_server_callbacks_t
 OnOff server callback list. More...
 
struct  generic_onoff_server_settings_t
 User provided settings and callbacks for the model instance. More...
 
struct  generic_onoff_server_t
 

Macros

#define GENERIC_ONOFF_SERVER_MODEL_ID   0x1000
 Server model ID.
 

Typedefs

typedef void(* generic_onoff_state_set_cb_t) (const generic_onoff_server_t *p_self, const access_message_rx_meta_t *p_meta, const generic_onoff_set_params_t *p_in, const model_transition_t *p_in_transition, generic_onoff_status_params_t *p_out)
 Callback type for Generic OnOff Set/Set Unacknowledged message. More...
 
typedef void(* generic_onoff_state_get_cb_t) (const generic_onoff_server_t *p_self, const access_message_rx_meta_t *p_meta, generic_onoff_status_params_t *p_out)
 Callback type for Generic OnOff Get message. More...
 

Functions

uint32_t generic_onoff_server_init (generic_onoff_server_t *p_server, uint8_t element_index)
 Initializes Generic OnOff server. More...
 
uint32_t generic_onoff_server_status_publish (generic_onoff_server_t *p_server, const generic_onoff_status_params_t *p_params)
 Publishes unsolicited Status message. More...
 
uint32_t generic_onoff_server_state_set (generic_onoff_server_t *p_server, bool onoff)
 Function to trigger onoff value set as a Generic OnOff server callback. More...
 

Detailed Description

Typedef Documentation

◆ generic_onoff_state_set_cb_t

typedef void(* generic_onoff_state_set_cb_t) (const generic_onoff_server_t *p_self, const access_message_rx_meta_t *p_meta, const generic_onoff_set_params_t *p_in, const model_transition_t *p_in_transition, generic_onoff_status_params_t *p_out)

Callback type for Generic OnOff Set/Set Unacknowledged message.

Parameters
[in]p_selfPointer to the model structure.
[in]p_metaAccess metadata for the received message.
[in]p_inPointer to the input parameters for the user application.
[in]p_in_transitionPointer to transition parameters, if present in the incoming message, otherwise set to null.
[out]p_outPointer to store the output parameters from the user application. If null, indicates that it is UNACKNOWLEDGED message and no output params are required.

Definition at line 70 of file generic_onoff_server.h.

◆ generic_onoff_state_get_cb_t

typedef void(* generic_onoff_state_get_cb_t) (const generic_onoff_server_t *p_self, const access_message_rx_meta_t *p_meta, generic_onoff_status_params_t *p_out)

Callback type for Generic OnOff Get message.

Parameters
[in]p_selfPointer to the model structure.
[in]p_metaAccess metadata for the received message.
[out]p_outPointer to store the output parameters from the user application.

Definition at line 83 of file generic_onoff_server.h.

Function Documentation

◆ generic_onoff_server_init()

uint32_t generic_onoff_server_init ( generic_onoff_server_t *  p_server,
uint8_t  element_index 
)

Initializes Generic OnOff server.

Note
The server handles the model allocation and adding.
Parameters
[in]p_serverGeneric OnOff server context pointer.
[in]element_indexElement index to add the model to.
Return values
NRF_SUCCESSThe model is initialized successfully.
NRF_ERROR_NULLNULL pointer given to function.
NRF_ERROR_NO_MEMACCESS_MODEL_COUNT number of models already allocated or no more subscription lists available in memory pool (see ACCESS_SUBSCRIPTION_LIST_COUNT).
NRF_ERROR_FORBIDDENMultiple model instances per element are not allowed or changes to device composition are not allowed. Adding a new model after device is provisioned is not allowed.
NRF_ERROR_NOT_FOUNDInvalid access element index.

◆ generic_onoff_server_status_publish()

uint32_t generic_onoff_server_status_publish ( generic_onoff_server_t *  p_server,
const generic_onoff_status_params_t p_params 
)

Publishes unsolicited Status message.

This function can be used to send unsolicited messages to report the updated state value as a result of local action.

Parameters
[in]p_serverStatus server context pointer.
[in]p_paramsMessage parameters.
Return values
NRF_SUCCESSIf the message is published successfully.
NRF_ERROR_NULLNULL pointer given to function.
NRF_ERROR_NO_MEMNo memory available to send the message at this point.
NRF_ERROR_NOT_FOUNDThe model is not initialized.
NRF_ERROR_INVALID_PARAMInvalid message parameters, the model not bound to application key, or publish address not set.
NRF_ERROR_FORBIDDENFailed to allocate a sequence number from network.
NRF_ERROR_INVALID_STATEThere's already a segmented packet that is being to sent to this destination. Wait for the transmission to finish before sending new segmented packets.

◆ generic_onoff_server_state_set()

uint32_t generic_onoff_server_state_set ( generic_onoff_server_t *  p_server,
bool  onoff 
)

Function to trigger onoff value set as a Generic OnOff server callback.

This is called when the mesh is initialized and stable. The caller is responsible for reading the saved state values out of flash and pass those to this function. So that function calls set_cb to propogate given value to higher layers.

Parameters
[in]p_serverServer context pointer.
[in]onoffSet value of the onoff state.
Return values
NRF_SUCCESSThe model is initialized successfully.
NRF_ERROR_NULLNULL pointer given to function.

Documentation feedback | Developer Zone | Subscribe | Updated