Skip to content

Commit ce844bc

Browse files
mykruppCuRahmanrestyled-commitsjmartinez-silabs
authored
[SILABS] Minor fixes for LWIP usage (#34393)
* 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 <67972863+jmartinez-silabs@users.noreply.github.com> * remove extraneous FreeRTOS includes --------- Co-authored-by: Curtis Rahman <curtis.rahman@silabs.com> Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com>
1 parent 5e274d9 commit ce844bc

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/platform/silabs/PlatformManagerImpl.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ namespace DeviceLayer {
4747
PlatformManagerImpl PlatformManagerImpl::sInstance;
4848

4949
#if defined(SL_MBEDTLS_USE_TINYCRYPT)
50-
sys_mutex_t PlatformManagerImpl::rngMutexHandle = NULL;
50+
osMutexId_t PlatformManagerImpl::rngMutexHandle = nullptr;
5151

5252
int PlatformManagerImpl::uECC_RNG_Function(uint8_t * dest, unsigned int size)
5353
{
54-
sys_mutex_lock(&rngMutexHandle);
54+
osMutexAcquire(rngMutexHandle, osWaitForever);
5555
int res = (chip::Crypto::DRBG_get_bytes(dest, size) == CHIP_NO_ERROR) ? size : 0;
56-
sys_mutex_unlock(&rngMutexHandle);
56+
osMutexRelease(rngMutexHandle);
5757

5858
return res;
5959
}
@@ -97,7 +97,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
9797
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16));
9898
#endif // !SLI_SI91X_MCU_INTERFACE
9999
/* Set RNG function for tinycrypt operations. */
100-
VerifyOrExit(sys_mutex_new(&rngMutexHandle) == ERR_OK, err = CHIP_ERROR_NO_MEMORY);
100+
rngMutexHandle = osMutexNew(nullptr);
101+
VerifyOrExit((&rngMutexHandle != nullptr), err = CHIP_ERROR_NO_MEMORY);
101102
uECC_set_rng(PlatformManagerImpl::uECC_RNG_Function);
102103
#endif // SL_MBEDTLS_USE_TINYCRYPT
103104

src/platform/silabs/PlatformManagerImpl.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#if CHIP_DEVICE_CONFIG_ENABLE_WIFI_STATION
2929
#include "wfx_host_events.h"
3030
#endif
31+
#include <cmsis_os2.h>
3132

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

5051
// Callback used by tinycrypt to generate random numbers.
5152
// It must be set before calling any sign operations,

src/platform/silabs/SiWx917/wifi/wfx_host_events.h

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
#include "wfx_msgs.h"
2424

2525
/* LwIP includes. */
26-
#include "lwip/apps/httpd.h"
2726
#include "lwip/ip_addr.h"
2827
#include "lwip/netif.h"
2928
#include "lwip/netifapi.h"

src/platform/silabs/efr32/wifi/wfx_host_events.h

-1
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ typedef struct __attribute__((__packed__)) sl_wfx_mib_req_s
117117
#endif /* WF200 */
118118

119119
/* LwIP includes. */
120-
#include "lwip/apps/httpd.h"
121120
#include "lwip/ip_addr.h"
122121
#include "lwip/netif.h"
123122
#include "lwip/netifapi.h"

0 commit comments

Comments
 (0)