Light CTL Server

The Color-Tunable Light (CTL) Server represents a single light on a mesh device. It should be instantiated in the light fixture node.

Three states can be used to configure the lighting output of an element:

  • Lightness - This state determines the lightness of a tunable white light emitted by an element.

  • Temperature - This state determines the color temperature of tunable white light emitted by an element.

  • Delta UV - This state determines the distance from the black body curve. The color temperatures fall on the black body locus.

The Light CTL Server adds two model instances in the composition data, in addition to the extended Light Lightness Server model. These model instances share the states of the Light CTL Server, but accept different messages. This allows for a fine-grained control of the access rights for the Light CTL states, as the model instances can be bound to different application keys. The following two model instances are added:

  • Light CTL Server - Provides write access to Lightness, Temperature and Delta UV states for the user, in addition to read access to all meta states

  • Light CTL Setup Server - Provides write access to Default CTL state and Temperature Range meta states, allowing configurator devices to set up a temperature range and a default CTL state

In addition to the extended Light Lightness Server model, the Light CTL Server also requires a Light CTL Temperature Server to be instantiated on a subsequent element. The Light Temperature Server should reference the bt_mesh_light_ctl_srv.temp_srv.

Conventionally, the Light Temperature Server model is instantiated on the very next element, and the composition data looks as presented below.

static struct bt_mesh_light_ctl_srv light_ctl_srv = BT_MESH_LIGHT_CTL_SRV_INIT(&lightness_handlers, &light_temp_handlers);

static struct bt_mesh_elem elements[] = {
    BT_MESH_ELEM(
        1,
        BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_CTL_SRV(&light_ctl_srv)),
        BT_MESH_MODEL_NONE),
    BT_MESH_ELEM(
        2,
        BT_MESH_MODEL_LIST(BT_MESH_MODEL_LIGHT_TEMP_SRV(&light_ctl_srv.temp_srv)),
        BT_MESH_MODEL_NONE),
};

The Light CTL Server does not require any message handler callbacks, as all its states are bound to the included Light Lightness Server and Light CTL Temperature Server models. The Lightness and Light Temperature Server callbacks will pass pointers to bt_mesh_light_ctl_srv.lightness_srv and bt_mesh_light_ctl_srv.temp_srv, respectively.

Note

The Light CTL Server will verify that its internal Light Temperature Server is instantiated on a subsequent element on startup. If the Light Temperature Server is missing or instantiated on the same or a preceding element, the Bluetooth® mesh startup procedure will fail, and the device will not be responsive.

States

The Generic Power OnOff Server model (extended by the Light Lightness Server model) contains the following states:

Lightness: uint16_t

The Lightness state represents the emitted light level of an element, and ranges from 0 to 65535. The Lightness state is shared by the extended Light Lightness Server model.

The Lightness state power-up behavior is determined by the On Power Up state of the extended Generic Power OnOff Server:

Your application is expected to hold the state memory and provide access to the state through the bt_mesh_light_ctl_srv_handlers handler structure.

Temperature: uint16_t

The Temperature state represents the color temperature of the tunable white light emitted by an element. It ranges from 800 to 20000, and is shared by the assosiated Light CTL Temperature Server.

The Temperature state power-up behavior is determined by the On Power Up state of the extended Generic Power OnOff Server:

Your application is expected to hold the state memory and provide access to the state through the bt_mesh_light_ctl_srv_handlers handler structure.

Delta UV: int16_t

The Temperature state represents the distance from the black body curve. The color temperatures all fall on the black body locus (curve). This is a 16-bit signed integer representation of a -1 to +1 scale using the following formula:

Represented Delta UV = (Light CTL Delta UV) / 32768

The Delta UV state of the Light CTL Server is shared by the assosiated Light CTL Temperature Server, and its power-up behavior is determined by the On Power Up state of the extended Generic Power OnOff Server:

Your application is expected to hold the state memory and provide access to the state through the bt_mesh_light_ctl_srv_handlers handler structure.

Default CTL: bt_mesh_light_ctl

The Default CTL state is a meta state that controls the default Lightness, Temperature and Delta UV level. It is used when the light is turned on, but its exact state levels are not specified.

The memory for the Default Light state is held by the model, and the application may receive updates on state changes through the bt_mesh_lightness_srv_handlers.default_update callback.

The Default Light state uses the configured lightness representation.

Temperature Range: bt_mesh_light_temp_range

