<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Dan</title>
    <description>The latest articles on Forem by Dan (@daniftodi).</description>
    <link>https://forem.com/daniftodi</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3381%2F304224.jpeg</url>
      <title>Forem: Dan</title>
      <link>https://forem.com/daniftodi</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/daniftodi"/>
    <language>en</language>
    <item>
      <title>Cloud-Native</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Sun, 27 Sep 2020 08:25:02 +0000</pubDate>
      <link>https://forem.com/daniftodi/cloud-native-3d18</link>
      <guid>https://forem.com/daniftodi/cloud-native-3d18</guid>
      <description>&lt;p&gt;This article describes how a Cloud Native application should look like, it is based on the well known 12 Factors.&lt;/p&gt;

&lt;p&gt;At the moment of writing this article, in my understanding, the Cloud Native is not only about code that developers write, but it is also a way of organizing engineering teams so that their work will be highly effective, flexible code, and at the end, you have fast time-to-market for your applications.&lt;/p&gt;

&lt;p&gt;In articles that I read, Cloud Native is strongly related to software as a service, Continuous Integration, Continuous delivery, Zero-downtime deployments, and teams that are deploying daily.&lt;/p&gt;

&lt;h1&gt;Codebase&lt;/h1&gt;

&lt;h4&gt;One codebase tracked in revision control, many deploys&lt;/h4&gt;

&lt;p&gt;This principle says that your codebase should produce one executable, you don’t produce multiple executables from one repository and you don’t maintain multiple repositories that and the end is used to produce one executable.&lt;/p&gt;

&lt;p&gt;When you have one repository that produces multiple executables is not good because easily you may end up messing models and some of your application doing work that they are not responsible for.&lt;/p&gt;

&lt;p&gt;Having multiple repositories that are used to produce one binary is hard to maintain and hard to evolve – after-all we are humans and we don’t have an infinite capacity to keep things in our memory, it is hard to work when multiple repositories are used to produce a single app.&lt;/p&gt;

&lt;h1&gt;Dependencies&lt;/h1&gt;

&lt;h4&gt;Explicitly declare and isolate dependencies&lt;/h4&gt;

&lt;p&gt;Your application should not make the assumption that it will run in an environment where some libraries or dependencies are available, or any tool is available, or the database is available on the same host or even it has access to storage.&lt;/p&gt;

&lt;p&gt;When writing applications for the cloud you make them stateless, they make zero assumptions about the env when they are going to run, storage/mail/database are external services that are pluggable using configurations.&lt;/p&gt;

&lt;p&gt;The only assumption that you can make is that your application has access to CPU and memory.&lt;/p&gt;

&lt;p&gt;The benefit of not having external dependencies is that it simplifies the application setup at different stages, developers setup the development-environment easily, the staging and production environments are easy to configure.&lt;/p&gt;

&lt;h1&gt;Configs&lt;/h1&gt;

&lt;h4&gt;Store config in the environment&lt;/h4&gt;

&lt;p&gt;Configuration of an application are the things that vary between environments:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dan.iftodi.com/2020/09/cloud-native/#backing-services"&gt;backing services&lt;/a&gt; like Memcached host, database resources&lt;/li&gt;
&lt;li&gt;credentials to your cloud provider or Facebook app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sometimes application store configurations in code as constants, some tools make this easy to do (example injecting a Value using Spring and providing a default value).&lt;/p&gt;

&lt;p&gt;In the 12 Factors, an application should store the configurations in the environment variables, configurations are easy to change and they are not written in a single file and prefixed with dev.&lt;em&gt;, prod.&lt;/em&gt; etc.&lt;/p&gt;

