17
17
18
18
#include < app/clusters/ota-requestor/BDXDownloader.h>
19
19
#include < app/clusters/ota-requestor/DefaultOTARequestor.h>
20
- #include < app/clusters/ota-requestor/DefaultOTARequestorDriver .h>
20
+ #include < app/clusters/ota-requestor/ExtendedOTARequestorDriver .h>
21
21
#include < app/clusters/ota-requestor/DefaultOTARequestorStorage.h>
22
22
#include < platform/ESP32/OTAImageProcessorImpl.h>
23
23
@@ -30,7 +30,7 @@ using chip::DefaultOTARequestor;
30
30
using chip::DefaultOTARequestorStorage;
31
31
using chip::OTAImageProcessorImpl;
32
32
using chip::Server;
33
- using chip::DeviceLayer::DefaultOTARequestorDriver ;
33
+ using chip::DeviceLayer::ExtendedOTARequestorDriver ;
34
34
35
35
using namespace esp_matter ;
36
36
using namespace esp_matter ::endpoint;
@@ -39,10 +39,15 @@ using namespace esp_matter::cluster;
39
39
#if CONFIG_ENABLE_OTA_REQUESTOR
40
40
DefaultOTARequestor gRequestorCore ;
41
41
DefaultOTARequestorStorage gRequestorStorage ;
42
- DefaultOTARequestorDriver gRequestorUser ;
42
+ ExtendedOTARequestorDriver gRequestorUser ;
43
43
BDXDownloader gDownloader ;
44
44
OTAImageProcessorImpl gImageProcessor ;
45
- #endif
45
+
46
+ static esp_matter_ota_requestor_impl_t s_ota_requestor_impl = {
47
+ .driver = &gRequestorUser ,
48
+ .image_processor = &gImageProcessor ,
49
+ };
50
+ #endif // CONFIG_ENABLE_OTA_REQUESTOR
46
51
47
52
esp_err_t esp_matter_ota_requestor_init (void )
48
53
{
@@ -61,16 +66,42 @@ esp_err_t esp_matter_ota_requestor_init(void)
61
66
#endif
62
67
}
63
68
69
+ static esp_err_t esp_matter_ota_override_impl (const esp_matter_ota_requestor_impl_t *impl)
70
+ {
71
+ #if CONFIG_ENABLE_OTA_REQUESTOR
72
+ VerifyOrReturnError (impl != nullptr , ESP_ERR_INVALID_ARG);
73
+
74
+ if (impl->driver != nullptr ) {
75
+ s_ota_requestor_impl.driver = impl->driver ;
76
+ }
77
+ if (impl->image_processor != nullptr ) {
78
+ s_ota_requestor_impl.image_processor = impl->image_processor ;
79
+ }
80
+
81
+ s_ota_requestor_impl.user_consent = impl->user_consent ;
82
+
83
+ return ESP_OK;
84
+ #else
85
+ return ESP_ERR_NOT_SUPPORTED;
86
+ #endif // CONFIG_ENABLE_OTA_REQUESTOR
87
+ }
88
+
64
89
void esp_matter_ota_requestor_start (void )
65
90
{
66
91
#if CONFIG_ENABLE_OTA_REQUESTOR
67
92
VerifyOrReturn (chip::GetRequestorInstance () == nullptr );
93
+
68
94
chip::SetRequestorInstance (&gRequestorCore );
69
95
gRequestorStorage .Init (Server::GetInstance ().GetPersistentStorage ());
70
- gRequestorCore .Init (Server::GetInstance (), gRequestorStorage , gRequestorUser , gDownloader );
71
- gImageProcessor .SetOTADownloader (&gDownloader );
72
- gDownloader .SetImageProcessorDelegate (&gImageProcessor );
73
- gRequestorUser .Init (&gRequestorCore , &gImageProcessor );
96
+
97
+ gRequestorCore .Init (Server::GetInstance (), gRequestorStorage , *s_ota_requestor_impl.driver , gDownloader );
98
+
99
+ s_ota_requestor_impl.image_processor ->SetOTADownloader (&gDownloader );
100
+
101
+ gDownloader .SetImageProcessorDelegate (s_ota_requestor_impl.image_processor );
102
+
103
+ s_ota_requestor_impl.driver ->SetUserConsentDelegate (s_ota_requestor_impl.user_consent );
104
+ s_ota_requestor_impl.driver ->Init (&gRequestorCore , s_ota_requestor_impl.image_processor );
74
105
#endif
75
106
}
76
107
@@ -93,6 +124,9 @@ esp_err_t esp_matter_ota_requestor_set_config(const esp_matter_ota_config_t & co
93
124
if (config.watchdog_timeout ) {
94
125
gRequestorUser .SetWatchdogTimeout (config.watchdog_timeout );
95
126
}
127
+ if (config.impl != nullptr ) {
128
+ esp_matter_ota_override_impl (config.impl );
129
+ }
96
130
97
131
return ESP_OK;
98
132
#else
0 commit comments