diff --git a/src/graphics/draw/NotificationRenderer.cpp b/src/graphics/draw/NotificationRenderer.cpp index 900ffdb8b..f3935b9a4 100644 --- a/src/graphics/draw/NotificationRenderer.cpp +++ b/src/graphics/draw/NotificationRenderer.cpp @@ -183,7 +183,7 @@ void NotificationRenderer::drawAlertBannerOverlay(OLEDDisplay *display, OLEDDisp for (int i = 0; i < lineCount; i++) { // is this line selected? // if so, start the buffer with -> and strncpy to the 4th location - if (i == 0 || alertBannerOptions == 0) { + if (i < lineCount - alertBannerOptions || alertBannerOptions == 0) { strncpy(lineBuffer, lineStarts[i], 40); if (lineLengths[i] > 39) lineBuffer[39] = '\0'; diff --git a/src/modules/KeyVerificationModule.cpp b/src/modules/KeyVerificationModule.cpp index e0f415408..f5a9f2359 100644 --- a/src/modules/KeyVerificationModule.cpp +++ b/src/modules/KeyVerificationModule.cpp @@ -59,7 +59,7 @@ bool KeyVerificationModule::handleReceivedProtobuf(const meshtastic_MeshPacket & r->hash1.size == 0) { memcpy(hash2, r->hash2.bytes, 32); if (screen) - screen->showOverlayBanner("Enter Security Number", 15000); + screen->showOverlayBanner("Enter Security Number", 30000); meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); cn->level = meshtastic_LogRecord_Level_WARNING; @@ -79,9 +79,15 @@ bool KeyVerificationModule::handleReceivedProtobuf(const meshtastic_MeshPacket & memset(message, 0, sizeof(message)); sprintf(message, "Verification: \n"); generateVerificationCode(message + 15); + sprintf(message + 24, "\nACCEPT\nREJECT"); LOG_INFO("Hash1 matches!"); if (screen) { - screen->showOverlayBanner(message, 15000); + screen->showOverlayBanner(message, 30000, 2, [=](int selected) { + if (selected == 0) { + auto remoteNodePtr = nodeDB->getMeshNode(currentRemoteNode); + remoteNodePtr->bitfield |= NODEINFO_BITFIELD_IS_KEY_MANUALLY_VERIFIED_MASK; + } + }); } meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); cn->level = meshtastic_LogRecord_Level_WARNING; @@ -179,7 +185,7 @@ meshtastic_MeshPacket *KeyVerificationModule::allocReply() responsePacket->pki_encrypted = true; if (screen) { snprintf(message, 25, "Security Number \n%03u %03u", currentSecurityNumber / 1000, currentSecurityNumber % 1000); - screen->showOverlayBanner(message, 15000); + screen->showOverlayBanner(message, 30000); LOG_WARN("%s", message); } meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); @@ -193,7 +199,7 @@ meshtastic_MeshPacket *KeyVerificationModule::allocReply() sizeof(cn->payload_variant.key_verification_number_inform.remote_longname)); cn->payload_variant.key_verification_number_inform.security_number = currentSecurityNumber; service->sendClientNotification(cn); - LOG_WARN("Security Number %04u", currentSecurityNumber); + LOG_WARN("Security Number %04u, nonce %llu", currentSecurityNumber, currentNonce); return responsePacket; } @@ -249,7 +255,7 @@ void KeyVerificationModule::processSecurityNumber(uint32_t incomingNumber) sprintf(message, "Verification: \n"); generateVerificationCode(message + 15); // send the toPhone packet if (screen) { - screen->showOverlayBanner(message, 15000); + screen->showOverlayBanner(message, 30000); } meshtastic_ClientNotification *cn = clientNotificationPool.allocZeroed(); cn->level = meshtastic_LogRecord_Level_WARNING; @@ -270,8 +276,10 @@ void KeyVerificationModule::updateState() { if (currentState != KEY_VERIFICATION_IDLE) { // check for the 30 second timeout - if (currentNonceTimestamp < getTime() - 30) { + if (currentNonceTimestamp < getTime() - 60) { resetToIdle(); + } else { + currentNonceTimestamp = getTime(); } } } diff --git a/src/modules/KeyVerificationModule.h b/src/modules/KeyVerificationModule.h index 3dcec9ace..f659e961a 100644 --- a/src/modules/KeyVerificationModule.h +++ b/src/modules/KeyVerificationModule.h @@ -53,7 +53,7 @@ class KeyVerificationModule : public ProtobufModule KeyVerificationState currentState = KEY_VERIFICATION_IDLE; uint8_t hash1[32] = {0}; // uint8_t hash2[32] = {0}; // - char message[26] = {0}; + char message[40] = {0}; void processSecurityNumber(uint32_t); void updateState(); // check the timeouts and maybe reset the state to idle