Skip to content

Commit af0e468

Browse files
committed
added firmware size
1 parent 4807cdf commit af0e468

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

internal/ota-api/dto.go

+6-4
Original file line numberDiff line numberDiff line change
@@ -217,15 +217,15 @@ func formatStateData(state, data string, firmware_size int64, hasReceivedFlashSt
217217
return data
218218
}
219219
if hasReceivedFlashState {
220-
return buildSimpleProgressBar(float64(100))
220+
return buildSimpleProgressBar(float64(100), firmware_size)
221221
}
222222
percentage := (float64(actualDownloadedData) / float64(firmware_size)) * 100
223-
return buildSimpleProgressBar(percentage)
223+
return buildSimpleProgressBar(percentage, firmware_size)
224224
}
225225
return data
226226
}
227227

228-
func buildSimpleProgressBar(progress float64) string {
228+
func buildSimpleProgressBar(progress float64, fw_size int64) string {
229229
progressInt := int(progress) / 10
230230
progressInt = progressInt * progressBarMultiplier
231231
maxProgress := 10 * progressBarMultiplier
@@ -235,7 +235,9 @@ func buildSimpleProgressBar(progress float64) string {
235235
bar.WriteString(strings.Repeat(" ", maxProgress-progressInt))
236236
bar.WriteString("] ")
237237
bar.WriteString(strconv.FormatFloat(progress, 'f', 2, 64))
238-
bar.WriteString("%")
238+
bar.WriteString("% (firmware size: ")
239+
bar.WriteString(strconv.FormatInt(fw_size, 10))
240+
bar.WriteString(" bytes)")
239241
return bar.String()
240242
}
241243

0 commit comments

Comments
 (0)