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
14 changes: 14 additions & 0 deletions include/osdp.h
Original file line number Diff line number Diff line change
Expand Up @@ -1176,6 +1176,20 @@ void osdp_cp_refresh(osdp_t *ctx);
OSDP_EXPORT
void osdp_cp_teardown(osdp_t *ctx);

/**
* @brief Get the PD offset (0-indexed) in the internal `osdp_pd_info_t *`
* list that is registered in the given address.
*
* @param ctx OSDP context
* @param address PD address of the device in `osdp_pd_info_t *` passed to
* osdp_cp_setup()
*
* @retval PD offset (0-indexed) on success
* @retval -1 on failure
*/
OSDP_EXPORT
int osdp_cp_get_pd_by_addr(osdp_t *ctx, int address);

/**
* @brief Generic command enqueue API.
*
Expand Down
5 changes: 5 additions & 0 deletions include/osdp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ class OSDP_EXPORT ControlPanel : public Common {
osdp_cp_set_command_completion_callback(_ctx, cb, arg);
}

int get_pd_by_addr(int address)
{
return osdp_cp_get_pd_by_addr(_ctx, address);
}

int get_pd_id(int pd, struct osdp_pd_id *id)
{
return osdp_cp_get_pd_id(_ctx, pd, id);
Expand Down
16 changes: 16 additions & 0 deletions src/osdp_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,22 @@ void osdp_cp_teardown(osdp_t *ctx)
#endif
}

int osdp_cp_get_pd_by_addr(osdp_t *ctx, int address)
{
input_check(ctx);
int i;
struct osdp_pd *pd;

for (i = 0; i < NUM_PD(ctx); i++) {
pd = osdp_to_pd(ctx, i);
if (pd->address == address) {
return i;
}
}

return -1;
}

void osdp_cp_refresh(osdp_t *ctx)
{
input_check(ctx);
Expand Down
2 changes: 1 addition & 1 deletion src/osdp_diag.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void osdp_packet_capture_finish(struct osdp_pd *pd)
LOG_ERR("Unable to stop capture (flush/close failed)");
return;
}
LOG_INF("Captured %d packets", num_packets);
LOG_INF("Captured %zu packets", num_packets);
}

void osdp_capture_packet(struct osdp_pd *pd, uint8_t *buf, int len)
Expand Down
Loading