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

_mqtt->setBufferSize #202

Closed
qibao07 opened this issue Nov 3, 2023 · 5 comments
Closed

_mqtt->setBufferSize #202

qibao07 opened this issue Nov 3, 2023 · 5 comments

Comments

@qibao07
Copy link

qibao07 commented Nov 3, 2023

Support setBufferSize.

bool HAMqtt::begin(
    const IPAddress serverIp,
    const uint16_t serverPort,
    const char* username,
    const char* password,
    const uint16_t bufferSize
)
{
    ARDUINOHA_DEBUG_PRINT(F("AHA: init server "))
    ARDUINOHA_DEBUG_PRINT(serverIp)
    ARDUINOHA_DEBUG_PRINT(F(":"))
    ARDUINOHA_DEBUG_PRINTLN(serverPort)

    if (_device.getUniqueId() == nullptr) {
        ARDUINOHA_DEBUG_PRINTLN(F("AHA: init failed. Missing device unique ID"))
        return false;
    }

    if (_initialized) {
        ARDUINOHA_DEBUG_PRINTLN(F("AHA: already initialized"))
        return false;
    }

    _username = username;
    _password = password;
    _initialized = true;

    _mqtt->setServer(serverIp, serverPort);
    _mqtt->setCallback(onMessageReceived);
    _mqtt->setBufferSize(bufferSize);

    return true;
}
@dawidchyrzynski
Copy link
Owner

Hi @qibao07, what's the use case?

@qibao07
Copy link
Author

qibao07 commented Jan 24, 2024

@dawidchyrzynski
Thank you for your reply. Sometimes the received message is too long, causing the message to be truncated. Modifying this value can only modify imported code files.

@dawidchyrzynski
Copy link
Owner

dawidchyrzynski commented Jan 30, 2024

@qibao07 Do you mean the messages that the library handles/generates, or are you handling your custom messages?

@qibao07
Copy link
Author

qibao07 commented Jan 31, 2024

@dawidchyrzynski I implemented HAText myself with reference to HANumber. It was found that long messages require large buffer. Custom messages are also required.

@dawidchyrzynski
Copy link
Owner

This feature will be available in the upcoming version of the library. Please refer to the linked Pull Request for more information.

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

2 participants