The Temperature Range state is a meta state that determines the accepted Temperature level range. If the Temperature level is set to a value outside the current Temperature Range, it is moved to fit inside the range. If the Temperature Range changes to exclude the current Temperature level, the Temperature level should be changed accordingly.

The Temperature Range state of the Light CTL Server is shared by the assosiated Light CTL Temperature Server.

The memory for the Temperature Range state is held by the model, and the application may receive updates on state changes through the bt_mesh_light_ctl_srv_handlers.temp_range_update callback.

Extended models

The Light CTL Server extends the following model:

The state of the extended Light Lightness Server model is for the most part bound to states in the Light CTL Server. The only exception is the Lightness range state, which is exposed to the application through the bt_mesh_light_ctl_srv_handlers.lightness_range_update callback of the Light CTL Server model.

In addition to the extended Light Lightness Server model, the Light CTL Server model is associated with a Light Temperature model on a subsequent element. Unlike the extended models, the associated models do not share subscription lists, but still share states.

Persistent storage

The Light CTL Server stores the following information:

  • Any changes to the Default CTL and Temperature Range states

  • The last known Lightness, Temperature and Delta UV level

This information is used to reestablish the correct light configuration when the device powers up.

API documentation

Header file: include/bluetooth/mesh/light_ctl_srv.h
Source file: subsys/bluetooth/mesh/light_ctl_srv.c
group bt_mesh_light_ctl_srv

API for the Light CTL Server model.

Defines

BT_MESH_LIGHT_CTL_SRV_INIT(_lightness_handlers, _light_temp_handlers)

Initialization parameters for a Light CTL Server model instance.

Parameters
  • _lightness_handlers[in] Lightness server callbacks.

  • _light_temp_handlers[in] Light temperature server callbacks.

BT_MESH_MODEL_LIGHT_CTL_SRV(_srv)

Light CTL Server model composition data entry.

Parameters

Functions

int bt_mesh_light_ctl_pub(struct bt_mesh_light_ctl_srv *srv, struct bt_mesh_msg_ctx *ctx, struct bt_mesh_light_ctl_status *status)

Publish the current CTL status.

Asynchronously publishes a CTL status message with the configured publish parameters.

Note

This API is only used for publishing unprompted status messages. Response messages for get and set messages are handled internally.

Parameters
  • srv[in] Server instance to publish on.

  • ctx[in] Message context to send with, or NULL to send with the default publish parameters.

  • status[in] Current status.

Return values
  • 0 – Successfully sent the message.

  • -EADDRNOTAVAIL – A message context was not provided and publishing is not configured.

  • -EAGAIN – The device has not been provisioned.

int bt_mesh_light_ctl_range_pub(struct bt_mesh_light_ctl_srv *srv, struct bt_mesh_msg_ctx *ctx, enum bt_mesh_model_status status)

Publish the current CTL Range status.

Asynchronously publishes a CTL Range status message with the configured publish parameters.

Note

This API is only used for publishing unprompted status messages. Response messages for get and set messages are handled internally.

Parameters
  • srv[in] Server instance to publish on.

  • ctx[in] Message context to send with, or NULL to send with the default publish parameters.

  • status[in] Current status.

Return values
  • 0 – Successfully sent the message.

  • -EADDRNOTAVAIL – A message context was not provided and publishing is not configured.

  • -EAGAIN – The device has not been provisioned.

int bt_mesh_light_ctl_default_pub(struct bt_mesh_light_ctl_srv *srv, struct bt_mesh_msg_ctx *ctx)

Publish the current CTL Default status.

Asynchronously publishes a CTL Default status message with the configured publish parameters.

Note

This API is only used for publishing unprompted status messages. Response messages for get and set messages are handled internally.

Parameters
  • srv[in] Server instance to publish on.

  • ctx[in] Message context to send with, or NULL to send with the default publish parameters.

Return values
  • 0 – Successfully sent the message.

  • -EADDRNOTAVAIL – A message context was not provided and publishing is not configured.

  • -EAGAIN – The device has not been provisioned.

struct bt_mesh_light_ctl_srv
#include <light_ctl_srv.h>

Light CTL Server instance. Should be initialized with BT_MESH_LIGHT_CTL_SRV_INIT.

Public Members

struct bt_mesh_light_temp_srv temp_srv

Light CTL Temp. Server instance.

struct bt_mesh_lightness_srv lightness_srv

Lightness Server instance.

struct bt_mesh_model *model

Model entry.

struct bt_mesh_model_pub pub

Publish parameters.

struct bt_mesh_tid_ctx prev_transaction

Transaction ID tracker for the set messages.