Skip to content
This repository was archived by the owner on Dec 20, 2023. It is now read-only.

Commit b3d1d79

Browse files
Add wdm update server support
-- add wdm update request processing and update response generation mechanism -- add TraitUpdatableDataSource
1 parent 6fb884d commit b3d1d79

20 files changed

+2200
-439
lines changed

src/lib/core/WeaveDMConfig.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,18 @@
293293
#define WDM_ENABLE_SUBSCRIPTIONLESS_NOTIFICATION 1
294294
#endif // WDM_ENABLE_SUBSCRIPTIONLESS_NOTIFICATION
295295

296+
/**
297+
* @def WDM_ENABLE_PUBLISHER_UPDATE_SERVER_SUPPORT
298+
*
299+
* @brief
300+
* Enable (1) or disable (0) sending/handling update response
301+
* in Weave Data Management Next profile.
302+
*
303+
*/
304+
#ifndef WDM_ENABLE_PUBLISHER_UPDATE_SERVER_SUPPORT
305+
#define WDM_ENABLE_PUBLISHER_UPDATE_SERVER_SUPPORT 1
306+
#endif // WDM_ENABLE_PUBLISHER_UPDATE_SERVER_SUPPORT
307+
296308
/**
297309
* @def WDM_PUBLISHER_ENABLE_VIEW
298310
*
@@ -572,6 +584,29 @@
572584
#define WDM_MIN_UPDATE_SIZE 1024
573585
#endif /* WDM_MIN_UPDATE_SIZE */
574586

587+
/**
588+
* @def WDM_MAX_UPDATE_RESPONSE_SIZE
589+
*
590+
* @brief
591+
* Specify the maximum size (in bytes) of a WDM update response
592+
* payload. Note that the WDM update payload is also limited
593+
* by the size of `nl::Weave::System::PacketBuffer`
594+
*/
595+
#ifndef WDM_MAX_UPDATE_RESPONSE_SIZE
596+
#define WDM_MAX_UPDATE_RESPONSE_SIZE 2048
597+
#endif /* WDM_MAX_UPDATE_SIZE */
598+
599+
/**
600+
* @def WDM_MIN_UPDATE_RESPONSE_SIZE
601+
*
602+
* @brief
603+
* Specify the minimum size (in bytes) of a WDM update response
604+
* payload.
605+
*/
606+
#ifndef WDM_MIN_UPDATE_RESPONSE_SIZE
607+
#define WDM_MIN_UPDATE_RESPONSE_SIZE 1024
608+
#endif /* WDM_MIN_UPDATE_SIZE */
609+
575610
/**
576611
* @def TDM_DISABLE_STRICT_SCHEMA_COMPLIANCE
577612
*

src/lib/profiles/common/WeaveMessage.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,14 +851,15 @@ bool ReferencedTLVData::isFree(void)
851851
* @brief Pack a ReferencedTLVData object using a TLVWriter.
852852
*
853853
* @param [in] i An iterator over the message being packed.
854+
* @param [in] maxLen The maximum number of bytes that should be written to the output buffer.
854855
*
855856
* @return a WEAVE_ERROR - WEAVE_NO_ERROR if all goes well, otherwise
856857
* an error reflecting an inability of the writer to write the
857858
* relevant bytes. Note that the write callback is not allowed to
858859
* return an error and so fails silently.
859860
*/
860861

861-
WEAVE_ERROR ReferencedTLVData::pack(MessageIterator &i)
862+
WEAVE_ERROR ReferencedTLVData::pack(MessageIterator &i, uint32_t maxLen)
862863
{
863864
WEAVE_ERROR err = WEAVE_NO_ERROR;
864865
System::PacketBuffer *theBuffer = i.GetBuffer();
@@ -868,7 +869,7 @@ WEAVE_ERROR ReferencedTLVData::pack(MessageIterator &i)
868869
if (theWriteCallback != NULL)
869870
{
870871
theData = i.thePoint;
871-
writer.Init(theBuffer);
872+
writer.Init(theBuffer, maxLen);
872873
theWriteCallback(writer, theAppState);
873874
theLength = theBuffer->DataLength() - oldDataLength;
874875
i.thePoint += theLength;

src/lib/profiles/common/WeaveMessage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ namespace Profiles {
289289
return pack(i);
290290
};
291291

292-
WEAVE_ERROR pack(MessageIterator&i);
292+
WEAVE_ERROR pack(MessageIterator&i, uint32_t maxLen = 0xFFFFFFFFUL);
293293

294294
/**
295295
* Return the data length assuming that the object has been packed

0 commit comments

Comments
 (0)