Skip to content

Bug fixed #2

@andreucci

Description

@andreucci

Bug fixed on MQTT.java: mqtt.retain il the last bit of the first byte, not on the second byte

public static MQTTMessage decode(byte[] message) {
    int i = 0;
    MQTTMessage mqtt = new MQTTMessage();
    mqtt.type = (message[i] >> 4) & 0x0F;
    mqtt.DUP = ((message[i] >> 3) & 0x01) == 0 ? false : true;
    mqtt.QoS = (message[i] >> 1) & 0x03;
     //mqtt.retain = (message[i++] & 0x01) == 0 ? false : true;    // credo che l' i++ sia sbagliato
    mqtt.retain = (message[i] & 0x01) == 0 ? false : true;

Then an i++ should be added before :

    switch (mqtt.type) {
    case CONNECT:

There is also something to fix after that to mage the message[0] work.
I still have the problem that I send a byte and I receive, on android side, a char. Any idea?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions