/* * 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. */ /* this file behaves like a config.h, comes first */ #include #include #include #include #include #include #if CHIP_SYSTEM_CONFIG_USE_LWIP #include #endif extern "C" { #include #include #include } namespace chip { namespace DeviceLayer { extern "C" int bl_rand_stream(unsigned char *, int); extern "C" void otrNotifyEvent(ot_system_event_t sevent); static int app_entropy_source(void * data, unsigned char * output, size_t len, size_t * olen) { bl_rand_stream(output, len); if (olen) { *olen = len; } return 0; } CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) { CHIP_ERROR err; TaskHandle_t backup_eventLoopTask; otRadio_opt_t opt; opt.byte = 0; opt.bf.isCoexEnable = true; ot_utils_init(); ot_alarmInit(); ot_radioInit(opt); ReturnErrorOnFailure(System::Clock::InitClock_RealTime()); #if CHIP_SYSTEM_CONFIG_USE_LWIP // Initialize LwIP. tcpip_init(NULL, NULL); #endif 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; exit: return err; } } // namespace DeviceLayer } // namespace chip