11

MQTT is widely used in IoT when it comes to exchanging application data between the end device and the host service. The publish-subscribe model makes it easy to use: no handshaking, negotiating etc (at least above the MQTT protocol layer). It's primarily geared towards data-producers being able to distribute their data easily to consumers.

However, when it comes to a central server wanting to configure settings on an end device, I'm not sure that the model is very suitable. The server will want to send a command to the device and wait for a response back (e.g. read a specific setting, wait for response), which doesn't really suit MQTT's publish-subscribe model.

I was wondering whether there are any existing protocols that are geared towards send and receiving commands and configuring remote devices?

Bence Kaulics
  • 7,843
  • 8
  • 42
  • 90
Amr Bekhit
  • 275
  • 1
  • 7

2 Answers2

7

Sounds like a job for CoAP:

Like HTTP, CoAP is based on the wildly successful REST model: Servers make resources available under a URL, and clients access these resources using methods such as GET, PUT, POST, and DELETE.

From a developer point of view, CoAP feels very much like HTTP. Obtaining a value from a sensor is not much different from obtaining a value from a Web API.

It can apparently be implemented with very low overhead:

CoAP has been designed to work on microcontrollers with as low as 10 KiB of RAM and 100 KiB of code space

CoAP is specified in RFC 7252, and there are various implementations (e.g. in C).

It's very heavily inspired by REST as used with HTTP for web APIs, so if you're familiar with those, you'll quickly pick up CoAP. If not, you might find this presentation useful for context. The idea is that each HTTP method has a semantic meaning, e.g. GET requests information from the device without changing anything and POST, PUT and DELETE mutate the data.

As you say, publish/subscribe models wouldn't work for a situation where your device acts as a 'server' to the central system coordinating (which acts as a client to each device). Instead, a model similar to HTTP is ideal, except HTTP has far too much overhead, which is where CoAP comes in.

Aurora0001
  • 18,520
  • 13
  • 55
  • 169
-1

I was wondering whether there are any existing protocols that are geared towards send and receiving commands and configuring remote devices?

Yes, there is a better protocol for device management in IoT. It is LwM2M - It is much more efficient than MQTT and above COAP, MQTT and HTTP.

LwM2M comes with a well-defined data and device management model, offering a variety of ready-to-use standard objects (IPSO Smart Objects), connectivity monitoring, remote device actions and structured FOTA and SOTA updates, whereas in MQTT these features are entirely vendor and platform-specific. What follows is that with MQTT, firmware updates or any other management features must be created from scratch. Contrastingly, LwM2M offers firmware upgrades as one of its basic functionalities, so there is no need to invent any new building blocks for communication.

Here you have comparison MQTT vs LwM2M and whole crash course.