Skip to content

Conversation

@GwendalRaoul
Copy link
Contributor

Feature can be tested with Console on this branch:
https://wirepas-tools.github.io/mqtt-console/chunk/

if acc is not None:
if (acc["seq"] != request.seq
or acc["total_size"] != total_size
or offset == 0):
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visually indented line with same indent as next logical line

"--gateway_max_scratchpad_size",
type=self.str2int,
default=os.environ.get("WM_GW_MAX_SCRAT_SIZE", None),
help=("Maximum scratchpad size a gateway can accept. If scratchpad is bigger"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (89 > 79 characters)

logging.info("Scratchpad fully received for %s", request.sink_id)

try:
res = sink.upload_scratchpad(request.seq, acc["buffer"])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens with the below _send_otap_response call if this throws an exception? Should the res be set to some error before this try block?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On the other hand, it doesn't seem that it might throw an exception, and other call is without a try. Do you remember why you added this inside a try block?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Idea was to be sure the scratchpad was removed from the accumulator In other cases, it is not persisted in memory.
I will fix the res initialization to something meaningful.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But you are right, upload_scratchpad is not supposed to raise exception

type=self.str2int,
default=os.environ.get("WM_GW_MAX_SCRAT_SIZE", None),
help=("Maximum scratchpad size a gateway can accept. If scratchpad is bigger"
"it must be sent as chunks smaller or equal to this value"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is consistent with the backend api naming and documentation, but should it be clarified more that it's the max chunk size and it's only a "suggestion" for the backend (since there is no limit in the code for max chunk size)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the code there is no limit, but in the customer example we have, there is a hard limit on the broker.
Of course backend should know this limit from broker too and it shouldn't be the gateway to inform it but as the feature already exist on our side for IMG let's use this feature also for that.
So I wouldn't consider it as a "suggestion", but more a : "trust me, you shouldn't send bigger chunk :-)"

@GwendalRaoul GwendalRaoul force-pushed the feature/scratchpad_as_chunk branch from 0ae9787 to 3f0b722 Compare January 19, 2026 10:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants