mongoose-os-libs / pppos

PPPoS / cellullar modem support
Other
27 stars 23 forks source link

Unable to get callback argument for mgos_pppos_cmd callback #12

Open suyashmathema opened 5 years ago

suyashmathema commented 5 years ago

When I pass a callback argument along with cmd and callback function, I am not able to get the callback argument inside the callback function handler.

When I do this

int a = 1;
int* a_ptr = &a
const struct mgos_pppos_cmd cmds[] = {
   {.cmd = "AT+CMGR", .cb = test_cb, .cb_arg=a_ptr},
   {.cmd = NULL},
};

bool test_cb(void* cb_arg, bool ok, struct mg_str data) {
 //The void pointer cb_arg is not same as a_ptr
}

https://github.com/mongoose-os-libs/pppos/blob/31db8aa861a52d2ba6b00adc0373bec152cbe62a/src/mgos_pppos.c#L689 cmd_res = cur_cmd->cb(pd, true, mg_strstrip(sd));

pd is passed instead of cur_cmd->cb_arg Shouldnt it be the callback argument?

rojer commented 5 years ago

indeed, you should. please send a PR. thank you!