Fix response size
This commit is contained in:
parent
5ce8ec864d
commit
5fc450ee63
@ -73,7 +73,7 @@ private:
|
||||
void processMessage(AuthenticatedMessage* message);
|
||||
SesameEvent verifyAndProcessReceivedMessage(AuthenticatedMessage* message);
|
||||
|
||||
uint16_t prepareResponseBuffer(SesameEvent event, uint8_t deviceId = 0);
|
||||
void prepareResponseBuffer(SesameEvent event, uint8_t deviceId = 0);
|
||||
void sendPreparedLocalResponse(AsyncWebServerRequest *request);
|
||||
void sendPreparedServerResponse();
|
||||
};
|
@ -55,8 +55,7 @@ void SesameController::loop(uint32_t millis) {
|
||||
|
||||
// MARK: Local
|
||||
|
||||
void
|
||||
SesameController::handleLocalMessage(AsyncWebServerRequest *request) {
|
||||
void SesameController::handleLocalMessage(AsyncWebServerRequest *request) {
|
||||
if (!request->hasParam(messageUrlParameter)) {
|
||||
Serial.println("Missing url parameter");
|
||||
prepareResponseBuffer(SesameEvent::InvalidUrlParameter);
|
||||
@ -147,19 +146,21 @@ bool allowMessageResponse(SesameEvent event) {
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t SesameController::prepareResponseBuffer(SesameEvent event, uint8_t deviceId) {
|
||||
void SesameController::prepareResponseBuffer(SesameEvent event, uint8_t deviceId) {
|
||||
*responseStatus = event;
|
||||
responseSize = 1;
|
||||
if (!allowMessageResponse(event)) {
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
responseMessage->message.time = timeCheck.getEpochTime();
|
||||
responseMessage->message.id = storage.getNextMessageCounter(deviceId);
|
||||
responseMessage->message.device = deviceId;
|
||||
|
||||
if (!authenticateMessage(responseMessage, keyConfig.localKey, keySize)) {
|
||||
*responseStatus = SesameEvent::InvalidResponseAuthentication;
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
return 1 + AUTHENTICATED_MESSAGE_SIZE;
|
||||
responseSize += AUTHENTICATED_MESSAGE_SIZE;
|
||||
}
|
||||
|
||||
// MARK: Reconnecting
|
||||
|
Loading…
Reference in New Issue
Block a user