&lt;p&gt;There are tools like &lt;a href="https://spring.io/projects/spring-cloud-config"&gt;Spring Cloud Config&lt;/a&gt; or &lt;a href="https://github.com/Netflix/archaius"&gt;Netflix Archaius&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Read full article on my blog: &lt;a href="https://dan.iftodi.com/2020/09/cloud-native/"&gt;Cloud Native&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cloud</category>
      <category>native</category>
      <category>twelve</category>
      <category>factors</category>
    </item>
    <item>
      <title>Remote invoke methods on your micro controller</title>
      <dc:creator>Dan</dc:creator>
      <pubDate>Tue, 03 Oct 2017 08:42:00 +0000</pubDate>
      <link>https://forem.com/daniftodi/remote-invoke-methods-on-your-micro-controller-999</link>
      <guid>https://forem.com/daniftodi/remote-invoke-methods-on-your-micro-controller-999</guid>
      <description>&lt;p&gt;Few months ago I started to create a small device that will turn on/off the lights in my room, I needed this feature because in the evening I like to read, but turning off lights is a little bit painful because I have to stand up of my bed.&lt;/p&gt;

&lt;p&gt;I've been started with ESP8266 controller because of incorporated Wifi and low price. First version of code used HTTP requests and executed actions based on GET calls (ex: put HIGH value on pin 13 was /action?pin=13&amp;amp;output=1 ), after first version I understood that controlling lights in other rooms will not be possible using the same code, project wasn't extendable in a easy way, I had to tune code for each room, adding additional parameter in request wasn't a good solution because I had to write source code on micro-controller customized for each device/room), also I had to remember IP addresses for calling actions. &lt;/p&gt;

&lt;p&gt;Imagine a mobile application where you have to add IP addresses for each device you want to control and you have to handle situation when your IP addresses changes - it's not that easy and UX will be a bad one.&lt;/p&gt;

&lt;p&gt;Knowing drawbacks and writing new requirements, my decision was to rewrite the project from scratch using MQTT as data transfer protocol.&lt;/p&gt;

&lt;p&gt;After reading some articles about MQTT, I've decided to write code that will allow to control unlimited devices and as additional requirement I wanted to use the same code to control other things from my house ( like reading temperature from sensors or writing/reading from analog pins ) with easy and minimal setup, without editing the source code for each micro controller.&lt;/p&gt;

&lt;p&gt;I started with idea that a small "core" should execute any methods that it knows about and they should be callable over MQTT. At this moment you can use MetalIO, add your methods in /src/functions and just register them in /src/main.cpp:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//create new instance
auto digitalWriteFunction = new DigitalWriteFunction("digitalWrite");
//register to metalio core
metal-&amp;gt;put(digitalWriteFunction);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can call your method over MQTT as:&lt;br&gt;
publish a message to your configured topic ( ex: /actions/room1 )&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;digitalWrite:13,1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;One important thing is that MetalIO is fully configurable over Wifi, when you start device and click on BTN1 ( or any button that you can choose at compilation time, "TRIGGER_PIN" parameter in platformio.ini ), your device will create a named AP where you can connect and see config interface ( default address: 192.168.1.4 )&lt;/p&gt;

&lt;p&gt;&lt;a href="https://camo.githubusercontent.com/26f41e1c89ff7d0dde3f1fff8972b19618878e10/687474703a2f2f692e696d6775722e636f6d2f56596a477163542e706e67" class="article-body-image-wrapper"&gt;&lt;img src="https://camo.githubusercontent.com/26f41e1c89ff7d0dde3f1fff8972b19618878e10/687474703a2f2f692e696d6775722e636f6d2f56596a477163542e706e67" width="200px"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this moment MetalIO software can be written on any ESPx, Arduino or Intel Galileo Board, configured over Wifi and any application/dashboard that supports MQTT can be used to communicate with hardware devices.&lt;/p&gt;

&lt;p&gt;Project can be found on GitHub: &lt;a href="https://github.com/daniftodi/metalio"&gt;https://github.com/daniftodi/metalio&lt;/a&gt;&lt;/p&gt;

</description>
      <category>esp32</category>
      <category>mqtt</category>
      <category>home</category>
      <category>automation</category>
    </item>
  </channel>
</rss>
