static void subscribe_callback(struct PubnubRequest* req, NubEv ev, char const* buf, int buf_len, void *ctx) { struct PubnubAt* nubat = (struct PubnubAt*) ctx; switch (ev) { case NUB_DATA: { Str str; if (!str_newn(&str, buf, buf_len)) return; /* This relies on the fact that command always sends at terminal response! */ nubat->atCmdPending = veTrue; if (ve_atCmdSendExt(str.data, veFalse, 0, nubat, at_rspHandler) != OK) nubat->atCmdPending = veFalse; str_free(&str); break; } case NUB_DONE: pubnub_atSubscribe(nubat); /* wait for commands when idle */ break; default: ; } }
void test_parse_reg_without_args(test_t *t) { char text[4] = "REG\n"; command_t cmd = parse(str_newn(text, 4)); assert_eq_int(t, CMD_REG, cmd.code); }