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_server Pointer to the health server instance structure. [in] attention_state trueif the device should enable the attention state,falseif 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_server Pointer to the server instance structure. [in] company_id Company ID of the requested test. [in] test_id ID of the test that should be run.
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_server Pointer to a server instance. [in] fault_code ID 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_server Pointer to a server instance. [in] fault_code ID 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_server Pointer to a server instance. [in] fault_code ID of the fault to check for.
- Returns
- Returns
trueif the specified fault is set andfalseotherwise.
◆ 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_server Pointer 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_server Pointer 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_server Pointer to a server instance. [in] attention New 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_server Pointer to the server instance structure. [in] element_index Element index to use when registering the health server. [in] company_id Company ID supported by this health model server. [in] attention_cb Callback function for enabling or disabling the attention state for the device. If NULLis passed as this argument, the attention state is considered to be unsupported by the model, and the attention timer is disabled.[in] p_selftests Pointer to an array of self-tests that will be supported by this device. If NULLis passed as this argument, self-tests will be unsupported by the model. In this case, thenum_selftestsparameter will be ignored.[in] num_selftests Number of self-tests provided by p_selftests.
- Return values
-
NRF_SUCCESS The model was successfully initialized.
- See also
- access_model_add()