blob: ce4c95a25907598fb99ba08bf0a21756f3c4ba26 [file] [log] [blame]
<!DOCTYPE html>
<html lang="1.4" 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.4</title>
<link href="/hono/docs/css/nucleus.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/fontawesome-all.min.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/hybrid.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/featherlight.min.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/perfect-scrollbar.min.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/auto-complete.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/atom-one-dark-reasonable.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/theme.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/hugo-theme.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/theme-hono.css?1626138727" rel="stylesheet">
<link href="/hono/docs/css/hono.css?1626138727" rel="stylesheet">
<script src="/hono/docs/js/jquery-3.3.1.min.js?1626138727"></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.4">
<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.4" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://www.eclipse.org/hono/docs/1.4/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.4/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?1626138727"></script>
<script type="text/javascript" src="/hono/docs/js/auto-complete.js?1626138727"></script>
<script type="text/javascript">
var baseurl = "https:\/\/www.eclipse.org\/hono\/docs\/\/1.4";
</script>
<script type="text/javascript" src="/hono/docs/js/search.js?1626138727"></script>
</div>
<div class="highlightable">
<ul class="topics">
<li data-nav-id="/hono/docs/1.4/concepts/" title="Concepts" class="dd-item
parent
">
<a href="/hono/docs/1.4/concepts/">
<i class="far fa-lightbulb"></i> Concepts
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/concepts/device-identity/" title="Device Identity" class="dd-item ">
<a href="/hono/docs/1.4/concepts/device-identity/">
Device Identity
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/tenancy/" title="Multi-Tenancy" class="dd-item ">
<a href="/hono/docs/1.4/concepts/tenancy/">
Multi-Tenancy
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/device-provisioning/" title="Device Provisioning" class="dd-item ">
<a href="/hono/docs/1.4/concepts/device-provisioning/">
Device Provisioning
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/connecting-devices/" title="Connecting Devices" class="dd-item ">
<a href="/hono/docs/1.4/concepts/connecting-devices/">
Connecting Devices
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/device-notifications/" title="Device Notifications" class="dd-item ">
<a href="/hono/docs/1.4/concepts/device-notifications/">
Device Notifications
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/command-and-control/" title="Command &amp; Control" class="dd-item active">
<a href="/hono/docs/1.4/concepts/command-and-control/">
Command &amp; Control
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/resource-limits/" title="Resource limits" class="dd-item ">
<a href="/hono/docs/1.4/concepts/resource-limits/">
Resource limits
</a>
</li>
<li data-nav-id="/hono/docs/1.4/concepts/connection-events/" title="Connection Events" class="dd-item ">
<a href="/hono/docs/1.4/concepts/connection-events/">
Connection Events
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/" title="User Guide" class="dd-item
">
<a href="/hono/docs/1.4/user-guide/">
<i class="fas fa-book-reader"></i> User Guide
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/user-guide/mongodb-based-device-registry/" title="MongoDB Based Device Registry" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/mongodb-based-device-registry/">
MongoDB Based Device Registry
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/file-based-device-registry/" title="File Based Device Registry" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/file-based-device-registry/">
File Based Device Registry
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/http-adapter/" title="HTTP Adapter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/http-adapter/">
HTTP Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/mqtt-adapter/" title="MQTT Adapter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/mqtt-adapter/">
MQTT Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/amqp-adapter/" title="AMQP Adapter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/amqp-adapter/">
AMQP Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/coap-adapter/" title="CoAP Adapter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/coap-adapter/">
CoAP Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/kura-adapter/" title="Kura Adapter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/kura-adapter/">
Kura Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/sigfox-adapter/" title="Sigfox Adapter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/sigfox-adapter/">
Sigfox Adapter
</a>
</li>
<li data-nav-id="/hono/docs/1.4/user-guide/jmeter_load_tests/" title="Load Tests with JMeter" class="dd-item ">
<a href="/hono/docs/1.4/user-guide/jmeter_load_tests/">
Load Tests with JMeter
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/" title="Admin Guide" class="dd-item
">
<a href="/hono/docs/1.4/admin-guide/">
<i class="fas fa-sliders-h"></i> Admin Guide
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/admin-guide/common-config/" title="Common Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/common-config/">
Common Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/auth-server-config/" title="Auth Server Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/auth-server-config/">
Auth Server Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/mongodb-device-registry-config/" title="MongoDB Based Device Registry Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/mongodb-device-registry-config/">
MongoDB Based Device Registry Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/file-based-device-registry-config/" title="File Based Device Registry Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/file-based-device-registry-config/">
File Based Device Registry Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/device-connection-config/" title="Configuring the Device Connection Service" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/device-connection-config/">
Device Connection Service Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/http-adapter-config/" title="HTTP Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/http-adapter-config/">
HTTP Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/mqtt-adapter-config/" title="MQTT Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/mqtt-adapter-config/">
MQTT Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/amqp-adapter-config/" title="AMQP Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/amqp-adapter-config/">
AMQP Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/coap-adapter-config/" title="CoAP Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/coap-adapter-config/">
CoAP Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/kura-adapter-config/" title="Kura Adapter Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/kura-adapter-config/">
Kura Adapter Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/hono-client-configuration/" title="Hono Client Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/hono-client-configuration/">
Hono Client Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/amqp-network-config/" title="AMQP 1.0 Messaging Network Configuration" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/amqp-network-config/">
AMQP 1.0 Messaging Network Configuration
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/secure_communication/" title="Secure Communication" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/secure_communication/">
Secure Communication
</a>
</li>
<li data-nav-id="/hono/docs/1.4/admin-guide/monitoring-tracing-config/" title="Monitoring &amp; Tracing" class="dd-item ">
<a href="/hono/docs/1.4/admin-guide/monitoring-tracing-config/">
Monitoring &amp; Tracing
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.4/dev-guide/" title="Developer Guide" class="dd-item
">
<a href="/hono/docs/1.4/dev-guide/">
<i class="fas fa-tools"></i> Developer Guide
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/dev-guide/building_hono/" title="Building from Source" class="dd-item ">
<a href="/hono/docs/1.4/dev-guide/building_hono/">
Building from Source
</a>
</li>
<li data-nav-id="/hono/docs/1.4/dev-guide/amqp_adapter_client/" title="AMQP Adapter Client for Java" class="dd-item ">
<a href="/hono/docs/1.4/dev-guide/amqp_adapter_client/">
AMQP Adapter Client for Java
</a>
</li>
<li data-nav-id="/hono/docs/1.4/dev-guide/java_client_consumer/" title="Consuming Messages from Java" class="dd-item ">
<a href="/hono/docs/1.4/dev-guide/java_client_consumer/">
Consuming Messages from Java
</a>
</li>
<li data-nav-id="/hono/docs/1.4/dev-guide/custom_http_adapter/" title="Implement a Custom Hono HTTP Protocol Adapter" class="dd-item ">
<a href="/hono/docs/1.4/dev-guide/custom_http_adapter/">
Implement a Custom Hono HTTP Protocol Adapter
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.4/api/" title="API" class="dd-item
">
<a href="/hono/docs/1.4/api/">
&nbsp;<i class='fas fa-plug'></i>&nbsp;API
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/api/telemetry/" title="Telemetry API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/telemetry/">
Telemetry API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/event/" title="Event API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/event/">
Event API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/command-and-control/" title="Command &amp; Control API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/command-and-control/">
Command &amp; Control API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/tenant/" title="Tenant API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/tenant/">
Tenant API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/device-connection/" title="Device Connection API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/device-connection/">
Device Connection API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/device-registration/" title="Device Registration API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/device-registration/">
Device Registration API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/credentials/" title="Credentials API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/credentials/">
Credentials API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/authentication/" title="Authentication API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/authentication/">
Authentication API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/management/" title="Device Registry Management API Specification" class="dd-item ">
<a href="/hono/docs/1.4/api/management/">
Device Registry Management API
</a>
</li>
<li data-nav-id="/hono/docs/1.4/api/metrics/" title="Metrics" class="dd-item ">
<a href="/hono/docs/1.4/api/metrics/">
Metrics
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.4/deployment/" title="Deployment" class="dd-item
">
<a href="/hono/docs/1.4/deployment/">
<i class="fas fa-shipping-fast"></i> Deployment
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/deployment/helm-based-deployment/" title="Helm based Deployment" class="dd-item ">
<a href="/hono/docs/1.4/deployment/helm-based-deployment/">
Helm based Deployment
</a>
</li>
<li data-nav-id="/hono/docs/1.4/deployment/openshift/" title="OpenShift / OKD" class="dd-item ">
<a href="/hono/docs/1.4/deployment/openshift/">
OpenShift / OKD
</a>
</li>
<li data-nav-id="/hono/docs/1.4/deployment/create-kubernetes-cluster/" title="Setting up a Kubernetes Cluster" class="dd-item ">
<a href="/hono/docs/1.4/deployment/create-kubernetes-cluster/">
Setting up a Kubernetes Cluster
</a>
</li>
<li data-nav-id="/hono/docs/1.4/deployment/resource-limitation/" title="Limiting Resource Usage" class="dd-item ">
<a href="/hono/docs/1.4/deployment/resource-limitation/">
Limiting Resource Usage
</a>
</li>
</ul>
</li>
<li data-nav-id="/hono/docs/1.4/architecture/" title="Architecture" class="dd-item
">
<a href="/hono/docs/1.4/architecture/">
<i class="fas fa-landmark"></i> Architecture
</a>
<ul>
<li data-nav-id="/hono/docs/1.4/architecture/component-view/" title="Component View" class="dd-item ">
<a href="/hono/docs/1.4/architecture/component-view/">
Component View
</a>
</li>
<li data-nav-id="/hono/docs/1.4/architecture/auth/" title="Authentication/Authorization" class="dd-item ">
<a href="/hono/docs/1.4/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="stable" value="https://www.eclipse.org/hono/docs/concepts/command-and-control/">stable (1.8)</option>
<option id="1.8" value="https://www.eclipse.org/hono/docs/1.8/concepts/command-and-control/">1.8</option>
<option id="1.7" value="https://www.eclipse.org/hono/docs/1.7/concepts/command-and-control/">1.7</option>
<option id="1.6" value="https://www.eclipse.org/hono/docs/1.6/concepts/command-and-control/">1.6</option>
<option id="1.5" value="https://www.eclipse.org/hono/docs/1.5/concepts/command-and-control/">1.5</option>
<option id="1.4" value="https://www.eclipse.org/hono/docs/1.4/concepts/command-and-control/" selected>1.4</option>
<option id="1.3" value="https://www.eclipse.org/hono/docs/1.3/concepts/command-and-control/">1.3</option>
<option id="dev" value="https://www.eclipse.org/hono/docs/dev/concepts/command-and-control/">dev</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.4</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/index.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.4/'>Documentation</a> > <a href='/hono/docs/1.4/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.4/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 till disconnect&rdquo;) parameter.</p>
<p>The protocol adapter will then create the necessary AMQP consumer link with the AMQP messaging network if it doesn&rsquo;t exist already (for more details see <a href="#command-consumer-links-in-the-protocol-adapter">below</a>) and will send a <a href="/hono/docs/1.4/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.</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 a gateway that has subscribed for such commands and that is configured to act on behalf of the command target device. If there are multiple matching gateways, the one that the command target device was last connected to is chosen.
The information about which gateways are subscribed and which gateway a device has last communicated by is managed via the <a href="/hono/docs/1.4/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 to which particular protocol adapter instance the target device (or mapped gateway) is actually connected. Since this kind of link is opened from all protocol adapter instances receiving commands for the tenant, a command message is first received by any one of these protocol adapter instances. Therefore, if necessary, the command will be delegated to the adapter instance that is connected to the target device or to the gateway receiving commands for the device.
That is done by forwarding the command to the AMQP messaging network on a link with the address <code>command_internal/${adapterInstanceId}</code> (see below).</p>
</li>
<li>
<p><strong>A link per protocol adapter instance on the address <code>command_internal/${adapterInstanceId}</code></strong>.<br>
On this link, commands will be received that have been forwarded from another protocol adapter instance. This link address is only used for communication between protocol adapter instances, so attaching to this link address should not be enabled for applications.</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 link (2) on the tenant-scoped link. The protocol adapter then updates the <a href="/hono/docs/1.4/api/device-connection/#set-command-handling-protocol-adapter-instance-for-device">command-handling protocol adapter instance for device</a> information (3), assigning the device 4711 to adapter instance id #1. Following that, the notification about the device subscription is sent 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. The protocol adapter then queries the <a href="/hono/docs/1.4/api/device-connection/#get-command-handling-protocol-adapter-instances-for-device">command-handling protocol adapter instances</a> information for the device id of the command message (4). In this case here, the protocol adapter instance #1 is returned (5). The command then gets forwarded to the AMQP messaging network on the address for adapter instance #1 (6). The protocol adapter instance #1 will receive the message (7) and forward it to the device (8). As the last step, an &ldquo;accepted&rdquo; disposition will be sent back to the application (9).</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.4/admin-guide/file-based-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 then updates the <a href="/hono/docs/1.4/api/device-connection/#set-command-handling-protocol-adapter-instance-for-device">command-handling protocol adapter instance for device</a> information (3), assigning the device 4711 to adapter instance id #1.</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.4/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). After receiving the command message, the protocol adapter determines the <a href="/hono/docs/1.4/api/device-connection/#get-command-handling-protocol-adapter-instances-for-device">command-handling protocol adapter instances</a> information for the device id of the command message (4). In this case here, the protocol adapter instance #1 is returned (5), meaning that the command is already at the right adapter instance. As the subscription for commands to device 4711 was done by gateway &ldquo;gw-1&rdquo;, the command gets forwarded to that gateway (6). It is then the responsibility of the gateway to forward the command to the device <code>4711</code>. After the gateway has acknowledged the command message, an &ldquo;accepted&rdquo; disposition will be sent back to the application (7).</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 then updates the <a href="/hono/docs/1.4/api/device-connection/#set-command-handling-protocol-adapter-instance-for-device">command-handling protocol adapter instance for device</a> information (3), assigning the device &lsquo;gw-1&rsquo; to adapter instance id #1.
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>
<figure>
<img src="command_control_concept_gateway_all_devices_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). After receiving the command message, the protocol adapter determines the <a href="/hono/docs/1.4/api/device-connection/#get-command-handling-protocol-adapter-instances-for-device">command-handling protocol adapter instances</a> information for the device id of the command message (4).</p>
<p>In the example above, there is no adapter instance associated with the device <code>4711</code>. Therefore it is checked whether there are adapter instances handling commands for the gateways, configured to possibly act on behalf of the device.
If there is an adapter instance associated with the last known gateway of the device, that instance is returned as the result. Otherwise, and in the example above, the command handling adapter instance for any of these gateways is returned (the choice being random if there are multiple instances). In the above example that is the instance #1 associated with gateway <code>gw-1</code> (5).</p>
<p>Then the command gets forwarded to that gateway (6). It is the responsibility of the gateway to forward the command to the device <code>4711</code>. After the gateway has acknowledged the command message, an &ldquo;accepted&rdquo; disposition will be sent back to the application (7).</p>
<p>Handling of the command response is done in the same way as shown in the chapter above for a gateway subscribing for a particular device and is therefore omitted here.</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?1626138727"></script>
<script src="/hono/docs/js/perfect-scrollbar.min.js?1626138727"></script>
<script src="/hono/docs/js/perfect-scrollbar.jquery.min.js?1626138727"></script>
<script src="/hono/docs/js/jquery.sticky.js?1626138727"></script>
<script src="/hono/docs/js/featherlight.min.js?1626138727"></script>
<script src="/hono/docs/js/highlight.pack.js?1626138727"></script>
<script>hljs.initHighlightingOnLoad();</script>
<script src="/hono/docs/js/modernizr.custom-3.6.0.js?1626138727"></script>
<script src="/hono/docs/js/learn.js?1626138727"></script>
<script src="/hono/docs/js/hugo-learn.js?1626138727"></script>
<link href="/hono/docs/mermaid/mermaid.css?1626138727" rel="stylesheet" />
<script src="/hono/docs/mermaid/mermaid.js?1626138727"></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>