RDK Documentation (Open Sourced RDK Components)
deviceUpdateMgr.h
1 /*
2  * If not stated otherwise in this file or this component's Licenses.txt file the
3  * following copyright and licenses apply:
4  *
5  * Copyright 2016 RDK Management
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18 */
19 ////////////////////////////////////////////////////////////////////////////////////
20 //
21 // Device Update Manager API
22 //
23 // Name: iarm_device_update.h
24 // Date: 07/24/14
25 // Author: Sal
26 //
27 // This file contains the IARM API definition used by the Device Update Manager, the Device Update Proxy and, potentially,
28 // an Update Master to find, negotiate, and execute updating an image on a device.
29 //
30 // ** Entities **
31 //
32 // Device Update Manager - The primary module that is responsible for discovering and managing updating images on various
33 // devices. On initialization or at some configured times, the Device Update manager will scan
34 // the update sub-filesystem of the rootfs for new images and announce the found images on the IARM
35 // bus. This can be extended to communicating with a server to identify updates on an update server
36 // that can be pulled down and announced. The Device Update Manager will also be able to aggregate
37 // data about devices that are downloaded and downloaded sessions that are executed. It will be
38 // able to gate when downloads go to devices and when they are loaded on devices. And it will be
39 // able to officiate between multiple Device Update Proxy's requesting downloads over low bandwidth
40 // or highly utilized mediums.
41 //
42 // Device Update Proxy - Each class of devices will have a single Device Update Proxy responsible for managing updates to
43 // its child devices. A Device Update Proxy can represent multiple devices as long as they are in
44 // the same class. An example of this is remote controls. The Device Update Proxy will be responsible
45 // for listening for announcements and accepting updates for specific devices that are ready for an
46 // update. It is assumed the Device Update Proxy will know the version of devices it managers and can
47 // either contact them to notify them of the update or receive polls from them asking about an update.
48 // The Device Update Proxy is responsible for understanding the physical transport connecting devices
49 // to the STB and whether downloads to those devices must be serialized or can be parallelized (and
50 // how many can be parallelized). The Device Update Manager can also restrict parallelized downloads
51 // across the same or different transports. The Device Update Proxy is responsible for accepting
52 // download and load events, informing on the status of these events and negotiating the download with
53 // the device over the device specific protocol.
54 //
55 // Update Master - The system can be figured with a config file to allow the Device Update Manager to fully manage device
56 // update activities or to have a third entity, called the Update Master, to initiate either/or downloads
57 // and loads. An example of an Update Master would be a UI which would query the user if they wanted to
58 // load and/or download the code. In a typical usage, the UI would gate on the download, then perform an
59 // immediate download followed by an automatic load or would perform a background download followed by a
60 // gated load.
61 //
62 // ** IDs **
63 //
64 // deviceID - ID of a particular device marked for download by its Device Update Proxy. The device ID is assigned by the
65 // Device Update Proxy and is unique only within that Device Update Proxy.
66 //
67 // updateSessionID - The update of a particular image tied to a particular device is described and tracked by the
68 // updateSessionID. All calls after an update has been accepted for a device is tracked by this
69 // session ID.
70 //
71 // ** Standard Call/Event sequences **
72 //
73 // Background Download and Load during Non-usage Time (middle of night)
74 //
75 // #define IARM_BUS_DEVICE_UPDATE_MASTER_DOWNLOAD_ENABLED 0
76 // #define IARM_BUS_DEVICE_UPDATE_MASTER_LOAD_ENABLED 0
77 //
78 // 1) Device Update Manager performs check and finds new device image in update sub-filesystem in the rootfs.
79 // 2) Device Update Manager sends an ANNOUNCE event with details of the new image
80 // 3) The Device Update Proxy receives the Announce, decides a device it manages needs it and calls AcceptUpdate to
81 // register its intent with the Device Update Manager and get an updateSessionID.
82 // 4) When the Device Update Proxy negotiates with its managed device that a download is ready and confirms the device
83 // is ready and able to receive the download, it sends the READY_TO_DOWNLOAD event with all of the relevant information
84 // about the download it is taking.
85 // 5) The Device Update Manager sends a DOWNLOAD_INITIATE event to begin the download with backgroundDownload set to true.
86 // 6) The Device Update Proxy sends DOWNLOAD_STATUS events back for 0, the requested percent increments, and finally 100.
87 // 7) If, say, its 8 PM, the Device Update Manager sends a LOAD_INITIATE event with a timeToLoad of 25200 and a timeAfterInactive
88 // of 300 seconds which will put the download happening at 3 AM and after 5 minute of inactivity (just in case the user is
89 // still using it.
90 // 8) At 3:05 AM (presumably and approximately), the device begins the load causing the Device Update Proxy to send a LOAD_STATUS
91 // of BEGIN. The device does what it needs to do to load the new image, notifying the Device Update Proxy when done, which then
92 // sends ao LOAD_STATUS of END. This will complete the session.
93 //
94 // User confirmed Immediate Download and Load
95 //
96 // #define IARM_BUS_DEVICE_UPDATE_MASTER_DOWNLOAD_ENABLED 1
97 // #define IARM_BUS_DEVICE_UPDATE_MASTER_LOAD_ENABLED 0
98 //
99 // 1) Device Update Manager performs check and finds new device image in update sub-filesystem in the rootfs.
100 // 2) Device Update Manager sends an ANNOUNCE event with details of the new image
101 // 3) The Device Update Proxy receives the Announce, decides a device it manages needs it and calls AcceptUpdate to
102 // register its intent with the Device Update Manager and get an updateSessionID.
103 // 4) When the Device Update Proxy negotiates with its managed device that a download is ready and confirms the device
104 // is ready and able to receive the download, it sends the READY_TO_DOWNLOAD event with all of the relevant information
105 // about the download it is taking.
106 // 5) A UI agent would be listening for this event and would pop up a window asking the user if he wants to download X update
107 // for Y device.
108 // 6) The user would click yes and the UI agent would send a DOWNLOAD_INITIATE event to begin the download with backgroundDownload
109 // set to false with increments as desired to update status bar on the screen.
110 // 7) The Device Update Proxy sends DOWNLOAD_STATUS events back for 0, the requested percent increments, and finally 100. The UI
111 // agent would receive these events and update the status bar on the screen appropriately (also accounting there will be a load
112 // at the end).
113 // 8) When the Device Update Manager sees the 100% DOWNLOAD_STATUS, it would send a LOAD_INITIATE event with a timeToLoad of 0 and
114 // a timeAfterInactive of 0 causing the load to Immediately happen
115 // 9) The device immediately begins the load causing the Device Update Proxy to send a LOAD_STATUS
116 // of BEGIN. The device does what it needs to do to load the new image, notifying the Device Update Proxy when done, which then
117 // sends ao LOAD_STATUS of END. This will complete the session.
118 //
119 //
120 ////////////////////////////////////////////////////////////////////////////////////
121 
122 
123 /**
124 * @defgroup iarmmgrs
125 * @{
126 * @defgroup deviceUpdateMgr
127 * @{
128 **/
129 
130 
131 #define IARM_BUS_DEVICE_UPDATE_NAME "DeviceUpdateManager" /*!< IARM BUS name for Device Update Manager */
132 
133 #define IARM_BUS_DEVICE_UPDATE_PATH_LENGTH 512
134 #define IARM_BUS_DEVICE_UPDATE_ERROR_LENGTH 256
135 #define IARM_BUS_DEVICE_UPDATE_VERSION_LENGTH 32
136 #define IARM_BUS_DEVICE_UPDATE_DEVICE_NAME_LENGTH 64
137 
138 
139 //
140 // Update Master Control
141 //
142 // These defines should be moved into a config file in the implementation. They are used to indicate if the Device
143 // Update Manager should allow an Update Master, such as the XRE receiver, to initiate either the download or the load.
144 // This allows the Device Update Manager to defer to a UI based trigger to initiate either a full download or simply a load
145 // without a Device Update Proxy having any knowledge of the UI and without a code update to the Device Update Manager.
146 //
147 #define IARM_BUS_DEVICE_UPDATE_MASTER_DOWNLOAD_ENABLED 0
148 #define IARM_BUS_DEVICE_UPDATE_MASTER_LOAD_ENABLED 0
149 
150 //
151 // IARM_BUS_DEVICE_UPDATE_API_AcceptUpdate
152 //
153 // When a Device Update Proxy has received an announcement that it wants to use to update a device it manages. It
154 // will call the Device Update Manager with the file path of the update it is interested in, the deviceID it wants to
155 // update and will receive an updateSessionID that will identify the rest of the transactions in the download. A Device Update
156 // Proxy must call the AcceptUpdate RPC BEFORE it sends a ReadyToInstall event. A Device Update Proxy can call
157 // AcceptUpdate immediately for all of its devices or it can wait until it wants to download for each one. It should not send
158 // the ReadyToDownload event until it is ready to immediately download the device represented by the updateSessionID.
159 //
160 // deviceImageFilePath - IN: The download announced by the Device Update Manager when a new image is discovered in the filesystem.
161 // Allows the particular download to be identified and tracked.
162 //
163 // deviceID - IN: ID of the device accepting the download. Unique only amount devices of a particular type.
164 //
165 // updateSessionID - OUT: ID of the download session from here until final loading.
166 //
167 // interactiveDownload - OUT: Indicates if the UI will be involved in the download. The DUP will know to poll the device on every
168 // keypress.
169 //
170 // interactiveLoad - OUT: Indicates if the UI will be involved in the load. The DUP will know to poll the device on every
171 // keypress.
172 //
173 #define IARM_BUS_DEVICE_UPDATE_API_AcceptUpdate "AcceptUpdate"
174 
176  {
177  char deviceImageFilePath[IARM_BUS_DEVICE_UPDATE_PATH_LENGTH];
178  unsigned char deviceID;
179  unsigned int updateSessionID;
180  unsigned char interactiveDownload;
181  unsigned char interactiveLoad;
182 
184 
185 
186 typedef enum _DEVICE_Update_EventId_t
187 {
188  IARM_BUS_DEVICE_UPDATE_EVENT_ANNOUNCE = 0,
189  IARM_BUS_DEVICE_UPDATE_EVENT_READY_TO_DOWNLOAD,
190  IARM_BUS_DEVICE_UPDATE_EVENT_DOWNLOAD_INITIATE,
191  IARM_BUS_DEVICE_UPDATE_EVENT_DOWNLOAD_STATUS,
192  IARM_BUS_DEVICE_UPDATE_EVENT_LOAD_INITIATE,
193  IARM_BUS_DEVICE_UPDATE_EVENT_LOAD_STATUS,
194  IARM_BUS_DEVICE_UPDATE_EVENT_ERROR,
195  IARM_BUS_DEVICE_UPDATE_EVENT_MAX
196 
197 } IARM_Bus_DEVICE_Update_EventId_t;
198 
199 
200 //
201 // IARM_Bus_Device_Update_LoadDelayType_t
202 //
203 // LOAD_DEFAULT - Allows the Master or the Device Update Manager to defer to the Device Proxy to determine how to load.
204 //
205 // LOAD_NORMAL - Allows the Master or the Device Update Manager to defer to a number of seconds in the future as well as
206 // a time after inactivity. This setting will drive two other parameters: timeToLoad and timeAfterInactivity.
207 // If the LoadDelayType is LOAD_NORMAL then the device must wait timeToLoad seconds where the load does
208 // not happen. Immediately after the timeToLoad timer expires, if the timeAfterInactivity is non-zero, the
209 // device must wait timeAfterInactivity seconds after all activity on the remote and then attempt to load the
210 // image. If the sender wants the remote to load immediately, it will simply set both time parameters to 0.
211 //
212 // LOAD_POLL - Indicates that the device should poll frequently for new instructions on whether or not to load. For example,
213 // a remote control would poll every keypress. Another device could poll once a second.
214 //
215 // LOAD_ABORT - Allows a caller to abort the download on the device if the device is currently waiting for some time or in a
216 // polling mode. If abort is called the session is considered over and the updateSessionID is considered invalid.
217 //
218 typedef enum _IARM_Bus_Device_Update_LoadDelayType_t
219 {
220  LOAD_DEFAULT,
221  LOAD_NORMAL,
222  LOAD_POLL,
223  LOAD_ABORT
224 
225 } IARM_Bus_Device_Update_LoadDelayType_t;
226 
227 
228 //
229 // IARM_Bus_Device_Update_LoadDelayType_t
230 //
231 // LOAD_STATUS_BEGIN - Notifies when the load has commenced on the device.
232 //
233 // LOAD_STATUS_END - Notifies that the load has completed and the device is updated and running the new image. Receiving
234 // this event ends the update and invalidates the updateSessionID
235 //
236 typedef enum _IARM_Bus_Device_Update_LoadStatusType_t
237 {
238  LOAD_STATUS_BEGIN,
239  LOAD_STATUS_END,
240 
241 } IARM_Bus_Device_Update_LoadStatusType_t;
242 
243 //SALTODO: Revisit these.
244 typedef enum _IARM_Bus_Device_Update_ErrorType_t
245 {
246  IMAGE_NOT_FOUND, // The firmware that was announced could not be found
247  IMAGE_INVALID, // The firmware was determined to be invalid prior to sending
248  IMAGE_REJECTED, // The firmware was rejected after sending, eg. CRC check etc...
249  IMAGE_TIMEOUT, // The request timed out
250  IMAGE_GENERIC_ERROR, // See the error message for specific details
251  IMAGE_BUSY //SALADD: If a 2nd update is attempted while one in progress?
252 
253 } IARM_Bus_Device_Update_ErrorType_t;
254 
255 
256 //
257 // IARM_Bus_DeviceUpdate_Announce_t
258 //
259 // Event: IARM_BUS_DEVICE_UPDATE_EVENT_ANNOUNCE
260 //
261 // The Device Update Manager will scan the filesystem for image updates for different devices at configurable times. When a new
262 // image is found, the Device Update Manager will send an Announce event for the particular image on the IARM bus. A Device Proxy
263 // for an updatable device should register for this event and look for updates meant for it. The Device Update Proxy is responsible for
264 // managing all devices it is proxying for to update each in a reasonable way. An example is a Remote Control Proxy which has
265 // multiple entries in its pairing table. It should take care to update them in a metered way, i.e., one at a time, or all
266 // background downloads, etc.
267 //
268 // deviceName - Device Name pulled from the XML file of the received device update package. Devices will know what name they are
269 // listening for and want information about.
270 //
271 // deviceImageVersion - Version of the new image to update.
272 //
273 // deviceImageType - Type of the new image. Pulled from the XML file of the received device update package.
274 //
275 // deviceImageFilePath - Absolute path of the image in the rootFS.
276 //
277 // forceUpdate - Boolean describing if the device update package is requesting to be forced onto devices regardless of version
278 //
280 {
281  char deviceName[IARM_BUS_DEVICE_UPDATE_DEVICE_NAME_LENGTH];
282  char deviceImageVersion[IARM_BUS_DEVICE_UPDATE_VERSION_LENGTH];
283  unsigned int deviceImageType;
284  char deviceImageFilePath[IARM_BUS_DEVICE_UPDATE_PATH_LENGTH];
285  unsigned char forceUpdate;
286 
288 
289 
290 //
291 // IARM_Bus_DeviceUpdate_ReadyToDownload_t
292 //
293 // Event: IARM_BUS_DEVICE_UPDATE_EVENT_READY_TO_DOWNLOAD
294 //
295 // After the Device Update Proxy Manager has called the AcceptUpdate RPC for a particular device, it can transmit a
296 // ReadyToDownload event out to the IARM bus. This event will notify the Device Update Manager and any other interested
297 // parties (such as the XRE receiver) that a particular device represented by the Device Update Proxy is ready to
298 // begin a download.
299 //
300 // updateSessionID - The session ID of the download. Corresponds to a specific download and a specific device.
301 //
302 // deviceCurrentSWVersion - Version that is currently installed on the device targeted for the image update.
303 //
304 // deviceNewSoftwareVersion - Version to update the device to.
305 //
306 // deviceHWVersion - Version of the device HW
307 //
308 // deviceBootloaderVersion - Version of the bootloader running on the device
309 //
310 // deviceName - Null terminated String containing the name of the device.
311 //
312 // totalSize - The size of the image accepted for download in bytes
313 //
314 // deviceImageType - Type of the new image. Pulled from the XML file of the received device update package.
315 //
317 {
318  unsigned int updateSessionID;
319  unsigned char deviceCurrentSWVersion[IARM_BUS_DEVICE_UPDATE_VERSION_LENGTH];
320  unsigned char deviceNewSoftwareVersion[IARM_BUS_DEVICE_UPDATE_VERSION_LENGTH];
321  unsigned char deviceHWVersion[IARM_BUS_DEVICE_UPDATE_VERSION_LENGTH];
322  unsigned char deviceBootloaderVersion[IARM_BUS_DEVICE_UPDATE_VERSION_LENGTH];
323  char deviceName[IARM_BUS_DEVICE_UPDATE_DEVICE_NAME_LENGTH];
324  unsigned int totalSize;
325  unsigned int deviceImageType;
326 
328 
329 
330 //
331 // IARM_Bus_DeviceUpdate_DownloadInitiate_t
332 //
333 // Event: IARM_BUS_DEVICE_UPDATE_EVENT_DOWNLOAD_INITIATE
334 //
335 // This event can be sent from either the Device Update Manager or Update Master to tell the Device Update Proxy to initiate
336 // a download for a particular device. An Update Master would have seen the ReadyToDownload event from a Device Update Proxy
337 // before sending this and would have obtained the updateSessionID from that event. The download can be initiated as a background
338 // download (meaning no impact to the device's normal operation) or an immediate download (move data to the device as fast as
339 // possible.
340 //
341 // updateSessionID - The session ID of the download. Corresponds to a specific download and a specific device.
342 //
343 // backgroundDownload - Whether the background should be full speed or in the background
344 //
345 // requestedPercentIncrement - Allows the Device Update Manager or Update Master to request what increments the Device Update
346 // Proxy will provide status update increments. This should be a best effort implementation by the
347 // Device Update Proxy. If it is set at 0x0, then it should only send at 0 and 100. if it is 0xFF
348 // then it should determined by the Device Update Proxy.
349 //
351 {
352  unsigned int updateSessionID;
353  unsigned char backgroundDownload;
354  unsigned char requestedPercentIncrement;
355  unsigned char loadImageImmediately;
356 
358 
359 
360 //
361 // IARM_Bus_DeviceUpdate_DownloadStatus_t
362 //
363 // Event: IARM_BUS_DEVICE_UPDATE_EVENT_DOWNLOAD_STATUS
364 //
365 // This event is sent from the Device Update Proxy to the IARM bus to inform listeners of the status of the download.
366 // The Device Update Proxy must sent an initial status with percentComplete == 0 and a final status with percentComplete == 100.
367 // This will notify listeners of the the beginning and end, respectively of the download. The Device Update Proxy should
368 // send status updates at periods defined by the requestedPercentIncrement in the Download Initiate command. If it is set at
369 // 0x0, then it should only send at 0 and 100. if it is 0xFF then it should determined by the Device Update Proxy.
370 //
371 // updateSessionID - The session ID of the download. Corresponds to a specific download and a specific device.
372 //
373 // percentComplete - Percent of the download that has completed. 0x0 means only start/end. 0xFF means let the DUP decide.
374 //
376 {
377  unsigned int updateSessionID;
378  unsigned int percentComplete; // 0-100
379 
381 
382 
383 //
384 // IARM_Bus_DeviceUpdate_LoadInitiate_t
385 //
386 // Event: IARM_BUS_DEVICE_UPDATE_EVENT_LOAD_INITIATE
387 //
388 // This event can be sent from either the Device Update Manager or Update Master to tell the Device Update Proxy to initiate
389 // a load for a particular device. The initiator can tell the Device Update Proxy to load immediately (this would be expected if
390 // the download was immediate), load after a given time and a given amount of inactivity, to poll repeatedly for updated
391 // instructions, or to abort an existing download session.
392 //
393 // updateSessionID - The session ID of the download. Corresponds to a specific download and a specific device.
394 //
395 // loadDelayType - The delay type/strategy for loading
396 //
397 // timeToLoad - The delta in time on the remote from receiving the command to monitoring the inactivity and starting the
398 // inactivity timer in seconds.
399 //
400 // timeAfterInactive
401 //
403 {
404  unsigned int updateSessionID;
405  IARM_Bus_Device_Update_LoadDelayType_t loadDelayType;
406  unsigned int timeToLoad;
407  unsigned int timeAfterInactive;
408 
410 
411 
412 //
413 // IARM_Bus_DeviceUpdate_LoadStatus_t
414 //
415 // Event: IARM_BUS_DEVICE_UPDATE_EVENT_LOAD_STATUS
416 //
417 // This event is sent from the Device Update Proxy to the IARM bus to inform listeners of the status of the load. The
418 // Device Update Proxy should know when the load gets initiated as well as wend it is complete and finished. When this
419 // event is sent with a status of LOAD_STATUS_END, the session should be considered complete and the updateSessionID
420 // invalidated.
421 //
422 // updateSessionID - The session ID of the download. Corresponds to a specific download and a specific device.
423 //
424 // loadStatus - Status of the load. Will signify the beginning and the end.
425 //
427 {
428  unsigned int updateSessionID;
429  IARM_Bus_Device_Update_LoadStatusType_t loadStatus;
430 
432 
433 
434 //
435 // IARM_Bus_Device_Update_Error_t
436 //
437 // IARM_BUS_DEVICE_UPDATE_EVENT_ERROR
438 //
439 // This event is sent from the Device Update Proxy to the IARM bus to inform listeners of the status of the load. The
440 // Device Update Proxy should know when the load gets initiated as well as wend it is complete and finished. When this
441 // event is sent with a status of LOAD_STATUS_END, the session should be considered complete and the updateSessionID
442 // invalidated.
443 //
444 // updateSessionID - The session ID of the download. Corresponds to a specific download and a specific device.
445 //
446 // errorMessage - Null terminated string describing error.
447 //
448 // errorType - Type of error.
449 //
451 {
452  unsigned int updateSessionID;
453  unsigned char errorMessage[IARM_BUS_DEVICE_UPDATE_ERROR_LENGTH];
454  IARM_Bus_Device_Update_ErrorType_t errorType;
455 
457 
458 
459 /** @} */
460 /** @} */
_IARM_Bus_Device_Update_Error_t
Definition: deviceUpdateMgr.h:450
_IARM_Bus_DeviceUpdate_DownloadInitiate_t
Definition: deviceUpdateMgr.h:350
_IARM_Bus_DeviceUpdate_AcceptUpdate_Param_t
Definition: deviceUpdateMgr.h:175
_IARM_Bus_DeviceUpdate_DownloadStatus_t
Definition: deviceUpdateMgr.h:375
_IARM_Bus_DeviceUpdate_LoadInitiate_t
Definition: deviceUpdateMgr.h:402
_IARM_Bus_DeviceUpdate_ReadyToDownload_t
Definition: deviceUpdateMgr.h:316
_IARM_Bus_DeviceUpdate_Announce_t
Definition: deviceUpdateMgr.h:279
_IARM_Bus_DeviceUpdate_LoadStatus_t
Definition: deviceUpdateMgr.h:426