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
  • 11
  • 17
  • 9
  • 5
  • 3

68
Online

11.4k
Users

11.1k
Topics

112.7k
Posts