nRF5 SDK for Mesh v5.0.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_selftest_cb_t selftest_function
Pointer to the self-test function.
Definition: health_server.h:95
#define HEALTH_SERVER_FAULT_ARRAY_SIZE
Size of the health server fault array.
Definition: health_server.h:58
uint16_t access_model_handle_t
Access layer handle type.
Definition: access.h:162
uint8_t attention_timer
Timer for the attention state.
uint8_t num_selftests
Number of self-tests in p_selftests.
void health_server_fault_register(health_server_t *p_server, uint8_t fault_code)
Registers a fault in the current fault array.
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.
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_fault_array_t current_faults
Array of current faults.
Health server instance structure.
const health_server_selftest_t * p_selftests
Pointer to an array of self-tests.
void health_server_fault_clear(health_server_t *p_server, uint8_t fault_code)
Clears a fault from the current fault array.
health_server_fault_array_t registered_faults
Array of registered faults.
struct __health_server_t * p_next
Pointer to the next instance.
uint8_t health_server_attention_get(const health_server_t *p_server)
Gets the current value of the attention timer.
uint8_t test_id
Self-test ID.
Definition: health_server.h:94
uint8_t fast_period_divisor
Fast period divisor, used to increase publishing interval when faults are present.
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
uint16_t company_id
Health server company ID.
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.
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
uint8_t previous_test_id
ID of the latest self-test run by the model.
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
void health_server_attention_set(health_server_t *p_server, uint8_t attention)
Sets the attention timer value.
access_model_handle_t model_handle
Model handle.
Structure defining a self-test function.
Definition: health_server.h:92
health_server_attention_cb_t attention_handler
Handler for the attention state.

Documentation feedback | Developer Zone | Subscribe | Updated