nRF5 SDK for Mesh v3.2.0  08c60f6

Data Structures

struct  simple_on_off_server_t
 Simple OnOff Server state structure. More...
 

Macros

#define SIMPLE_ON_OFF_SERVER_MODEL_ID   (0x0000)
 Simple OnOff Server model ID.
 

Typedefs

typedef bool(* simple_on_off_get_cb_t) (const simple_on_off_server_t *p_self)
 Get callback type. More...
 
typedef bool(* simple_on_off_set_cb_t) (const simple_on_off_server_t *p_self, bool on)
 Set callback type. More...
 

Functions

uint32_t simple_on_off_server_init (simple_on_off_server_t *p_server, uint16_t element_index)
 Initializes the Simple OnOff server. More...
 
uint32_t simple_on_off_server_status_publish (simple_on_off_server_t *p_server, bool value)
 Publishes unsolicited status message. More...
 

Detailed Description

This module implements a vendor specific Simple OnOff Server.

Typedef Documentation

◆ simple_on_off_get_cb_t

typedef bool(* simple_on_off_get_cb_t) (const simple_on_off_server_t *p_self)

Get callback type.

Parameters
[in]p_selfPointer to the Simple OnOff Server context structure.
Returns
true if the state is On, false otherwise.

Definition at line 63 of file simple_on_off_server.h.

◆ simple_on_off_set_cb_t

typedef bool(* simple_on_off_set_cb_t) (const simple_on_off_server_t *p_self, bool on)

Set callback type.

Parameters
[in]p_selfPointer to the Simple OnOff Server context structure.
[in]on_offDesired state
Returns
true if the current state is On, false otherwise.

Definition at line 71 of file simple_on_off_server.h.

Function Documentation

◆ simple_on_off_server_init()

uint32_t simple_on_off_server_init ( simple_on_off_server_t *  p_server,
uint16_t  element_index 
)

Initializes the Simple OnOff server.

Note
This function should only be called once.
The server handles the model allocation and adding.
Parameters
[in]p_serverSimple OnOff Server structure pointer.
[in]element_indexElement index to add the server model.
Return values
NRF_SUCCESSSuccessfully added server.
NRF_ERROR_NULLNULL pointer supplied to function.
NRF_ERROR_NO_MEMNo more memory available to allocate model.
NRF_ERROR_FORBIDDENMultiple model instances per element is not allowed.
NRF_ERROR_NOT_FOUNDInvalid element index.

◆ simple_on_off_server_status_publish()

uint32_t simple_on_off_server_status_publish ( simple_on_off_server_t *  p_server,
bool  value 
)

Publishes unsolicited status message.

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

Parameters
[in]p_serverSimple OnOff Server structure pointer
[in]valueCurrent on/off value to be published
Return values
NRF_SUCCESSSuccessfully queued packet for transmission.
NRF_ERROR_NULLNULL pointer supplied to function.
NRF_ERROR_NO_MEMNot enough memory available for message.
NRF_ERROR_NOT_FOUNDInvalid model handle or model not bound to element.
NRF_ERROR_INVALID_ADDRThe element index is greater than the number of local unicast addresses stored by the Device State Manager.
NRF_ERROR_INVALID_PARAMModel not bound to appkey, publish address not set or wrong opcode format.
NRF_ERROR_INVALID_LENGTHAttempted to send message larger than ACCESS_MESSAGE_LENGTH_MAX.