@@ -67,25 +67,25 @@ type componentUpdateStatus struct {
6767
6868// RPCState represents the current OTA state for the RPC API
6969type RPCState struct {
70- Updating bool `json:"updating"`
71- Error string `json:"error,omitempty"`
72- MetadataFetchedAt time.Time `json:"metadataFetchedAt,omitempty"`
73- AppUpdatePending bool `json:"appUpdatePending"`
74- SystemUpdatePending bool `json:"systemUpdatePending"`
75- AppDownloadProgress float32 `json:"appDownloadProgress,omitempty"` //TODO: implement for progress bar
76- AppDownloadFinishedAt time.Time `json:"appDownloadFinishedAt,omitempty"`
77- SystemDownloadProgress float32 `json:"systemDownloadProgress,omitempty"` //TODO: implement for progress bar
78- SystemDownloadFinishedAt time.Time `json:"systemDownloadFinishedAt,omitempty"`
79- AppVerificationProgress float32 `json:"appVerificationProgress,omitempty"`
80- AppVerifiedAt time.Time `json:"appVerifiedAt,omitempty"`
81- SystemVerificationProgress float32 `json:"systemVerificationProgress,omitempty"`
82- SystemVerifiedAt time.Time `json:"systemVerifiedAt,omitempty"`
83- AppUpdateProgress float32 `json:"appUpdateProgress,omitempty"` //TODO: implement for progress bar
84- AppUpdatedAt time.Time `json:"appUpdatedAt,omitempty"`
85- SystemUpdateProgress float32 `json:"systemUpdateProgress,omitempty"` //TODO: port rk_ota, then implement
86- SystemUpdatedAt time.Time `json:"systemUpdatedAt,omitempty"`
87- SystemTargetVersion string `json:"systemTargetVersion,omitempty"`
88- AppTargetVersion string `json:"appTargetVersion,omitempty"`
70+ Updating bool `json:"updating"`
71+ Error string `json:"error,omitempty"`
72+ MetadataFetchedAt * time.Time `json:"metadataFetchedAt,omitempty"`
73+ AppUpdatePending bool `json:"appUpdatePending"`
74+ SystemUpdatePending bool `json:"systemUpdatePending"`
75+ AppDownloadProgress * float32 `json:"appDownloadProgress,omitempty"` //TODO: implement for progress bar
76+ AppDownloadFinishedAt * time.Time `json:"appDownloadFinishedAt,omitempty"`
77+ SystemDownloadProgress * float32 `json:"systemDownloadProgress,omitempty"` //TODO: implement for progress bar
78+ SystemDownloadFinishedAt * time.Time `json:"systemDownloadFinishedAt,omitempty"`
79+ AppVerificationProgress * float32 `json:"appVerificationProgress,omitempty"`
80+ AppVerifiedAt * time.Time `json:"appVerifiedAt,omitempty"`
81+ SystemVerificationProgress * float32 `json:"systemVerificationProgress,omitempty"`
82+ SystemVerifiedAt * time.Time `json:"systemVerifiedAt,omitempty"`
83+ AppUpdateProgress * float32 `json:"appUpdateProgress,omitempty"` //TODO: implement for progress bar
84+ AppUpdatedAt * time.Time `json:"appUpdatedAt,omitempty"`
85+ SystemUpdateProgress * float32 `json:"systemUpdateProgress,omitempty"` //TODO: port rk_ota, then implement
86+ SystemUpdatedAt * time.Time `json:"systemUpdatedAt,omitempty"`
87+ SystemTargetVersion * string `json:"systemTargetVersion,omitempty"`
88+ AppTargetVersion * string `json:"appTargetVersion,omitempty"`
8989}
9090
9191// HwRebootFunc is a function that reboots the hardware
@@ -221,35 +221,48 @@ func NewState(opts Options) *State {
221221}
222222
223223// ToRPCState converts the State to the RPCState
224+ // probably we need a generator for this ...
224225func (s * State ) ToRPCState () * RPCState {
225226 r := & RPCState {
226227 Updating : s .updating ,
227228 Error : s .error ,
228- MetadataFetchedAt : s .metadataFetchedAt ,
229+ MetadataFetchedAt : & s .metadataFetchedAt ,
229230 }
230231
231232 app , ok := s .componentUpdateStatuses ["app" ]
232233 if ok {
233234 r .AppUpdatePending = app .pending
234- r .AppDownloadProgress = app .downloadProgress
235- r .AppDownloadFinishedAt = app .downloadFinishedAt
236- r .AppVerificationProgress = app .verificationProgress
237- r .AppVerifiedAt = app .verifiedAt
238- r .AppUpdateProgress = app .updateProgress
239- r .AppUpdatedAt = app .updatedAt
240- r .AppTargetVersion = app .targetVersion
235+ r .AppDownloadProgress = & app .downloadProgress
236+ if ! app .downloadFinishedAt .IsZero () {
237+ r .AppDownloadFinishedAt = & app .downloadFinishedAt
238+ }
239+ r .AppVerificationProgress = & app .verificationProgress
240+ if ! app .verifiedAt .IsZero () {
241+ r .AppVerifiedAt = & app .verifiedAt
242+ }
243+ r .AppUpdateProgress = & app .updateProgress
244+ if ! app .updatedAt .IsZero () {
245+ r .AppUpdatedAt = & app .updatedAt
246+ }
247+ r .AppTargetVersion = & app .targetVersion
241248 }
242249
243250 system , ok := s .componentUpdateStatuses ["system" ]
244251 if ok {
245252 r .SystemUpdatePending = system .pending
246- r .SystemDownloadProgress = system .downloadProgress
247- r .SystemDownloadFinishedAt = system .downloadFinishedAt
248- r .SystemVerificationProgress = system .verificationProgress
249- r .SystemVerifiedAt = system .verifiedAt
250- r .SystemUpdateProgress = system .updateProgress
251- r .SystemUpdatedAt = system .updatedAt
252- r .SystemTargetVersion = system .targetVersion
253+ r .SystemDownloadProgress = & system .downloadProgress
254+ if ! system .downloadFinishedAt .IsZero () {
255+ r .SystemDownloadFinishedAt = & system .downloadFinishedAt
256+ }
257+ r .SystemVerificationProgress = & system .verificationProgress
258+ if ! system .verifiedAt .IsZero () {
259+ r .SystemVerifiedAt = & system .verifiedAt
260+ }
261+ r .SystemUpdateProgress = & system .updateProgress
262+ if ! system .updatedAt .IsZero () {
263+ r .SystemUpdatedAt = & system .updatedAt
264+ }
265+ r .SystemTargetVersion = & system .targetVersion
253266 }
254267
255268 return r
0 commit comments