Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions EPD/EPD_service.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,19 @@ static void handle_direct_write_start(ble_epd_t* p_epd, uint8_t* data, uint16_t
send_error_response(p_epd, RESP_DIRECT_WRITE_ERROR);
return;
}
// nRF only renders BW (color_scheme 0) and BWR (color_scheme 1). For any
// other scheme the client streams data whose size this firmware cannot
// compute, so it would over/under-run RAM and refresh garbage while still
// ACKing success. Reject unsupported schemes up front instead of powering
// the panel. Reply with the standard 4-byte NACK frame
// {0xFF, cmd, error, 0x00} so the client fails fast.
if (p_epd->display_config == NULL || p_epd->display_config->color_scheme > 1) {
NRF_LOG_WARNING("DW: unsupported color_scheme; sending NACK");
uint8_t nack[] = {0xFF, (uint8_t)(CMD_DIRECT_WRITE_START & 0xFF),
RESP_ERR_UNSUPPORTED_SCHEME, 0x00};
(void)send_response(p_epd, nack, sizeof(nack));
return;
}
if (directWriteState.active) {
cleanup_direct_write_state(p_epd);
}
Expand Down
1 change: 1 addition & 0 deletions EPD/EPD_service.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,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_SCHEME 0x02 // NACK error code for color schemes this firmware cannot render
#define RESP_LED_ACTIVATE_ACK 0x73
#define RESP_FIRMWARE_VERSION 0x43
#define RESP_MSD_READ 0x44
Expand Down