Repository navigation
[SL-ONLY] Porting the MQTTs and HTTPs features on the newer release - #1206
Rohan Sahay (rosahay-silabs) wants to merge 4 commits into
Conversation
10be33e to
e4be40e
Compare
* feat(silabs): add NWP HTTPS client demo Start http_client_demo after connectivity when services are enabled; turn on SiWx HTTP_CLIENT feature bit. * [SL-ONLY] MATTER-6537: Refactor NWP HTTPS into Matter HttpClient service (#1149) * Update CA certificate header in cacert.pem.h with new copyright year and description * Update matter_service.h documentation to clarify return values for Start and Stop methods * Refactor service feature checks to ensure proper conditional compilation * Enhance HTTP client header with status and error codes, and add TODOs for future HTTP methods * Refactor HTTPS client demo to remove unnecessary deinitialization and stopping operations, simplifying the return logic. * Update http_client_demo_start deinit and stop. * Remove unused application buffer and update related logic in response handling. * restyled * Review comments * Refactor HTTP client to support chunked body uploads, replacing PUT logic with chunked handling. Update related state management and response processing for improved efficiency. * Added comments for better clarity * Refactor HTTP client state management by replacing mEndOfFile with mEndOfData for improved clarity and handling of response data states. Update related logic in response callbacks to utilize the new EndOfData enum for better readability and maintainability. * add comments for explanation * Update PostResponseCallback to use SL_STATUS_OK for HTTP response code checks, improving error handling clarity. * Add mapping function for NWP status to CHIP_ERROR in HTTP client header for improved error handling. * changes as per review comments
* feat(silabs): add NWP HTTPS client demo Start http_client_demo after connectivity when services are enabled; turn on SiWx HTTP_CLIENT feature bit. * [SL-ONLY] MATTER-6537: Refactor NWP HTTPS into Matter HttpClient service (#1149) * Update CA certificate header in cacert.pem.h with new copyright year and description * Update matter_service.h documentation to clarify return values for Start and Stop methods * Refactor service feature checks to ensure proper conditional compilation * Enhance HTTP client header with status and error codes, and add TODOs for future HTTP methods * Refactor HTTPS client demo to remove unnecessary deinitialization and stopping operations, simplifying the return logic. * Update http_client_demo_start deinit and stop. * Remove unused application buffer and update related logic in response handling. * restyled * feat(silabs): add Paho MQTT client demo Start mqtt_client_demo after connectivity when MQTT service is enabled; turn on LwIP sockets under dual-stack for Paho. * feat(silabs): update FreeRTOS heap configuration for MQTT TLS support Added a new preprocessor directive to manage additional heap requirements for MQTT when using host LwIP with TLS. Adjusted the MQTT client thread stack size and priority to accommodate the increased memory needs for mbedTLS operations. * feat(silabs): enhance memory management for Si91x MCU interface * feat(freertos): improve static message queue handling in TCPIP thread Added a mechanism to prevent reinitialization of the static message queue for the TCPIP thread, ensuring proper queue management when multiple mboxes are created. This change enhances memory safety and prevents potential blocking issues in the FreeRTOS environment. * feat(silabs): integrate PSA Crypto support in WifiInterfaceImpl Added conditional inclusion of PSA Crypto headers and initialization in the WifiInterfaceImpl to enhance cryptographic capabilities when using mbedTLS. This change improves compatibility with PSA Crypto features while maintaining existing functionality for TinyCrypt users. * Rename the FreeRTOS extra heap variable * Resolve merge-conflict * Refactor MQTT service (#1151) * Revert file * Adds changes based on review * Revert "feat(freertos): improve static message queue handling in TCPIP thread" This reverts commit 09d13d8. * Resolve rebase issue * Update MQTT broker IP address and clean up commented-out deinitialization code in mqtt_example.cpp * Restyled * Review comments * Refactor HTTP client to support chunked body uploads, replacing PUT logic with chunked handling. Update related state management and response processing for improved efficiency. * Added comments for better clarity * Refactor HTTP client state management by replacing mEndOfFile with mEndOfData for improved clarity and handling of response data states. Update related logic in response callbacks to utilize the new EndOfData enum for better readability and maintainability. * add comments for explanation * Update PostResponseCallback to use SL_STATUS_OK for HTTP response code checks, improving error handling clarity. * Add mapping function for NWP status to CHIP_ERROR in HTTP client header for improved error handling. * Update MQTT client implementation in mqtt_example.cpp to use gMqttsClient for secure connections, configure broker IP and TLS hostname, and clean up commented-out code for improved clarity. * Adds a new flag `SL_MATTER_ENABLE_MQTT_OVER_LWIP_SOCKETS` * Rename `MqttQos` to `MqttQoS` for better readability * Rename `MqttMessage` to `MqttSubscription` for clarity and update related method signatures in the MQTT client implementation. * Update mqtt_example.h to include Apache License 2.0 and enhance documentation with a detailed MQTT client usage guide. * Simplified the example * changes as per review comments * Enhance MQTT example configuration by defining broker IP, TLS hostname, port, client credentials, and publish message in mqtt_example.h. Update mqtt_example.cpp to utilize these new definitions for improved clarity and maintainability. * Enhance HTTPS offload example by adding error checks for required configuration parameters (HTTP_SERVER_IP, HTTP_HOSTNAME, HTTP_PORT) to ensure proper setup before compilation. * use `SL_SI91X_FREERTOS_HEAP_4_REDIRECT` instead to preserve compability with other apps * Refactor MQTT client implementation to improve memory management and error handling. Updated PahoMessageHandler to dynamically allocate memory for topic names and added a dedicated function for logging network connection errors. Enhanced configuration structure for clarity and consistency. Updated mqtt_example.h with broker details for better setup.
* Added conditional compilation for HTTP client feature under dual-stack settings and improved formatting for clarity. * Update response handling to utilize mEndOfData for improved clarity in data state management. * Refactor MQTT client header and implementation to improve clarity by moving the MQTT_USE_HOST_LWIP_TLS definition to the header file and removing it from the source file. This change enhances code organization and maintains consistent configuration management. * Enhance documentation in matter_service.h to clarify the purpose of the initialization delay for Matter services, ensuring the network is fully established before service startup. * Updating MQTT HEAP to 60K as per expectation * Refactor HTTPS client configuration to use default certificate index for improved clarity and maintainability. Removed hardcoded certificate index in the demo example. * Revert the RAM changes * Move to AppTask instead of BaseApplicationTask * Enhance MQTT client functionality by adding idle yield management and subscription callback for incoming messages. Updated the MQTT service thread to handle idle conditions more effectively, ensuring timely keepalive and message processing. Improved logging for MQTT operations to provide clearer feedback on session status. * Replaced direct disconnection flag manipulation with a dedicated ProcessDisconnect function for better clarity and maintainability. * Enhance MQTT client by adding comments to clarify idle yield timeout logic and its default value. Ensure that idle yield timeout does not exceed the keep-alive interval, improving connection stability and maintainability. * Adding a TODO comment to revisit idle yield timeout calculations. This aims to streamline the connection keep-alive process by suggesting a more efficient invocation of the MQTTYield function. * Improve error handling in MQTT disconnection process by logging failures in ProcessDisconnect during idle yield and yield operations. This enhances debugging capabilities and ensures better visibility of connection issues. * [PATCH] Restyled by whitespace
…Config (#1190) * Adding the option for the QoS level selection * Addressing the review comments
e4be40e to
92dfa7b
Compare
| // NOTE: Changes for HEAP4 + redirect of malloc/free to heap4 | ||
| // NOTE: 42KB heap size is required for HEAP4 and 30KB heap is required for the redirect of malloc/free to heap4 | ||
| // NOTE: HEAP watermark was 64KB, additional 8KB is overhead provided to the application | ||
| #define configTOTAL_HEAP_SIZE ((size_t) ((72 + EXTRA_HEAP_k + MQTT_EXTRA_HEAP_k) * 1024)) |
There was a problem hiding this comment.
That seems like a huge increase in heap...
|
|
||
| #pragma once | ||
|
|
||
| const unsigned char kCaCertExample[] = ""; |
There was a problem hiding this comment.
nit:
this isn't Thermostat Specific, while i know you currently only focused on this app. It is not additional work to place common elements in a common location.
| */ | ||
| CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree(uint64_t & currentHeapFree) | ||
| { | ||
| #if defined(SL_SI91X_FREERTOS_HEAP_4_REDIRECT) && SL_SI91X_FREERTOS_HEAP_4_REDIRECT |
There was a problem hiding this comment.
Since this ifdef pattern is done in a few places, I think this now warrants a platform abstraction api in SPAM
| configuration->boot_config.ext_tcp_ip_feature_bit_map |= SL_SI91X_EXT_TCP_IP_FEAT_SSL_MEMORY_CLOUD; | ||
|
|
||
| #if defined(SL_MATTER_ENABLE_SERVICES) && SL_MATTER_ENABLE_SERVICES | ||
| #if defined(SL_MATTER_ENABLE_HTTP_SERVICE) && SL_MATTER_ENABLE_HTTP_SERVICE |
There was a problem hiding this comment.
wouldn't just
#if defined(SL_MATTER_ENABLE_HTTP_SERVICE) && SL_MATTER_ENABLE_HTTP_SERVICE be enough ?
| if (mConfig.idleYieldTimeoutMs == 0) | ||
| { | ||
| ChipLogError(DeviceLayer, "MQTT idleYieldTimeoutMs is 0 (ignored); using default 1000 ms"); | ||
| mConfig.idleYieldTimeoutMs = 1000; | ||
| } |
There was a problem hiding this comment.
Should that not be enforced in the constructor and setter? rather than the getter?
| const uint32_t configuredMs = mConfig.idleYieldTimeoutMs; | ||
|
|
||
| // MQTTYield timeout_ms must be <= keepAliveInterval * 1000 so PINGREQ can fire in time. | ||
| VerifyOrReturnValue(mConfig.keepAliveIntervalSec > 0, configuredMs); |
There was a problem hiding this comment.
redundant check with what is done after.
| } | ||
| else if (md->topicName->lenstring.data != nullptr && md->topicName->lenstring.len > 0) | ||
| { | ||
| topic = static_cast<char *>(malloc(md->topicName->lenstring.len + 1)); |
There was a problem hiding this comment.
do we need to malloc ? can't we just point md->topicName->lenstring.data? Or is it really about the null char added?
| } | ||
| ChipLogProgress(DeviceLayer, "MQTT message: %.*s", static_cast<int>(payload.size()), | ||
| reinterpret_cast<const char *>(payload.data())); | ||
| free(topic); |
There was a problem hiding this comment.
In the case of topic = md->topicName->cstring; at line 81.
Is it correct to free at that address? was that allocated somewhere else?
| while (!gOpDone) | ||
| { | ||
| osDelay(10); | ||
| } |
There was a problem hiding this comment.
Why do we have to run this every 10 ms ? Why is this not a block state with a event or semaphore unblocked by OnOperationDone
Issue Link: MATTER-6957
Description of Problem/Feature:
Adds wiseconnect example for HTTPs and MQTTs clients along with MATTER
Description of Fix/Solution:
Testing Done: