String message length



  • In MyMessage.c is length of string message incorrect for longer messages. Right now is:

    MyMessage& MyMessage::set(const char* value) {
    uint8_t length = strlen(value);
    miSetLength(length);
    miSetPayloadType(P_STRING);
    strncpy(data, value, min(length, MAX_PAYLOAD));
    return *this;
    }

    Correct calculation of length is:

    MyMessage& MyMessage::set(const char* value) {
    ** uint8_t length = min(strlen(value), MAX_PAYLOAD);**
    miSetLength(length);
    miSetPayloadType(P_STRING);
    ** strncpy(data, value, length);**
    return *this;
    }

    I have problems in EasyIoT server if gw.sendSketchInfo text is longer than 24 characters. I've added additional checks but it's right to fix problem at source.


  • Admin

    @EasyIoT said:

    uint8_t length = min(strlen(value), MAX_PAYLOAD);

    Thanks, update pushed.


 

282
Online

8.7k
Users

9.5k
Topics

99.6k
Posts