Hi, I’m trying to pass arguments to the mgos_pppos_run_cmds callback. I’m not familiar with the mechanism.
The following is a snippet of the code I’m using:
void getGPS(int seconds, void (*callback)(int, void *), void *user_data) {
if (nSomeNum) {
(*nSomeNum)++;
}
struct mgos_pppos_cmd ATCmd[] = {
{.cmd = "AT$GPSACP", .cb = ATGPS_cb, .cb_arg=(nSomeNum)},
{.cmd = NULL},
};
if (user_data) {
// (*callback)(*nSomeNum, user_data);
mgos_pppos_run_cmds(0, ATCmd);
}
}
static bool ATGPS_cb(void *cb_arg, bool ok, struct mg_str data) {
if (!ok) {
return false;
}
// Want to see the value of nSomeNum here
(void)cb_arg;
return true;
}
How do I pass the reference of nSomeNum to mgos_pppos_run_cmds so that the callback may get its reference?