-
Notifications
You must be signed in to change notification settings - Fork 178
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
Fix bug for messages of length 0x100 #187
Fix bug for messages of length 0x100 #187
Conversation
eb41b23
to
887e109
Compare
If the parameter `length` is 255 bytes the result of the previous `MQTTSNPacket_len` implementation was 256 bytes. But such a message actually needs a 3-octet long Length field, so it should return 258 instead. Signed-off-by: Martin Kirsche <martin.kirsche@gmail.com>
887e109
to
d27bd86
Compare
This issue has nothing to do with the spec. The problem is that the output of the function Here is a test that demonstrates this: import socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.bind(("127.0.0.1", 12001))
def connect():
return bytearray([
0x07, # Length(0)
0x04, # MsgType(1)
0x04, # Flags(2)
0x01, # ProtocolId(3)
0x00, # Duration(4)
0x3c, # Duration(5)
0x47 # ClientId(6)
])
def sub():
return bytearray([
0x07, # Length(0)
0x12, # MsgType(1)
0x02, # Flags(2)
0x00, # MsgId (3)
0x01, # MsgId (4)
0x41, # TopicName (5)
0x41 # TopicName (6)
])
def pub():
return bytearray([
0x01, # Length(0)
0x01,
0x02,
0x0C, # MsgType(1)
0x02, # Flags(2)
0x41, # TopicName (3)
0x41, # TopicName (4)
0x00, # MsgId (5)
0x02, # MsgId (6)
]) + (bytearray((0x41,)) * (0x102-9))
sock.sendto(connect(), ("127.0.0.1", 10000))
print(sock.recvfrom(2))
sock.sendto(sub(), ("127.0.0.1", 10000))
print(sock.recvfrom(8))
sock.sendto(pub(), ("127.0.0.1", 10000))
print(sock.recvfrom(0x102)) Here is the MQTT-SN-Gateway log:
|
Thank you, |
If the parameter
length
is 255 bytes the result of the previousMQTTSNPacket_len
implementation was 256 bytes. But such a message actually needs a 3-octet long Length field, so it should return 258 instead.Signed-off-by: Martin Kirsche martin.kirsche@gmail.com