> For the complete documentation index, see [llms.txt](https://docs.mclimate.eu/mclimate-lorawan-devices/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mclimate.eu/mclimate-lorawan-devices/devices/mclimate-wireless-thermostat/wireless-thermostat-device-communication-protocol/device-to-device-communication-d2d.md).

# Device to device communication (D2D)

## Set D2D state

Enables or disables the D2D communication functionality. Once D2D communication is enabled by radio command, the device tries to join to the corresponding class C listener device with exponential back-off retry period. Initially the period is 4 minutes and if the device is unable to join with the listener device, the period will gradually increase to 64 minutes.

{% hint style="info" %}
Note: This command is available for devices with firmware version ≥ 2.0.
{% endhint %}

{% tabs %}
{% tab title="SET" %}

<table><thead><tr><th width="121.05745554035565">Byte index</th><th>Hex value - Meaning</th></tr></thead><tbody><tr><td>0</td><td>D0 – The command code.</td></tr><tr><td>1</td><td><p>00 – Disable D2D communication; <strong>Default state.</strong></p><p>01 – Enable D2D communication.</p></td></tr></tbody></table>

**Example command:** `0xD001` – Enable the D2D communication.
{% endtab %}

{% tab title="GET" %}

<table><thead><tr><th width="121.79296875"></th><th width="215.78125"></th><th></th></tr></thead><tbody><tr><td></td><td>Hex value – Meaning</td><td></td></tr><tr><td><strong>Byte index</strong></td><td><strong>Sent request</strong></td><td><strong>Received response</strong></td></tr><tr><td>0</td><td>D1 – The command code.</td><td>D1 – The command code.</td></tr><tr><td>1</td><td></td><td>00 - D2D communication is disabled;<br>01 -  D2D communication is enabled.</td></tr></tbody></table>

**Example command:** `0xD1`

**Example response:** `0xD101` – D2D communication is enabled.
{% endtab %}
{% endtabs %}

## Get D2D packet loss statistic

Reports the current packet loss statistics for D2D communication.

{% hint style="info" %}
Note: This command is available for devices with firmware version ≥ 2.0.
{% endhint %}

{% hint style="warning" %}
Note: The command is sent together with the keepalive of the device when D2D is enabled.&#x20;
{% endhint %}

{% hint style="warning" %}
Note: The packet loss statistics automatically reset daily at 24:00 (midnight), provided the [device's clock is synchronized](/mclimate-lorawan-devices/devices/mclimate-wireless-thermostat/wireless-thermostat-device-communication-protocol/device-time-and-time-zone.md). If the clock is not synchronized, the statistics will automatically reset daily at an unpredictable time.
{% endhint %}

The keepalive data in the example below is omitted for clarity.

<table><thead><tr><th width="109"></th><th width="218"></th><th></th></tr></thead><tbody><tr><td></td><td><strong>Hex value / Meaning</strong></td><td></td></tr><tr><td>Byte index</td><td><strong>Sent request</strong></td><td><strong>Received response</strong></td></tr><tr><td>0</td><td>D6 – The command code.</td><td>D6 – The command code.</td></tr><tr><td>1</td><td></td><td>XX - D2D packet loss statistic.</td></tr></tbody></table>

**Example command:** `0xD6`

**Example response:** `0xD60A` – D2D packet loss is 10%.

## Reset D2D packet loss statistic

Resets the current packet loss statistics for D2D communication. Use that command in order to clear all the information reported by command D6.

{% hint style="info" %}
Note: This command is available for devices with firmware version ≥ 2.0.
{% endhint %}

<table><thead><tr><th width="109"></th><th></th></tr></thead><tbody><tr><td>Byte index</td><td><strong>Hex value / Meaning</strong></td></tr><tr><td>0</td><td>D7 – The command code.</td></tr></tbody></table>

**Example command:** `0xD7` – Reset D2D packet loss statistic.

## Get D2D packet confirmation statistics

The D2D protocol requires packet confirmation from the listener device. If no confirmation was got from 1<sup>st</sup> packet sending, that packet will be retransmitted shortly. That command is used to get statistics about the packets being confirmed.

{% hint style="info" %}
Note: This command is available for devices with firmware version ≥ 2.0.
{% endhint %}

<table><thead><tr><th width="106"></th><th width="225"></th><th></th></tr></thead><tbody><tr><td></td><td><strong>Hex value / Meaning</strong></td><td></td></tr><tr><td>Byte index</td><td><strong>Sent request</strong></td><td><strong>Received response</strong></td></tr><tr><td>0</td><td>D4 – The command code.</td><td>D4 – The command code.</td></tr><tr><td>1</td><td></td><td>XX- Percentage of packets which gets confirmation from 1<sup>st</sup> attempt.</td></tr><tr><td>2</td><td></td><td>XX - Percentage of packets which gets confirmation from 2<sup>nd</sup> attempt.</td></tr><tr><td>3</td><td></td><td>Total number of D2D sent packets – MSB.</td></tr><tr><td>...</td><td></td><td></td></tr><tr><td>6</td><td></td><td>Total number of D2D sent packets – LSB.</td></tr></tbody></table>

**Example command:** `0xD4`

**Example response:** `0xD45707` → % of sent packets are confirmed at the 1<sup>st</sup> attempt, % at the 2<sup>nd</sup> attempt and packets are totally sent so far.

## Reset D2D packet confirmation statistics

Resets the current packet confirmation statistics for D2D communication. Use that command in order to clear all the information reported by command D4.

{% hint style="info" %}
Note: This command is available for devices with firmware version ≥ 2.0.
{% endhint %}

<table><thead><tr><th width="109"></th><th></th></tr></thead><tbody><tr><td>Byte index</td><td><strong>Hex value / Meaning</strong></td></tr><tr><td>0</td><td>D5 – The command code.</td></tr></tbody></table>

**Example command:** `0xD5` – Reset D2D packet confirmation statistic.

## Get D2D radio settings

Тhese radio settings are equal to the ones used during LoRaWAN RX2 window. Since the default values can be modified by MAC command, the current command is used to retrieve them. When the device is unable to join the LoRaWAN network it still uses that settings. We recommend using of SF no greater than 9 for D2D communication in order to keep low current consumption.

{% hint style="info" %}
Note: This command is available for devices with firmware version ≥ 2.0.
{% endhint %}

<table><thead><tr><th width="131"></th><th width="192"></th><th></th></tr></thead><tbody><tr><td></td><td><strong>Hex value / Meaning</strong></td><td></td></tr><tr><td><strong>Byte index</strong></td><td><strong>Sent request</strong></td><td><strong>Received response</strong></td></tr><tr><td>0</td><td>D3 – The command code.</td><td>D3 – The command code.</td></tr><tr><td>1</td><td></td><td><p>XX – Bandwidth.</p><p>00 – 125kHz;</p><p>01 – 250kHz;</p><p>02 – 500kHz.</p></td></tr><tr><td>2</td><td></td><td>XX – Spreading factor. Value in the range 7-12.</td></tr><tr><td>3</td><td></td><td>XX – frequency bits [23:16].</td></tr><tr><td>4</td><td></td><td>XX – frequency bits [15:8].</td></tr><tr><td>5</td><td></td><td><p>XX – frequency bits [7:0].</p><p>Resultant frequency in hertz can be got by that equation:</p><p>f, [Hz] = frequency bits [23:0] * 100</p></td></tr></tbody></table>

**Example command:** `0xD3`

**Example response:** D3000984ADD2 → The device radio receiver is configured on SF9, 125kHz bandwidth and the channel frequency is 0x84ADD2 \* 100 = 869.525MHz.

## D2D Transmission Status Visualization

The display now features visual icons that show the transmission status.

{% hint style="info" %}
Note: This visualization is available for devices with firmware version ≥ 2.0.
{% endhint %}

{% hint style="warning" %}
Note: The icon for the last transmission status (*Sent Successfully* or *Sent Failed*) will remain on the display until the next transmission.
{% endhint %}

What the display icons mean:

* **Sending:** The device is currently sending a message. Please wait for the process to complete.

<figure><img src="/files/bdBx2J9iPIRMfBhi1Kc2" alt="" width="50"><figcaption></figcaption></figure>

* **Sent Successfully:** The message has been delivered successfully.

<figure><img src="/files/KjV8xC1w5fwZ52Me2jn9" alt="" width="50"><figcaption></figcaption></figure>

* **Sent Failed:** Please ensure the other device is turned on, in range, and try again.

<figure><img src="/files/dXWK4BPPeqdzTdqYI2RN" alt="" width="50"><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.mclimate.eu/mclimate-lorawan-devices/devices/mclimate-wireless-thermostat/wireless-thermostat-device-communication-protocol/device-to-device-communication-d2d.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
