nRF5 SDK for Mesh v5.0.0
Data Structures | Macros | Typedefs | Functions

Model implementing the Health Server foundation model. More...

Data Structures

struct  health_server_selftest_t
 Structure defining a self-test function. More...
 
struct  health_server_t
 Health server instance structure. More...
 

Macros

#define HEALTH_SERVER_FAULT_ARRAY_SIZE   256
 Size of the health server fault array. More...
 

Typedefs

typedef void(* health_server_attention_cb_t) (const health_server_t *p_server, bool attention_state)
 Callback function for the attention state. More...
 
typedef void(* health_server_selftest_cb_t) (health_server_t *p_server, uint16_t company_id, uint8_t test_id)
 Self-test function type. More...
 
typedef uint32_t health_server_fault_array_t[BITFIELD_BLOCK_COUNT(HEALTH_SERVER_FAULT_ARRAY_SIZE)]
 Health server fault array type. More...
 

Functions

void health_server_fault_register (health_server_t *p_server, uint8_t fault_code)
 Registers a fault in the current fault array. More...
 
void health_server_fault_clear (health_server_t *p_server, uint8_t fault_code)
 Clears a fault from the current fault array. More...
 
bool health_server_fault_is_set (health_server_t *p_server, uint8_t fault_code)
 Checks if a fault code is set in current fault array. More...
 
uint8_t health_server_fault_count_get (const health_server_t *p_server)
 Gets the number of currently set faults in the fault array. More...
 
uint8_t health_server_attention_get (const health_server_t *p_server)
 Gets the current value of the attention timer. More...
 
void health_server_attention_set (health_server_t *p_server, uint8_t attention)
 Sets the attention timer value. More...
 
uint32_t health_server_init (health_server_t *p_server, uint16_t element_index, uint16_t company_id, health_server_attention_cb_t attention_cb, const health_server_selftest_t *p_selftests, uint8_t num_selftests)
 Initializes the health server model. More...
 

Detailed Description

Model implementing the Health Server foundation model.

Macro Definition Documentation

◆ HEALTH_SERVER_FAULT_ARRAY_SIZE

#define HEALTH_SERVER_FAULT_ARRAY_SIZE   256

Size of the health server fault array.

Definition at line 58 of file health_server.h.

Typedef Documentation

◆ health_server_attention_cb_t

typedef void(* health_server_attention_cb_t) (const health_server_t *p_server, bool attention_state)

Callback function for the attention state.

The attention state is enabled when a health client sets the attention timer to a nonzero value, and disabled when the attention timer reaches zero.

Parameters
[in]p_serverPointer to the health server instance structure.
[in]attention_statetrue if the device should enable the attention state, false if the device should disable the attention state.

Definition at line 71 of file health_server.h.

◆ health_server_selftest_cb_t

typedef void(* health_server_selftest_cb_t) (health_server_t *p_server, uint16_t company_id, uint8_t test_id)

Self-test function type.

A self-test should perform a specific test and set or clear corresponding fault(s) in the fault array using the health_server_fault_register() or health_server_fault_clear() functions.

Parameters
[in]p_serverPointer to the server instance structure.
[in]company_idCompany ID of the requested test.
[in]test_idID of the test that should be run.
See also
health_server_fault_register(), health_server_fault_clear(), health_server_fault_is_set()

Definition at line 85 of file health_server.h.

◆ health_server_fault_array_t

typedef uint32_t health_server_fault_array_t[BITFIELD_BLOCK_COUNT(HEALTH_SERVER_FAULT_ARRAY_SIZE)]

Health server fault array type.

Definition at line 99 of file health_server.h.

Function Documentation

◆ health_server_fault_register()

void health_server_fault_register ( health_server_t *  p_server,
uint8_t  fault_code 
)

Registers a fault in the current fault array.

If the device is publishing a periodic Current Status message and there are no active faults before this function is called, the model will enable fast publishing of the Current Status message. This is done by dividing the current publishing interval with 2fast period interval and using the result as the new publishing interval.

Note
The fast publishing interval will never go lower than 100 ms.
Parameters
[in,out]p_serverPointer to a server instance.
[in]fault_codeID of the fault to register.
See also
health_server_fault_clear()

◆ health_server_fault_clear()

void health_server_fault_clear ( health_server_t *  p_server,
uint8_t  fault_code 
)

Clears a fault from the current fault array.

If the device is currently publishing a periodic Current Status message with a fast publishing period, and there are no active faults after this function is called, the publishing interval will be reset back to the original interval.

Parameters
[in,out]p_serverPointer to a server instance.
[in]fault_codeID of the fault to clear.
See also
health_server_fault_register()

◆ health_server_fault_is_set()

bool health_server_fault_is_set ( health_server_t *  p_server,
uint8_t  fault_code 
)

Checks if a fault code is set in current fault array.

Parameters
[in,out]p_serverPointer to a server instance.
[in]fault_codeID of the fault to check for.
Returns
Returns true if the specified fault is set and false otherwise.

◆ health_server_fault_count_get()

uint8_t health_server_fault_count_get ( const health_server_t *  p_server)

Gets the number of currently set faults in the fault array.

Parameters
[in]p_serverPointer to a server instance.
Returns
Returns the number of currently set faults in the fault array.

◆ health_server_attention_get()

uint8_t health_server_attention_get ( const health_server_t *  p_server)

Gets the current value of the attention timer.

Parameters
[in]p_serverPointer to a server instance.
Returns
Returns the current value of the attention timer.

◆ health_server_attention_set()

void health_server_attention_set ( health_server_t *  p_server,
uint8_t  attention 
)

Sets the attention timer value.

Parameters
[in]p_serverPointer to a server instance.
[in]attentionNew value for the attention timer.

◆ health_server_init()

uint32_t health_server_init ( health_server_t *  p_server,
uint16_t  element_index,
uint16_t  company_id,
health_server_attention_cb_t  attention_cb,
const health_server_selftest_t p_selftests,
uint8_t  num_selftests 
)

Initializes the health server model.

Parameters
[in]p_serverPointer to the server instance structure.
[in]element_indexElement index to use when registering the health server.
[in]company_idCompany ID supported by this health model server.
[in]attention_cbCallback function for enabling or disabling the attention state for the device. If NULL is passed as this argument, the attention state is considered to be unsupported by the model, and the attention timer is disabled.
[in]p_selftestsPointer to an array of self-tests that will be supported by this device. If NULL is passed as this argument, self-tests will be unsupported by the model. In this case, the num_selftests parameter will be ignored.
[in]num_selftestsNumber of self-tests provided by p_selftests.
Return values
NRF_SUCCESSThe model was successfully initialized.
See also
access_model_add()

Documentation feedback | Developer Zone | Subscribe | Updated