Generic Default Transition Time Server

The DTT Server provides a common way to specify the state transition time for other models on the same element. If other generic models on the same element receive state change commands without transition parameters, they will use the default transition time specified by the DTT Server model. This way, the DTT Server can define a consistent transition time for all states on their elements, without depending on client configurations.

Configuration

The following configuration parameters are associated with the Generic DTT Server model:

States

The Generic Level Server model contains the following state:

Generic Default Transition Time: int32_t

This state can have the following values:

  • 0 to perform the state change instantly or when no transition is planned

  • Positive number of milliseconds that defines the transition time

  • SYS_FOREVER_MS if the transition time is undefined

On the air, the transition time is encoded into a single byte, and loses some of its granularity:

  • Step count: 6 bits (range 0x00 to 0x3e)

  • Step resolution: 2 bits

    • Step 0: 100-millisecond resolution

    • Step 1: 1-second resolution

    • Step 2: 10-second resolution

    • Step 3: 10-minute resolution

The state is encoded with the highest resolution available, and rounded to the nearest representation. Values lower than 100 milliseconds and higher than 0 are encoded as 100 milliseconds. Values higher than the max value of 620 minutes are encoded as “undefined”.

The DTT Server holds the memory for this state itself, and optionally notifies the user of any changes through bt_mesh_dtt_srv.update_handler. If your application changes the transition time manually, the change must be published using bt_mesh_dtt_srv_pub().

Persistent storage

The Generic Default Transition Time is stored persistently if CONFIG_BT_MESH_DTT_SRV_PERSISTENT is enabled.

API documentation

Header file: include/bluetooth/mesh/gen_dtt_srv.h
Source file: subsys/bluetooth/mesh/gen_dtt_srv.c
group bt_mesh_dtt_srv

model

API for the Generic Default Transition Time (DTT) Server model.

Defines

BT_MESH_DTT_SRV_INIT(_update)

Initialization parameters for Generic Default Transition Time Server.

Parameters
  • [in] _update: Update handler called on every change to the transition time in this server.

BT_MESH_MODEL_DTT_SRV(_srv)

Generic Default Transition Time Server model composition data entry.

Parameters

Functions

void bt_mesh_dtt_srv_set(struct bt_mesh_dtt_srv *srv, uint32_t transition_time)

Set the Default Transition Time of the DTT server.

If an update handler is set, it’ll be called with the updated transition time. If publication is configured, the change will cause the server to publish.

Parameters
  • [in] srv: Server to set the DTT of.

  • [in] transition_time: New Default Transition Time, in milliseconds.

int bt_mesh_dtt_srv_pub(struct bt_mesh_dtt_srv *srv, struct bt_mesh_msg_ctx *ctx)

Publish the current transition time.

Parameters
  • [in] srv: Server instance to publish with.

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

Return Value
  • 0: Successfully published the current transition time.

  • -ENOTSUP: A message context was not provided and publishing is not supported.

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

  • -EAGAIN: The device has not been provisioned.

struct bt_mesh_dtt_srv *bt_mesh_dtt_srv_get(const struct bt_mesh_elem *elem)

Find the Generic DTT server in a given element.

Return

A pointer to the DTT server instance, or NULL if no instance is found.

Parameters
  • [in] elem: Element to find the DTT server in.

bool bt_mesh_dtt_srv_transition_get(struct bt_mesh_model *mod, struct bt_mesh_model_transition *transition)

Get the default transition parameters for the given model.

Return

Whether the transition was set.

Parameters
  • [in] mod: Model to get the DTT for.

  • [out] transition: Transition buffer.

struct bt_mesh_dtt_srv
#include <gen_dtt_srv.h>

Generic Default Transition Time server instance.

Public Members

uint32_t transition_time

Current transition time in milliseconds

void (*const update)(struct bt_mesh_dtt_srv *srv, struct bt_mesh_msg_ctx *ctx, uint32_t old_transition_time, uint32_t new_transition_time)

Update handler for the transition time state.

Called every time the transition time is updated.

Parameters
  • [in] srv: Server instance that was updated.

  • [in] ctx: Context of the set message that caused the update, or NULL if the update was not a result of a set message.

  • [in] old_transition_time: The transition time prior to the update, in milliseconds.

  • [in] new_transition_time: The new transition time after the update, in milliseconds.

struct bt_mesh_model *model

Composition data Model entry pointer.

struct bt_mesh_model_pub pub

Model publish parameters.