Skip to content

Commit

Permalink
CP: API: Fix callback signature in cpp header
Browse files Browse the repository at this point in the history
Initializing _ctx in common is enough, Needed args for set command in places where you need to pass class object
  • Loading branch information
mehmoodmalik committed Nov 30, 2023
1 parent 0a01dda commit cdfdfa8
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
8 changes: 3 additions & 5 deletions include/osdp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace OSDP {

class Common {
public:
Common() {}
Common() : _ctx(nullptr) {}

void logger_init(const char *name, int log_level,
osdp_log_puts_fn_t puts_fn)
Expand Down Expand Up @@ -63,7 +63,6 @@ class ControlPanel : public Common {
public:
ControlPanel()
{
_ctx = nullptr;
}

~ControlPanel()
Expand Down Expand Up @@ -110,7 +109,6 @@ class PeripheralDevice : public Common {
public:
PeripheralDevice()
{
_ctx = nullptr;
}

~PeripheralDevice()
Expand All @@ -131,9 +129,9 @@ class PeripheralDevice : public Common {
osdp_pd_refresh(_ctx);
}

void set_command_callback(pd_command_callback_t cb)
void set_command_callback(pd_command_callback_t cb, void* args)
{
osdp_pd_set_command_callback(_ctx, cb, _ctx);
osdp_pd_set_command_callback(_ctx, cb, args);
}

int notify_event(struct osdp_event *event)
Expand Down
2 changes: 1 addition & 1 deletion samples/cpp/pd_app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ int main()

pd.setup(&info_pd);

pd.set_command_callback(pd_command_handler);
pd.set_command_callback(pd_command_handler, nullptr);

while (1) {
pd.refresh();
Expand Down

0 comments on commit cdfdfa8

Please sign in to comment.