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.


Log in to reply
 

Suggested Topics

  • 33
  • 9
  • 5
  • 17
  • 8
  • 6

0
Online

11.2k
Users

11.1k
Topics

112.5k
Posts