|
| 1 | +/* |
| 2 | + * Copyright (c) 2019 Nordic Semiconductor ASA |
| 3 | + * |
| 4 | + * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic |
| 5 | + */ |
| 6 | + |
| 7 | +/** |
| 8 | + * @file |
| 9 | + * @defgroup bt_mesh_lvl Bluetooth Mesh Generic Level models |
| 10 | + * @{ |
| 11 | + * @brief Common API for the Bluetooth Mesh Generic Level models. |
| 12 | + */ |
| 13 | +#ifndef BT_MESH_GEN_LVL_H__ |
| 14 | +#define BT_MESH_GEN_LVL_H__ |
| 15 | + |
| 16 | +#include <bluetooth/mesh.h> |
| 17 | +#include <bluetooth/mesh/model_types.h> |
| 18 | + |
| 19 | +#ifdef __cplusplus |
| 20 | +extern "C" { |
| 21 | +#endif |
| 22 | + |
| 23 | +/** @cond INTERNAL_HIDDEN */ |
| 24 | +#define BT_MESH_LVL_OP_GET BT_MESH_MODEL_OP_2(0x82, 0x05) |
| 25 | +#define BT_MESH_LVL_OP_SET BT_MESH_MODEL_OP_2(0x82, 0x06) |
| 26 | +#define BT_MESH_LVL_OP_SET_UNACK BT_MESH_MODEL_OP_2(0x82, 0x07) |
| 27 | +#define BT_MESH_LVL_OP_STATUS BT_MESH_MODEL_OP_2(0x82, 0x08) |
| 28 | +#define BT_MESH_LVL_OP_DELTA_SET BT_MESH_MODEL_OP_2(0x82, 0x09) |
| 29 | +#define BT_MESH_LVL_OP_DELTA_SET_UNACK BT_MESH_MODEL_OP_2(0x82, 0x0A) |
| 30 | +#define BT_MESH_LVL_OP_MOVE_SET BT_MESH_MODEL_OP_2(0x82, 0x0B) |
| 31 | +#define BT_MESH_LVL_OP_MOVE_SET_UNACK BT_MESH_MODEL_OP_2(0x82, 0x0C) |
| 32 | + |
| 33 | +#define BT_MESH_LVL_MSG_LEN_GET 0 |
| 34 | +#define BT_MESH_LVL_MSG_MINLEN_SET 3 |
| 35 | +#define BT_MESH_LVL_MSG_MAXLEN_SET 5 |
| 36 | +#define BT_MESH_LVL_MSG_MINLEN_STATUS 2 |
| 37 | +#define BT_MESH_LVL_MSG_MAXLEN_STATUS 5 |
| 38 | +#define BT_MESH_LVL_MSG_MINLEN_DELTA_SET 5 |
| 39 | +#define BT_MESH_LVL_MSG_MAXLEN_DELTA_SET 7 |
| 40 | +#define BT_MESH_LVL_MSG_MINLEN_MOVE_SET 3 |
| 41 | +#define BT_MESH_LVL_MSG_MAXLEN_MOVE_SET 5 |
| 42 | +/** @endcond */ |
| 43 | + |
| 44 | +/** Generic Level minimum value. */ |
| 45 | +#define BT_MESH_LVL_MIN INT16_MIN |
| 46 | +/** Generic Level maximum value. */ |
| 47 | +#define BT_MESH_LVL_MAX INT16_MAX |
| 48 | + |
| 49 | +/** Generic Level set message parameters. */ |
| 50 | +struct bt_mesh_lvl_set { |
| 51 | + /** New level. */ |
| 52 | + s16_t lvl; |
| 53 | + /** Whether this is a new action. */ |
| 54 | + bool new_transaction; |
| 55 | + /** |
| 56 | + * Transition time parameters for the state change. Setting the |
| 57 | + * transition to NULL makes the server use its default transition time |
| 58 | + * parameters. |
| 59 | + */ |
| 60 | + const struct bt_mesh_model_transition *transition; |
| 61 | +}; |
| 62 | + |
| 63 | +/** Generic Level delta set message parameters. */ |
| 64 | +struct bt_mesh_lvl_delta_set { |
| 65 | + /** Translation from original value. */ |
| 66 | + s32_t delta; |
| 67 | + /** |
| 68 | + * Whether this is a new transaction. If true, the delta should be |
| 69 | + * relative to the current value. If false, the delta should be |
| 70 | + * relative to the original value in the previous delta_set command. |
| 71 | + */ |
| 72 | + bool new_transaction; |
| 73 | + /** |
| 74 | + * Transition time parameters for the state change. Setting the |
| 75 | + * transition to NULL makes the server use its default transition time |
| 76 | + * parameters. |
| 77 | + */ |
| 78 | + const struct bt_mesh_model_transition *transition; |
| 79 | +}; |
| 80 | + |
| 81 | +/** Generic Level move set message parameters. */ |
| 82 | +struct bt_mesh_lvl_move_set { |
| 83 | + /** Translation to make for every transition step. */ |
| 84 | + s16_t delta; |
| 85 | + /** Whether this is a new action. */ |
| 86 | + bool new_transaction; |
| 87 | + /** |
| 88 | + * Transition parameters. @c delay indicates time until the move |
| 89 | + * should start, @c transition indicates the amount of time each |
| 90 | + * @c delta step should take. Setting the transition to NULL makes the |
| 91 | + * server use its default transition time parameters. |
| 92 | + */ |
| 93 | + const struct bt_mesh_model_transition *transition; |
| 94 | +}; |
| 95 | + |
| 96 | +/** Generic Level status message parameters. */ |
| 97 | +struct bt_mesh_lvl_status { |
| 98 | + /** Current level value. */ |
| 99 | + s16_t current; |
| 100 | + /** |
| 101 | + * Target value for the ongoing transition. If there's no ongoing |
| 102 | + * transition, @c target should match @c value. |
| 103 | + */ |
| 104 | + s16_t target; |
| 105 | + /** |
| 106 | + * Time remaining of the ongoing transition, or @ref K_FOREVER. |
| 107 | + * If there's no ongoing transition, @c remaining_time is 0. |
| 108 | + */ |
| 109 | + s32_t remaining_time; |
| 110 | +}; |
| 111 | + |
| 112 | +#ifdef __cplusplus |
| 113 | +} |
| 114 | +#endif |
| 115 | + |
| 116 | +#endif /* BT_MESH_GEN_LVL_H__ */ |
| 117 | + |
| 118 | +/** @} */ |
0 commit comments