Skip to content

Commit

Permalink
[SILABS] Minor fixes for LWIP usage (project-chip#34393)
Browse files Browse the repository at this point in the history
* Changes necessary for WiFi SDK lwip component usage vs. source/header file reference

* Restyled by clang-format

* Update src/platform/silabs/PlatformManagerImpl.cpp

Co-authored-by: Junior Martinez <[email protected]>

* remove extraneous FreeRTOS includes

---------

Co-authored-by: Curtis Rahman <[email protected]>
Co-authored-by: Restyled.io <[email protected]>
Co-authored-by: Junior Martinez <[email protected]>
  • Loading branch information
4 people authored and j-ororke committed Jul 31, 2024
1 parent b84a4a1 commit 4b3a2e7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
9 changes: 5 additions & 4 deletions src/platform/silabs/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ namespace DeviceLayer {
PlatformManagerImpl PlatformManagerImpl::sInstance;

#if defined(SL_MBEDTLS_USE_TINYCRYPT)
sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL;
osMutexId_t PlatformManagerImpl::rngMutexHandle = nullptr;

int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size)
{
sys_mutex_lock(&rngMutexHandle);
osMutexAcquire(rngMutexHandle, osWaitForever);
int res = (chip::Crypto::DRBG_get_bytes(dest, size) == CHIP_NO_ERROR) ? size : 0;
sys_mutex_unlock(&rngMutexHandle);
osMutexRelease(rngMutexHandle);

return res;
}
Expand Down Expand Up @@ -97,7 +97,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16));
#endif // !SLI_SI91X_MCU_INTERFACE
/* Set RNG function for tinycrypt operations. */
VerifyOrExit(sys_mutex_new(&rngMutexHandle) == ERR_OK, err = CHIP_ERROR_NO_MEMORY);
rngMutexHandle = osMutexNew(nullptr);
VerifyOrExit((&rngMutexHandle != nullptr), err = CHIP_ERROR_NO_MEMORY);
uECC_set_rng(PlatformManagerImpl::uECC_RNG_Function);
#endif // SL_MBEDTLS_USE_TINYCRYPT

Expand Down
3 changes: 2 additions & 1 deletion src/platform/silabs/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
#include "wfx_host_events.h"
#endif
#include <cmsis_os2.h>

namespace chip {
namespace DeviceLayer {
Expand All @@ -45,7 +46,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
// Since the RNG callback will be called from multiple threads,
// use this mutex to lock/unlock the call to Matter RNG API, which
// uses some global variables.
static sys_mutex_t rngMutexHandle;
static osMutexId_t rngMutexHandle;

// Callback used by tinycrypt to generate random numbers.
// It must be set before calling any sign operations,
Expand Down
1 change: 0 additions & 1 deletion src/platform/silabs/SiWx917/wifi/wfx_host_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include "wfx_msgs.h"

/* LwIP includes. */
#include "lwip/apps/httpd.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/netifapi.h"
Expand Down
1 change: 0 additions & 1 deletion src/platform/silabs/efr32/wifi/wfx_host_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s
#endif /* WF200 */

/* LwIP includes. */
#include "lwip/apps/httpd.h"
#include "lwip/ip_addr.h"
#include "lwip/netif.h"
#include "lwip/netifapi.h"
Expand Down

0 comments on commit 4b3a2e7

Please sign in to comment.