Version info in firmware without using Blynk library

We are using Blynk to connect our devices using MQTT. Our firmware doe snot contain the Blynk library, we are managing sending and receiving of messages through MQTT topics ourselves.
The version of our firmware is determined by the git hash of the commit, so it is a 8 character hexadecimal string, and we publish that version through the info/mcu topic.

We want to publish new versions of the firmware using Blynk.Air, implementing receiving messages on the downlink/ota/json topic.
The documentation states that the payload on this topic will contain type, ver and build if Blynk.Cloud can extract this information from the uploaded OTA package file.

As we do not use the Blynk library, we cannot use the BLYNK_* defines to include this information in our binary. I assume that the Blynk library include this information in a recognizable form in the binary.

Is there another way to include this information in the binary so that Blynk.Cloud will recognize this info and include it in the json payload?

You don’t need the Blynk library to be used to add a line to your firmware file like:

#define BLYNK_FIRMWARE_VERSION "0.1.0"

I’m not sure how successful you’ll be when using an 8 character hex version number though.

Pete.

I don’t think that typing a #define somewhere in code without using it anywhere will result in anything in the binary. As I said, we are not using the Blynk library.

I assume that the Blynk library will use this define to include those version bytes in a fixed position, or on some other identifyable place in the binary. I would like to know how this is done, so I can use the same method in our binaries.

Bas

Pete.

Hi Pete, thanks for the link.

I would like to know how the version is parsed from the uploaded firmware, so I can prepare our binaries and make that parsing it will result in our githash versionstring.

In C/C++ just definining a macro with #define does not create any code or bytes in the binary. The macro has to be used somewhere. That is why I’m asking how the Blynk.libary is using the defines to include that data into the binary.

Bas

It would if you added an #ifdef and #endif

My limited understanding is that the Blynk library simply passes the version number to the server on startup, so you can see in the web console what software version your device is running. When using MQTT you’re passing this info yourself anyway.
Your challenge is to put the version number into the binary file so that it can be parsed by Blynk.Air.
I assume that the same challenge exists with BLYNK_TEMPLATE_ID and possibly BLYNK_TEMPLATE_NAME, because (as far as I’m aware) Blynk.Air checks that the template name is correct in the binary before allowing the OTA upload…

Pete.

Hi Bascy,

Approach you are looking for is located at blynk-library/src/BlynkApiArduino.h at 7a6fbdb630b05e6ca917ba07407e3b4eda7c81b4 · blynkkk/blynk-library · GitHub

Your fimware binary should contain such block of data to be recognised by Cloud and extracted version information.

Hope this helps!

Thank you very much Vasil, that was exactly what i was looking for.

I assume that the leading blnkinf\0 is the identification of the block somewhere in the binary?

What is the minimum info that is needed to use the binary with Blynk.Air?

Bas

You are welcome! I think you may omit all parameters inside under #define guards.

correct!

Ok.
When the firmware is uploaded for shipping with Blynk.Air,
does the interface check if the templateId is defined and the same as the devices I wanna deploy it to? Are there maybe any other checks done in Blynk.Air?

Hello.

Yes. This is the main check during OTA. Also, on the business plan, it’s allowed to skip this check (for the emergency cases, when for example, wrong firmware was uploaded to the hardware).

Yes. The other checks depend on your Shipment setup. Like time of the day, and what field to compare (firmware version, blynk friware version, build date, etc)

Thanks again!

I am a bit confused by the terminology used in the console, info block and Shipping interface.

The developer tools interface talks about

  • Board type: ESP (where does it get this?)
  • Firmware version: from /info/mcu/ver
  • Blynk library version: Where does it get this?
  • Template Id: from provisioning of device in console
  • Last build: from /info/mcu/build

The Shipping interface talks about (after analyzing a binary)

  • Version => from “mcu” string in info block?
  • Type => from “fw-type” string in info block
  • Hardware => Where is this comming from?
  • Firmware type: “MCU” What does this mean?
  • Build => from “build” string in info block

“/info/mcu” mqtt topic is using:

  • tmpl => where is this used?
  • ver => shows as formware version in developer tools and device info
  • type => where is this used?
  • build => shows as Last build in the developer tools

The info block inside a binary uses:

  • mcu
  • fw-type
  • blynk
  • dev
  • cpu
  • tmpl
  • build

Can you tell me which properties are compared with eachother when using Blynk.Air?

We take it either from the template settings:

Or from the device firmware (if the device uses blynk firmware - blynk firmware sends this info on the initial device login).

Blynk library version: Where does it get this?

It’s taken from blynk firmware (you can search by BLYNK_VERSION).

Yes.

It comes from the blynk firmware. It’s hardcoded there. This is the same value you should see as “Board type”.

Firmware type: “MCU” What does this mean?

Blynk currently has 2 types of firmware: MCU and NCP. The difference is explained here - Blynk.NCP overview | Blynk Documentation. To put it simple - if your hardware has 1 core - it’s MCU type (blynk firmware runs on the single core available, doing networking + app logic). If your hardware has multiple cores it may be a NCP type (meaning blynk firmware runs only on 1 core doing all the networking, while app logic is run on another core doing business logic).