blob: b15366ea9687633b851caa85b8210d5948ebf16e [file] [log] [blame]
<!DOCTYPE html>
<html lang="1.0" class="js csstransforms3d">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="generator" content="Hugo 0.81.0" />
<meta name="description" content="A set of micro-services for connecting millions of devices.">
<meta name="author" content="The Eclipse Hono Project">
<link rel="apple-touch-icon" sizes="180x180" href="/hono/docs/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="48x48" href="/hono/docs/favicon/favicon-48x48.png">
<link rel="icon" type="image/png" sizes="32x32" href="/hono/docs/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/hono/docs/favicon/favicon-16x16.png">
<link rel="manifest" href="/hono/docs/favicon/site.webmanifest">
<link rel="mask-icon" href="/hono/docs/favicon/safari-pinned-tab.svg" color="#5bbad5">
<link rel="shortcut icon" href="/hono/docs/favicon/favicon.ico">
<meta name="msapplication-TileColor" content="#da532c">
<meta name="msapplication-config" content="/hono/docs/favicon/browserconfig.xml">
<meta name="theme-color" content="#ffffff">
<title>Command & Control :: Eclipse Hono&trade; Vers.: 1.0</title>
<link href="/hono/docs/css/nucleus.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/fontawesome-all.min.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/hybrid.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/featherlight.min.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/perfect-scrollbar.min.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/auto-complete.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/atom-one-dark-reasonable.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/theme.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/hugo-theme.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/theme-hono.css?1626138736" rel="stylesheet">
<link href="/hono/docs/css/hono.css?1626138736" rel="stylesheet">
<script src="/hono/docs/js/jquery-3.3.1.min.js?1626138736"></script>
<style>
:root #header + #content > #left > #rlblock_left{
display:none !important;
}
:not(pre) > code + span.copy-to-clipboard {
display: none;
}
</style>
<link rel="stylesheet" href="https://www.eclipse.org/eclipse.org-common/themes/solstice/public/stylesheets/vendor/cookieconsent/cookieconsent.min.css">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@EclipseHono">
<meta name="twitter:title" content="Command &amp; Control :: Eclipse Hono&amp;trade; Vers.: 1.0">
<meta name="twitter:image" content="https://www.eclipse.org/hono/docs/images/twitter_image.png">
<meta name="twitter:description" content="A set of micro-services for connecting millions of devices.">
<meta property="og:title" content="Command &amp; Control :: Eclipse Hono&amp;trade; Vers.: 1.0" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.eclipse.org/hono/docs/1.0/concepts/command-and-control//" />
<meta property="og:image" content="https://www.eclipse.org/hono/docs/images/twitter_image.png" />
</head>
<body class="" data-url="/hono/docs/1.0/concepts/command-and-control/">
<nav id="sidebar" class="">
<div id="header-wrapper">
<div id="header">
<a href="https://www.eclipse.org/hono/">
<img src="/hono/docs/images/HONO-Logo_Bild-Wort_quer-w-310x120px.svg" alt="Hono logo" class="logo-img">
</a>
</div>
<div class="searchbox">
<label for="search-by"><i class="fas fa-search"></i></label>
<input data-search-input id="search-by" type="search" placeholder="Search...">
<span data-search-clear=""><i class="fas fa-times"></i></span>
</div>
<script type="text/javascript" src="/hono/docs/js/lunr.min.js?1626138736"></script>
<script type="text/javascript" src="/hono/docs/js/auto-complete.js?1626138736"></script>
<script type="text/javascript">
var baseurl = "https:\/\/www.eclipse.org\/hono\/docs\/\/1.0";
</script>
<script type="text/javascript" src="/hono/docs/js/search.js?1626138736"></script>
</div>
<div class="highlightable">
<ul class="topics">
<li data-nav-id="/hono/docs/1.0/concepts/" title="Concepts" class="dd-item
parent
">
<a href="/hono/docs/1.0/concepts/">
<i class="far fa-lightbulb"></i> Concepts
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/concepts/device-identity/" title="Device Identity" class="dd-item ">
<a href="/hono/docs/1.0/concepts/device-identity/">
Device Identity
</a>
</li>
<li data-nav-id="/hono/docs/1.0/concepts/tenancy/" title="Multi-Tenancy" class="dd-item ">
<a href="/hono/docs/1.0/concepts/tenancy/">
Multi-Tenancy
</a>
</li>
<li data-nav-id="/hono/docs/1.0/concepts/device-notifications/" title="Device Notifications" class="dd-item ">
<a href="/hono/docs/1.0/concepts/device-notifications/">
Device Notifications
</a>
</li>
<li data-nav-id="/hono/docs/1.0/concepts/command-and-control/" title="Command &amp; Control" class="dd-item active">
<a href="/hono/docs/1.0/concepts/command-and-control/">
Command &amp; Control
</a>
</li>
<li data-nav-id="/hono/docs/1.0/concepts/resource-limits/" title="Resource limits" class="dd-item ">
<a href="/hono/docs/1.0/concepts/resource-limits/">
Resource limits
</a>
</li>
<li data-nav-id="/hono/docs/1.0/concepts/connection-events/" title="Connection Events" class="dd-item ">
<a href="/hono/docs/1.0/concepts/connection-events/">
Connection Events
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/" title="User Guide" class="dd-item
">
<a href="/hono/docs/1.0/user-guide/">
<i class="fas fa-book-reader"></i> User Guide
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/user-guide/device-registry/" title="Device Registry" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/device-registry/">
Device Registry
</a>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/http-adapter/" title="HTTP Adapter" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/http-adapter/">
HTTP Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/mqtt-adapter/" title="MQTT Adapter" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/mqtt-adapter/">
MQTT Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/amqp-adapter/" title="AMQP Adapter" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/amqp-adapter/">
AMQP Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/kura-adapter/" title="Kura Adapter" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/kura-adapter/">
Kura Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/sigfox-adapter/" title="Sigfox Adapter" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/sigfox-adapter/">
Sigfox Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.0/user-guide/jmeter_load_tests/" title="Load Tests with JMeter" class="dd-item ">
<a href="/hono/docs/1.0/user-guide/jmeter_load_tests/">
Load Tests with JMeter
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/" title="Admin Guide" class="dd-item
">
<a href="/hono/docs/1.0/admin-guide/">
<i class="fas fa-sliders-h"></i> Admin Guide
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/admin-guide/common-config/" title="Common Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/common-config/">
Common Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/auth-server-config/" title="Auth Server Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/auth-server-config/">
Auth Server Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/device-registry-config/" title="Device Registry Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/device-registry-config/">
Device Registry Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/device-connection-config/" title="Configuring the Device Connection Service" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/device-connection-config/">
Device Connection Service Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/http-adapter-config/" title="HTTP Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/http-adapter-config/">
HTTP Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/amqp-adapter-config/" title="AMQP Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/amqp-adapter-config/">
AMQP Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/mqtt-adapter-config/" title="MQTT Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/mqtt-adapter-config/">
MQTT Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/kura-adapter-config/" title="Kura Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/kura-adapter-config/">
Kura Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/hono-client-configuration/" title="Hono Client Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/hono-client-configuration/">
Hono Client Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/amqp-network-config/" title="AMQP 1.0 Messaging Network Configuration" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/amqp-network-config/">
AMQP 1.0 Messaging Network Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/secure_communication/" title="Secure Communication" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/secure_communication/">
Secure Communication
</a>
</li>
<li data-nav-id="/hono/docs/1.0/admin-guide/monitoring-tracing-config/" title="Monitoring &amp; Tracing" class="dd-item ">
<a href="/hono/docs/1.0/admin-guide/monitoring-tracing-config/">
Monitoring &amp; Tracing
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.0/dev-guide/" title="Developer Guide" class="dd-item
">
<a href="/hono/docs/1.0/dev-guide/">
<i class="fas fa-tools"></i> Developer Guide
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/dev-guide/building_hono/" title="Building from Source" class="dd-item ">
<a href="/hono/docs/1.0/dev-guide/building_hono/">
Building from Source
</a>
</li>
<li data-nav-id="/hono/docs/1.0/dev-guide/java_client_consumer/" title="Consuming Messages from Java" class="dd-item ">
<a href="/hono/docs/1.0/dev-guide/java_client_consumer/">
Consuming Messages from Java
</a>
</li>
<li data-nav-id="/hono/docs/1.0/dev-guide/custom_http_adapter/" title="Implement a Custom Hono HTTP Protocol Adapter" class="dd-item ">
<a href="/hono/docs/1.0/dev-guide/custom_http_adapter/">
Implement a Custom Hono HTTP Protocol Adapter
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.0/api/" title="API" class="dd-item
">
<a href="/hono/docs/1.0/api/">
&nbsp;<i class='fas fa-plug'></i>&nbsp;API
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/api/telemetry/" title="Telemetry API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/telemetry/">
Telemetry API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/event/" title="Event API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/event/">
Event API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/command-and-control/" title="Command &amp; Control API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/command-and-control/">
Command &amp; Control API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/tenant/" title="Tenant API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/tenant/">
Tenant API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/device-connection/" title="Device Connection API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/device-connection/">
Device Connection API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/device-registration/" title="Device Registration API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/device-registration/">
Device Registration API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/credentials/" title="Credentials API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/credentials/">
Credentials API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/authentication/" title="Authentication API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/authentication/">
Authentication API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/management/" title="Device Registry Management API Specification" class="dd-item ">
<a href="/hono/docs/1.0/api/management/">
Device Registry Management API
</a>
</li>
<li data-nav-id="/hono/docs/1.0/api/metrics/" title="Metrics" class="dd-item ">
<a href="/hono/docs/1.0/api/metrics/">
Metrics
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.0/deployment/" title="Deployment" class="dd-item
">
<a href="/hono/docs/1.0/deployment/">
<i class="fas fa-shipping-fast"></i> Deployment
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/deployment/helm-based-deployment/" title="Helm based Deployment" class="dd-item ">
<a href="/hono/docs/1.0/deployment/helm-based-deployment/">
Helm based Deployment
</a>
</li>
<li data-nav-id="/hono/docs/1.0/deployment/openshift/" title="OpenShift / OKD" class="dd-item ">
<a href="/hono/docs/1.0/deployment/openshift/">
OpenShift / OKD
</a>
</li>
<li data-nav-id="/hono/docs/1.0/deployment/create-kubernetes-cluster/" title="Setting up a Kubernetes Cluster" class="dd-item ">
<a href="/hono/docs/1.0/deployment/create-kubernetes-cluster/">
Setting up a Kubernetes Cluster
</a>
</li>
<li data-nav-id="/hono/docs/1.0/deployment/resource-limitation/" title="Limiting Resource Usage" class="dd-item ">
<a href="/hono/docs/1.0/deployment/resource-limitation/">
Limiting Resource Usage
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.0/architecture/" title="Architecture" class="dd-item
">
<a href="/hono/docs/1.0/architecture/">
<i class="fas fa-landmark"></i> Architecture
</a>
<ul>
<li data-nav-id="/hono/docs/1.0/architecture/component-view/" title="Component View" class="dd-item ">
<a href="/hono/docs/1.0/architecture/component-view/">
Component View
</a>
</li>
<li data-nav-id="/hono/docs/1.0/architecture/auth/" title="Authentication/Authorization" class="dd-item ">
<a href="/hono/docs/1.0/architecture/auth/">
Authentication/Authorization
</a>
</li>
</ul>
</li>
</ul>
<section id="shortcuts">
<h3></h3>
<ul>
<li>
<a class="padding" href="https://www.eclipse.org/hono/" title="Hono&#39;s Homepage"><i class='fas fa-home'></i> Hono Home</a>
</li>
<li>
<a class="padding" href="https://www.eclipse.org/hono/getting-started/" title="Getting started with Eclipse Hono"><i class='fas fa-plane-departure'></i> Getting Started</a>
</li>
</ul>
</section>
<section id="prefooter">
<hr/>
<ul>
<li>
<div id="select-box-wrapper">
<div id="select-box">
<a class="padding">
Version:&nbsp;
<div class="select-style">
<select id="select-language" onchange="location = this.value;">
<option id="1.2" value="https://www.eclipse.org/hono/docs/1.2/concepts/command-and-control/">1.2</option>
<option id="1.1" value="https://www.eclipse.org/hono/docs/1.1/concepts/command-and-control/">1.1</option>
<option id="1.0" value="https://www.eclipse.org/hono/docs/1.0/concepts/command-and-control/" selected>1.0</option>
</select>
<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="255px" height="255px" viewBox="0 0 255 255" style="enable-background:new 0 0 255 255;" xml:space="preserve">
<g>
<g id="arrow-drop-down">
<polygon points="0,63.75 127.5,191.25 255,63.75 " />
</g>
</g>
</svg>
</div>
</a>
</div>
</div>
</li>
</ul>
</section>
<section id="footer">
<p>&copy; 2021 <a href="https://www.eclipse.org/hono/">The Eclipse Hono Project</a></p>
<p>
Documentation built with
<a href="https://gohugo.io/" target="_blank">Hugo</a>
using the
<a href="https://github.com/matcornic/hugo-theme-learn" target="_blank">Learn</a> theme.
</p>
<div class="eclipse-logo">
<a href="https://www.eclipse.org" target="_blank">
<img src="https://www.eclipse.org/hono/docs/images/eclipse_foundation_logo.svg"/>
</a>
</div>
</section>
</div>
</nav>
<section id="body">
<div id="overlay"></div>
<div class="old-version-hint">
<p>This page refers to version <em>1.0</em>.
You might want to use the <a href="https://www.eclipse.org/hono/docs/">current stable</a> version.
</p>
</div>
<div class="padding highlightable">
<div>
<div id="top-bar">
<div id="top-github-link">
<a class="github-link" title='Edit this page' href="https://github.com/eclipse/hono/edit/master/site/documentation/content/concepts/command-and-control.md" target="blank">
<i class="fas fa-code-branch"></i>
<span id="top-github-link-text">Edit this page</span>
</a>
</div>
<div id="breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb">
<span id="sidebar-toggle-span">
<a href="#" id="sidebar-toggle" data-sidebar-toggle="">
<i class="fas fa-bars"></i>
</a>
</span>
<span id="toc-menu"><i class="fas fa-list-alt"></i></span>
<span class="links">
<a href='/hono/docs/1.0/'>Documentation</a> > <a href='/hono/docs/1.0/concepts/'>Concepts</a> > Command & Control
</span>
</div>
<div class="progress">
<div class="wrapper">
<nav id="TableOfContents">
<ul>
<li><a href="#general-concept">General concept</a>
<ul>
<li></li>
</ul>
</li>
<li><a href="#gateway-subscriptions">Gateway subscriptions</a>
<ul>
<li><a href="#gateway-subscribing-for-commands-for-a-particular-device">Gateway subscribing for commands for a particular device</a></li>
<li><a href="#gateway-subscribing-for-commands-for-all-its-devices">Gateway subscribing for commands for all its devices</a></li>
</ul>
</li>
</ul>
</nav>
</div>
</div>
</div>
</div>
<div id="head-tags">
</div>
<div id="body-inner">
<h1>
Command &amp; Control
</h1>
<p><em>Business applications</em> can send commands to devices following the <a href="/hono/docs/1.0/api/command-and-control/">Command &amp; Control API</a>. This concept page describes how this API is used by applications to send commands and describes how Hono&rsquo;s protocol adapters process the commands so that they reach their target device.</p>
<p>Commands can be sent following a <em>request/response</em> or a <em>one-way</em> pattern. For <em>Request/Response</em> commands, there is always a response expected from the device.</p>
<h2 id="general-concept">General concept</h2>
<p>The following sequence diagram gives an overview of a device indicating its availability for receiving commands, of a business application sending a command to the device and of the device sending back a command response.</p>
<p>The application and the adapter connect to the AMQP Network, which forwards the transfer - for clarity this is not shown in the diagram below.</p>
<figure>
<img src="../command_control_concept.svg"/> <figcaption>
<h4>Request/Response Command overview</h4>
</figcaption>
</figure>
<p>In (1) the device subscribes for commands (if connecting to the AMQP or MQTT adapter) or indicates that it will stay connected for a given amount of time to receive a command (if connecting to the HTTP adapter), using the <code>ttd</code> (&ldquo;time til disconnect&rdquo;) parameter.</p>
<p>The protocol adapter will then create the necessary AMQP consumer links with the AMQP messaging network (for more details see <a href="#command-consumer-links-in-the-protocol-adapter">below</a>) and will send a <a href="/hono/docs/1.0/concepts/device-notifications/">notification</a> to the application that the device is ready to receive commands (2).</p>
<p>After having created a sender link on the <code>command/TENANT</code> address, the application can then send commands, with the target device given in the AMQP message <code>to</code> address <code>command/TENANT/4711</code> (3). If a command response is expected, the command response address <code>command_response/TENANT/${replyId}</code> (with <code>replyId</code> being an arbitrary identifier chosen by the application) is to be set as <code>reply-to</code> property in the command message and a corresponding receiver link is to be opened by the application. For one-way commands, both is to be omitted.</p>
<p>After receiving the command, the protocol adapter instance will forward the command to the device (4) and send a disposition update back to the application (5).</p>
<p>In case of a Request/Response command, the device can then send a command response (6) that will be forwarded by the protocol adapter back to the application (7).</p>
<h4 id="command--control-involving-a-gateway">Command &amp; Control involving a gateway</h4>
<p>Hono has special support for sending commands to devices that are connected via a gateway to Hono.
Such devices are configured in the Hono device registration service in such a way, that certain gateways may act on behalf of the device.
The information, which of the configured gateways for a particular device was the last one through which a device interacted with Hono, is managed in the Hono <a href="/hono/docs/1.0/api/device-connection/">device connection service</a>.</p>
<p>When sending commands, the northbound applications do not have to know to which gateway the command target device is connected to.
The application sends the command with the device address and Hono will direct the command to the gateway that the command target device was last connected to.
This mapping information is retrieved via the <a href="/hono/docs/1.0/api/device-connection/">device connection service</a>.</p>
<h4 id="command-consumer-links-in-the-protocol-adapter">Command consumer links in the protocol adapter</h4>
<p>The protocol adapter opens 2 kinds of consumer links to receive commands.</p>
<ol>
<li>
<p><strong>A tenant-scoped link on the address <code>command/${tenant}</code></strong>.<br>
This is the link address used by applications to send commands. Upon receiving a command message on this link, the protocol adapter checks whether the command target device id needs to be mapped to a gateway. Furthermore it is checked whether the target device (or mapped gateway) is actually connected to this particular protocol adapter instance. Since this kind of link is opened from all protocol adapter instances receiving commands for the tenant, the choice of which instance will get a particular command is random. Therefore, if necessary, the command (with the mapped gateway id if found) will be delegated to the adapter instance that is connected to the target device/gateway.
That is done by forwarding the command on a device specific link address <code>control/${tenant}/${device}</code> to the AMQP messaging network.</p>
</li>
<li>
<p><strong>The device-scoped link on the address <code>control/${tenant}/${device}</code></strong>.<br>
On this link, commands will be received that have been forwarded from another protocol adapter instance. This link is also used for applications using the legacy control endpoint. Once support for the legacy endpoint has been removed, this link address will only be used for communication between protocol adapter instances, so attaching to this link address should not be enabled for applications then.</p>
</li>
</ol>
<h4 id="example-with-multiple-adapters-involved">Example with multiple adapters involved</h4>
<p>The following diagrams show the message flow if the command message is first received on a protocol adapter instance that the target device is <em>not</em> connected to.</p>
<figure>
<img src="../command_control_concept_delegate_1.svg"/> <figcaption>
<h4>Command subscription</h4>
</figcaption>
</figure>
<p>In the scenario here there is a protocol adapter instance 2 through which a command subscription for the example tenant was already made (0).</p>
<p>The device subscribes for commands (1) and the protocol adapter creates the receiver links (2,3) and sends the notification to the application via the AMQP messaging network (4).</p>
<figure>
<img src="../command_control_concept_delegate_2.svg"/> <figcaption>
<h4>Command handling</h4>
</figcaption>
</figure>
<p>Upon receiving the notification, the application prepares sender and command response receiver links (1,2) and sends the command message to the AMQP messaging network.
Here it is received by protocol adapter instance 2. It is first checked here, whether the command needs to be mapped to a gateway. This is not the case here. As there is no such device subscribed for handling the command at this adapter instance, the command gets forwarded with the device specific address to the AMQP messaging network (4).
The protocol adapter instance that has opened a receiver link on this device-specific address is instance 1, which will receive the message (5) and forward it to the device (6). As the last step, an &ldquo;accepted&rdquo; disposition will be sent back to the application (7).</p>
<figure>
<img src="../command_control_concept_delegate_3.svg"/> <figcaption>
<h4>Command response handling</h4>
</figcaption>
</figure>
<p>The command response message is sent back to the application from the protocol adapter via the AMQP messaging network.</p>
<h2 id="gateway-subscriptions">Gateway subscriptions</h2>
<h3 id="gateway-subscribing-for-commands-for-a-particular-device">Gateway subscribing for commands for a particular device</h3>
<p>The following sequence diagrams show the different steps involved in having a gateway subscribe for commands of a particular device.</p>
<figure>
<img src="../command_control_concept_gateway_1.svg"/> <figcaption>
<h4>Command subscription</h4>
</figcaption>
</figure>
<p>The gateway &ldquo;gw-1&rdquo; is connected to a protocol adapter and subscribes to commands for a device 4711 (1). This device has to be configured so that the gateway may act on its behalf (see <a href="/hono/docs/1.0/admin-guide/device-registry-config/">Configuring Gateway Devices</a> for details).</p>
<p>The protocol adapter creates the tenant-scoped consumer link on the <code>command/TENANT</code> address (if it doesn&rsquo;t already exist) (2) and creates a device-specific consumer link with the gateway id in the address (<code>control/TENANT/gw-1</code>) (3).</p>
<p>Just like it is done when a protocol adapter handles any kind of message from a gateway acting on behalf of a device, the protocol adapter updates the <a href="/hono/docs/1.0/api/device-connection/#set-last-known-gateway-for-device">last-known gateway</a> information here, sending a request to the device connection service (4). The notification event is then sent containing the device id 4711 (5)</p>
<figure>
<img src="../command_control_concept_gateway_2.svg"/> <figcaption>
<h4>Command handling</h4>
</figcaption>
</figure>
<p>After the application has prepared the sender and consumer links (1,2), it sends the command message on the <code>command/TENANT</code> link with the AMQP message <code>to</code> property set to <code>command/TENANT/4711</code> and <code>reply-to</code> set to the address of the command response consumer link (<code>command_response/TENANT/${replyId}</code> with <code>replyId</code> being an arbitrary identifier chosen by the application) (3).</p>
<p>After receiving the command message, the protocol adapter determines whether the command message needs to be mapped to a gateway. This is done by querying the <a href="/hono/docs/1.0/api/device-connection/#get-last-known-gateway-for-device">last-known gateway</a> operation of the device connection service. In the shown scenario, the determined gateway id is <code>gw-1</code>. As the protocol adapter instance has a subscription for the command target device <code>4711</code> connected via gateway <code>gw-1</code>, the command is published to that gateway (6). It is then the responsibility of the gateway to forward the command to the device <code>4711</code>.</p>
<figure>
<img src="../command_control_concept_gateway_3.svg"/> <figcaption>
<h4>Command response handling</h4>
</figcaption>
</figure>
<p>When the device sends a command response via the gateway (1), the protocol adapter forwards the command message on the <code>command_response/TENANT/${replyId}</code> link to the application (2).</p>
<h3 id="gateway-subscribing-for-commands-for-all-its-devices">Gateway subscribing for commands for all its devices</h3>
<p>A gateway may also subscribe for commands sent to all the different devices that the gateway acts on behalf of. Such a scenario is shown in the following sequence diagram.</p>
<figure>
<img src="../command_control_concept_gateway_all_devices_1.svg"/> <figcaption>
<h4>Command subscription</h4>
</figcaption>
</figure>
<p>The gateway subscribes for commands just like a normal device would, only using its id <code>gw-1</code> (1). The protocol adapter creates the tenant-scoped consumer link on the <code>command/TENANT</code> address (if it doesn&rsquo;t already exist) (2) and creates a device-specific consumer link with the gateway id in the address (<code>control/TENANT/gw-1</code>) (3).
The subscription notification sent to the application contains the gateway id <code>gw-1</code>. That means that either the application has to know about the gateway, or that it just assumes that the devices it sends commands to (and that are connected to the gateway) are always available for receiving commands. This may especially be the case for long-lasting command subscriptions (with the MQTT or AMQP adapter).</p>
<p>Note that the steps above do not involve an update of the last-known gateway information in the device connection service.
That means that when an application sends a command message to a particular device (not the gateway), one of the following conditions has to met for the command to be mapped to the gateway:</p>
<ul>
<li>The command target device has already sent a message via the gateway, so that the last-known gateway information was set.</li>
<li>Or, the gateway is configured as the one and only <code>via</code> gateway of the command target device.</li>
</ul>
<p>If one or the other is the case, commands targeted at the particular device will be handled the same way as shown in the chapter above for a gateway subscribing for a particular device. Handling of the command response is also the same and is therefore omitted here as well.</p>
<p>If a gateway has already subscribed for commands for all its device, it may still subscribe for commands for a particular device (and the other way around).
The particular device subscription has precedence then in choosing over which subscription protocol/channel to send the command to the gateway.</p>
<footer class="footline">
</footer>
</div>
</div>
<div id="navigation">
</div>
</section>
<div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
<div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
</div>
<script src="/hono/docs/js/clipboard.min.js?1626138736"></script>
<script src="/hono/docs/js/perfect-scrollbar.min.js?1626138736"></script>
<script src="/hono/docs/js/perfect-scrollbar.jquery.min.js?1626138736"></script>
<script src="/hono/docs/js/jquery.sticky.js?1626138736"></script>
<script src="/hono/docs/js/featherlight.min.js?1626138736"></script>
<script src="/hono/docs/js/highlight.pack.js?1626138736"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/hono/docs/js/modernizr.custom-3.6.0.js?1626138736"></script>
<script src="/hono/docs/js/learn.js?1626138736"></script>
<script src="/hono/docs/js/hugo-learn.js?1626138736"></script>
<link href="/hono/docs/mermaid/mermaid.css?1626138736" rel="stylesheet" />
<script src="/hono/docs/mermaid/mermaid.js?1626138736"></script>
<script>
mermaid.initialize({ startOnLoad: true });
</script>
<script>
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-5WLCZXC');
</script>
<script src="https://www.eclipse.org/eclipse.org-common/themes/solstice/public/javascript/vendor/cookieconsent/default.min.js"></script>
</body>
</html>