kpn-iot / thingsml-c-library

C library for ThingsML on your device
https://kpn-iot.github.io/thingsml-c-library/
MIT License
6 stars 4 forks source link

parseFirmwareMessage resets url and token #13

Closed Lah123 closed 2 years ago

Lah123 commented 3 years ago

I would like to suggest a change to the parseFirmwareMessage method. It resets the url and token before it checks if the message is actually a firmware message. Could we relocate the resetting to after the check if a message is a firmware message? It would reduce the chance of a deletion of a valid URL and token.

My suggestion:

    bool HttpFirmwareDownload::parseFirmwareMessage(char message[], int messageLength) {
        if (!isFirmwareMessage(message, messageLength)) {
            return false;
        }

        _url.set(nullptr);
        _token.set(nullptr);

        int start = getHttpBodyStart(message, messageLength);
        _firmwareMessage.fromJson(&message[start]);

        return _url.get() != nullptr && _token.get() != nullptr;
    }

I can create a PR if needed.

josephverburg commented 2 years ago

Thanks for the suggestion, it has been implemented in v1.3.1