<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/">
	<channel>
		<title>Author at Infinum</title>
		<atom:link href="https://infinum.com/blog/author/jurica-martincevic/feed/" rel="self" type="application/rss+xml" />
		<link></link>
		<description>Building digital products</description>
		<lastBuildDate>Fri, 17 Apr 2026 13:59:15 +0000</lastBuildDate>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>

					<item>
				<image>
					<url>19265798https://infinum.com/uploads/2025/05/Enhancing-Embedded-Devices-with-Firmware-Updates-hero.webp</url>
				</image>
				<title>Enhancing Embedded Devices with Firmware Updates</title>
				<link>https://infinum.com/blog/iot-embedded-devices-firmware-updates/</link>
				<pubDate>Mon, 01 Sep 2025 10:31:42 +0000</pubDate>
				<dc:creator>Jurica Martinčević</dc:creator>
				<guid isPermaLink="false">https://infinum.com/?p=19265798</guid>
				<description>
					<![CDATA[<p>Learn how to how to build a reliable update system that keeps your embedded IoT devices running smoothly in the field.</p>
<p>The post <a href="https://infinum.com/blog/iot-embedded-devices-firmware-updates/">Enhancing Embedded Devices with Firmware Updates</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</description>
				<content:encoded>
					<![CDATA[<div
	class="wrapper"
	data-id="es-280"
	 data-animation-target='inner-items'>
		
			<div class="wrapper__inner">
			<div class="block-blog-content js-block-blog-content">
	
<div class="block-blog-content-sidebar" data-id="es-92">
	</div>

<div class="block-blog-content-main">
	
<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-95"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-93">
	<p	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-94'
	>
	<strong>From bug fixes to new features, firmware updates are essential for a device’s evolution. Here’s how to build a reliable update system that keeps your embedded IoT devices running smoothly in the field.</strong></p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-98"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-96">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-97'
	>
	Updating firmware is a critical component in the lifecycle of any embedded IoT device. It provides flexibility during development, but also simplifies support and enables long-term feature evolution. In essence, firmware updates allow these devices to modify their current operational software to fix bugs, improve performance, or introduce new capabilities – like supporting <a href="https://infinum.com/blog/iot-data-business-value/" target="_blank" rel="noreferrer noopener">machine learning models that optimize business processes</a> using real-time IoT inputs.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-101"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-99">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-100'
	>
	Think of firmware as a program on a computer or a smartphone – except it’s designed specifically to run on embedded systems. Firmware updates can be performed wirelessly when a device is connected via Bluetooth or WiFi. This method is known as an Over-the-Air (OTA) update, or more specifically, Firmware Over-the-Air (FOTA), highlighting its remote and seamless execution.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-104"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-102">
	<h2	class='typography typography--size-52-default js-typography block-typography__typography'
	data-id='es-103'
	>
	Problems that firmware updates can solve</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-108"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-105">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-106'
	>
	<strong>Bug fixes</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-107'
	>
	Simple bugs can be addressed through code changes and library upgrades.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-112"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-109">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-110'
	>
	<strong>Introduction of new features</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-111'
	>
	More complex changes that expand device capabilities.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-116"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-113">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-114'
	>
	<strong>Security updates</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-115'
	>
	Resolving critical security issues.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-120"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-117">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-118'
	>
	<strong>Settings changes</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-119'
	>
	Modifying system configurations or default behaviors.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-123"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-121">
	<h2	class='typography typography--size-52-default js-typography block-typography__typography'
	data-id='es-122'
	>
	Potential issues with firmware updates</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-126"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-124">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-125'
	>
	While beneficial, firmware updates can also impose certain risks. If the update contains a bug, or worse, malicious code, it may cause problems with the device:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-130"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-127">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-128'
	>
	<strong><strong>Inability to update again</strong></strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-129'
	>
	Faulty updates may block future installations.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-134"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-131">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-132'
	>
	<strong>Bricked device</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-133'
	>
	Updates can render a device unusable.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-138"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-135">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-136'
	>
	<strong>Malicious firmware</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-137'
	>
	Unauthorized updates can compromise device security.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-141"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-139">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-140'
	>
	It is crucial to approach firmware updates with caution and ensure proper implementation. Otherwise, a poorly executed update might create more problems than it aims to solve.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-144"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-142">
	<h2	class='typography typography--size-52-default js-typography block-typography__typography'
	data-id='es-143'
	>
	How firmware updates work</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-147"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-145">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-146'
	>
	Enabling firmware updates on a device requires certain memory compromises. The device’s non-volatile memory (Flash memory) should be partitioned into three sections:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-151"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--number bullet__color--infinum block-bullet__bullet" data-id="es-148">
	<p	class='typography typography--size-14-text js-typography bullet__dot'
	data-id='es-149'
	>
	1</p>	<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-150'
	>
	Current firmware</h3>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-155"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--number bullet__color--infinum block-bullet__bullet" data-id="es-152">
	<p	class='typography typography--size-14-text js-typography bullet__dot'
	data-id='es-153'
	>
	2</p>	<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-154'
	>
	Update firmware</h3>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-159"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--number bullet__color--infinum block-bullet__bullet" data-id="es-156">
	<p	class='typography typography--size-14-text js-typography bullet__dot'
	data-id='es-157'
	>
	3</p>	<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-158'
	>
	Bootloader</h3>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-162"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-160">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-161'
	>
	The bootloader section can be just large enough to fit the bootloader, while the sections for the current firmware and the update must be equal in size and large enough to store the device firmware.&nbsp;</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-165"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-163">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-164'
	>
	To partition the Flash memory properly, a linker script should be used to ensure that the linker does not store parts of the code in the bootloader or update the firmware sections. Additionally, the application code should be compiled to execute from the start of the current firmware section to ensure correct jump addresses when running.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-168"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-166">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-167'
	>
	Bootloader</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-171"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-169">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-170'
	>
	A bootloader is essential for enabling firmware updates on the device. Its primary functions include optional firmware verification, installing new firmware, and jumping to the start of the application code. The firmware verification can be done either in the application code before entering the bootloader or within the bootloader itself. When the device boots, it always goes into the bootloader first.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-174"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-172">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-173'
	>
	The bootloader then checks if there is new firmware to install: if so, it performs the installation and eventually jumps to the start of the application code. Different methods can be used to notify the bootloader that new firmware is available, such as reading a specific Flash memory address set by the application after downloading the firmware.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-177"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-175">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-176'
	>
	Firmware updates involve several key steps:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-182"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--number bullet__color--infinum block-bullet__bullet" data-id="es-178">
	<p	class='typography typography--size-14-text js-typography bullet__dot'
	data-id='es-179'
	>
	1</p>	<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-180'
	>
	<strong>Receiving the firmware</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-181'
	>
	The device receives the new firmware in chunks and saves it in non-volatile memory. This can be done via Bluetooth, WiFi, UART, or CAN. Typically, it is done in the application code to ensure the device remains functional during download, and downtime is kept to a minimum.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-187"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--number bullet__color--infinum block-bullet__bullet" data-id="es-183">
	<p	class='typography typography--size-14-text js-typography bullet__dot'
	data-id='es-184'
	>
	2</p>	<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-185'
	>
	<strong>Verifying the firmware</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-186'
	>
	This step checks if the firmware is valid and authorized, preventing the installation of corrupted or unauthorized firmware that could be malicious.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-192"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--number bullet__color--infinum block-bullet__bullet" data-id="es-188">
	<p	class='typography typography--size-14-text js-typography bullet__dot'
	data-id='es-189'
	>
	3</p>	<div class="bullet__content">
		<h3	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-190'
	>
	<strong>Installing the firmware</strong></h3><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-191'
	>
	The installation process is performed in the bootloader. It involves overriding the current application code with the new firmware, which cannot be done while the application code is running. The bootloader transfers the new firmware from the temporary storage area (update firmware section) to the main operational area (current firmware section) of the Flash memory.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-195"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-193">
	<h2	class='typography typography--size-52-default js-typography block-typography__typography'
	data-id='es-194'
	>
	Remote firmware distribution</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-198"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-196">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-197'
	>
	There are two ways to initiate a firmware update: automatically and manually. The choice of how to start the update depends on the use case and the device&#8217;s connectivity capabilities, which can vary significantly in the IoT space.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-201"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-199">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-200'
	>
	Automatic firmware updates</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-204"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-202">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-203'
	>
	With automatic updates, the device takes charge of connecting to the server, checking for new firmware, and initiating the update. Users don&#8217;t have direct control over starting the update process.&nbsp;</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-207"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-205">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-206'
	>
	This approach is suitable for devices with continuous or intermittent connectivity or those with unstable connections. All that&#8217;s needed is to release the firmware update on the server. The device can be configured to start the update based on certain conditions, such as a specific time of day or reaching a particular state.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-210"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-208">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-209'
	>
	Manual firmware updates</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-213"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-211">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-212'
	>
	For a manual update, the user must trigger the firmware update process – highlighting the importance of <a href="https://infinum.com/blog/iot-user-experience/" target="_blank" rel="noreferrer noopener">designing clear, user-friendly interactions in IoT interfaces</a>. This can be done in various ways. It could be initiated by the device itself, using some form of user input available. Alternatively, another device could be used to start the update, or an external device might be employed to initiate the process. This type of update works for all types of devices, regardless of their connectivity, ranging from always connected to never connected.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-216"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-214">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-215'
	>
	Manual updates require user intervention to start the firmware update process. There are several ways to initiate this process:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-219"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="lists" data-id="es-217">
	<ul	class='typography typography--size-16-text-roman js-typography lists__typography'
	data-id='es-218'
	>
	<li>Directly on the device itself, using the input methods available</li><li>Through another connected device</li><li>Via external hardware</li></ul></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-222"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-220">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-221'
	>
	The advantage of manual updates is their versatility – they work with all types of devices regardless of connectivity status, from always-online devices to those with no regular network connection.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-225"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-223">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-224'
	>
	Updating non-connected devices</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-228"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-226">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-227'
	>
	Devices that are only connected on demand can be updated through Bluetooth connectivity solely for firmware updates. In this scenario, the device advertises itself and waits for a connection. The user can connect the device to a smartphone via Bluetooth, download the firmware update file to the smartphone, and then transfer it to the device to start the update.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-231"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-229">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-230'
	>
	Non-connected devices can also be updated manually using wired protocols like UART or CAN, or external storage devices like an SD card. The device can have a specific user input that triggers the firmware reception from the UART, SD card, or other wired protocol. If using UART, CAN, or any other wired protocol, there must be an external device to communicate with the main device being updated and to contain the firmware file.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-234"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-232">
	<h2	class='typography typography--size-52-default js-typography block-typography__typography'
	data-id='es-233'
	>
	Security measures in firmware updates</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-237"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-235">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-236'
	>
	Security is enforced primarily during the firmware validation step. The main goal is to ensure the received firmware is legitimate and free from tampering. Several essential steps fall under this category, including integrity checks, firmware decryption, and firmware signing checks. Some of these operations may involve asymmetric encryption, with the keys needing to be securely stored in encrypted Flash memory or protected against unauthorized access.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-240"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-238">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-239'
	>
	When both firmware encryption and firmware signing are in place, the following keys are typically found on the device:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-244"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-241">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-242'
	>
	<strong>Device private key</strong></p><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-243'
	>
	This key is known only to the device manufacturer and is used for firmware encryption.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-248"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-245">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text js-typography bullet__heading'
	data-id='es-246'
	>
	<strong>Manufacturer public key</strong></p><p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-247'
	>
	This key is employed for firmware signing and is made public by the manufacturer.</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-251"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-249">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-250'
	>
	Integrity check</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-254"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-252">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-253'
	>
	The integrity check step ensures that the received firmware is error-free during communication, detecting potential issues like bit-flips. The device calculates the hash of the received firmware using methods like md5, and compares it with the hash received along with the firmware. A match indicates that the received firmware is intact and uncorrupted, allowing the device to proceed to the next validation step. This step is crucial for preventing the installation of corrupted firmware that might lead to unexpected behavior.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-257"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-255">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-256'
	>
	Firmware decryption</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-260"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-258">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-259'
	>
	Firmware encryption is the process of encoding the firmware information to prevent unauthorized access to its content. When encrypting the firmware, the device&#8217;s public key is utilized. Upon receiving the firmware, the device uses its private key to decrypt the firmware for further processing.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-263"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-261">
	<h3	class='typography typography--size-36-text js-typography block-typography__typography'
	data-id='es-262'
	>
	Firmware signing check</h3></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-266"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-264">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-265'
	>
	Firmware signing involves encrypting the firmware with the manufacturer&#8217;s private key, which confirms that the firmware comes from the manufacturer. However, it is not practical to encrypt the entire firmware with the private key. Instead, only the firmware hash is encrypted, and cryptographic hash functions like SHA-256 are commonly employed for this purpose. This way, the device can validate the authenticity of the firmware by decrypting the hash using the manufacturer&#8217;s public key.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-269"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-267">
	<h2	class='typography typography--size-52-default js-typography block-typography__typography'
	data-id='es-268'
	>
	The importance of updating firmware</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-272"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-270">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-271'
	>
	As technology advances, digital services constantly evolve. With the continuous introduction of new products featuring the latest technologies and improved features, you can enhance your existing devices by simply updating their firmware, enabling your older hardware to keep up with the latest capabilities.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-275"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-273">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-274'
	>
	Firmware update capability has also become a legal requirement for products sold in the EU. The <a href="https://infinum.com/blog/cyber-resilience-act/">Cyber Resilience Act</a> mandates that manufacturers maintain security updates for the expected lifespan of a device — typically at least five years. Building a reliable OTA update system isn&#8217;t just good engineering practice; for any connected device on the EU market, it&#8217;s now a compliance obligation.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-278"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-typography" data-id="es-276">
	<p	class='typography typography--size-16-text-roman js-typography block-typography__typography'
	data-id='es-277'
	>
	<em>This article is adapted from our <a href="https://infinum.com/iot-implementation/" target="_blank" rel="noreferrer noopener">Guide to Successful IoT Implementation</a>, where we cover the technical foundations and strategic considerations behind building modern IoT solutions. For more insights, download the full guide.</em></p></div>	</div>
</div>
</div>		</div>
	</div><p>The post <a href="https://infinum.com/blog/iot-embedded-devices-firmware-updates/">Enhancing Embedded Devices with Firmware Updates</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</content:encoded>
			</item>
					<item>
				<image>
					<url>35038https://infinum.com/uploads/2023/03/JSONvsProtocols.webp</url>
				</image>
				<title>Data Exchange in Embedded Systems – JSON vs Protocol Buffers</title>
				<link>https://infinum.com/blog/json-vs-protocol-buffers/</link>
				<pubDate>Wed, 15 Mar 2023 13:56:27 +0000</pubDate>
				<dc:creator>Jurica Martinčević</dc:creator>
				<guid isPermaLink="false">https://infinum.com/?p=35038</guid>
				<description>
					<![CDATA[<p>Choosing between JSON and Protocol Buffers for data exchange in embedded systems affects performance, information transfer speed and the ease of use.</p>
<p>The post <a href="https://infinum.com/blog/json-vs-protocol-buffers/">Data Exchange in Embedded Systems – JSON vs Protocol Buffers</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</description>
				<content:encoded>
					<![CDATA[<div
	class="wrapper"
	data-id="es-473"
	 data-animation-target='inner-items'>
		
			<div class="wrapper__inner">
			<div class="block-blog-content js-block-blog-content">
	
<div class="block-blog-content-sidebar" data-id="es-281">
	</div>

<div class="block-blog-content-main">
	
<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-284"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-282">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-283'
	>
	Both JSON and Protocol Buffers can be used to exchange data between systems. The main difference between the two is that JSON is just text, while Protocol Buffers are binary.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-287"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-285">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-286'
	>
	This difference can have a significant impact on the performance and speed of information transfer between different devices. In this blog post, the speed of information transfer refers mainly to the size of the transmitted message, while the underlying protocol used to transmit and receive messages is a separate issue currently out of our scope. Basically, the smaller the message, the faster the transmission and reception.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-290"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-288">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-289'
	>
	However, the differences go beyond performance and speed of transfer, and another important aspect to consider is the ease of use. Depending on system requirements and priorities, either JSON or Protocol Buffers might prove to be the better option.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-293"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-291">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-292'
	>
	We’ll use the following message in C++ as the basis for our comparison:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-295"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-php github-light" data-language="php" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #d73a49;">class</span><span class="token"> </span><span class="token" style="color: #6f42c1;">TemperatureSensorReading</span><span class="token">
</span></span><span class="line"><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">public</span><span class="token">:</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #6f42c1;">TemperatureSensorReading</span><span class="token">(</span><span class="token" style="color: #d73a49;">const</span><span class="token"> </span><span class="token" style="color: #005cc5;">char</span><span class="token" style="color: #d73a49;">*</span><span class="token"> </span><span class="token" style="color: #005cc5;">id</span><span class="token">,</span><span class="token"> </span><span class="token" style="color: #d73a49;">int</span><span class="token"> </span><span class="token" style="color: #005cc5;">value</span><span class="token">)</span><span class="token"> </span><span class="token">:</span><span class="token"> </span><span class="token" style="color: #6f42c1;">sensor_id</span><span class="token">(</span><span class="token" style="color: #005cc5;">id</span><span class="token">)</span><span class="token">,</span><span class="token"> </span><span class="token" style="color: #6f42c1;">sensor_value</span><span class="token">(</span><span class="token" style="color: #005cc5;">value</span><span class="token">)</span><span class="token"> </span><span class="token">{</span><span class="token">}</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">int</span><span class="token"> </span><span class="token" style="color: #005cc5;">sensorId</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">float</span><span class="token"> </span><span class="token" style="color: #005cc5;">sensorValue</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token">}</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token" style="color: #005cc5;">TemperatureSensorReading</span><span class="token"> </span><span class="token" style="color: #6f42c1;">sensorReading</span><span class="token">(</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">temperature_sensor_1</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">,</span><span class="token"> </span><span class="token" style="color: #005cc5;">24</span><span class="token">)</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #6f42c1;">serialize_and_send</span><span class="token">(</span><span class="token" style="color: #d73a49;">&amp;</span><span class="token" style="color: #005cc5;">sensor_reading</span><span class="token">)</span><span class="token">;</span><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-298"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-296">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-297'
	>
	JSON</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-301"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-299">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-300'
	>
	JSON is a human-readable data interchange format based on key-value pairs contained inside of an object. Each JSON message must have at least one root object that contains key-value pairs or other objects. There are several data types in JSON, and the value of a key-value pair can be any one of them:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-304"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-302">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-303'
	>
	object</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-307"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-305">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-306'
	>
	array</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-310"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-308">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-309'
	>
	string</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-313"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-311">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-312'
	>
	number</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-316"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-314">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-315'
	>
	boolean</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-319"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-317">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-318'
	>
	null</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-322"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-320">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-321'
	>
	The key part of a key-value pair must always be a string type.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-325"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-323">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-324'
	>
	To send messages using JSON, we first need to create the data object. In C, this is a structure filled with values. The next part is serializing this object into the string. This string is then sent using the communication protocol of our choice. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-328"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-326">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-327'
	>
	To receive messages using JSON, we have to parse the received strings into objects that represent data in JSON messages. This means that in order to use JSON in your application, you only need a JSON parser that parses and serializes JSON messages.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-331"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-329">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-330'
	>
	Most popular programming languages have native or third-party support for JSON. For example, Python has a native JSON parser, while C/C++ uses third-party libraries for JSON parsers.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-334"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-332">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-333'
	>
	If we want to use JSON to send the message from our example, we’ll first have to serialize the object representing the message into a JSON-formatted string. This string is then transmitted. If we use a logic analyzer to listen for data on the transmission lines, we’ll see the next string to be transmitted:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-336"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-php github-light" data-language="php" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token">{</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">sensorId</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">:</span><span class="token"> </span><span class="token" style="color: #005cc5;">32</span><span class="token">,</span><span class="token" style="color: #032f62;">&quot;</span><span class="token" style="color: #032f62;">sensorValue</span><span class="token" style="color: #032f62;">&quot;</span><span class="token">:</span><span class="token"> </span><span class="token" style="color: #005cc5;">24</span><span class="token" style="color: #005cc5;">.</span><span class="token" style="color: #005cc5;">5</span><span class="token">}</span><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-339"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-337">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-338'
	>
	This string is 36 characters long, but the information content of the string is only 6 characters long. This means that about 16% of transmitted data is actual data, while the rest is metadata. The ratio of useful data in the whole message is increased by decreasing key length or increasing value size, for example, when using a string or array.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-342"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-340">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-341'
	>
	Protocol Buffers</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-345"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-343">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-344'
	>
	Protocol Buffers are Google&#8217;s mechanism for serializing structured data that uses a binary format to transfer messages. Because of their small memory footprint, Protocol Buffer messages can also be used for data storage, especially on devices with limited memory, like embedded systems. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-348"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-346">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-347'
	>
	For example, if an embedded system needs to buffer messages in the flash or EEPROM memory because the connection is down, it’s convenient to store Protocol Buffer messages right in that memory. There’s no need to convert them into more basic data structures as they are already designed to be compact.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-351"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-349">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-350'
	>
	Using Protocol Buffers in your code is slightly more complicated than using JSON. With JSON, all we need to do is include a library, unless of course we are writing the parser ourselves, while Protocol Buffers require a couple more steps. The user must first define a message using the <code>.proto</code> file. This file is then compiled using Google’s protoc compiler, which generates source files that contain the Protocol Buffer implementation for the defined messages.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-354"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-352">
	<p	class='typography typography--size-20-text-roman js-typography block-paragraph__paragraph'
	data-id='es-353'
	>
	This is how our message would look in the <code>.proto</code> definition file:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-356"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-php github-light" data-language="php" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #005cc5;">message</span><span class="token"> </span><span class="token" style="color: #005cc5;">TemperatureSensorReading</span><span class="token"> </span><span class="token">{</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #005cc5;">optional</span><span class="token"> </span><span class="token" style="color: #005cc5;">uint32</span><span class="token"> </span><span class="token" style="color: #005cc5;">sensor_id</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #005cc5;">1</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #005cc5;">optional</span><span class="token"> </span><span class="token" style="color: #d73a49;">float</span><span class="token"> </span><span class="token" style="color: #005cc5;">sensor_value</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #005cc5;">2</span><span class="token">;</span><span class="token">
</span></span><span class="line"><span class="token">}</span><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-359"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-357">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-358'
	>
	Google supports most common languages like Python, Java, and C++. Unfortunately, there is no official support for C even though it’s a language widely used for embedded development, but there are third-party implementations that offer Protocol Buffers for C.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-362"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-360">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-361'
	>
	When we serialize the message from our example, it’s only 7 bytes long. This can be confusing at first because we would expect <code>uint32</code> and <code>float</code> to be 8 bytes long when combined. However, Protocol Buffers won’t use all 4 bytes for <code>uint32</code> if they can encode the data in fewer bytes. In this example, the <code>sensor_id</code> value can be stored in 1 byte. It means that in this serialized message, 1 byte is metadata for the first field, and the field data itself is only 1 byte long. The remaining 5 bytes are metadata and data for the second field; 1 byte for metadata and 4 bytes for data because float always uses 4 bytes in Protocol Buffers. This gives us 5 bytes or 71% of actual data in a 7-byte message.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-365"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-363">
	<h2	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-364'
	>
	Field types</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-368"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-366">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-367'
	>
	The field can have any of the data types from the list below. These data types determine how the data is encoded, or in other words, how many bytes the specified field takes up in the encoded message.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-371"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-369">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-370'
	>
	<code>float</code>, <code>double</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-374"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-372">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-373'
	>
	<code>int32</code>, <code>int64</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-377"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-375">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-376'
	>
	<code>uint32</code>, <code>uint64</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-380"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-378">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-379'
	>
	<code>sint32</code>, <code>sint64</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-383"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-381">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-382'
	>
	<code>fixed32</code>, <code>fixed64</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-386"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-384">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-385'
	>
	<code>sfixed32</code>, <code>sfixed64</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-389"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-387">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-388'
	>
	<code>bool</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-392"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-390">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-391'
	>
	<code>string</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-395"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-393">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-394'
	>
	<code>Bytes</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-398"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-396">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-397'
	>
	<code>enum</code></p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-401"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-399">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-400'
	>
	Each of the above types is best suited for a certain type of data. For example, both <code>int32</code> and <code>sint32</code> can encode signed integers but <code>sint32</code> is more efficient when encoding negative numbers, so if you only use negative numbers in the specified field, it is better to use <code>sint32</code> or <code>sint64</code>. If you’re using both positive and negative numbers, then you should use <code>int32</code> or <code>int64</code>. The enum type allows us to specify a list of possible values.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-404"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-402">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-403'
	>
	Depending on the language used, the types in the generated code may also differ. For example, in Python, the bytes type is str type in Python2 and bytes type in Python3. Bytes are also converted into strings in C++, PHP, and ByteString in Java.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-407"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-405">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-406'
	>
	Most of the above types are variable-length. This means that even if the type is named <code>int32</code>, it might not take 4 bytes. This is the property that enables Protocol Buffer messages to have a small memory footprint. The exceptions are <code>fixed32</code>, <code>fixed64</code>, <code>sfixed32</code>, and <code>sfixed64</code>, which are 4 and 8 bytes.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-410"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-408">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-409'
	>
	Protocol Buffers allow for message nesting, which means that we can define one message and use it as a field type in a different one.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-413"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-411">
	<h2	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-412'
	>
	Field rules</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-416"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-414">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-415'
	>
	These rules define how to fill the fields when creating the message. If we fill the fields in a different way from the one specified in the field rules, the message won’t be formed well, and depending on the version of the encoder, it might fail at encoding. There are three types of field rules:</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-419"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-417">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-418'
	>
	required</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-422"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-420">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-421'
	>
	optional</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-425"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="bullet bullet--left bullet__type--dot bullet__color--infinum block-bullet__bullet" data-id="es-423">
			<div class="bullet__dot"></div>
		<div class="bullet__content">
		<p	class='typography typography--size-20-text-roman js-typography bullet__paragraph'
	data-id='es-424'
	>
	repeated</p>	</div>
</div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-428"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-426">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-427'
	>
	The <code>optional</code> rule is the most common one because it offers the most flexibility. With this rule, messages can be sent without setting some of the fields. If we have a message with a number of fields and we rarely need to send all of them, we can fill only those with changing values while leaving the rest unfilled. This will, in turn, decrease the encoded message size. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-431"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-429">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-430'
	>
	Another use case for this rule is the situation when a field is no longer needed. Instead of updating the firmware, we can just stop sending that one field.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-434"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-432">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-433'
	>
	The <code>required</code> rules must be used carefully because it can be difficult to make changes to this field when changing a message. For example, this rule can be used for a <code>version</code> field, the field you can use when you’re defining your own message. This is useful because you can change the Protocol Buffer message structure later on and still receive old versions of a message, and this field helps us determine what version the device is using. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-437"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-435">
	<h2	class='typography typography--size-36-text js-typography block-heading__heading'
	data-id='es-436'
	>
	Field Numbers</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-440"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-438">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-439'
	>
	Field numbers are used to identify fields in the received message since the message is in binary format. Once a field number is assigned to a field, it can’t be used for another field. If the field is removed, its field number should not be reused for another field. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-443"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-441">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-442'
	>
	The reasoning is that when a field is removed, some devices can send the message with this removed field, but when we receive it, the removed field won’t be in the data structure. This allows us to add new fields in the message and send it to the device without updating the firmware of the receiving device. The new fields will simply be ignored by the receiving device.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-446"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-444">
	<p	class='typography typography--size-20-text-roman js-typography block-paragraph__paragraph'
	data-id='es-445'
	>
	Numbers from 1 to 15 take 1 byte of memory and should be used for the most frequently used fields. Numbers from 16 to 2047 use 2 bytes and should be used for less frequent fields or very long ones, like long strings where the one extra byte doesn’t contribute much to the overall message size. This saves one byte field for more frequent fields we might need in the future.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-449"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-447">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-448'
	>
	JSON vs Protocol Buffers</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-452"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-450">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-451'
	>
	When comparing the use of JSON and Protocol Buffers for communication purposes, we can observe some key differences. Getting started with JSON is simpler than with Protocol Buffers. To start using JSON, just download the library and start using it in the code. Protocol Buffers are more complex at first because they require us to define messages in <code>.proto</code> files, install the protoc compiler, compile these messages to generate headers and sources, and import libraries like <code>nanopb</code> for C. On the other hand, JSON messages take up more space when serialized, while Protocol Buffers messages take up less space than JSON messages when encoded.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-454"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-highlighted-text">
	<p	class='typography typography--size-24-text js-typography block-highlighted-text__typography'
	data-id='es-453'
	>
	Protocol Buffers offer a way to convert JSON to a Protocol Buffer message and vice versa. This allows for more flexibility when dealing with devices that communicate with each other, some using JSON and some using Protocol Buffers. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-457"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-455">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-456'
	>
	If we have a battery-powered embedded device, server, and web client, we can use Protocol Buffers for communication between the embedded device and the server, then convert the Protocol Buffer message to JSON on the server side, and then use it in communication between the server and the web client.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-460"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-458">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-459'
	>
	If we assume that the server application is written in Python and uses the message defined above, then we can receive a message, convert it into JSON, and save it in the NoSQL database, where we can later read it when a web client requests data.</p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-462"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-code">
	<pre class="phiki language-php github-light" data-language="php" style="background-color: #fff;color: #24292e;"><code><span class="line"><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> Import Protocol Buffer  JSON conversion package</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token" style="color: #005cc5;">from</span><span class="token">  </span><span class="token" style="color: #005cc5;">google</span><span class="token" style="color: #d73a49;">.</span><span class="token" style="color: #005cc5;">protobuf</span><span class="token"> </span><span class="token" style="color: #005cc5;">import</span><span class="token"> </span><span class="token" style="color: #005cc5;">json_format</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> This file is generated by protoc from .proto file.</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token" style="color: #005cc5;">import</span><span class="token"> </span><span class="token" style="color: #005cc5;">temperature_sensor_reading_pb2</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">...</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">while</span><span class="token">(</span><span class="token" style="color: #005cc5;">True</span><span class="token">)</span><span class="token">:</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> Receive Protocol Buffer message from the sensor.</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #005cc5;">temperatureSensorReading</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #005cc5;">temperature_sensor_reading_pb2</span><span class="token" style="color: #d73a49;">.</span><span class="token" style="color: #6f42c1;">TemperatureSensorReadingJSON</span><span class="token">(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #d73a49;">if</span><span class="token"> </span><span class="token">(</span><span class="token" style="color: #6f42c1;">receive_message</span><span class="token">(</span><span class="token" style="color: #005cc5;">temperatureSensorReadingJSON</span><span class="token">)</span><span class="token">)</span><span class="token">:</span><span class="token">
</span></span><span class="line"><span class="token">        </span><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> Convert message to JSON.</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token">        </span><span class="token" style="color: #005cc5;">temperatureSensorReadingJSON</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #005cc5;">json_format</span><span class="token" style="color: #d73a49;">.</span><span class="token" style="color: #6f42c1;">MessageToJson</span><span class="token">(</span><span class="token" style="color: #005cc5;">temperatureSensorReading</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">
</span></span><span class="line"><span class="token">        </span><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> Save JSON to NoSQL database.</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token">        </span><span class="token" style="color: #6f42c1;">save_to_database</span><span class="token">(</span><span class="token" style="color: #005cc5;">temperatureSensorReadingJSON</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">...</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #005cc5;">def</span><span class="token"> </span><span class="token" style="color: #6f42c1;">GET_Handler</span><span class="token">(</span><span class="token">)</span><span class="token">:</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> Read from the NoSQL database directly in JSON format.</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #005cc5;">temperatureSensorReadingJSON</span><span class="token"> </span><span class="token" style="color: #d73a49;">=</span><span class="token"> </span><span class="token" style="color: #6f42c1;">read_from_database</span><span class="token">(</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #6a737d;">#</span><span class="token" style="color: #6a737d;"> Send response.</span><span class="token" style="color: #6a737d;">
</span></span><span class="line"><span class="token">    </span><span class="token" style="color: #6f42c1;">send_resp</span><span class="token">(</span><span class="token" style="color: #005cc5;">temperatureSensorReadingJSON</span><span class="token">)</span><span class="token">
</span></span><span class="line"><span class="token" style="color: #d73a49;">...</span><span class="token">
</span></span></code></pre></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-465"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-heading" data-id="es-463">
	<h2	class='typography typography--size-52-default js-typography block-heading__heading'
	data-id='es-464'
	>
	The choice is yours</h2></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-468"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-466">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-467'
	>
	Since both protocols are valid options, the choice between JSON and Protocol Buffers will depend on the use case. We should first think about the needs of our embedded device that communicates with the app or the backend in terms of how much data is transmitted and what kind of data is transmitted, for example. </p></div>	</div>

<div
	class="wrapper wrapper__use-simple--true"
	data-id="es-471"
	 data-animation='slideFade' data-animation-target='inner-items'>
		
			<div class="block-paragraph" data-id="es-469">
	<p	class='typography typography--size-16-text-roman js-typography block-paragraph__paragraph'
	data-id='es-470'
	>
	With embedded devices that do not communicate heavily with applications or the backend, there’s not much difference what protocol you decide to use since only a small portion of processing power is diverted to the communication itself. Of course, there can be exceptions, like when the device is battery-powered and communicates using some wireless method. In that case, it would be preferable to use Protocol Buffers to minimize radio transmission time, as this operation can consume a significant amount of energy.</p></div>	</div>
</div>
</div>		</div>
	</div><p>The post <a href="https://infinum.com/blog/json-vs-protocol-buffers/">Data Exchange in Embedded Systems – JSON vs Protocol Buffers</a> appeared first on <a href="https://infinum.com">Infinum</a>.</p>
]]>
				</content:encoded>
			</item>
		
	</channel>
</rss>