> 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-16a-dry-switch-16ads/mclimate-16ads-device-communication-protocol/device-to-device-communication-d2d.md).

# Device to device communication (D2D)

## Set D2D device credentials

The command sets the required information in order this device (listener, class C) to accept D2D packets from another device.

The two necessary parameters are the DevEUI and App Key of the device (sender device, class A).

One listener device can be associated with up to 6 sender devices.

{% hint style="warning" %}
Make sure you set up the two parameters correctly, if there is an error in either the DevEUI or App Key, D2D communication will not be established.
{% endhint %}

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

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

<table><thead><tr><th width="125.97265625"></th><th></th></tr></thead><tbody><tr><td><strong>Byte index</strong></td><td><strong>Hex value / Meaning</strong></td></tr><tr><td>0</td><td>D0 - command code</td></tr><tr><td>1</td><td>XX - Index the position the device information will be stored at: 0-5</td></tr><tr><td>2</td><td>XX - DevEUI byte 0 (Most significant)</td></tr><tr><td>...</td><td></td></tr><tr><td>9</td><td>XX - DevEUI byte 7 (Least significant)</td></tr><tr><td>10</td><td>XX - AppKey byte 0 (Most significant)</td></tr><tr><td>...</td><td></td></tr><tr><td>25</td><td>XX - App Key byte 15 (Least significant)</td></tr></tbody></table>

**Example command:** `0xD00070B3D52DD80009A2AA6C900C51AAF17E905DEB0AB683E7E3`

The command instruct the device to accept D2D related packets from a device with:\
DevEUI `70B3D52DD80009A2`\
AppKey `AA6C900C51AAF17E905DEB0AB683E7E3`

This information is stored at index 0 (out of a total of 6) in the device.
{% endtab %}

{% tab title="GET" %}

<table><thead><tr><th width="112.3203125"></th><th width="221.5234375"></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>D1 - The command code.</td><td>D1 - The command code.</td></tr><tr><td>1</td><td>Device index - 0-5.</td><td>XX - Device index - 0-5.</td></tr><tr><td>2-9<br>10-25</td><td></td><td>DevEUI as represented in D0 command.<br>AppKey as represented in D0 command.</td></tr></tbody></table>

**Example command:** `0xD100`

**Example response:** D10070B3D52DD80009A200112233445566778899AABBCCDDEEFF

Device index is 00;

DevEUI is 70B3D52DD80009A2;

AppKey is 00112233445566778899AABBCCDDEEFF.
{% endtab %}
{% endtabs %}

## Remove all stored D2D credentials

The command removes the entire list of credentials stored via the `0xD0` command (both the DevEUI and App Key). Essentially any D2D device association will be removed after executing the command.

{% hint style="warning" %}
In case you want to add a sender device to the list of the receiver again, you need to reset the sender device in order for the communication chain to be established (even if the sender device was previously in the list).
{% endhint %}

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

<table><thead><tr><th width="124"></th><th></th></tr></thead><tbody><tr><td><strong>Byte index</strong></td><td><strong>Hex value / Meaning</strong></td></tr><tr><td>0</td><td>D2 – command code</td></tr></tbody></table>

**Example command:** `0xD2`<br>

## Get D2D radio settings

Тhese radio settings mirror the ones used for the LoRaWAN RX2 window. Since the default values can be modified by MAC command, the current command is used to retrieve them (as they might have changed through the the time the device has been operational).

{% hint style="warning" %}
These parameters are still used for D2D communication, even if the device is not pat of or is not able to join a LoRaWAN Network. We recommend using a spreading factor no greater than SF9 for D2D communication in order to keep the air time short (this will limit interference, network congestion and optimize battery life).
{% endhint %}

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

<table><thead><tr><th width="131"></th><th width="192"></th><th></th></tr></thead><tbody><tr><td><strong>Byte index</strong></td><td><strong>Hex value / Meaning</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 calculated by the equation:</p><p>f, [Hz] = frequency bits [23:0] * 100</p></td></tr></tbody></table>

**Example command:** `0xD3`

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


---

# 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-16a-dry-switch-16ads/mclimate-16ads-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.
