Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to publish messages more than 121 bytes #2

Open
chouyazi opened this issue Sep 20, 2017 · 1 comment
Open

Unable to publish messages more than 121 bytes #2

chouyazi opened this issue Sep 20, 2017 · 1 comment

Comments

@chouyazi
Copy link

Hi,
As stated in the subject, it seems I can only publish messages up to about 121 bytes, is this a known issue? possible to fix it? Thank you.

@gallacci97
Copy link

gallacci97 commented Jun 29, 2021

Hi, I know it's been a while since you posted the issue but I encoutered the same problem just a week ago. You have to change the variable byte encoding following mqtt specs this way:

proc ::mqtt::encode128 {{in_num 0}} {
set x $in_num
set result 0
set nbit 0
#split into 128 blocks
while {$x > 0 && $nbit < 4} {
set e [expr ($x % 128)]
set x [expr ($x/128)]
if {$x > 0} {
set e [expr $e | 128]
}
set result [expr $result * 256]
incr result $e
incr nbit
}
return [format %02x $result]
}

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

No branches or pull requests

2 participants