# Sending a MAC Command to a device using 'ttnctl downlink'

**URL:** <https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321>\
**Category:** v2 Backend\
**Created:** [July 6, 2017, 9:55am UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321 "2017-07-06T09:55:11Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hoonppark](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/hoonppark/32/7999_2.png) [@hoonppark](https://www.thethingsnetwork.org/forum/u/hoonppark)\
**Post date:** [July 6, 2017, 9:55am UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/1 "2017-07-06T09:55:11Z")

</div>

I’ve tried to send a MAC Command (Sample MAC Command for DevStatusReq : 0x06 ) using a ttnctl command as follows:

```
ttnctl downlink <my-dev-id> --fport 0 06

```

I thought by specifying the fport as ‘0’, 0x06 will be handled as a MAC command. But what shows on the device AT command window is the following:

```
>fport=1
>rxmsg=06

```

This means the device has received the downlink message as an ordinary data on ‘Fport 1’, not as a MAC command.

Is it expected to work this way? Or, should it be donwlinked as a MAC command?

---

<div class="post-metadata">

**Author:** ![hoonppark](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/hoonppark/32/7999_2.png) [@hoonppark](https://www.thethingsnetwork.org/forum/u/hoonppark)\
**Post date:** [July 6, 2017, 12:29pm UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/2 "2017-07-06T12:29:34Z")

</div>

I found this issue was filed as [a bug](https://github.com/TheThingsNetwork/ttn/issues/570) and was reported as [fixed](https://github.com/TheThingsNetwork/ttn/commit/70de104fdc8ef9c2dc78c7500cc51d4326a67fa7) on May 1st, 2017.

But, the result shows the bug hasn’t been fixed yet as of ttn v2.7.1. The ‘fport=0’ is still changed to ‘fport=1’ in the downlink message process.

See [this posting](https://www.thethingsnetwork.org/forum/t/rak811-lora-module-connecting-to-ttn/6805/16) for reference on filing this issue as a bug.

---

<div class="post-metadata">

**Author:** ![htdvisser](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/htdvisser/32/45312_2.png) [@htdvisser](https://www.thethingsnetwork.org/forum/u/htdvisser)\
**Post date:** [July 6, 2017, 2:34pm UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/3 "2017-07-06T14:34:54Z")

</div>

It is not possible to send MAC commands from the application layer. In the future we will add functionality to schedule (a subset of) MAC commands

---

<div class="post-metadata">

**Author:** ![hoonppark](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/hoonppark/32/7999_2.png) [@hoonppark](https://www.thethingsnetwork.org/forum/u/hoonppark)\
**Post date:** [July 6, 2017, 3:04pm UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/4 "2017-07-06T15:04:44Z")

</div>

What would be the time frame to implement this function? By the end of 2017? Or, earlier than that?

---

<div class="post-metadata">

**Author:** ![hobo](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/hobo/32/25844_2.png) [@hobo](https://www.thethingsnetwork.org/forum/u/hobo)\
**Post date:** [July 6, 2017, 3:57pm UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/5 "2017-07-06T15:57:58Z")

</div>

Are you going to add a possibility to send MAC commands in FOpt field?

---

<div class="post-metadata">

**Author:** ![htdvisser](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/htdvisser/32/45312_2.png) [@htdvisser](https://www.thethingsnetwork.org/forum/u/htdvisser)\
**Post date:** [July 7, 2017, 6:16am UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/6 "2017-07-07T06:16:16Z")

</div>

It’s really hard to make estimates for release dates of new features. We already have a large backlog of backend features and as there are hardly any outside (community) contributions to our open source backend, all of these tasks fall on the shoulders of the core team. That’s not a problem for us, but it asks some patience from our users.

---

<div class="post-metadata">

**Author:** ![hoonppark](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/hoonppark/32/7999_2.png) [@hoonppark](https://www.thethingsnetwork.org/forum/u/hoonppark)\
**Post date:** [July 7, 2017, 9:03am UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/7 "2017-07-07T09:03:52Z")

</div>

I see. It is very understandable. I always appreciate the good work of your team.

---

<div class="post-metadata">

**Author:** ![duwbak](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/duwbak/32/36575_2.png) [@duwbak](https://www.thethingsnetwork.org/forum/u/duwbak)\
**Post date:** [November 15, 2019, 9:11am UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/8 "2019-11-15T09:11:17Z")

</div>

I am wondering if this is already fixed? I am trying to do downlink messages via the console, but it doesn’t respect the port settings. It will change it to something else when entering port = 0.

Furthermore I try to use it via the ttnctl, but I don’t manage to get the downlink to show up in the console at all. Here are my settings (.ttnctl.yml):

```
discovery-address: discover.thethingsnetwork.org:1900
auth-server: https://account.thethingsnetwork.org
router-id: ttn-router-asia-se
handler-id: ttn-handler-asia-se
mqtt-address: asia-se.thethings.network:1883

```

I am running the following command

`ttnctl downlink <dev_id> --fport 0 0300ff0001`

I also tried it via HTTP but didn’t manage to get any downlink through at all. I tried the following command:

`curl -i -X POST --data '{"dev_id":"2604273B", "payload_raw":"AwD/AAE=", "port" : 0 }' https://integrations.thethingsnetwork.org/ttn-asia-se/api/v2/down/[app_id]/[process_id]?key=[app_key]`

Response was a 202 success.

I know the device is able to receive the downlink messages as via the console they arrive, I just need to have the FPORT being set properly, which isn’t the case now.

Cheers

---

<div class="post-metadata">

**Author:** ![arjanvanb](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/arjanvanb/32/46626_2.png) [@arjanvanb](https://www.thethingsnetwork.org/forum/u/arjanvanb)\
**Post date:** [November 24, 2019, 1:18pm UTC](https://www.thethingsnetwork.org/forum/t/sending-a-mac-command-to-a-device-using-ttnctl-downlink/8321/9 "2019-11-24T13:18:54Z")

</div>

> [@duwbak](#):
>
> I am wondering if this is already fixed?

I guess you’re asking about sending MAC commands as per this topic’s title, but just to be sure: what “fix” are you expecting? As noted:

> [@htdvisser](#):
>
> It is not possible to send MAC commands from the application layer.

But if you’re referring to [the (fixed) bug](https://github.com/TheThingsNetwork/ttn/issues/570) mentioned above: that was about ADR **as generated by TTN** (and limited to the case where no application downlink was included).

> [@duwbak](#):
>
> I am trying to do downlink messages via the console, but it doesn’t respect the port settings. It will change it to something else when entering port = 0.

Application downlinks, like you can send [using `ttnctl downlink`](https://www.thethingsnetwork.org/docs/network/cli/api.html#ttnctl-downlink), should not use port 0.

When transmitted as a MAC command, 0x03 would decode to a LinkADRReq and the next 4 bytes would be the requested settings. However, **I think that ADR changes should be controlled by the network operator only** , so would probably not be part of the allowed subset mentioned in:

> [@htdvisser](#):
>
> In the future we will add functionality to schedule (a subset of) MAC commands

(Also, I don’t think the above has been implemented, which I guess is what you’re asking.)

So, TTN rightfully assumes your `0x0300ff0001` is an application-level downlink, which should not use port 0. One might argue if silently changing the port number should be changed into raising an error instead.

So: what are you trying to achieve? Do you feel that TTN should allow for ADR MAC commands to be created by the application?
