Skip to content

Commit c1401ee

Browse files
authored
Merge branch 'master' into feature/app-install-flow-public
2 parents 731d8f8 + 71d9f61 commit c1401ee

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/platform/ESP32/PlatformManagerImpl.cpp

+14-8
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ namespace chip {
4848
namespace DeviceLayer {
4949

5050
namespace Internal {
51-
extern CHIP_ERROR InitLwIPCoreLock(void);
51+
extern CHIP_ERROR InitLwIPCoreLock();
5252
}
5353

5454
PlatformManagerImpl PlatformManagerImpl::sInstance;
@@ -60,20 +60,25 @@ static int app_entropy_source(void * data, unsigned char * output, size_t len, s
6060
return 0;
6161
}
6262

63-
CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
63+
CHIP_ERROR PlatformManagerImpl::_InitChipStack()
6464
{
6565
// Arrange for CHIP-encapsulated ESP32 errors to be translated to text
6666
Internal::ESP32Utils::RegisterESP32ErrorFormatter();
6767
// Make sure the LwIP core lock has been initialized
6868
ReturnErrorOnFailure(Internal::InitLwIPCoreLock());
69+
70+
// Initialize TCP/IP network interface, which internally initializes LwIP stack. We have to
71+
// call this before the usage of PacketBufferHandle::New() because in case of LwIP-based pool
72+
// allocator, the LwIP pool allocator uses the LwIP stack.
73+
esp_err_t err = esp_netif_init();
74+
VerifyOrReturnError(err == ESP_OK, Internal::ESP32Utils::MapError(err));
75+
6976
// Arrange for the ESP event loop to deliver events into the CHIP Device layer.
70-
esp_err_t err = esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, NULL);
71-
if (err != ESP_OK)
72-
{
73-
return Internal::ESP32Utils::MapError(err);
74-
}
77+
err = esp_event_handler_register(IP_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent, nullptr);
78+
VerifyOrReturnError(err == ESP_OK, Internal::ESP32Utils::MapError(err));
79+
7580
mStartTime = System::SystemClock().GetMonotonicTimestamp();
76-
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, NULL, 16));
81+
ReturnErrorOnFailure(chip::Crypto::add_entropy_source(app_entropy_source, nullptr, 16));
7782

7883
// Call _InitChipStack() on the generic implementation base class
7984
// to finish the initialization process.
@@ -108,6 +113,7 @@ void PlatformManagerImpl::_Shutdown()
108113
Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>::_Shutdown();
109114

110115
esp_event_handler_unregister(IP_EVENT, ESP_EVENT_ANY_ID, PlatformManagerImpl::HandleESPSystemEvent);
116+
esp_netif_deinit();
111117
}
112118

113119
void PlatformManagerImpl::HandleESPSystemEvent(void * arg, esp_event_base_t eventBase, int32_t eventId, void * eventData)

src/system/tests/TestSystemPacketBuffer.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckNew)
324324
}
325325
}
326326

327-
#if 0 // TODO: Fix this check on ESP32 (issue #34145)
328327
#if CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL || CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_POOL
329328
// Use the rest of the buffer space
330329
std::vector<PacketBufferHandle> allocate_all_the_things;
@@ -339,7 +338,6 @@ TEST_F_FROM_FIXTURE(TestSystemPacketBuffer, CheckNew)
339338
allocate_all_the_things.push_back(std::move(buffer));
340339
}
341340
#endif // CHIP_SYSTEM_PACKETBUFFER_FROM_LWIP_POOL || CHIP_SYSTEM_PACKETBUFFER_FROM_CHIP_POOL
342-
#endif
343341
}
344342

345343
/**

0 commit comments

Comments
 (0)