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

MQTTSN Gateway -- First publish from broker is ignored. #36

Closed
PaulKierstead opened this issue Oct 12, 2016 · 5 comments
Closed

MQTTSN Gateway -- First publish from broker is ignored. #36

PaulKierstead opened this issue Oct 12, 2016 · 5 comments
Milestone

Comments

@PaulKierstead
Copy link

PaulKierstead commented Oct 12, 2016

Gateway v0.9.0 (the pull request)

Look at the following log. This behaviour is consistent. Only look at "AnotherClientID". We are publishing the values '0' and '1' (hex 30 and 31) on topic "test2/pin/12". We send "1" from the broker, the gateway sends "1". We send "0", the gateway sends "1" again. We send "0" again, the gateway sends "0". After the first publish this will be consistent; the first publish will send the previous value, the next publish will send the updated value. It is easy to see as the value send is the last byte in every publish (broker->gateway or gateway->end)

20161012 210849.798   PUBLISH     0000  <---  AnotherClientID                     30 0F 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 32 31
     PacketHandleTask gets PUBLISH  0000 from the broker.

===> Send:     7e 00 16 10 25 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  08 0c 00 00 03 00 00 31   checksum   ae
 7e
===> Recv:     00 07 8b 25 4a 81 00 00 00 84    checksum ok
20161012 210849.889   PUBLISH     0000  --->  AnotherClientID                     0C 00 00 03 00 00 31
 7e
===> Recv:     00 14 90 00 13 a2 00 40 a6 92 b1 8b 00 01 08 0c 00 00 02 00 00 36 b9    checksum ok

20161012 210854.841   PUBLISH     0000  <---  SomeClientID                        0C 00 00 02 00 00 36
     PacketHandleTask gets PUBLISH  0000 from the client.
20161012 210854.842   PUBLISH     0000  --->  SomeClientID                        30 15 00 12 6D 71 74 74 73 6E 74 65 73 74 2F 43 6F 75 6E 74 65 72 36

20161012 210859.449   PUBLISH     0000  <---  AnotherClientID                     30 0F 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 32 30
     PacketHandleTask gets PUBLISH  0000 from the broker.

===> Send:     7e 00 16 10 26 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  08 0c 00 00 03 00 00 31   checksum   ad
 7e
===> Recv:     00 07 8b 26 4a 81 04 00 00 7f    checksum ok
20161012 210859.576   PUBLISH     0000  --->  AnotherClientID                     0C 00 00 03 00 00 31

20161012 210859.877   PUBLISH     0000  <---  AnotherClientID                     30 0F 00 0C 74 65 73 74 32 2F 70 69 6E 2F 31 32 30
     PacketHandleTask gets PUBLISH  0000 from the broker.

===> Send:     7e 00 16 10 27 00 13 a2 00 40 f1 6e b5 4a 81 00 00
     Payload:  08 0c 00 00 03 00 00 30   checksum   ad
 7e
===> Recv:     00 07 8b 27 4a 81 00 00 00 82    checksum ok
20161012 210900.092   PUBLISH     0000  --->  AnotherClientID                     0C 00 00 03 00 00 30
@ty4tw
Copy link
Contributor

ty4tw commented Oct 13, 2016

20161012 210859.449   PUBLISH     0000  <---  AnotherClientID    30
20161012 210859.576   PUBLISH     0000  --->  AnotherClientID    31

I have no hint.

Could you insert lines as follows to developmeny branch of my repo. and test again? The result will help me to find the root cause.

line 37
void MQTTGWPublishHandler::handlePublish(Client* client, MQTTGWPacket* packet)
{
    if ( !client->isActive() && !client->isSleep() )
    {
        WRITELOG("     The client is neither active nor sleep %s\n", client->getStatus());
        return;
    }

    Publish pub;
    packet->getPUBLISH(&pub);
    WRITELOG(" Paylod= %c\n", *pub.payload);  <==== Insert this line for test.

    MQTTSNPacket* snPacket = new MQTTSNPacket();
 ........
line 117
    /* send PUBLISH */
    topicId.data.id = id;
    WRITELOG(" Paylod= %c\n", *pub.payload);  <==== Insert this line for test.

    snPacket->setPUBLISH((uint8_t) pub.header.bits.dup, (int) pub.header.bits.qos,

@PaulKierstead
Copy link
Author

The developmeny doesn't do it. Since it was extremely consistent before, I think it is fixed there. That branch also doesn't have the seg fault, I'm guessing there was corruption previously.

@ty4tw
Copy link
Contributor

ty4tw commented Oct 13, 2016

Fine, i pushed it to gateway branch.

@PaulKierstead
Copy link
Author

Ah, it came back ... I guess it isn't as easy to reproduce as I thought, though once it starts happening it stays happening for that run. I've added your changes and will see if I can get a log of it happening

@PaulKierstead
Copy link
Author

Seems well fixed now.

@icraggs icraggs modified the milestone: 1.0 May 15, 2017
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

3 participants