/* * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ #include #include #include #include #include #include #include #include #include namespace chip { namespace DeviceLayer { static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen) { bl_rand_stream(reinterpret_cast(output), static_cast(len)); *olen = len; return 0; } CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err = CHIP_NO_ERROR; TaskHandle_t backup_eventLoopTask; // Initialize LwIP. tcpip_init(NULL, NULL); ReturnErrorOnFailure(System::Clock::InitClock_RealTime()); err = chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16); SuccessOrExit(err); // Call _InitChipStack() on the generic implementation base class // to finish the initialization process. /** weiyin, backup mEventLoopTask which is reset in _InitChipStack */ backup_eventLoopTask = Internal::GenericPlatformManagerImpl_FreeRTOS::mEventLoopTask; err = Internal::GenericPlatformManagerImpl_FreeRTOS::_InitChipStack(); SuccessOrExit(err); Internal::GenericPlatformManagerImpl_FreeRTOS::mEventLoopTask = backup_eventLoopTask; wifi_start_firmware_task(); exit: return err; } } // namespace DeviceLayer } // namespace chip