1 /* Bluetooth: Mesh Generic OnOff, Generic Level, Lighting & Vendor Models 2 * 3 * Copyright (c) 2018 Vikrant More 4 * 5 * SPDX-License-Identifier: Apache-2.0 6 */ 7 8 #ifndef _DEVICE_COMPOSITION_H 9 #define _DEVICE_COMPOSITION_H 10 11 #define CID_ZEPHYR 0x0002 12 13 #define STATE_OFF 0x00 14 #define STATE_ON 0x01 15 #define STATE_DEFAULT 0x01 16 #define STATE_RESTORE 0x02 17 18 /* Following 4 values are as per Mesh Model specification */ 19 #define LIGHTNESS_MIN 0x0001 20 #define LIGHTNESS_MAX 0xFFFF 21 #define TEMP_MIN 0x0320 22 #define TEMP_MAX 0x4E20 23 #define DELTA_UV_DEF 0x0000 24 25 /* Refer 7.2 of Mesh Model Specification */ 26 #define RANGE_SUCCESSFULLY_UPDATED 0x00 27 #define CANNOT_SET_RANGE_MIN 0x01 28 #define CANNOT_SET_RANGE_MAX 0x02 29 30 struct vendor_state { 31 int current; 32 uint32_t response; 33 uint8_t last_tid; 34 uint16_t last_src_addr; 35 uint16_t last_dst_addr; 36 int64_t last_msg_timestamp; 37 }; 38 39 struct lightness { 40 uint16_t current; 41 uint16_t target; 42 43 uint16_t def; 44 uint16_t last; 45 46 uint8_t status_code; 47 uint16_t range_min; 48 uint16_t range_max; 49 uint32_t range; 50 51 int delta; 52 }; 53 54 struct temperature { 55 uint16_t current; 56 uint16_t target; 57 58 uint16_t def; 59 60 uint8_t status_code; 61 uint16_t range_min; 62 uint16_t range_max; 63 uint32_t range; 64 65 int delta; 66 }; 67 68 69 struct delta_uv { 70 int16_t current; 71 int16_t target; 72 73 int16_t def; 74 75 int delta; 76 }; 77 78 struct light_ctl_state { 79 struct lightness *light; 80 struct temperature *temp; 81 struct delta_uv *duv; 82 83 uint8_t onpowerup, tt; 84 85 uint8_t last_tid; 86 uint16_t last_src_addr; 87 uint16_t last_dst_addr; 88 int64_t last_msg_timestamp; 89 90 struct transition_data *transition; 91 }; 92 93 extern struct vendor_state vnd_user_data; 94 extern struct light_ctl_state *const ctl; 95 96 extern const struct bt_mesh_model root_models[]; 97 extern const struct bt_mesh_model vnd_models[]; 98 extern const struct bt_mesh_model s0_models[]; 99 100 extern const struct bt_mesh_comp comp; 101 102 void gen_onoff_publish(const struct bt_mesh_model *model); 103 void gen_level_publish(const struct bt_mesh_model *model); 104 void light_lightness_publish(const struct bt_mesh_model *model); 105 void light_lightness_linear_publish(const struct bt_mesh_model *model); 106 void light_ctl_publish(const struct bt_mesh_model *model); 107 void light_ctl_temp_publish(const struct bt_mesh_model *model); 108 void gen_level_publish_temp(const struct bt_mesh_model *model); 109 110 #endif 111