From 631361ece0ddbb8479b11d717c0020e94873377f Mon Sep 17 00:00:00 2001 From: Robin Herrmann Date: Tue, 7 Apr 2026 17:11:47 +0200 Subject: [PATCH] add file transfer event --- include/osdp.h | 28 ++++++++++++++++++++++++++++ src/osdp_cp.c | 8 ++++++++ 2 files changed, 36 insertions(+) diff --git a/include/osdp.h b/include/osdp.h index 6a087020..1312afe2 100644 --- a/include/osdp.h +++ b/include/osdp.h @@ -937,9 +937,36 @@ enum osdp_event_type { OSDP_EVENT_MFGREP, /**< Manufacturer specific reply event */ OSDP_EVENT_STATUS, /**< Status event */ OSDP_EVENT_NOTIFICATION, /**< LibOSDP notification event */ + OSDP_EVENT_FILE, /**< File event */ OSDP_EVENT_SENTINEL /**< Max event value */ }; +/** + * @brief File Transfer Status Detail + */ +enum osdp_event_file_status_e { + OSDP_FILE_STATUS_OK_TO_PROCEED = 0, + OSDP_FILE_STATUS_PROCESSED = 1, + OSDP_FILE_STATUS_REBOOTING = 2, + OSDP_FILE_STATUS_PD_FINISHING = 3, + OSDP_FILE_STATUS_ABORT = -1, + OSDP_FILE_STATUS_UNRECOGNIZED_CONTENTS = -2, + OSDP_FILE_STATUS_MALFORMED_DATA = -3 +}; + +/** + * @brief OSDP Event file transfer status + * + * The event indicates the status of the file transfer for a file id. + * + * @param id id of the transferred file + * @param status status of the file + */ +struct osdp_event_file { + int id; /**< ID of the transferred file */ + enum osdp_event_file_status_e status; /**< Status of the file transfer */ +}; + /** * @brief OSDP Event structure. */ @@ -954,6 +981,7 @@ struct osdp_event { struct osdp_event_mfgrep mfgrep; /**< Manufacturer specific response event struture */ struct osdp_status_report status; /**< Status report event structure */ struct osdp_event_notification notif;/**< Notification event structure */ + struct osdp_event_file file; /**< File transfer event structure */ }; }; diff --git a/src/osdp_cp.c b/src/osdp_cp.c index e326e727..4ee1b419 100644 --- a/src/osdp_cp.c +++ b/src/osdp_cp.c @@ -579,6 +579,14 @@ static int cp_decode_response(struct osdp_pd *pd, uint8_t *buf, int len) break; case REPLY_FTSTAT: ret = osdp_file_cmd_stat_decode(pd, buf + pos, len); + if (ret == 0) { + struct osdp_cmd_file_stat *p = (struct osdp_cmd_file_stat *)(buf + pos); + struct osdp_file *f = TO_FILE(pd); + event.type = OSDP_EVENT_FILE; + event.file.id = f->file_id; + event.file.status = (enum osdp_event_file_status_e)(p->status); + cp_dispatch_event(pd, &event); + } break; case REPLY_CCRYPT: if (sc_is_active(pd) || pd->cmd_id != CMD_CHLNG) {