nRF5 SDK for Mesh v4.1.0
health_server.h
1 /* Copyright (c) 2010 - 2020, Nordic Semiconductor ASA
2  * All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without modification,
5  * are permitted provided that the following conditions are met:
6  *
7  * 1. Redistributions of source code must retain the above copyright notice, this
8  * list of conditions and the following disclaimer.
9  *
10  * 2. Redistributions in binary form, except as embedded into a Nordic
11  * Semiconductor ASA integrated circuit in a product or a software update for
12  * such product, must reproduce the above copyright notice, this list of
13  * conditions and the following disclaimer in the documentation and/or other
14  * materials provided with the distribution.
15  *
16  * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
17  * contributors may be used to endorse or promote products derived from this
18  * software without specific prior written permission.
19  *
20  * 4. This software, with or without modification, must only be used with a
21  * Nordic Semiconductor ASA integrated circuit.
22  *
23  * 5. Any software provided in binary form under this license must not be reverse
24  * engineered, decompiled, modified and/or disassembled.
25  *
26  * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
27  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
28  * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
29  * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
30  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
32  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
33  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
35  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  */
37 
38 #ifndef HEALTH_SERVER_H__
39 #define HEALTH_SERVER_H__
40 
41 #include <stdbool.h>
42 #include <stdint.h>
43 
44 #include "access.h"
45 #include "bitfield.h"
46 
47 #include "health_common.h"
48 #include "nrf_mesh_config_app.h"
49 
58 #define HEALTH_SERVER_FAULT_ARRAY_SIZE 256
59 
61 typedef struct __health_server_t health_server_t;
62 
71 typedef void (*health_server_attention_cb_t)(const health_server_t * p_server, bool attention_state);
72 
85 typedef void (*health_server_selftest_cb_t)(health_server_t * p_server, uint16_t company_id, uint8_t test_id);
86 
92 typedef struct
93 {
94  uint8_t test_id;
97 
99 typedef uint32_t health_server_fault_array_t[BITFIELD_BLOCK_COUNT(HEALTH_SERVER_FAULT_ARRAY_SIZE)];
100 
105 {
109  uint8_t num_selftests;
111  uint16_t company_id;
115  uint8_t attention_timer;
117 };
118 
134 void health_server_fault_register(health_server_t * p_server, uint8_t fault_code);
135 
148 void health_server_fault_clear(health_server_t * p_server, uint8_t fault_code);
149 
156 bool health_server_fault_is_set(health_server_t * p_server, uint8_t fault_code);
157 
163 uint8_t health_server_fault_count_get(const health_server_t * p_server);
164 
170 uint8_t health_server_attention_get(const health_server_t * p_server);
171 
177 void health_server_attention_set(health_server_t * p_server, uint8_t attention);
178 
198 uint32_t health_server_init(health_server_t * p_server, uint16_t element_index, uint16_t company_id,
199  health_server_attention_cb_t attention_cb,
201 
204 #endif
205 
__health_server_t::fast_period_divisor
uint8_t fast_period_divisor
Fast period divisor, used to increase publishing interval when faults are present.
Definition: health_server.h:107
__health_server_t::registered_faults
health_server_fault_array_t registered_faults
Array of registered faults.
Definition: health_server.h:112
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.
__health_server_t::company_id
uint16_t company_id
Health server company ID.
Definition: health_server.h:111
__health_server_t::p_next
struct __health_server_t * p_next
Pointer to the next instance.
Definition: health_server.h:116
__health_server_t::previous_test_id
uint8_t previous_test_id
ID of the latest self-test run by the model.
Definition: health_server.h:110
health_server_selftest_t::test_id
uint8_t test_id
Self-test ID.
Definition: health_server.h:94
__health_server_t::attention_handler
health_server_attention_cb_t attention_handler
Handler for the attention state.
Definition: health_server.h:114
__health_server_t::model_handle
access_model_handle_t model_handle
Model handle.
Definition: health_server.h:106
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.
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.
__health_server_t::attention_timer
uint8_t attention_timer
Timer for the attention state.
Definition: health_server.h:115
__health_server_t::num_selftests
uint8_t num_selftests
Number of self-tests in p_selftests.
Definition: health_server.h:109
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.
access_model_handle_t
uint16_t access_model_handle_t
Access layer handle type.
Definition: access.h:162
health_server_attention_get
uint8_t health_server_attention_get(const health_server_t *p_server)
Gets the current value of the attention timer.
__health_server_t
Health server instance structure.
Definition: health_server.h:104
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.
health_server_fault_array_t
uint32_t health_server_fault_array_t[BITFIELD_BLOCK_COUNT(HEALTH_SERVER_FAULT_ARRAY_SIZE)]
Health server fault array type.
Definition: health_server.h:99
health_server_selftest_t::selftest_function
health_server_selftest_cb_t selftest_function
Pointer to the self-test function.
Definition: health_server.h:95
health_server_attention_cb_t
void(* health_server_attention_cb_t)(const health_server_t *p_server, bool attention_state)
Callback function for the attention state.
Definition: health_server.h:71
health_server_selftest_t
Structure defining a self-test function.
Definition: health_server.h:92
__health_server_t::current_faults
health_server_fault_array_t current_faults
Array of current faults.
Definition: health_server.h:113
health_server_selftest_cb_t
void(* health_server_selftest_cb_t)(health_server_t *p_server, uint16_t company_id, uint8_t test_id)
Self-test function type.
Definition: health_server.h:85
health_server_attention_set
void health_server_attention_set(health_server_t *p_server, uint8_t attention)
Sets the attention timer value.
__health_server_t::p_selftests
const health_server_selftest_t * p_selftests
Pointer to an array of self-tests.
Definition: health_server.h:108
HEALTH_SERVER_FAULT_ARRAY_SIZE
#define HEALTH_SERVER_FAULT_ARRAY_SIZE
Size of the health server fault array.
Definition: health_server.h:58