Code optimization with Stm32 Cube IDE

I’m using STM32 Cube IDE suite for STM32 development. This suite is based on Eclipse and GCC and it works quite well. In a recent project I was looking for some optimization I could apply on top of the basic existing settings to reduce the FLASH and RAM size.

In this post I want to share what I found and how it helped me.

Continue reading

10 things you can’t ignore when writing a Firmware

When you write an IoT firmware, there are different things you may never forget to think about… The coming 10 things you can’t ignore are coming from my experience of smart object creation and the associated field experience.

The field experience is unfortunately the real step where you will improve your firmware and discover all you have forgotten when you have written the firmware and tested it in your laboratory. In laboratory everything is perfect.

The following 10 things you can’t ignore when writing a Firmware is a non exhaustive checklist of points to verify before pushing your code to the field. It is also a list of  test conditions you can execute to validate a Firmware / device made by a third party.

Continue reading

MongoDB collection format mass modifications

MongoDB is a NoSQL database and one of the main difference compared to relational DB is you can put in your collection documents with different structure. In fact you don’t really care about structure of documents and type of data you are storing.

This is particularly true when you start using your Mongo instance with langage like PHP or JS where the langage itself does not manage data type explicitly.

As a consequence your document format may not be optimized (like storing numbers in String and making search on them later) and once you decide to move your backend to a more structured language like Java you start to have to make this more robust and organized. At this point you may want to reformat your documents to match the right type, eventually update your previous documents to a new version.

This kind of operation can be done “easily” with Mongo scripting language. This post will details 2 of the current structure to manipulate and transform Documents.

Continue reading

SpringBoot – Mongo / Create a Mutex to synchronize multiple frontends

When deploying a API in a scalable environment we usually try tom implement a stateless solution to avoid parallelism conflicts between the different nodes.

This works well for event management synchronously executed. But in some case these event need to have a part of the work managed asynchronously. It was my was my case when I had to process alarm report potentially generating multiple communications with execution time not predictable. To manage this I decided to process theses operation asynchronously. There are multiple architecture for managing this like Queuing (my preferred) of dedicate asynchronous engine. I’ve in fact preferred another way to do it for keeping my infrastructure more simple : adding in all of my nodes a batch function processing the alarms asynchronously.

The alarm events are written into the database and processed by the first of the batch taking it. This allow to preserve a fully redundant and simple architecture. That said I need to ensure only one of the process will execute this process at a time and potentially split the work to do between all the nodes. For making this I had to create a mutex solution.

This post describes the way to create a Mutex solution based on MongoDB with Spring Boot.

Continue reading

SpringBoot and JWT security

When creating an API you can manage a “session” with a JWT Json Web Tokens ensuring the user has login previously.

This post explains how JWT is working and how to implement it with SpringBoot using user identity stored in a Database.

This is based on a real implementation and is the sum of lots of search on Internet to make it correctly working.

Continue reading

SpringBoot webservices full example

SpringBoot is a really efficient framework for creating webservices and much more. For this reason I’m using it to design my backend applications.

This framework is also well referenced on Internet and many people are downloading it and using it. All of this sounds really good and you will see you can make a webservice in less than 5 minutes following the many examples existing on Internet. As usually in this kind of technology once you have made the classical HelloWorld and university classical practices you have a lot of difficulties to make your first real program coupling different simple use-cases. So As I spent a couple of hours searching solution on Internet, this post will give you a full example of a project getting data from a MongoDB instance to provide a simple webservice.

Continue reading

Gcc – wrap a function in a closed archive

Here is the situation : you have a function in an archive but you do not have the source code. And you would like to change the behavior of this function or intercept the call to this function.

This is possible with gcc and the -Wl,-wrap linker options. Thanks to this option you can create a new function starting by __wrap_ followed by the function name. This function will be called instead of the original one. In the function you can decide to call the original function by using its name starting by __real_

Continue reading

Update Telecom Design SDK from 5 to 6.3.4

TD1204 / Sigfox & GPS

TD1204 / Sigfox & GPS

New version of the Telecom design SDK has been released for TD1208 / TD1208R / TD1204 and now officially supporting TD1205.

This new version provide some bug fixes, like a crash after 21285 transmissions that could be after 212 days in case of full use… some I had in touch with could be interested… @pioupiou and also a bug that disable gpio interrupt after sigfox transmission (I experimented it !)

For the main evolution, this version is supporting FCC and TD1508 and improving sigfox transmissions.

From my experience, this version is also a good way to decrease the size of your binary files.

This post is about upgrading from a SDK 5 to SDK6 and the impact you can when recompiling your projects.

To install the SDK from scratch, just follow the well documented official post here.

Continue reading