Converting firmware string to an integer,

Hi,

I want to display BLE ScannerApp firmware version on a log file. How can i be able to Covert the firmware string to an integer so that I can write it in the log using Log_write. Log_write only accepts Integer.

Thanks in advance

Hello @Feelit,
to convert the firmware version string into an integer you could do for example the following conversion.
Since the length of the “fwrev” string is not given, for the BleApp_EvtDevinfo() callback, it is a good idea to check the length of the string, before accessing the individual bytes.

Convert_fw_version()
{
  new fwrev{6+1} = "01v001";
  new fw_major;
  new fw_minor;

  // Check if the string has the expected length
  if(strlen(fwrev) != 6)
    return(ERROR);

  // Calculate the major/minor version based on the firmware version string
  fw_major = ((fwrev{0} - '0') * 10) + (fwrev{1} - '0');
  fw_minor = ((fwrev{3} - '0') * 100) + ((fwrev{4} - '0') * 10) + (fwrev{5} - '0'); 
  #log("%02dv%03d", fw_major, fw_minor);
 
  // NOTE: Two separate Log_write() calls necessary

  return(OK);
}

Using this example you should be able to use the Log_write() function you are describing.
With two calls to the Log_write() function you can log the major and minor version of the firmware version string.

Kind regards,
Stefan