|
| 1 | +/* |
| 2 | + * |
| 3 | + * Copyright (c) 2023 Project CHIP Authors |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | + * you may not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + */ |
| 18 | + |
| 19 | +#include <platform/internal/CHIPDeviceLayerInternal.h> |
| 20 | +#include <platform/silabs/multi-ota/OTAMultiImageProcessorImpl.h> |
| 21 | +#include <platform/silabs/multi-ota/efr32/OTAFirmwareProcessor.h> |
| 22 | + |
| 23 | +#include <app/clusters/ota-requestor/OTARequestorInterface.h> |
| 24 | +#include "wfx_host_events.h" |
| 25 | +#include <platform/silabs/SilabsConfig.h> |
| 26 | +#ifdef __cplusplus |
| 27 | +extern "C" { |
| 28 | +#endif |
| 29 | +#include "sl_si91x_driver.h" |
| 30 | +#ifdef SLI_SI91X_MCU_INTERFACE |
| 31 | +#include "sl_si91x_hal_soc_soft_reset.h" |
| 32 | +#endif |
| 33 | +#ifdef __cplusplus |
| 34 | +} |
| 35 | +#endif |
| 36 | + |
| 37 | +// TODO: more descriptive error codes |
| 38 | +#define SL_OTA_ERROR 1L |
| 39 | + |
| 40 | +namespace chip { |
| 41 | + |
| 42 | +CHIP_ERROR OTAFirmwareProcessor::Init() |
| 43 | +{ |
| 44 | + ReturnErrorCodeIf(mCallbackProcessDescriptor == nullptr, CHIP_OTA_PROCESSOR_CB_NOT_REGISTERED); |
| 45 | + return OTAUtilityFirmwareProcessor::getInstance()->Init(); |
| 46 | +} |
| 47 | + |
| 48 | +CHIP_ERROR OTAFirmwareProcessor::Clear() |
| 49 | +{ |
| 50 | + OTATlvProcessor::ClearInternal(); |
| 51 | + return OTAUtilityFirmwareProcessor::getInstance()->Clear(); |
| 52 | +} |
| 53 | + |
| 54 | +CHIP_ERROR OTAFirmwareProcessor::ProcessInternal(ByteSpan & block) |
| 55 | +{ |
| 56 | + return OTAUtilityFirmwareProcessor::getInstance()->ProcessInternal917(block); |
| 57 | +} |
| 58 | + |
| 59 | +CHIP_ERROR OTAFirmwareProcessor::ProcessDescriptor(ByteSpan & block) |
| 60 | +{ |
| 61 | + OTADataAccumulator *mAccumulator = &OTAUtilityFirmwareProcessor::getInstance()->mAccumulator; |
| 62 | + ReturnErrorOnFailure(mAccumulator->Accumulate(block)); |
| 63 | + ReturnErrorOnFailure(mCallbackProcessDescriptor(static_cast<void *>(mAccumulator->data()))); |
| 64 | + return OTAUtilityFirmwareProcessor::getInstance()->ProcessDescriptor(block); |
| 65 | +} |
| 66 | + |
| 67 | +CHIP_ERROR OTAFirmwareProcessor::ApplyAction() |
| 68 | +{ |
| 69 | + return OTAUtilityFirmwareProcessor::getInstance()->ApplyAction917(); |
| 70 | +} |
| 71 | + |
| 72 | +CHIP_ERROR OTAFirmwareProcessor::FinalizeAction() |
| 73 | +{ |
| 74 | + return OTAUtilityFirmwareProcessor::getInstance()->FinalizeAction917(); |
| 75 | +} |
| 76 | + |
| 77 | +} // namespace chip |
0 commit comments