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  * @note If firmware is updated (via fwupdate tool) or new legato is installed (via instlegato)
213  * , all suspend/resume information stored by avcService is erased. So if developer updates firmware
214  * or legato (via ethernet or ecm etc.) in the middle of any update initiated by avcService, this
215  * need to be cancelled and restarted again from airVantage server.
216  *
217  * @section c_le_avc_Timers Timers
218  *
219  * Polling timers sets the time that the Target will communicate with the AirVantage Server to check
220  * for new jobs. Retry timers will try and re-establish a connection to the AirVantage Server in
221  * accordance with the times that are declared.
222  *
223  * @subsection c_le_avc_PollingTimer Polling Timer
224  *
225  * The target will periodically initiate a connection to the AirVantage Server according to the
226  * settings for the polling timer to check if there are any pending jobs.
227  *
228  * If you need to disable the poling timer call le_avc_SetPollingTimer() and set the value to 0.
229  *
230  * The polling timer accepts ranges from 0 to 525600 minutes and is persistent across reboots and
231  * upgrades.
232  *
233  * To read the polling timer call: le_avc_GetPollingTimer()
234  *
235  * To write a new value to the polling timer call: le_avc_SetPollingTimer()
236  *
237  * Writing to the polling timer stops the current polling timer if it is running and starts a timer
238  * with the new value. The next connection will be initated when the new polling timer expires.
239  *
240  * @subsection c_le_avc_RetryTimers Retry Timers
241  *
242  * If an error occurs during a connection to the Device Services server (WWAN DATA establishment
243  * failed and an http error code is received) the embedded module will initiate a new connection
244  * according to the values defined in the retry timers.
245  *
246  * The timers are tried in sequence until a connection is established, or all enabled retry timers
247  * are exhausted. After all the enabled timers are exhausted, a new session must be initiated again
248  * by calling le_avc_startSession() after the expiry of the retry timer.
249  *
250  * The retry timer values are persistent (reboots and updates do not effect the retry timers).
251  * If you wish to disable a retry timer set the timer value
252  * to 0. You must always pass in at least 8 values to the retry timers.
253  *
254  * Retry timer values range from 0 to 20160 minutes.
255  * The function le_avc_GetRetryTimers() reads the retry timers in an array and the function
256  * le_avc_SetRetryTimers() writes the retry timers. When writing to the retry timers, values of
257  * all the 8 timers have to be defined.
258  *
259  * Example of calling retry timers, the session will be retried after 15 minutes, 1 hour, 4 hours,
260  * 8 hours, 1 day and 2 days, the last two retries are disabled:
261  * @code
262  * uint16_t RetryTimers[LE_AVC_NUM_RETRY_TIMERS] = {15, 60, 240, 480, 1440, 2880, 0, 0};
263  * le_avc_SetRetryTimers(RetryTimers, LE_AVC_NUM_RETRY_TIMERS);
264  * @endcode
265  *
266  * @section c_le_avc_reboot Device reboot
267  *
268  * The AirVantage server can request to reboot the device. If a reboot is requested a notification
269  * is sent to the registered Apps. The App can either accept the reboot with le_avc_AcceptReboot()
270  * or defer it for a specified number of minutes with le_avc_DeferReboot(). After the defer time
271  * has elapsed, the pending reboot notification will be re-sent. This allows the registered app to
272  * make a new decision or defer the reboot again.
273  *
274  * If no App has registered for notifications using le_avc_AddStatusEventHandler(), then
275  * any pending reboot will happen automatically.
276  *
277  * @section c_le_avc_GetCredentialStatus Credential Status
278  * The device is provisioned with bootstrap credentials from factory. The Device Management (DM)
279  * credentials are provisioned by AirVantage Bootstrap Server. This API is used to retrieve the
280  * status of credentials provisioned on the device.
281  *
282  * @section c_le_avc_connection Connection pending
283  *
284  * The AirVantage agent can request a connection to the AirVantage server, especially when a
285  * firmware package is installed (after a platform reboot) or device reboots in the middle of
286  * software update (after finishing software update on reboot). In this case a notification is sent
287  * to the control App, which can start the connection with le_avc_StartSession().
288  *
289  * @section c_le_avc_routing Data routing
290  *
291  * By default the AirVantage connection uses the default mobile data profile and the default route
292  * set by the data connection service.
293  *
294  * If the user wishes to control the network configuration, e.g. to use the AirVantage agent with
295  * multi-PDP contexts, they should first bind the application to the data connection service:
296  * @verbatim
297  bindings:
298  {
299  clientExe.clientComponent.le_data -> dataConnectionService.le_data
300  }
301  @endverbatim
302  *
303  * The data connection service should then be configured before launching the AirVantage connection:
304  * - le_data_SetCellularProfileIndex() allows to change the data profile to use.
305  * - le_data_GetDefaultRouteStatus() indicates if the default route is activated in the data
306  * connection service. This default route can be deactivated in the data connection service
307  * configuration database, as explained in @ref c_le_data_defaultRoute. If the default route is
308  * deactivated, the AirVantage agent will automatically add routes to be able to reach the
309  * AirVantage server through the connection used by AirVantage.
310  *
311  * @section c_le_avc_timeout Connection / Download timeout
312  *
313  * The AirVantage connector service will abort FOTA/SOTA download, if it takes more than
314  * 300 seconds to establish a connection. Download will also be aborted, if the download speed is
315  * too low (less than 100 bytes /second) for too long (for more than 1000 seconds).
316  * These values are chosen based on experiments on low speed network. There is no configuration
317  * for these timeouts.
318  *
319  * @section le_avcService_configdb Service Configuration Tree
320  * @copydoc le_avcService_configdbPage_Hide
321  *
322  *
323  * Copyright (C) Sierra Wireless Inc.
324  */
325 /**
326  * @interface le_avcService_configdbPage_Hide
327  *
328  * The configuration database path for the activityTimeout is:
329  * @verbatim
330  /
331  apps/
332  avcService/
333  activityTimeout
334  @endverbatim
335  *
336  *
337  * After an AirVantage session is started, if there's no activity between the device and the server
338  * within the timer interval, then LE_AVC_NO_UPDATE state will be returned to the app. However,
339  * this activity timeout can be overridden by setting an integer value for
340  * /apps/avcService/activityTimeout. The activity timer is initialized only when the @c avcService
341  * starts. If a valid entry >0 is found, then it will be used instead of the default value of 20
342  * seconds. The following steps should be used to set the activityTimeout.
343  *
344  *
345  * @verbatim
346  config set /apps/avcService/activityTimeout xx int
347  app restart avcService
348  @endverbatim
349  *
350  * @note
351  * Everytime a new value is written to activityTimeout, the avcService needs to be
352  * restarted to read the new value.
353  *
354  *
355  */
356 /**
357  * @file le_avc_interface.h
358  *
359  * Legato @ref c_le_avc include file.
360  *
361  * Copyright (C) Sierra Wireless Inc.
362  */
363 
364 #ifndef LE_AVC_INTERFACE_H_INCLUDE_GUARD
365 #define LE_AVC_INTERFACE_H_INCLUDE_GUARD
366 
367 
368 #include "legato.h"
369 
370 // Interface specific includes
371 #include "le_limit_interface.h"
372 
373 
374 //--------------------------------------------------------------------------------------------------
375 /**
376  * Type for handler called when a server disconnects.
377  */
378 //--------------------------------------------------------------------------------------------------
379 typedef void (*le_avc_DisconnectHandler_t)(void *);
380 
381 //--------------------------------------------------------------------------------------------------
382 /**
383  *
384  * Connect the current client thread to the service providing this API. Block until the service is
385  * available.
386  *
387  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
388  * called before any other functions in this API. Normally, ConnectService is automatically called
389  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
390  *
391  * This function is created automatically.
392  */
393 //--------------------------------------------------------------------------------------------------
395 (
396  void
397 );
398 
399 //--------------------------------------------------------------------------------------------------
400 /**
401  *
402  * Try to connect the current client thread to the service providing this API. Return with an error
403  * if the service is not available.
404  *
405  * For each thread that wants to use this API, either ConnectService or TryConnectService must be
406  * called before any other functions in this API. Normally, ConnectService is automatically called
407  * for the main thread, but not for any other thread. For details, see @ref apiFilesC_client.
408  *
409  * This function is created automatically.
410  *
411  * @return
412  * - LE_OK if the client connected successfully to the service.
413  * - LE_UNAVAILABLE if the server is not currently offering the service to which the client is
414  * bound.
415  * - LE_NOT_PERMITTED if the client interface is not bound to any service (doesn't have a binding).
416  * - LE_COMM_ERROR if the Service Directory cannot be reached.
417  */
418 //--------------------------------------------------------------------------------------------------
420 (
421  void
422 );
423 
424 //--------------------------------------------------------------------------------------------------
425 /**
426  * Set handler called when server disconnection is detected.
427  *
428  * When a server connection is lost, call this handler then exit with LE_FATAL. If a program wants
429  * to continue without exiting, it should call longjmp() from inside the handler.
430  */
431 //--------------------------------------------------------------------------------------------------
433 (
434  le_avc_DisconnectHandler_t disconnectHandler,
435  void *contextPtr
436 );
437 
438 //--------------------------------------------------------------------------------------------------
439 /**
440  *
441  * Disconnect the current client thread from the service providing this API.
442  *
443  * Normally, this function doesn't need to be called. After this function is called, there's no
444  * longer a connection to the service, and the functions in this API can't be used. For details, see
445  * @ref apiFilesC_client.
446  *
447  * This function is created automatically.
448  */
449 //--------------------------------------------------------------------------------------------------
451 (
452  void
453 );
454 
455 
456 //--------------------------------------------------------------------------------------------------
457 /**
458  * Maximum APN name length without NULL terminator.
459  */
460 //--------------------------------------------------------------------------------------------------
461 #define LE_AVC_APN_NAME_MAX_LEN 48
462 
463 //--------------------------------------------------------------------------------------------------
464 /**
465  * Maximum APN name length including NULL terminator.
466  */
467 //--------------------------------------------------------------------------------------------------
468 #define LE_AVC_APN_NAME_MAX_LEN_BYTES 49
469 
470 //--------------------------------------------------------------------------------------------------
471 /**
472  * Maximum user name length without NULL terminator.
473  */
474 //--------------------------------------------------------------------------------------------------
475 #define LE_AVC_USERNAME_MAX_LEN 28
476 
477 //--------------------------------------------------------------------------------------------------
478 /**
479  * Maximum user name length including NULL terminator.
480  */
481 //--------------------------------------------------------------------------------------------------
482 #define LE_AVC_USERNAME_MAX_LEN_BYTES 29
483 
484 //--------------------------------------------------------------------------------------------------
485 /**
486  * Maximum password length without NULL terminator..
487  */
488 //--------------------------------------------------------------------------------------------------
489 #define LE_AVC_PASSWORD_MAX_LEN 28
490 
491 //--------------------------------------------------------------------------------------------------
492 /**
493  * Maximum password length including NULL terminator.
494  */
495 //--------------------------------------------------------------------------------------------------
496 #define LE_AVC_PASSWORD_MAX_LEN_BYTES 29
497 
498 //--------------------------------------------------------------------------------------------------
499 /**
500  * Maximum number of retry timers.
501  */
502 //--------------------------------------------------------------------------------------------------
503 #define LE_AVC_NUM_RETRY_TIMERS 8
504 
505 //--------------------------------------------------------------------------------------------------
506 /**
507  * Polling timer value range in minutes. 525600 minutes = 1 year.
508  */
509 //--------------------------------------------------------------------------------------------------
510 #define LE_AVC_POLLING_TIMER_MAX_VAL 525600
511 
512 //--------------------------------------------------------------------------------------------------
513 /**
514  */
515 //--------------------------------------------------------------------------------------------------
516 #define LE_AVC_POLLING_TIMER_MIN_VAL 0
517 
518 //--------------------------------------------------------------------------------------------------
519 /**
520  * Retry timer value range in minutes. 20160 minutes = 2 weeks.
521  */
522 //--------------------------------------------------------------------------------------------------
523 #define LE_AVC_RETRY_TIMER_MAX_VAL 20160
524 
525 //--------------------------------------------------------------------------------------------------
526 /**
527  */
528 //--------------------------------------------------------------------------------------------------
529 #define LE_AVC_RETRY_TIMER_MIN_VAL 0
530 
531 //--------------------------------------------------------------------------------------------------
532 /**
533  * Default HTTP status.
534  */
535 //--------------------------------------------------------------------------------------------------
536 #define LE_AVC_HTTP_STATUS_INVALID 65535
537 
538 //--------------------------------------------------------------------------------------------------
539 /**
540  * Status of session or update
541  *
542  * If an update is pending, it must first be downloaded and then installed.
543  */
544 //--------------------------------------------------------------------------------------------------
545 typedef enum
546 {
548  ///< No updates pending
550  ///< Update pending download
552  ///< Download in progress
554  ///< Download has completed
556  ///< An error occurred downloading the update
558  ///< Install is pending (implies download complete)
560  ///< Install in progress
562  ///< Update has been successfully installed
564  ///< An error occurred installing the update
566  ///< Uninstall is pending
568  ///< Uninstall in progress
570  ///< App has been successfully uninstalled
572  ///< An error occurred uninstalling the update
574  ///< Session with AV server started
576  ///< Session with AV server stopped
578  ///< Device reboot is pending
580  ///< Connection to the server is required. This is necessary when
581  ///< firmware package is installed (after a platform reboot). Also
582  ///< necessary after software update if device reboots(or session stops)
583  ///< in the middle of software update.
585  ///< Authentication with AV server started
587  ///< Authentication with AV server failed
588 }
590 
591 
592 //--------------------------------------------------------------------------------------------------
593 /**
594  * Operations which require user agreement
595  */
596 //--------------------------------------------------------------------------------------------------
597 typedef enum
598 {
600  ///< User agreement for connection
602  ///< User agreement for download
604  ///< User agreement for install
606  ///< User agreement for uninstall
608  ///< User agreement for reboot
609 }
611 
612 
613 //--------------------------------------------------------------------------------------------------
614 /**
615  * Request to open or close avms session.
616  */
617 //--------------------------------------------------------------------------------------------------
618 typedef enum
619 {
621  ///< Request by user app to open AV session
623  ///< Request by user app to close AV session
624 }
626 
627 
628 //--------------------------------------------------------------------------------------------------
629 /**
630  * The type of pending update
631  */
632 //--------------------------------------------------------------------------------------------------
633 typedef enum
634 {
635  LE_AVC_UNKNOWN_UPDATE = 0,
636  ///<
637  LE_AVC_FIRMWARE_UPDATE = 1,
638  ///<
639  LE_AVC_FRAMEWORK_UPDATE = 2,
640  ///<
641  LE_AVC_APPLICATION_UPDATE = 3
642  ///<
643 }
645 
646 
647 //--------------------------------------------------------------------------------------------------
648 /**
649  * Error code used to provide diagnostic information after a failure (includes both download and
650  * install failure).
651  *
652  * @note
653  * Additional information may also be available in the target device's system log.
654  */
655 //--------------------------------------------------------------------------------------------------
656 typedef enum
657 {
659  ///< No error.
661  ///< Encountered a bad package.
663  ///< Something failed while doing install/download.
665  ///< Security check failure while installing the package.
666 }
668 
669 
670 //--------------------------------------------------------------------------------------------------
671 /**
672  * Session type indicates whether the device is connected to the bootstrap server or the
673  * device management server.
674  */
675 //--------------------------------------------------------------------------------------------------
676 typedef enum
677 {
679  ///< Bootstrap session.
681  ///< Device Management session.
683  ///< Session type invalid.
684 }
686 
687 
688 //--------------------------------------------------------------------------------------------------
689 /**
690  * Status of the device credentials
691  */
692 //--------------------------------------------------------------------------------------------------
693 typedef enum
694 {
696  ///< Neither Bootstrap nor Device Management
697  ///< credential is provisioned.
699  ///< Bootstrap credential is provisioned but Device
700  ///< Management credential is not provisioned.
702  ///< Device Management credential is provisioned.
703 }
705 
706 
707 //--------------------------------------------------------------------------------------------------
708 /**
709  * Reference type used by Add/Remove functions for EVENT 'le_avc_StatusEvent'
710  */
711 //--------------------------------------------------------------------------------------------------
712 typedef struct le_avc_StatusEventHandler* le_avc_StatusEventHandlerRef_t;
713 
714 
715 //--------------------------------------------------------------------------------------------------
716 /**
717  * Reference type used by Add/Remove functions for EVENT 'le_avc_SessionRequestEvent'
718  */
719 //--------------------------------------------------------------------------------------------------
720 typedef struct le_avc_SessionRequestEventHandler* le_avc_SessionRequestEventHandlerRef_t;
721 
722 
723 //--------------------------------------------------------------------------------------------------
724 /**
725  * Reference returned by BlockInstall function and used by UnblockInstall function
726  */
727 //--------------------------------------------------------------------------------------------------
728 typedef struct le_avc_BlockRequest* le_avc_BlockRequestRef_t;
729 
730 
731 //--------------------------------------------------------------------------------------------------
732 /**
733  * Handler for update availability status
734  */
735 //--------------------------------------------------------------------------------------------------
736 typedef void (*le_avc_StatusHandlerFunc_t)
737 (
738  le_avc_Status_t updateStatus,
739  ///< status of pending update, if available
740  int32_t totalNumBytes,
741  ///< Total number of bytes to be downloaded
742  ///< only valid when updateStatus is one of
743  ///< DOWNLOAD_PENDING, DOWNLOAD_IN_PROGRESS or DOWNLOAD_COMPLETE.
744  ///< returns -1 if value is unknown
745  int32_t dloadProgress,
746  ///< download completion in percentage
747  ///< only valid when updateStatus is one of
748  ///< DOWNLOAD_PENDING, DOWNLOAD_IN_PROGRESS or DOWNLOAD_COMPLETE.
749  ///< returns -1 if value is unknown
750  void* contextPtr
751  ///<
752 );
753 
754 //--------------------------------------------------------------------------------------------------
755 /**
756  * Handler for receiving session open or close request.
757  */
758 //--------------------------------------------------------------------------------------------------
760 (
761  le_avc_SessionRequest_t request,
762  ///< Request to open or close AV session
763  void* contextPtr
764  ///<
765 );
766 
767 //--------------------------------------------------------------------------------------------------
768 /**
769  * Add handler function for EVENT 'le_avc_StatusEvent'
770  *
771  * This event provides information on update availability status
772  */
773 //--------------------------------------------------------------------------------------------------
775 (
776  le_avc_StatusHandlerFunc_t handlerPtr,
777  ///< [IN]
778  void* contextPtr
779  ///< [IN]
780 );
781 
782 //--------------------------------------------------------------------------------------------------
783 /**
784  * Remove handler function for EVENT 'le_avc_StatusEvent'
785  */
786 //--------------------------------------------------------------------------------------------------
788 (
790  ///< [IN]
791 );
792 
793 //--------------------------------------------------------------------------------------------------
794 /**
795  * Add handler function for EVENT 'le_avc_SessionRequestEvent'
796  *
797  * This event provides information on session open or close request.
798  */
799 //--------------------------------------------------------------------------------------------------
801 (
803  ///< [IN]
804  void* contextPtr
805  ///< [IN]
806 );
807 
808 //--------------------------------------------------------------------------------------------------
809 /**
810  * Remove handler function for EVENT 'le_avc_SessionRequestEvent'
811  */
812 //--------------------------------------------------------------------------------------------------
814 (
816  ///< [IN]
817 );
818 
819 //--------------------------------------------------------------------------------------------------
820 /**
821  * Start a session with the AirVantage server
822  *
823  * This will cause a query to be sent to the server, for pending updates. If a download was
824  * previously suspended, then this resumes the download.
825  *
826  * @return
827  * - LE_OK if connection request has been sent.
828  * - LE_FAULT on failure
829  * - LE_DUPLICATE if already connected.
830  * - LE_BUSY if currently retrying.
831  */
832 //--------------------------------------------------------------------------------------------------
834 (
835  void
836 );
837 
838 //--------------------------------------------------------------------------------------------------
839 /**
840  * Stop a session with the AirVantage server
841  *
842  * If a download is in progress, then this suspends the download.
843  *
844  * @return
845  * - LE_OK on success
846  * - LE_FAULT on failure
847  */
848 //--------------------------------------------------------------------------------------------------
850 (
851  void
852 );
853 
854 //--------------------------------------------------------------------------------------------------
855 /**
856  * Send a specific message to the server to be sure that the route between the device and the server
857  * is available.
858  * This API needs to be called when any package download is over (successfully or not) and before
859  * sending any notification on asset data to the server.
860  *
861  * @return
862  * - LE_OK when the treatment is launched
863  * - LE_FAULT on failure
864  * - LE_UNSUPPORTED when the API is not supported
865  *
866  */
867 //--------------------------------------------------------------------------------------------------
869 (
870  void
871 );
872 
873 //--------------------------------------------------------------------------------------------------
874 /**
875  * Defer the currently pending connection, for the given number of minutes
876  *
877  * @return
878  * - LE_OK on success
879  * - LE_FAULT on failure
880  */
881 //--------------------------------------------------------------------------------------------------
883 (
884  uint32_t deferMinutes
885  ///< [IN]
886 );
887 
888 //--------------------------------------------------------------------------------------------------
889 /**
890  * Accept the currently pending download
891  *
892  * @return
893  * - LE_OK on success
894  * - LE_FAULT on failure
895  */
896 //--------------------------------------------------------------------------------------------------
898 (
899  void
900 );
901 
902 //--------------------------------------------------------------------------------------------------
903 /**
904  * Defer the currently pending download, for the given number of minutes
905  *
906  * @return
907  * - LE_OK on success
908  * - LE_FAULT on failure
909  */
910 //--------------------------------------------------------------------------------------------------
912 (
913  uint32_t deferMinutes
914  ///< [IN]
915 );
916 
917 //--------------------------------------------------------------------------------------------------
918 /**
919  * Accept the currently pending install
920  *
921  * @return
922  * - LE_OK on success
923  * - LE_FAULT on failure
924  */
925 //--------------------------------------------------------------------------------------------------
927 (
928  void
929 );
930 
931 //--------------------------------------------------------------------------------------------------
932 /**
933  * Defer the currently pending install
934  *
935  * @return
936  * - LE_OK on success
937  * - LE_FAULT on failure
938  */
939 //--------------------------------------------------------------------------------------------------
941 (
942  uint32_t deferMinutes
943  ///< [IN]
944 );
945 
946 //--------------------------------------------------------------------------------------------------
947 /**
948  * Accept the currently pending uninstall
949  *
950  * @return
951  * - LE_OK on success
952  * - LE_FAULT on failure
953  */
954 //--------------------------------------------------------------------------------------------------
956 (
957  void
958 );
959 
960 //--------------------------------------------------------------------------------------------------
961 /**
962  * Defer the currently pending uninstall
963  *
964  * @return
965  * - LE_OK on success
966  * - LE_FAULT on failure
967  */
968 //--------------------------------------------------------------------------------------------------
970 (
971  uint32_t deferMinutes
972  ///< [IN]
973 );
974 
975 //--------------------------------------------------------------------------------------------------
976 /**
977  * Accept the currently pending reboot
978  *
979  * @return
980  * - LE_OK on success
981  * - LE_FAULT on failure
982  */
983 //--------------------------------------------------------------------------------------------------
985 (
986  void
987 );
988 
989 //--------------------------------------------------------------------------------------------------
990 /**
991  * Defer the currently pending reboot
992  *
993  * @return
994  * - LE_OK on success
995  * - LE_FAULT on failure
996  */
997 //--------------------------------------------------------------------------------------------------
999 (
1000  uint32_t deferMinutes
1001  ///< [IN]
1002 );
1003 
1004 //--------------------------------------------------------------------------------------------------
1005 /**
1006  * Get the update type of the currently pending update
1007  *
1008  * @return
1009  * - LE_OK on success
1010  * - LE_FAULT if not available
1011  */
1012 //--------------------------------------------------------------------------------------------------
1014 (
1015  le_avc_UpdateType_t* updateTypePtr
1016  ///< [OUT]
1017 );
1018 
1019 //--------------------------------------------------------------------------------------------------
1020 /**
1021  * Get the name for the currently pending app update
1022  *
1023  * @return
1024  * - LE_OK on success
1025  * - LE_FAULT if not available, or isn't APPL_UPDATE type
1026  */
1027 //--------------------------------------------------------------------------------------------------
1029 (
1030  char* updateName,
1031  ///< [OUT]
1032  size_t updateNameSize
1033  ///< [IN]
1034 );
1035 
1036 //--------------------------------------------------------------------------------------------------
1037 /**
1038  * Prevent any pending updates from being installed.
1039  *
1040  * @return
1041  * - Reference for block update request (to be used later for unblocking updates)
1042  * - NULL if the operation was not successful
1043  */
1044 //--------------------------------------------------------------------------------------------------
1046 (
1047  void
1048 );
1049 
1050 //--------------------------------------------------------------------------------------------------
1051 /**
1052  * Allow any pending updates to be installed
1053  */
1054 //--------------------------------------------------------------------------------------------------
1056 (
1057  le_avc_BlockRequestRef_t blockRef
1058  ///< [IN] block request ref returned by le_avc_BlockInstall
1059 );
1060 
1061 //--------------------------------------------------------------------------------------------------
1062 /**
1063  * Function to get error code when update fails.
1064  *
1065  * @return
1066  * - Error code of encountered error.
1067  * - ERR_NONE if update is in any other state.
1068  */
1069 //--------------------------------------------------------------------------------------------------
1071 (
1072  void
1073 );
1074 
1075 //--------------------------------------------------------------------------------------------------
1076 /**
1077  * Function to read the current session type, or the last session type if there is no
1078  * active session.
1079  *
1080  * @return
1081  * - SessionType
1082  */
1083 //--------------------------------------------------------------------------------------------------
1085 (
1086  void
1087 );
1088 
1089 //--------------------------------------------------------------------------------------------------
1090 /**
1091  * Function to read the http status of the last download.
1092  *
1093  * @return
1094  * - HttpStatus as defined in RFC 7231, Section 6.
1095  */
1096 //--------------------------------------------------------------------------------------------------
1097 uint16_t le_avc_GetHttpStatus
1098 (
1099  void
1100 );
1101 
1102 //--------------------------------------------------------------------------------------------------
1103 /**
1104  * Function to read the polling timer.
1105  *
1106  * @return
1107  * - LE_OK on success
1108  * - LE_FAULT if not available
1109  * - LE_OUT_OF_RANGE if the polling timer value is out of range (0 to 525600).
1110  */
1111 //--------------------------------------------------------------------------------------------------
1113 (
1114  uint32_t* pollingTimerPtr
1115  ///< [OUT] Polling timer
1116 );
1117 
1118 //--------------------------------------------------------------------------------------------------
1119 /**
1120  * Function to read the retry timers.
1121  *
1122  * @return
1123  * - LE_OK on success.
1124  * - LE_FAULT if not able to read the timers.
1125  * - LE_OUT_OF_RANGE if one of the retry timers is out of range (0 to 20160).
1126  */
1127 //--------------------------------------------------------------------------------------------------
1129 (
1130  uint16_t* timerValuePtr,
1131  ///< [OUT] Array of the retry timers.
1132  size_t* timerValueSizePtr
1133  ///< [INOUT]
1134 );
1135 
1136 //--------------------------------------------------------------------------------------------------
1137 /**
1138  * Function to read APN configuration.
1139  *
1140  * @return
1141  * - LE_OK on success.
1142  * - LE_FAULT if there is any error while reading.
1143  * - LE_OVERFLOW if the buffer provided is too small.
1144  */
1145 //--------------------------------------------------------------------------------------------------
1147 (
1148  char* apnName,
1149  ///< [OUT]
1150  size_t apnNameSize,
1151  ///< [IN]
1152  char* userName,
1153  ///< [OUT]
1154  size_t userNameSize,
1155  ///< [IN]
1156  char* userPwd,
1157  ///< [OUT]
1158  size_t userPwdSize
1159  ///< [IN]
1160 );
1161 
1162 //--------------------------------------------------------------------------------------------------
1163 /**
1164  * Function to write APN configuration.
1165  *
1166  * @return
1167  * - LE_OK on success.
1168  * - LE_OVERFLOW if one of the input strings is too long.
1169  */
1170 //--------------------------------------------------------------------------------------------------
1172 (
1173  const char* LE_NONNULL apnName,
1174  ///< [IN]
1175  const char* LE_NONNULL userName,
1176  ///< [IN]
1177  const char* LE_NONNULL userPwd
1178  ///< [IN]
1179 );
1180 
1181 //--------------------------------------------------------------------------------------------------
1182 /**
1183  * Function to set the polling timer.
1184  *
1185  * @return
1186  * - LE_OK on success.
1187  * - LE_OUT_OF_RANGE if the polling timer value is out of range (0 to 525600).
1188  */
1189 //--------------------------------------------------------------------------------------------------
1191 (
1192  uint32_t pollingTimer
1193  ///< [IN] Polling timer
1194 );
1195 
1196 //--------------------------------------------------------------------------------------------------
1197 /**
1198  * Function to set the retry timers.
1199  *
1200  * @return
1201  * - LE_OK on success.
1202  * - LE_FAULT if not able to set the timers.
1203  * - LE_OUT_OF_RANGE if one of the retry timers is out of range (0 to 20160).
1204  */
1205 //--------------------------------------------------------------------------------------------------
1207 (
1208  const uint16_t* timerValuePtr,
1209  ///< [IN] Array of 8 retry timers.
1210  size_t timerValueSize
1211  ///< [IN]
1212 );
1213 
1214 //--------------------------------------------------------------------------------------------------
1215 /**
1216  * Function to retrieve status of the credentials provisioned on the device.
1217  *
1218  * @return
1219  * LE_AVC_NO_CREDENTIAL_PROVISIONED
1220  * - If neither Bootstrap nor Device Management credential is provisioned.
1221  * LE_AVC_BS_CREDENTIAL_PROVISIONED
1222  * - If Bootstrap credential is provisioned but Device Management credential is
1223  * not provisioned.
1224  * LE_AVC_DM_CREDENTIAL_PROVISIONED
1225  * - If Device management key is provisioned.
1226  */
1227 //--------------------------------------------------------------------------------------------------
1229 (
1230  void
1231 );
1232 
1233 //--------------------------------------------------------------------------------------------------
1234 /**
1235  * Function to set user agreements for download, install, reboot, connection and uninstall.
1236  *
1237  * @return
1238  * - LE_OK on success.
1239  * - LE_FAULT if failed to configure user agreement.
1240  */
1241 //--------------------------------------------------------------------------------------------------
1243 (
1244  le_avc_UserAgreement_t updateStatus,
1245  ///< [IN] Operation for which user agreements has to be set.
1246  bool enable
1247  ///< [IN] true = enable, false = disable.
1248 );
1249 
1250 //--------------------------------------------------------------------------------------------------
1251 /**
1252  * Function to get user agreements for download, install, reboot, connection and uninstall.
1253  *
1254  * @return
1255  * - LE_OK on success.
1256  * - LE_FAULT if failed to read user agreement state.
1257  */
1258 //--------------------------------------------------------------------------------------------------
1260 (
1261  le_avc_UserAgreement_t updateStatus,
1262  ///< [IN] Operation for which user agreements has to be read.
1263  bool* enablePtr
1264  ///< [OUT] true = enable, false = disable.
1265 );
1266 
1267 #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:567
void(* le_avc_StatusHandlerFunc_t)(le_avc_Status_t updateStatus, int32_t totalNumBytes, int32_t dloadProgress, void *contextPtr)
Definition: le_avc_interface.h:737
Uninstall is pending.
Definition: le_avc_interface.h:565
Request by user app to close AV session.
Definition: le_avc_interface.h:622
User agreement for reboot.
Definition: le_avc_interface.h:607
User agreement for connection.
Definition: le_avc_interface.h:599
An error occurred installing the update.
Definition: le_avc_interface.h:563
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:760
le_result_t le_avc_AcceptReboot(void)
An error occurred uninstalling the update.
Definition: le_avc_interface.h:571
Install in progress.
Definition: le_avc_interface.h:559
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:720
le_avc_SessionRequest_t
Definition: le_avc_interface.h:618
An error occurred downloading the update.
Definition: le_avc_interface.h:555
le_avc_UserAgreement_t
Definition: le_avc_interface.h:597
le_result_t le_avc_DeferUninstall(uint32_t deferMinutes)
Install is pending (implies download complete)
Definition: le_avc_interface.h:557
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:379
Session with AV server stopped.
Definition: le_avc_interface.h:575
Session with AV server started.
Definition: le_avc_interface.h:573
le_avc_SessionType_t
Definition: le_avc_interface.h:676
Download in progress.
Definition: le_avc_interface.h:551
Definition: le_avc_interface.h:695
Device reboot is pending.
Definition: le_avc_interface.h:577
Session type invalid.
Definition: le_avc_interface.h:682
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:584
le_result_t le_avc_GetUserAgreement(le_avc_UserAgreement_t updateStatus, bool *enablePtr)
Update pending download.
Definition: le_avc_interface.h:549
User agreement for uninstall.
Definition: le_avc_interface.h:605
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:561
User agreement for install.
Definition: le_avc_interface.h:603
le_result_t le_avc_AcceptInstall(void)
Something failed while doing install/download.
Definition: le_avc_interface.h:662
User agreement for download.
Definition: le_avc_interface.h:601
Bootstrap session.
Definition: le_avc_interface.h:678
struct le_avc_BlockRequest * le_avc_BlockRequestRef_t
Definition: le_avc_interface.h:728
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:680
No error.
Definition: le_avc_interface.h:658
le_result_t le_avc_SetUserAgreement(le_avc_UserAgreement_t updateStatus, bool enable)
Definition: le_avc_interface.h:698
Definition: le_avc_interface.h:579
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:633
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:664
Request by user app to open AV session.
Definition: le_avc_interface.h:620
le_result_t le_avc_GetAppUpdateName(char *updateName, size_t updateNameSize)
le_avc_ErrorCode_t
Definition: le_avc_interface.h:656
Download has completed.
Definition: le_avc_interface.h:553
le_result_t le_avc_GetRetryTimers(uint16_t *timerValuePtr, size_t *timerValueSizePtr)
No updates pending.
Definition: le_avc_interface.h:547
le_avc_CredentialStatus_t
Definition: le_avc_interface.h:693
uint16_t le_avc_GetHttpStatus(void)
struct le_avc_StatusEventHandler * le_avc_StatusEventHandlerRef_t
Definition: le_avc_interface.h:712
Encountered a bad package.
Definition: le_avc_interface.h:660
le_avc_Status_t
Definition: le_avc_interface.h:545
App has been successfully uninstalled.
Definition: le_avc_interface.h:569
Device Management credential is provisioned.
Definition: le_avc_interface.h:701
Authentication with AV server failed.
Definition: le_avc_interface.h:586
le_avc_ErrorCode_t le_avc_GetErrorCode(void)
void le_avc_ConnectService(void)