From 58e3727ec5a64e66164e6a3e8a18e321e1fa86d8 Mon Sep 17 00:00:00 2001 From: Paulus Schoutsen Date: Sun, 5 Jul 2026 17:37:10 -0400 Subject: [PATCH] Send NACK for unsupported client commands (0x76, 0x77) Partial-update (0x76) and buzzer (0x77) commands that the client sends and blocks on hit the dispatch default case, which only logged and returned nothing. The client waited for an ACK that never arrived and timed out. Reply with the firmware's standard 4-byte NACK frame {0xFF, cmd, error, 0x00} so the client fails fast: the Python client's parse_nack recognizes it for 0x76 (clean fallback to full upload) and validate_ack_response rejects it as a non-ACK for 0x77 (prompt error). Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_012g2e8mr132vcizx92WsgiR --- EPD/EPD_service.c | 13 +++++++++++++ EPD/EPD_service.h | 4 ++++ 2 files changed, 17 insertions(+) diff --git a/EPD/EPD_service.c b/EPD/EPD_service.c index 7f34a5c..2b5439e 100755 --- a/EPD/EPD_service.c +++ b/EPD/EPD_service.c @@ -661,6 +661,19 @@ static void dispatch_command(ble_epd_t* p_epd, uint16_t command_16bit, case CMD_FIRMWARE_VERSION: handle_firmware_version(p_epd); break; + case CMD_DIRECT_WRITE_PARTIAL_START: + case CMD_BUZZER_ACTIVATE: + // Commands the client sends and blocks on, but this firmware does + // not implement. Reply with the standard 4-byte NACK frame + // {0xFF, cmd, error, 0x00} so the client fails fast instead of + // waiting for an ACK that never comes and timing out. + { + NRF_LOG_WARNING("Unsupported command 0x%04X; sending NACK", command_16bit); + uint8_t nack[] = {0xFF, (uint8_t)(command_16bit & 0xFF), + RESP_ERR_UNSUPPORTED_CMD, 0x00}; + (void)send_response(p_epd, nack, sizeof(nack)); + } + break; default: NRF_LOG_DEBUG("Unknown command: 0x%04X", command_16bit); break; diff --git a/EPD/EPD_service.h b/EPD/EPD_service.h index 7ff82ef..b1eee0b 100755 --- a/EPD/EPD_service.h +++ b/EPD/EPD_service.h @@ -74,6 +74,9 @@ void ble_epd_evt_handler(ble_evt_t const* p_ble_evt, void* p_context); #define CMD_LED_ACTIVATE 0x0073 +#define CMD_DIRECT_WRITE_PARTIAL_START 0x0076 // Not implemented on nRF; client waits for a response +#define CMD_BUZZER_ACTIVATE 0x0077 // Not implemented on nRF; client waits for a response + #define CMD_REBOOT 0x000F #define CMD_FIRMWARE_VERSION 0x0043 #define CMD_READ_MSD 0x0044 @@ -101,6 +104,7 @@ void ble_epd_evt_handler(ble_evt_t const* p_ble_evt, void* p_context); #define RESP_DIRECT_WRITE_REFRESH_SUCCESS 0x73 #define RESP_DIRECT_WRITE_REFRESH_TIMEOUT 0x74 #define RESP_DIRECT_WRITE_ERROR 0xFF +#define RESP_ERR_UNSUPPORTED_CMD 0x01 // NACK error code for commands this firmware does not implement #define RESP_LED_ACTIVATE_ACK 0x73 #define RESP_FIRMWARE_VERSION 0x43 #define RESP_MSD_READ 0x44