1 /** @file 2 * @brief Bluetooth Mesh Health Server Model APIs. 3 */ 4 5 /* 6 * Copyright (c) 2017 Intel Corporation 7 * 8 * SPDX-License-Identifier: Apache-2.0 9 */ 10 #ifndef __BT_MESH_HEALTH_SRV_H 11 #define __BT_MESH_HEALTH_SRV_H 12 13 /** 14 * @brief Mesh Bluetooth Mesh Health Server Model 15 * @defgroup bt_mesh_health_srv 16 * @ingroup bt_mesh 17 * @{ 18 */ 19 20 struct bt_mesh_health_srv_cb { 21 /* Fetch current faults */ 22 int (*fault_get_cur)(struct bt_mesh_model *model, u8_t *test_id, 23 u16_t *company_id, u8_t *faults, 24 u8_t *fault_count); 25 26 /* Fetch registered faults */ 27 int (*fault_get_reg)(struct bt_mesh_model *model, u16_t company_id, 28 u8_t *test_id, u8_t *faults, 29 u8_t *fault_count); 30 31 /* Clear registered faults */ 32 int (*fault_clear)(struct bt_mesh_model *model, u16_t company_id); 33 34 /* Run a specific test */ 35 int (*fault_test)(struct bt_mesh_model *model, u8_t test_id, 36 u16_t company_id); 37 38 /* Attention on */ 39 void (*attn_on)(struct bt_mesh_model *model); 40 41 /* Attention off */ 42 void (*attn_off)(struct bt_mesh_model *model); 43 }; 44 45 /** @def BT_MESH_HEALTH_FAULT_MSG 46 * 47 * A helper to define a health fault message. 48 * 49 * @param max_faults Maximum number of faults the element can have. 50 * 51 * @return a New net_buf_simple of the needed size. 52 */ 53 #define BT_MESH_HEALTH_FAULT_MSG(max_faults) \ 54 NET_BUF_SIMPLE(1 + 3 + (max_faults)) 55 56 /** Mesh Health Server Model Context */ 57 struct bt_mesh_health_srv { 58 struct bt_mesh_model *model; 59 60 /* Optional callback struct */ 61 const struct bt_mesh_health_srv_cb *cb; 62 63 /* Attention Timer state */ 64 struct k_delayed_work attn_timer; 65 }; 66 67 int bt_mesh_fault_update(struct bt_mesh_elem *elem); 68 69 extern const struct bt_mesh_model_op bt_mesh_health_srv_op[]; 70 71 /** @def BT_MESH_MODEL_HEALTH_SRV 72 * 73 * Define a new health server model. Note that this API needs to be 74 * repeated for each element that the application wants to have a 75 * health server model on. Each instance also needs a unique 76 * bt_mesh_health_srv and bt_mesh_model_pub context. 77 * 78 * @param srv Pointer to a unique struct bt_mesh_health_srv. 79 * @param pub Pointer to a unique struct bt_mesh_model_pub. 80 * 81 * @return New mesh model instance. 82 */ 83 #define BT_MESH_MODEL_HEALTH_SRV(srv, pub) \ 84 BT_MESH_MODEL(BT_MESH_MODEL_ID_HEALTH_SRV, \ 85 bt_mesh_health_srv_op, pub, srv) 86 87 /** 88 * @} 89 */ 90 91 #endif /* __BT_MESH_HEALTH_SRV_H */ 92