libwebsockets
Lightweight C library for HTML5 websockets
Toggle main menu visibility
class="ui-resizable-handle">
Loading...
Searching...
No Matches
lws-ota.h
Go to the documentation of this file.
1
/*
2
* lws OTA updates
3
*
4
* Copyright (C) 2019 - 2022 Andy Green <andy@warmcat.com>
5
*
6
* Permission is hereby granted, free of charge, to any person obtaining a copy
7
* of this software and associated documentation files (the "Software"), to
8
* deal in the Software without restriction, including without limitation the
9
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
10
* sell copies of the Software, and to permit persons to whom the Software is
11
* furnished to do so, subject to the following conditions:
12
*
13
* The above copyright notice and this permission notice shall be included in
14
* all copies or substantial portions of the Software.
15
*
16
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
22
* IN THE SOFTWARE.
23
*
24
* This is the platform interface that lws_ota uses to flash new firmware.
25
* The platform implementation for these ops is set via lws_system and consists
26
* of user code.
27
*
28
* All the update-related calls have async interfaces with a callback and opaque
29
* callback context that is called on completion. This allows us to, eg,
30
* download the next buffer while flashing the previous one.
31
*
32
* If the platform implementation is actually synchronous, then just call the
33
* callback before returning.
34
*
35
* If it is async, because eg, erase is slow, in the platform ota op
36
* implementation spawn a thread to do the platform operation, return
37
* immediately with LWSOTARET_ONGOING, and call the callback from the spawned
38
* thread context with the real return before terminating the thread.
39
*/
40
41
typedef
void
*
lws_ota_process_t
;
42
43
typedef
enum
{
44
LWSOTARET_OK
,
45
LWSOTARET_ONGOING
,
/* result not ready to read yet */
46
LWSOTARET_REJECTED
,
47
LWSOTARET_NOSLOT
,
48
49
LWSOTARET_UPDATE_AVAILABLE
,
50
LWSOTARET_PROGRESS
,
51
LWSOTARET_FAILED
,
52
LWSOTARET_COMPLETED
53
}
lws_ota_ret_t
;
54
55
typedef
enum
{
56
LWS_OTA_ASYNC_START
= 1,
57
LWS_OTA_ASYNC_WRITE
,
58
LWS_OTA_ASYNC_ABORT
,
59
LWS_OTA_ASYNC_FINALIZE
60
}
lws_ota_async_t
;
61
62
struct
lws_ota;
63
64
typedef
void (*
lws_ota_cb_t
)(
void
*ctx,
lws_ota_ret_t
r);
65
66
typedef
struct
{
67
68
/* asynchronous (completions via lws_cancel_service) */
69
70
int (*
ota_start
)(
struct
lws_ota *g);
72
73
void (*
ota_queue
)(
struct
lws_ota *g,
lws_ota_async_t
a);
75
76
/* synchronous */
77
78
int (*
ota_report_current
)(
struct
lws_ota *g,
int
bad);
84
85
int (*
ota_progress
)(
lws_ota_ret_t
state,
int
percent);
88
89
int (*
ota_get_last_fw_unixtime
)(uint64_t *fw_unixtime);
93
94
int
ota_periodic_check_secs
;
96
}
lws_ota_ops_t
;
97
104
105
LWS_VISIBLE
LWS_EXTERN
const
char
*
106
lws_ota_variant_name
(
void
);
107
108
LWS_VISIBLE
LWS_EXTERN
int
109
lws_plat_ota_start
(
struct
lws_ota *g);
110
111
112
#define LWSOTAFIN_OK 0
113
#define LWSOTAFIN_BAD 1
114
115
LWS_VISIBLE
LWS_EXTERN
void
116
lws_plat_ota_queue
(
struct
lws_ota *g,
lws_ota_async_t
a);
117
118
LWS_VISIBLE
LWS_EXTERN
int
119
lws_plat_ota_report_current
(
struct
lws_ota *g,
int
bad);
120
121
LWS_VISIBLE
LWS_EXTERN
int
122
lws_plat_ota_get_last_fw_unixtime
(uint64_t *fw_unixtime);
LWS_EXTERN
#define LWS_EXTERN
Definition
libwebsockets.h:296
LWS_VISIBLE
#define LWS_VISIBLE
Definition
libwebsockets.h:291
lws_ota_ops_t::ota_queue
void(* ota_queue)(struct lws_ota *g, lws_ota_async_t a)
Definition
lws-ota.h:73
lws_ota_variant_name
LWS_VISIBLE LWS_EXTERN const char * lws_ota_variant_name(void)
lws_plat_ota_get_last_fw_unixtime
LWS_VISIBLE LWS_EXTERN int lws_plat_ota_get_last_fw_unixtime(uint64_t *fw_unixtime)
lws_plat_ota_start
LWS_VISIBLE LWS_EXTERN int lws_plat_ota_start(struct lws_ota *g)
lws_plat_ota_report_current
LWS_VISIBLE LWS_EXTERN int lws_plat_ota_report_current(struct lws_ota *g, int bad)
lws_ota_ops_t::ota_get_last_fw_unixtime
int(* ota_get_last_fw_unixtime)(uint64_t *fw_unixtime)
Definition
lws-ota.h:89
lws_ota_ops_t::ota_periodic_check_secs
int ota_periodic_check_secs
Definition
lws-ota.h:94
lws_plat_ota_queue
LWS_VISIBLE LWS_EXTERN void lws_plat_ota_queue(struct lws_ota *g, lws_ota_async_t a)
lws_ota_ops_t::ota_report_current
int(* ota_report_current)(struct lws_ota *g, int bad)
Definition
lws-ota.h:78
lws_ota_async_t
lws_ota_async_t
Definition
lws-ota.h:55
LWS_OTA_ASYNC_START
@ LWS_OTA_ASYNC_START
Definition
lws-ota.h:56
LWS_OTA_ASYNC_WRITE
@ LWS_OTA_ASYNC_WRITE
Definition
lws-ota.h:57
LWS_OTA_ASYNC_ABORT
@ LWS_OTA_ASYNC_ABORT
Definition
lws-ota.h:58
LWS_OTA_ASYNC_FINALIZE
@ LWS_OTA_ASYNC_FINALIZE
Definition
lws-ota.h:59
lws_ota_ret_t
lws_ota_ret_t
Definition
lws-ota.h:43
LWSOTARET_UPDATE_AVAILABLE
@ LWSOTARET_UPDATE_AVAILABLE
Definition
lws-ota.h:49
LWSOTARET_REJECTED
@ LWSOTARET_REJECTED
Definition
lws-ota.h:46
LWSOTARET_OK
@ LWSOTARET_OK
Definition
lws-ota.h:44
LWSOTARET_PROGRESS
@ LWSOTARET_PROGRESS
Definition
lws-ota.h:50
LWSOTARET_NOSLOT
@ LWSOTARET_NOSLOT
Definition
lws-ota.h:47
LWSOTARET_FAILED
@ LWSOTARET_FAILED
Definition
lws-ota.h:51
LWSOTARET_ONGOING
@ LWSOTARET_ONGOING
Definition
lws-ota.h:45
LWSOTARET_COMPLETED
@ LWSOTARET_COMPLETED
Definition
lws-ota.h:52
lws_ota_ops_t::ota_start
int(* ota_start)(struct lws_ota *g)
Definition
lws-ota.h:70
lws_ota_process_t
void * lws_ota_process_t
Definition
lws-ota.h:41
lws_ota_ops_t::ota_progress
int(* ota_progress)(lws_ota_ret_t state, int percent)
Definition
lws-ota.h:85
lws_ota_cb_t
void(* lws_ota_cb_t)(void *ctx, lws_ota_ret_t r)
Definition
lws-ota.h:64
lws_ota_ops_t
Definition
lws-ota.h:66
include
libwebsockets
lws-ota.h
Generated on
for libwebsockets by
1.18.0