# Downlinks

Fencyboy supports several downlink commands to change [config settings](/technical-documentation/config.md), manage the lifecycle (e.g. restart the device) and get debug information. Fencyboy accepts the commands on downlink port 2. Some commands require additional parameters, which are validated on the client side. The following table lists all currently supported downlink commands.

| Description                                                                                             | Opcode | Parameter                                                                                                                                                                                                                                                    |
| ------------------------------------------------------------------------------------------------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Restart device                                                                                          | 0x10   | One uint16 (2 bytes, Big-endian) encoding the delay before restarting the device in minutes. For example sending 0x100005 restarts the device in 5 minutes.                                                                                                  |
| Get time till restart                                                                                   | 0x11   | Returns the time until the next periodic or forced restart happens in minutes as a single uint16 (See Restart device 0x10). No Parameter required.                                                                                                           |
| Cancel next restart                                                                                     | 0x12   | Cancel the next upcoming periodic or forced restart. The device will not reboot after issuing this command. No Parameter required.                                                                                                                           |
| Set periodic restart interval in config and restart timer                                               | 0x13   | One uint16 (2 bytes, Big-endian) encoding restart interval in minutes (0x134EC0 sets it to the default of 20160 minutes, i.e., 2 weeks). A value of 0 disables the periodic restart (0x130000). The timer is restarted with the new value with this command. |
| Set [transmission interval](/technical-documentation/config.md#send-interval) (send interval) in config | 0x80   | One uint8 (1 byte) encoding the transmission interval length in minutes minus 1. For example sending 0x8004 will set the interval to 1+4=5 minutes.                                                                                                          |
| Set expected time between impulses in config                                                            | 0x81   | One uint16 (2 bytes, Big-endian) encoding the expected time between impulses in milliseconds. For example sending 0x8103E8 sets the time to 1000ms.                                                                                                          |
| Set voltage divider multiplier in config                                                                | 0x82   | One IEE-754 float (4 bytes, Big-endian) encoding the multiplier as decimal value. For example sending 0x8245a14000 sets the multiplier to 5160.                                                                                                              |
| Set smart sleep status in config                                                                        | 0x83   | One uint8 (1 byte) encoding a boolean value to activate or deactivate the [smart sleep](/technical-documentation/smart-sleep.md) feature. For example sending 0x8301 activates the smart sleep feature.                                                      |
| Set battery full capacity in config                                                                     | 0x84   | One uint16 (2 bytes, Big-endian) encoding the battery cpacity in mAh. For example sending 0x840258 sets the capacity to 600mAh which is the standard value for the solar variant.                                                                            |
| Save config to EEPROM                                                                                   | 0x90   | -                                                                                                                                                                                                                                                            |
| Load config from EEPROM                                                                                 | 0x91   | -                                                                                                                                                                                                                                                            |
| Get currently used config via LoRaWAN uplink                                                            | 0x92   | -                                                                                                                                                                                                                                                            |
| Reset config to default values                                                                          | 0x93   | -                                                                                                                                                                                                                                                            |
| Save currently used battery capacity to EEPROM                                                          | 0xA0   | -                                                                                                                                                                                                                                                            |
| Reset used battery capacity in EEPROM                                                                   | 0xA1   | -                                                                                                                                                                                                                                                            |

## Sending Multiple Commands

Fencyboy supports multiple commands in one downlink request. You can add up to `16` bytes of commands and parameters in a single request. The request is ignored if you exceed this limit. All commands in your request are processed sequentially. Some common sequences of commands are listed below.

### Updating the Transmission Interval Permanently

If you want to permanently change the transmission interval, you can make use of a combination of three commands. First, set the new transmission interval using opcode `0x80` to the desired value. Next, save the currently used settings to the EEPROM using opcode `0x90` so that they won't get lost after the device restarts. Finally use opcode `0x92` to get the currently active config to assure that all settings are correct.

```c
// Permanently sets the transmission interval to 15 minutes
0x80149092
```

<figure><img src="/files/Q9JDfwWzeoM1OIfdKdo5" alt=""><figcaption><p>You can send a downlink from the things stack web interface using the messaging function.</p></figcaption></figure>

### Save Used Battery Capacity and Reboot

```c
// saves the currently used battery capacity to the EEPROM and reboots the device in 5 minutes
0xA0100005
```


---

# Agent Instructions: 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:

```
GET https://docs.fencyboy.com/features/downlinks.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
