le_avc_interface.h

Go to the documentation of this file.
1 
2 
3 /*
4  * ====================== WARNING ======================
5  *
6  * THE CONTENTS OF THIS FILE HAVE BEEN AUTO-GENERATED.
7  * DO NOT MODIFY IN ANY WAY.
8  *
9  * ====================== WARNING ======================
10  */
11 
12 /**
13  * @page c_le_avc AirVantage Connector API
14  *
15  * @ref le_avc_interface.h "API Reference" <br>
16  * @ref legatoServicesAirVantage "AirVantage Connector Platform Service"
17  *
18  *
19  * The AirVantage connector service provides an API to communicate with the AirVantage Server to
20  * download and install updates.
21  *
22  * @section c_le_avc_update Firmware/Application Updates
23  *
24  * The API for firmware/application update is divided into two parts:
25  * - Allow an App to contact the server for pending updates. If available,
26  * can select to download or install the update.
27  * - Allow an App to block an update from being installed. An App may need this if it's
28  * performing a critical operation that can't be interrupted (e.g., eCall). This is necessary
29  * as installing an update will cause the App to restart (either the App itself needs to restart
30  * or a firmware change causes the modem to reset).
31  *
32  * @subsection c_le_avc_user_agreement User Agreement
33  *
34  * When writing a control app for the AirVantage Service it is up to the developer to ensure that
35  * user agreements have been enabled for all actions the control app performs. By default all
36  * user agreements are enabled and the avcService app will notify the control app and wait for a
37  * response before downloading or installing the update. If the avcService can't communicate with
38  * the control app it waits for 3 minutes and tries again. To not have the avcService wait for the
39  * control app to accept the agreement the user agreement must be disabled.
40  *
41  * There are 5 events that require user agreements:
42  * - LE_AVC_CONNECTION_PENDING
43  * - LE_AVC_DOWNLOAD_PENDING
44  * - LE_AVC_INSTALL_PENDING
45  * - LE_AVC_REBOOT_PENDING
46  * - LE_AVC_UNINSTALL_PENDING
47  *
48  * An app can respond to these user agreement notification by opening a connection if the
49  * notification is connection pending or by accepting or deferring the operation if the notification
50  * is one of download, install, uninstall or reboot pending.
51  *
52  * Whether avcService should forward these notifications to an app or act on these notifications by
53  * itself is determined by the individual configuration flags that enables or disables user
54  * agreement for these operations. If the user agreement flag is turned off for an operation,
55  * the default action by avcService is to automatically accept that pending operation. An app can
56  * register its handler by calling le_avc_AddStatusEventHandler() described in
57  * c_le_avc_update_control and the configuration flags can be set by le_avc_SetUserAgreement().
58  *
59  * Example of enabling user agreement for LE_AVC_DOWNLOAD_PENDING:
60  * @code
61  * le_result_t result;
62  * result = le_avc_SetUserAgreement(LE_AVC_USER_AGREEMENT_DOWNLOAD, true);
63  *
64  * if (result != LE_OK)
65  * {
66  * LE_ERROR("Failed to enable user agreement for download operation");
67  * }
68  * @endcode
69  *
70  * @subsection c_le_avc_update_control Update Control
71  *
72  * Any App can start a session with an AirVantage server to determine if there
73  * is a pending update. This is done with le_avc_StartSession().
74  *
75  * The current session can be stopped using le_avc_StopSession(). This cancels any query for pending
76  * update, or suspends a download in progress; however, it <b>won't stop</b> an install in progress.
77  *
78  * The status of a pending update is sent to all Apps registered for receiving a notification.
79  * An App can use le_avc_AddStatusEventHandler() to register a handler function to
80  * receive this notification. The notification will be received after a session is started.
81  *
82  * Example of registering an AVC handler and starting a session with fault checking:
83  * @code
84  * // Start AVC Session
85  * LE_INFO("AirVantage Connection Controller started.");
86  * le_avc_AddStatusEventHandler(avcStatusHandler, NULL); //register a AVC handler
87  *
88  * //Start AVC session. Note: AVC handler must be registered prior starting a session
89  * le_result_t result = le_avc_StartSession();
90  * if (LE_FAULT == result)
91  * {
92  * le_avc_StopSession();
93  * le_avc_StartSession();
94  * }
95  * @endcode
96  *
97  * Sometimes, @c avcService may decide to start a session with the AirVantage
98  * server; for instance if a call to le_avc_AcceptDownload() when the session is stopped,
99  * @c avcService will open a session to proceed with the download. In this case, a session started
100  * notification could also be received, even if le_avc_StartSession() is not called explicitly.
101  *
102  * @subsubsection c_le_avc_updateControl_pending Pending Updates
103  *
104  * There can only be one pending update at a time. To query the type of update, use
105  * le_avc_GetUpdateType(). App updates can call le_avc_GetAppUpdateName() to retrieve the App name.
106  *
107  * If a download is pending, le_avc_AcceptDownload() can be used to allow the update to be
108  * downloaded. An AirVantage session will be initiated if this api is called while there is no
109  * active AirVantage session. le_avc_DeferDownload() can be used to defer the download for the
110  * specified number of minutes. After the defer time has elapsed, the pending download notification
111  * will be re-sent again to all registered apps. le_avc_AcceptDownload() can be used to accept the
112  * download even before the defer timer expires. This behaviour is true for deferring install
113  * and uninstall as well.
114  *
115  * Once an update has been downloaded, a new notification will be received to indicate that an
116  * install is pending. Apps can then use le_avc_AcceptInstall() to allow the install to proceed.
117  *
118  * If an uninstall is pending, then le_avc_AcceptUninstall() can be used to allow the uninstall to
119  * proceed. To defer the decision, le_avc_DeferUninstall() can be used to defer the uninstall for
120  * the specified number of minutes. In case of an upgrade, the existing application will not be
121  * uninstalled after le_avc_AcceptUninstall() is called. le_avc_AcceptUninstall() is only used to
122  * signal the server to start downloading the new application. To proceed with an upgrade process,
123  * accept the uninstall of the existing version followed by accepting the download and install of
124  * the new version.
125  *
126  * @code
127  * switch (updateStatus)
128  * {
129  * case LE_AVC_DOWNLOAD_PENDING:
130  * LE_INFO("Accepting %s update.", GetUpdateType());
131  * res = le_avc_AcceptDownload();
132  * if (res != LE_OK)
133  * {
134  * LE_ERROR("Failed to accept download from AirVantage (%s)", LE_RESULT_TXT(res));
135  * }
136  * break;
137  *
138  * case LE_AVC_INSTALL_PENDING:
139  * LE_INFO("Accepting %s installation.", GetUpdateType());
140  * res = le_avc_AcceptInstall();
141  * if (res != LE_OK)
142  * {
143  * LE_ERROR("Failed to accept install from AirVantage (%s)", LE_RESULT_TXT(res));
144  * }
145  * break;
146  *
147  * case LE_AVC_UNINSTALL_PENDING:
148  * LE_INFO("Accepting %s uninstall.", GetUpdateType());
149  * res = le_avc_AcceptUninstall();
150  * if (res != LE_OK)
151  * {
152  * LE_ERROR("Failed to accept uninstall from AirVantage (%s)", LE_RESULT_TXT(res));
153  * }
154  * break;
155  *
156  * case LE_AVC_REBOOT_PENDING:
157  * LE_INFO("Accepting device reboot.");
158  * res = le_avc_AcceptReboot();
159  * if (res != LE_OK)
160  * {
161  * LE_ERROR("Failed to accept reboot from AirVantage (%s)", LE_RESULT_TXT(res));
162  * }
163  * break;
164  *
165  * default:
166  * // No action required
167  * break;
168  * }
169  * @endcode
170  *
171  * @note Even if an App calls le_avc_AcceptInstall(), the install may still be blocked by another
172  * App using the @ref c_le_avc_update_app functions. To defer the decision, an App can use
173  * le_avc_DeferInstall() to defer the install for the specified number of minutes. After the defer
174  * time has elapsed, the pending install notification will be re-sent to allow Apps to make a new
175  * decision, or again defer.
176  *
177  *
178  * @subsubsection c_le_avc_updateControl_accepting Accepting Installs/Uninstalls
179  *
180  * Accepting an App install or uninstall will not initiate an AirVantage session if no session
181  * is active. An App should start an AirVantage session before accepting an App install/uninstall,
182  * to ensure the process is completed, and the server is updated.
183  *
184  * If no app has registered for notifications using le_avc_AddStatusEventHandler(),
185  * then any pending downloads and installs will happen automatically, subject to any restrictions
186  * imposed by app using the @ref c_le_avc_update_app functions.
187  *
188  * There is no restriction on the number of Apps registering for notifications.
189  *
190  * In case of any error incurred during App download/install, an error code will be set which can be
191  * retrieved by calling le_avc_GetErrorCode().
192  *
193  * @subsection c_le_avc_update_app Application Installation Blocking
194  *
195  * When an App is about to perform a critical operation, it can block the installation of
196  * an update with le_avc_BlockInstall(), and after it's finished with the critical operation, it
197  * can unblock the install with le_avc_UnblockInstall().
198  *
199  * What constitutes a critical operation depends on the App. An eCall App might
200  * block installs for the duration that it runs. A data collection App that wakes up
201  * once an hour might block installs while it collects and stores and/or transmits a new data
202  * sample, and then unblock installs just before it goes to sleep again.
203  *
204  * If an install can't be applied because it's blocked, another attempt to apply the install
205  * will be made at a later time.
206  *
207  * An App can add a session control handler using le_avc_AddSessionRequestEventHandler(). Requests
208  * by user Apps to open or close session will be forwarded to the session control handler. If no App
209  * has registered a session request handler, AVC session can be opened or closed anytime by
210  * user Apps.
211  *
212  * @subsection c_le_avc_suspend_resume Suspend and resume an update
213  *
214  * A firmware/application update can be interrupted or suspended by different events:
215  * - a device reboot
216  * - a network loss
217  * - a manual suspend through a session stop.
218  *
219  * After the update suspension, when the @c avcService is ready to resume the update process:
220  * - If the user agreements are disabled, the update process is automatically restarted.
221  * - If the user agreements are enabled, the previous @c PENDING notification is sent to the App,
222  * as indicated in the table below.
223  *
224  * @note The @c avcService might take a while to suspend the update process (typically a few
225  * minutes), e.g. in some cases of firmware update. The @c PENDING notification will therefore be
226  * sent only when the suspension is over. Trying to resume the update process while the suspension
227  * is not over and the notification is not received has no effect.
228  *
229  * | Last received event | Event sent to resume | Expected action from App |
230  * |--------------------------------|-------------------------------------------------------------|--------------------------|
231  * | @c LE_AVC_DOWNLOAD_PENDING | @c LE_AVC_DOWNLOAD_PENDING | Accept download |
232  * | @c LE_AVC_DOWNLOAD_IN_PROGRESS | @c LE_AVC_DOWNLOAD_PENDING with remaining bytes to download | Accept download |
233  * | @c LE_AVC_DOWNLOAD_COMPLETE | @c LE_AVC_DOWNLOAD_PENDING with zero bytes to download | Accept download |
234  * | @c LE_AVC_INSTALL_PENDING | @c LE_AVC_INSTALL_PENDING | Accept install |
235  * | @c LE_AVC_INSTALL_IN_PROGRESS | @c LE_AVC_INSTALL_PENDING | Accept install |
236  * | @c LE_AVC_UNINSTALL_PENDING | @c LE_AVC_UNINSTALL_PENDING | Accept uninstall |
237  * | @c LE_AVC_CONNECTION_PENDING | @c LE_AVC_CONNECTION_PENDING | Start session |
238  *
239  * @note If firmware is updated (via fwupdate tool) or new legato is installed (via instlegato),
240  * all suspend/resume information stored by avcService is erased. So if developer updates firmware
241  * or legato (via ethernet or ecm etc.) in the middle of any update initiated by avcService, this
242  * need to be cancelled and restarted again from airVantage server.
243  *
244  * @section c_le_avc_Timers Timers
245  *
246  * Polling timers sets the time that the Target will communicate with the AirVantage Server to check
247  * for new jobs. Retry timers will try and re-establish a connection to the AirVantage Server in
248  * accordance with the times that are declared.
249  *
250  * @subsection c_le_avc_PollingTimer Polling Timer
251  *
252  * The target will periodically initiate a connection to the AirVantage Server according to the
253  * settings for the polling timer to check if there are any pending jobs.
254  *
255  * If you need to disable the poling timer call le_avc_SetPollingTimer() and set the value to 0.
256  *
257  * The polling timer accepts ranges from 0 to 525600 minutes and is persistent across reboots and
258  * upgrades.
259  *
260  * To read the polling timer call: le_avc_GetPollingTimer()
261  *
262  * To write a new value to the polling timer call: le_avc_SetPollingTimer()
263  *
264  * Writing to the polling timer stops the current polling timer if it is running and starts a timer
265  * with the new value. The next connection will be initated when the new polling timer expires.
266  *
267  * @subsection c_le_avc_RetryTimers Retry Timers
268  *
269  * If an error occurs during a connection to the Device Services server (WWAN DATA establishment
270  * failed and an http error code is received) the embedded module will initiate a new connection
271  * according to the values defined in the retry timers.
272  *
273  * The timers are tried in sequence until a connection is established, or all enabled retry timers
274  * are exhausted. After all the enabled timers are exhausted, a new session must be initiated again
275  * by calling le_avc_startSession() after the expiry of the retry timer.
276  *
277  * The retry timer values are persistent (reboots and updates do not effect the retry timers).
278  * If you wish to disable a retry timer set the timer value
279  * to 0. You must always pass in at least 8 values to the retry timers.
280  *
281  * Retry timer values range from 0 to 20160 minutes.
282  * The function le_avc_GetRetryTimers() reads the retry timers in an array and the function
283  * le_avc_SetRetryTimers() writes the retry timers. When writing to the retry timers, values of
284  * all the 8 timers have to be defined.
285  *
286  * Example of calling retry timers, the session will be retried after 15 minutes, 1 hour, 4 hours,
287  * 8 hours, 1 day and 2 days, the last two retries are disabled:
288  * @code
289  * uint16_t RetryTimers[LE_AVC_NUM_RETRY_TIMERS] = {15, 60, 240, 480, 1440, 2880, 0, 0};
290  * le_avc_SetRetryTimers(RetryTimers, LE_AVC_NUM_RETRY_TIMERS);
291  * @endcode
292  *
293  * @section c_le_avc_reboot Device reboot
294  *
295  * The AirVantage server can request to reboot the device. If a reboot is requested a notification
296  * is sent to the registered Apps. The App can either accept the reboot with le_avc_AcceptReboot()
297  * or defer it for a specified number of minutes with le_avc_DeferReboot(). After the defer time
298  * has elapsed, the pending reboot notification will be re-sent. This allows the registered app to
299  * make a new decision or defer the reboot again.
300  *
301  * If no App has registered for notifications using le_avc_AddStatusEventHandler(), then
302  * any pending reboot will happen automatically.
303  *
304  * @section c_le_avc_GetCredentialStatus Credential Status
305  * The device is provisioned with bootstrap credentials from factory. The Device Management (DM)
306  * credentials are provisioned by AirVantage Bootstrap Server. This API is used to retrieve the
307  * status of credentials provisioned on the device.
308  *
309  * @section c_le_avc_connection Connection pending
310  *
311  * The AirVantage agent can request a connection to the AirVantage server, especially when a
312  * firmware package is installed (after a platform reboot) or device reboots in the middle of
313  * software update (after finishing software update on reboot). In this case a notification is sent
314  * to the control App, which can start the connection with le_avc_StartSession().
315  *
316  * @section c_le_avc_routing Data routing
317  *
318  * By default the AirVantage connection uses the default mobile data profile and the default route
319  * set by the data connection service.
320  *
321  * If the user wishes to control the network configuration, e.g. to use the AirVantage agent with
322  * multi-PDP contexts, they should first bind the application to the data connection service:
323  * @verbatim
324  bindings:
325  {
326  clientExe.clientComponent.le_data -> dataConnectionService.le_data
327  }
328  @endverbatim
329  *
330  * The data connection service should then be configured before launching the AirVantage connection:
331  * - le_data_SetCellularProfileIndex() allows to change the data profile to use.
332  * - le_data_GetDefaultRouteStatus() indicates if the default route is activated in the data
333  * connection service. This default route can be deactivated in the data connection service
334  * configuration database, as explained in @ref c_le_data_defaultRoute. If the default route is
335  * deactivated, the AirVantage agent will automatically add routes to be able to reach the
336  * AirVantage server through the connection used by AirVantage.
337  *
338  * @section c_le_avc_timeout Connection / Download timeout
339  *
340  * The AirVantage connector service will abort FOTA/SOTA download, if it takes more than
341  * 300 seconds to establish a connection. Download will also be aborted, if the download speed is
342  * too low (less than 100 bytes /second) for too long (for more than 1000 seconds).
343  * These values are chosen based on experiments on low speed network. There is no configuration
344  * for these timeouts.
345  *
346  * @section le_avcService_configdb Service Configuration Tree
347  * @copydoc le_avcService_configdbPage_Hide
348  *
349  *
350  * Copyright (C) Sierra Wireless Inc.
351  */
352 /**
353  * @interface le_avcService_configdbPage_Hide
354  *
355  * The configuration database path for the activityTimeout is:
356  * @verbatim
357  /
358  apps/
359  avcService/
360  activityTimeout
361  @endverbatim
362  *
363  *
364  * After an AirVantage session is started, if there's no activity between the device and the server
365  * within the timer interval, then LE_AVC_NO_UPDATE state will be returned to the app. However,
366  * this activity timeout can be overridden by setting an integer value for
367  * /apps/avcService/activityTimeout. The activity timer is initialized only when the @c avcService
368  * starts. If a valid entry >0 is found, then it will be used instead of the default value of 20
369  * seconds. The following steps should be used to set the activityTimeout.
370  *
371  *
372  * @verbatim
373  config set /apps/avcService/activityTimeout xx int
374  app restart avcService
375  @endverbatim
376  *
377  * @note
378  * Everytime a new value is written to activityTimeout, the avcService needs to be
379  * restarted to read the new value.
380  *
381  *
382  */
383 /**
384  * @file le_avc_interface.h
385  *
386  * Legato @ref c_le_avc include file.
387  *
388  * Copyright (C) Sierra Wireless Inc.
389  */
390 
391 #ifndef LE_AVC_INTERFACE_H_INCLUDE_GUARD
392 #define LE_AVC_INTERFACE_H_INCLUDE_GUARD
393 
394 
395 #include "legato.h"
396 
397 // Interface specific includes
398 #include "le_limit_interface.h"
399 
400 
401 //--------------------------------------------------------------------------------------------------
402 /**
403  * Type for handler called when a server disconnects.
404  */
405 //--------------------------------------------------------------------------------------------------
406 typedef void (*le_avc_DisconnectHandler_t)(void *);
407 
408 //--------------------------------------------------------------------------------------------------
409 /**
410  *
411  * Connect the current client thread to the service providing this API. Block until the service is
412  * available.
413  *
414  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
415  * called before any other functions in this API. Normally, ConnectService is automatically called
416  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
417  *
418  * This function is created automatically.
419  */
420 //--------------------------------------------------------------------------------------------------
422 (
423  void
424 );
425 
426 //--------------------------------------------------------------------------------------------------
427 /**
428  *
429  * Try to connect the current client thread to the service providing this API. Return with an error
430  * if the service is not available.
431  *
432  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
433  * called before any other functions in this API. Normally, ConnectService is automatically called
434  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
435  *
436  * This function is created automatically.
437  *
438  * @return
439  * - LE_OK if the client connected successfully to the service.
440  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
441  * bound.
442  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
443  * - LE_COMM_ERROR if the Service Directory cannot be reached.
444  */
445 //--------------------------------------------------------------------------------------------------
447 (
448  void
449 );
450 
451 //--------------------------------------------------------------------------------------------------
452 /**
453  * Set handler called when server disconnection is detected.
454  *
455  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
456  * to continue without exiting, it should call longjmp() from inside the handler.
457  */
458 //--------------------------------------------------------------------------------------------------
460 (
461  le_avc_DisconnectHandler_t disconnectHandler,
462  void *contextPtr
463 );
464 
465 //--------------------------------------------------------------------------------------------------
466 /**
467  *
468  * Disconnect the current client thread from the service providing this API.
469  *
470  * Normally, this function doesn't need to be called. After this function is called, there's no
471  * longer a connection to the service, and the functions in this API can't be used. For details, see
472  * @ref apiFilesC_client.
473  *
474  * This function is created automatically.
475  */
476 //--------------------------------------------------------------------------------------------------
478 (
479  void
480 );
481 
482 
483 //--------------------------------------------------------------------------------------------------
484 /**
485  * Maximum APN name length without NULL terminator.
486  */
487 //--------------------------------------------------------------------------------------------------
488 #define LE_AVC_APN_NAME_MAX_LEN 48
489 
490 //--------------------------------------------------------------------------------------------------
491 /**
492  * Maximum APN name length including NULL terminator.
493  */
494 //--------------------------------------------------------------------------------------------------
495 #define LE_AVC_APN_NAME_MAX_LEN_BYTES 49
496 
497 //--------------------------------------------------------------------------------------------------
498 /**
499  * Maximum user name length without NULL terminator.
500  */
501 //--------------------------------------------------------------------------------------------------
502 #define LE_AVC_USERNAME_MAX_LEN 28
503 
504 //--------------------------------------------------------------------------------------------------
505 /**
506  * Maximum user name length including NULL terminator.
507  */
508 //--------------------------------------------------------------------------------------------------
509 #define LE_AVC_USERNAME_MAX_LEN_BYTES 29
510 
511 //--------------------------------------------------------------------------------------------------
512 /**
513  * Maximum password length without NULL terminator..
514  */
515 //--------------------------------------------------------------------------------------------------
516 #define LE_AVC_PASSWORD_MAX_LEN 28
517 
518 //--------------------------------------------------------------------------------------------------
519 /**
520  * Maximum password length including NULL terminator.
521  */
522 //--------------------------------------------------------------------------------------------------
523 #define LE_AVC_PASSWORD_MAX_LEN_BYTES 29
524 
525 //--------------------------------------------------------------------------------------------------
526 /**
527  * Maximum number of retry timers.
528  */
529 //--------------------------------------------------------------------------------------------------
530 #define LE_AVC_NUM_RETRY_TIMERS 8
531 
532 //--------------------------------------------------------------------------------------------------
533 /**
534  * Polling timer value range in minutes. 525600 minutes = 1 year.
535  */
536 //--------------------------------------------------------------------------------------------------
537 #define LE_AVC_POLLING_TIMER_MAX_VAL 525600
538 
539 //--------------------------------------------------------------------------------------------------
540 /**
541  */
542 //--------------------------------------------------------------------------------------------------
543 #define LE_AVC_POLLING_TIMER_MIN_VAL 0
544 
545 //--------------------------------------------------------------------------------------------------
546 /**
547  * Retry timer value range in minutes. 20160 minutes = 2 weeks.
548  */
549 //--------------------------------------------------------------------------------------------------
550 #define LE_AVC_RETRY_TIMER_MAX_VAL 20160
551 
552 //--------------------------------------------------------------------------------------------------
553 /**
554  */
555 //--------------------------------------------------------------------------------------------------
556 #define LE_AVC_RETRY_TIMER_MIN_VAL 0
557 
558 //--------------------------------------------------------------------------------------------------
559 /**
560  * Default HTTP status.
561  */
562 //--------------------------------------------------------------------------------------------------
563 #define LE_AVC_HTTP_STATUS_INVALID 65535
564 
565 //--------------------------------------------------------------------------------------------------
566 /**
567  * Status of session or update
568  *
569  * If an update is pending, it must first be downloaded and then installed.
570  */
571 //--------------------------------------------------------------------------------------------------
572 typedef enum
573 {
575  ///< No updates pending
577  ///< Update pending download
579  ///< Download in progress
581  ///< Download has completed
583  ///< An error occurred downloading the update
585  ///< Install is pending (implies download complete)
587  ///< Install in progress
589  ///< Update has been successfully installed
591  ///< An error occurred installing the update
593  ///< Uninstall is pending
595  ///< Uninstall in progress
597  ///< App has been successfully uninstalled
599  ///< An error occurred uninstalling the update
601  ///< Session with AV server started
603  ///< Session with AV server stopped
605  ///< Device reboot is pending
607  ///< Connection to the server is required. This is necessary when
608  ///< firmware package is installed (after a platform reboot). Also
609  ///< necessary after software update if device reboots(or session stops)
610  ///< in the middle of software update.
612  ///< Authentication with AV server started
614  ///< Authentication with AV server failed
615 }
617 
618 
619 //--------------------------------------------------------------------------------------------------
620 /**
621  * Operations which require user agreement
622  */
623 //--------------------------------------------------------------------------------------------------
624 typedef enum
625 {
627  ///< User agreement for connection
629  ///< User agreement for download
631  ///< User agreement for install
633  ///< User agreement for uninstall
635  ///< User agreement for reboot
636 }
638 
639 
640 //--------------------------------------------------------------------------------------------------
641 /**
642  * Request to open or close avms session.
643  */
644 //--------------------------------------------------------------------------------------------------
645 typedef enum
646 {
648  ///< Request by user app to open AV session
650  ///< Request by user app to close AV session
651 }
653 
654 
655 //--------------------------------------------------------------------------------------------------
656 /**
657  * The type of pending update
658  */
659 //--------------------------------------------------------------------------------------------------
660 typedef enum
661 {
662  LE_AVC_UNKNOWN_UPDATE = 0,
663  ///<
664  LE_AVC_FIRMWARE_UPDATE = 1,
665  ///<
666  LE_AVC_FRAMEWORK_UPDATE = 2,
667  ///<
668  LE_AVC_APPLICATION_UPDATE = 3
669  ///<
670 }
672 
673 
674 //--------------------------------------------------------------------------------------------------
675 /**
676  * Error code used to provide diagnostic information after a failure (includes both download and
677  * install failure).
678  *
679  * @note
680  * Additional information may also be available in the target device's system log.
681  */
682 //--------------------------------------------------------------------------------------------------
683 typedef enum
684 {
686  ///< No error.
688  ///< Encountered a bad package.
690  ///< Something failed while doing install/download.
692  ///< Security check failure while installing the package.
693 }
695 
696 
697 //--------------------------------------------------------------------------------------------------
698 /**
699  * Session type indicates whether the device is connected to the bootstrap server or the
700  * device management server.
701  */
702 //--------------------------------------------------------------------------------------------------
703 typedef enum
704 {
706  ///< Bootstrap session.
708  ///< Device Management session.
710  ///< Session type invalid.
711 }
713 
714 
715 //--------------------------------------------------------------------------------------------------
716 /**
717  * Status of the device credentials
718  */
719 //--------------------------------------------------------------------------------------------------
720 typedef enum
721 {
723  ///< Neither Bootstrap nor Device Management
724  ///< credential is provisioned.
726  ///< Bootstrap credential is provisioned but Device
727  ///< Management credential is not provisioned.
729  ///< Device Management credential is provisioned.
730 }
732 
733 
734 //--------------------------------------------------------------------------------------------------
735 /**
736  * Reference type used by Add/Remove functions for EVENT 'le_avc_StatusEvent'
737  */
738 //--------------------------------------------------------------------------------------------------
739 typedef struct le_avc_StatusEventHandler* le_avc_StatusEventHandlerRef_t;
740 
741 
742 //--------------------------------------------------------------------------------------------------
743 /**
744  * Reference type used by Add/Remove functions for EVENT 'le_avc_SessionRequestEvent'
745  */
746 //--------------------------------------------------------------------------------------------------
747 typedef struct le_avc_SessionRequestEventHandler* le_avc_SessionRequestEventHandlerRef_t;
748 
749 
750 //--------------------------------------------------------------------------------------------------
751 /**
752  * Reference returned by BlockInstall function and used by UnblockInstall function
753  */
754 //--------------------------------------------------------------------------------------------------
755 typedef struct le_avc_BlockRequest* le_avc_BlockRequestRef_t;
756 
757 
758 //--------------------------------------------------------------------------------------------------
759 /**
760  * Handler for update availability status
761  */
762 //--------------------------------------------------------------------------------------------------
763 typedef void (*le_avc_StatusHandlerFunc_t)
764 (
765  le_avc_Status_t updateStatus,
766  ///< status of pending update, if available
767  int32_t totalNumBytes,
768  ///< Total number of bytes to be downloaded
769  ///< only valid when updateStatus is one of
770  ///< DOWNLOAD_PENDING, DOWNLOAD_IN_PROGRESS or DOWNLOAD_COMPLETE.
771  ///< returns -1 if value is unknown
772  int32_t dloadProgress,
773  ///< download completion in percentage
774  ///< only valid when updateStatus is one of
775  ///< DOWNLOAD_PENDING, DOWNLOAD_IN_PROGRESS or DOWNLOAD_COMPLETE.
776  ///< returns -1 if value is unknown
777  void* contextPtr
778  ///<
779 );
780 
781 //--------------------------------------------------------------------------------------------------
782 /**
783  * Handler for receiving session open or close request.
784  */
785 //--------------------------------------------------------------------------------------------------
787 (
788  le_avc_SessionRequest_t request,
789  ///< Request to open or close AV session
790  void* contextPtr
791  ///<
792 );
793 
794 //--------------------------------------------------------------------------------------------------
795 /**
796  * Add handler function for EVENT 'le_avc_StatusEvent'
797  *
798  * This event provides information on update availability status
799  */
800 //--------------------------------------------------------------------------------------------------
802 (
803  le_avc_StatusHandlerFunc_t handlerPtr,
804  ///< [IN]
805  void* contextPtr
806  ///< [IN]
807 );
808 
809 //--------------------------------------------------------------------------------------------------
810 /**
811  * Remove handler function for EVENT 'le_avc_StatusEvent'
812  */
813 //--------------------------------------------------------------------------------------------------
815 (
817  ///< [IN]
818 );
819 
820 //--------------------------------------------------------------------------------------------------
821 /**
822  * Add handler function for EVENT 'le_avc_SessionRequestEvent'
823  *
824  * This event provides information on session open or close request.
825  */
826 //--------------------------------------------------------------------------------------------------
828 (
830  ///< [IN]
831  void* contextPtr
832  ///< [IN]
833 );
834 
835 //--------------------------------------------------------------------------------------------------
836 /**
837  * Remove handler function for EVENT 'le_avc_SessionRequestEvent'
838  */
839 //--------------------------------------------------------------------------------------------------
841 (
843  ///< [IN]
844 );
845 
846 //--------------------------------------------------------------------------------------------------
847 /**
848  * Start a session with the AirVantage server
849  *
850  * This will cause a query to be sent to the server, for pending updates.
851  *
852  * @return
853  * - LE_OK if connection request has been sent.
854  * - LE_FAULT on failure
855  * - LE_DUPLICATE if already connected.
856  */
857 //--------------------------------------------------------------------------------------------------
859 (
860  void
861 );
862 
863 //--------------------------------------------------------------------------------------------------
864 /**
865  * Stop a session with the AirVantage server
866  *
867  * If a download is in progress, then this suspends the download.
868  *
869  * @return
870  * - LE_OK on success
871  * - LE_FAULT on failure
872  */
873 //--------------------------------------------------------------------------------------------------
875 (
876  void
877 );
878 
879 //--------------------------------------------------------------------------------------------------
880 /**
881  * Send a specific message to the server to be sure that the route between the device and the server
882  * is available.
883  * This API needs to be called when any package download is over (successfully or not) and before
884  * sending any notification on asset data to the server.
885  *
886  * @return
887  * - LE_OK when the treatment is launched
888  * - LE_FAULT on failure
889  * - LE_UNSUPPORTED when the API is not supported
890  *
891  */
892 //--------------------------------------------------------------------------------------------------
894 (
895  void
896 );
897 
898 //--------------------------------------------------------------------------------------------------
899 /**
900  * Defer the currently pending connection, for the given number of minutes
901  *
902  * @return
903  * - LE_OK on success
904  * - LE_FAULT on failure
905  */
906 //--------------------------------------------------------------------------------------------------
908 (
909  uint32_t deferMinutes
910  ///< [IN]
911 );
912 
913 //--------------------------------------------------------------------------------------------------
914 /**
915  * Accept the currently pending download
916  *
917  * @return
918  * - LE_OK on success
919  * - LE_FAULT on failure
920  */
921 //--------------------------------------------------------------------------------------------------
923 (
924  void
925 );
926 
927 //--------------------------------------------------------------------------------------------------
928 /**
929  * Defer the currently pending download, for the given number of minutes
930  *
931  * @return
932  * - LE_OK on success
933  * - LE_FAULT on failure
934  */
935 //--------------------------------------------------------------------------------------------------
937 (
938  uint32_t deferMinutes
939  ///< [IN]
940 );
941 
942 //--------------------------------------------------------------------------------------------------
943 /**
944  * Accept the currently pending install
945  *
946  * @return
947  * - LE_OK on success
948  * - LE_FAULT on failure
949  */
950 //--------------------------------------------------------------------------------------------------
952 (
953  void
954 );
955 
956 //--------------------------------------------------------------------------------------------------
957 /**
958  * Defer the currently pending install
959  *
960  * @return
961  * - LE_OK on success
962  * - LE_FAULT on failure
963  */
964 //--------------------------------------------------------------------------------------------------
966 (
967  uint32_t deferMinutes
968  ///< [IN]
969 );
970 
971 //--------------------------------------------------------------------------------------------------
972 /**
973  * Accept the currently pending uninstall
974  *
975  * @return
976  * - LE_OK on success
977  * - LE_FAULT on failure
978  */
979 //--------------------------------------------------------------------------------------------------
981 (
982  void
983 );
984 
985 //--------------------------------------------------------------------------------------------------
986 /**
987  * Defer the currently pending uninstall
988  *
989  * @return
990  * - LE_OK on success
991  * - LE_FAULT on failure
992  */
993 //--------------------------------------------------------------------------------------------------
995 (
996  uint32_t deferMinutes
997  ///< [IN]
998 );
999 
1000 //--------------------------------------------------------------------------------------------------
1001 /**
1002  * Accept the currently pending reboot
1003  *
1004  * @return
1005  * - LE_OK on success
1006  * - LE_FAULT on failure
1007  */
1008 //--------------------------------------------------------------------------------------------------
1010 (
1011  void
1012 );
1013 
1014 //--------------------------------------------------------------------------------------------------
1015 /**
1016  * Defer the currently pending reboot
1017  *
1018  * @return
1019  * - LE_OK on success
1020  * - LE_FAULT on failure
1021  */
1022 //--------------------------------------------------------------------------------------------------
1024 (
1025  uint32_t deferMinutes
1026  ///< [IN]
1027 );
1028 
1029 //--------------------------------------------------------------------------------------------------
1030 /**
1031  * Get the update type of the currently pending update
1032  *
1033  * @return
1034  * - LE_OK on success
1035  * - LE_FAULT if not available
1036  */
1037 //--------------------------------------------------------------------------------------------------
1039 (
1040  le_avc_UpdateType_t* updateTypePtr
1041  ///< [OUT]
1042 );
1043 
1044 //--------------------------------------------------------------------------------------------------
1045 /**
1046  * Get the name for the currently pending app update
1047  *
1048  * @return
1049  * - LE_OK on success
1050  * - LE_FAULT if not available, or isn't APPL_UPDATE type
1051  */
1052 //--------------------------------------------------------------------------------------------------
1054 (
1055  char* updateName,
1056  ///< [OUT]
1057  size_t updateNameSize
1058  ///< [IN]
1059 );
1060 
1061 //--------------------------------------------------------------------------------------------------
1062 /**
1063  * Prevent any pending updates from being installed.
1064  *
1065  * @return
1066  * - Reference for block update request (to be used later for unblocking updates)
1067  * - NULL if the operation was not successful
1068  */
1069 //--------------------------------------------------------------------------------------------------
1071 (
1072  void
1073 );
1074 
1075 //--------------------------------------------------------------------------------------------------
1076 /**
1077  * Allow any pending updates to be installed
1078  */
1079 //--------------------------------------------------------------------------------------------------
1081 (
1082  le_avc_BlockRequestRef_t blockRef
1083  ///< [IN] block request ref returned by le_avc_BlockInstall
1084 );
1085 
1086 //--------------------------------------------------------------------------------------------------
1087 /**
1088  * Function to get error code when update fails.
1089  *
1090  * @return
1091  * - Error code of encountered error.
1092  * - ERR_NONE if update is in any other state.
1093  */
1094 //--------------------------------------------------------------------------------------------------
1096 (
1097  void
1098 );
1099 
1100 //--------------------------------------------------------------------------------------------------
1101 /**
1102  * Function to read the current session type, or the last session type if there is no
1103  * active session.
1104  *
1105  * @return
1106  * - SessionType
1107  */
1108 //--------------------------------------------------------------------------------------------------
1110 (
1111  void
1112 );
1113 
1114 //--------------------------------------------------------------------------------------------------
1115 /**
1116  * Function to read the http status of the last download.
1117  *
1118  * @return
1119  * - HttpStatus as defined in RFC 7231, Section 6.
1120  */
1121 //--------------------------------------------------------------------------------------------------
1122 uint16_t le_avc_GetHttpStatus
1123 (
1124  void
1125 );
1126 
1127 //--------------------------------------------------------------------------------------------------
1128 /**
1129  * Function to read the polling timer.
1130  *
1131  * @return
1132  * - LE_OK on success
1133  * - LE_FAULT if not available
1134  * - LE_OUT_OF_RANGE if the polling timer value is out of range (0 to 525600).
1135  */
1136 //--------------------------------------------------------------------------------------------------
1138 (
1139  uint32_t* pollingTimerPtr
1140  ///< [OUT] Polling timer
1141 );
1142 
1143 //--------------------------------------------------------------------------------------------------
1144 /**
1145  * Function to read the retry timers.
1146  *
1147  * @return
1148  * - LE_OK on success.
1149  * - LE_FAULT if not able to read the timers.
1150  * - LE_OUT_OF_RANGE if one of the retry timers is out of range (0 to 20160).
1151  */
1152 //--------------------------------------------------------------------------------------------------
1154 (
1155  uint16_t* timerValuePtr,
1156  ///< [OUT] Array of the retry timers.
1157  size_t* timerValueSizePtr
1158  ///< [INOUT]
1159 );
1160 
1161 //--------------------------------------------------------------------------------------------------
1162 /**
1163  * Function to read APN configuration.
1164  *
1165  * @return
1166  * - LE_OK on success.
1167  * - LE_FAULT if there is any error while reading.
1168  * - LE_OVERFLOW if the buffer provided is too small.
1169  */
1170 //--------------------------------------------------------------------------------------------------
1172 (
1173  char* apnName,
1174  ///< [OUT]
1175  size_t apnNameSize,
1176  ///< [IN]
1177  char* userName,
1178  ///< [OUT]
1179  size_t userNameSize,
1180  ///< [IN]
1181  char* userPwd,
1182  ///< [OUT]
1183  size_t userPwdSize
1184  ///< [IN]
1185 );
1186 
1187 //--------------------------------------------------------------------------------------------------
1188 /**
1189  * Function to write APN configuration.
1190  *
1191  * @return
1192  * - LE_OK on success.
1193  * - LE_OVERFLOW if one of the input strings is too long.
1194  */
1195 //--------------------------------------------------------------------------------------------------
1197 (
1198  const char* LE_NONNULL apnName,
1199  ///< [IN]
1200  const char* LE_NONNULL userName,
1201  ///< [IN]
1202  const char* LE_NONNULL userPwd
1203  ///< [IN]
1204 );
1205 
1206 //--------------------------------------------------------------------------------------------------
1207 /**
1208  * Function to set the polling timer.
1209  *
1210  * @return
1211  * - LE_OK on success.
1212  * - LE_OUT_OF_RANGE if the polling timer value is out of range (0 to 525600).
1213  */
1214 //--------------------------------------------------------------------------------------------------
1216 (
1217  uint32_t pollingTimer
1218  ///< [IN] Polling timer
1219 );
1220 
1221 //--------------------------------------------------------------------------------------------------
1222 /**
1223  * Function to set the retry timers.
1224  *
1225  * @return
1226  * - LE_OK on success.
1227  * - LE_FAULT if not able to set the timers.
1228  * - LE_OUT_OF_RANGE if one of the retry timers is out of range (0 to 20160).
1229  */
1230 //--------------------------------------------------------------------------------------------------
1232 (
1233  const uint16_t* timerValuePtr,
1234  ///< [IN] Array of 8 retry timers.
1235  size_t timerValueSize
1236  ///< [IN]
1237 );
1238 
1239 //--------------------------------------------------------------------------------------------------
1240 /**
1241  * Function to retrieve status of the credentials provisioned on the device.
1242  *
1243  * @return
1244  * LE_AVC_NO_CREDENTIAL_PROVISIONED
1245  * - If neither Bootstrap nor Device Management credential is provisioned.
1246  * LE_AVC_BS_CREDENTIAL_PROVISIONED
1247  * - If Bootstrap credential is provisioned but Device Management credential is
1248  * not provisioned.
1249  * LE_AVC_DM_CREDENTIAL_PROVISIONED
1250  * - If Device management key is provisioned.
1251  */
1252 //--------------------------------------------------------------------------------------------------
1254 (
1255  void
1256 );
1257 
1258 //--------------------------------------------------------------------------------------------------
1259 /**
1260  * Function to set user agreements for download, install, reboot, connection and uninstall.
1261  *
1262  * @return
1263  * - LE_OK on success.
1264  * - LE_FAULT if failed to configure user agreement.
1265  */
1266 //--------------------------------------------------------------------------------------------------
1268 (
1269  le_avc_UserAgreement_t updateStatus,
1270  ///< [IN] Operation for which user agreements has to be set.
1271  bool enable
1272  ///< [IN] true = enable, false = disable.
1273 );
1274 
1275 //--------------------------------------------------------------------------------------------------
1276 /**
1277  * Function to get user agreements for download, install, reboot, connection and uninstall.
1278  *
1279  * @return
1280  * - LE_OK on success.
1281  * - LE_FAULT if failed to read user agreement state.
1282  */
1283 //--------------------------------------------------------------------------------------------------
1285 (
1286  le_avc_UserAgreement_t updateStatus,
1287  ///< [IN] Operation for which user agreements has to be read.
1288  bool* enablePtr
1289  ///< [OUT] true = enable, false = disable.
1290 );
1291 
1292 #endif // LE_AVC_INTERFACE_H_INCLUDE_GUARD
void le_avc_RemoveSessionRequestEventHandler(le_avc_SessionRequestEventHandlerRef_t handlerRef)
le_result_t le_avc_GetPollingTimer(uint32_t *pollingTimerPtr)
Uninstall in progress.
Definition: le_avc_interface.h:594
void(* le_avc_StatusHandlerFunc_t)(le_avc_Status_t updateStatus, int32_t totalNumBytes, int32_t dloadProgress, void *contextPtr)
Definition: le_avc_interface.h:764
Uninstall is pending.
Definition: le_avc_interface.h:592
Request by user app to close AV session.
Definition: le_avc_interface.h:649
User agreement for reboot.
Definition: le_avc_interface.h:634
User agreement for connection.
Definition: le_avc_interface.h:626
An error occurred installing the update.
Definition: le_avc_interface.h:590
le_result_t le_avc_DeferReboot(uint32_t deferMinutes)
le_result_t le_avc_SetRetryTimers(const uint16_t *timerValuePtr, size_t timerValueSize)
le_avc_SessionRequestEventHandlerRef_t le_avc_AddSessionRequestEventHandler(le_avc_SessionRequestHandlerFunc_t handlerPtr, void *contextPtr)
le_result_t le_avc_SetApnConfig(const char *LE_NONNULL apnName, const char *LE_NONNULL userName, const char *LE_NONNULL userPwd)
le_result_t le_avc_DeferConnect(uint32_t deferMinutes)
le_result_t
Definition: le_basics.h:35
void(* le_avc_SessionRequestHandlerFunc_t)(le_avc_SessionRequest_t request, void *contextPtr)
Definition: le_avc_interface.h:787
le_result_t le_avc_AcceptReboot(void)
An error occurred uninstalling the update.
Definition: le_avc_interface.h:598
Install in progress.
Definition: le_avc_interface.h:586
void le_avc_UnblockInstall(le_avc_BlockRequestRef_t blockRef)
void le_avc_SetServerDisconnectHandler(le_avc_DisconnectHandler_t disconnectHandler, void *contextPtr)
le_avc_StatusEventHandlerRef_t le_avc_AddStatusEventHandler(le_avc_StatusHandlerFunc_t handlerPtr, void *contextPtr)
struct le_avc_SessionRequestEventHandler * le_avc_SessionRequestEventHandlerRef_t
Definition: le_avc_interface.h:747
le_avc_SessionRequest_t
Definition: le_avc_interface.h:645
An error occurred downloading the update.
Definition: le_avc_interface.h:582
le_avc_UserAgreement_t
Definition: le_avc_interface.h:624
le_result_t le_avc_DeferUninstall(uint32_t deferMinutes)
Install is pending (implies download complete)
Definition: le_avc_interface.h:584
le_result_t le_avc_AcceptUninstall(void)
le_result_t le_avc_GetUpdateType(le_avc_UpdateType_t *updateTypePtr)
void(* le_avc_DisconnectHandler_t)(void *)
Definition: le_avc_interface.h:406
Session with AV server stopped.
Definition: le_avc_interface.h:602
Session with AV server started.
Definition: le_avc_interface.h:600
le_avc_SessionType_t
Definition: le_avc_interface.h:703
Download in progress.
Definition: le_avc_interface.h:578
Definition: le_avc_interface.h:722
Device reboot is pending.
Definition: le_avc_interface.h:604
Session type invalid.
Definition: le_avc_interface.h:709
le_result_t le_avc_StartSession(void)
le_result_t le_avc_StopSession(void)
void le_avc_RemoveStatusEventHandler(le_avc_StatusEventHandlerRef_t handlerRef)
Authentication with AV server started.
Definition: le_avc_interface.h:611
le_result_t le_avc_GetUserAgreement(le_avc_UserAgreement_t updateStatus, bool *enablePtr)
Update pending download.
Definition: le_avc_interface.h:576
User agreement for uninstall.
Definition: le_avc_interface.h:632
le_result_t le_avc_AcceptDownload(void)
le_result_t le_avc_TryConnectService(void)
le_result_t le_avc_CheckRoute(void)
le_result_t le_avc_DeferInstall(uint32_t deferMinutes)
Update has been successfully installed.
Definition: le_avc_interface.h:588
User agreement for install.
Definition: le_avc_interface.h:630
le_result_t le_avc_AcceptInstall(void)
Something failed while doing install/download.
Definition: le_avc_interface.h:689
User agreement for download.
Definition: le_avc_interface.h:628
Bootstrap session.
Definition: le_avc_interface.h:705
struct le_avc_BlockRequest * le_avc_BlockRequestRef_t
Definition: le_avc_interface.h:755
le_avc_BlockRequestRef_t le_avc_BlockInstall(void)
void le_avc_DisconnectService(void)
le_avc_SessionType_t le_avc_GetSessionType(void)
Device Management session.
Definition: le_avc_interface.h:707
No error.
Definition: le_avc_interface.h:685
le_result_t le_avc_SetUserAgreement(le_avc_UserAgreement_t updateStatus, bool enable)
Definition: le_avc_interface.h:725
Definition: le_avc_interface.h:606
le_result_t le_avc_GetApnConfig(char *apnName, size_t apnNameSize, char *userName, size_t userNameSize, char *userPwd, size_t userPwdSize)
le_avc_UpdateType_t
Definition: le_avc_interface.h:660
le_avc_CredentialStatus_t le_avc_GetCredentialStatus(void)
le_result_t le_avc_DeferDownload(uint32_t deferMinutes)
le_result_t le_avc_SetPollingTimer(uint32_t pollingTimer)
Security check failure while installing the package.
Definition: le_avc_interface.h:691
Request by user app to open AV session.
Definition: le_avc_interface.h:647
le_result_t le_avc_GetAppUpdateName(char *updateName, size_t updateNameSize)
le_avc_ErrorCode_t
Definition: le_avc_interface.h:683
Download has completed.
Definition: le_avc_interface.h:580
le_result_t le_avc_GetRetryTimers(uint16_t *timerValuePtr, size_t *timerValueSizePtr)
No updates pending.
Definition: le_avc_interface.h:574
le_avc_CredentialStatus_t
Definition: le_avc_interface.h:720
uint16_t le_avc_GetHttpStatus(void)
struct le_avc_StatusEventHandler * le_avc_StatusEventHandlerRef_t
Definition: le_avc_interface.h:739
Encountered a bad package.
Definition: le_avc_interface.h:687
le_avc_Status_t
Definition: le_avc_interface.h:572
App has been successfully uninstalled.
Definition: le_avc_interface.h:596
Device Management credential is provisioned.
Definition: le_avc_interface.h:728
Authentication with AV server failed.
Definition: le_avc_interface.h:613
le_avc_ErrorCode_t le_avc_GetErrorCode(void)
void le_avc_ConnectService(void)