Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Improve request] AT sets Action #10

Open
Love4yzp opened this issue Apr 19, 2024 · 0 comments
Open

[Improve request] AT sets Action #10

Love4yzp opened this issue Apr 19, 2024 · 0 comments

Comments

@Love4yzp
Copy link
Contributor

I've notice that save_jpeg function is defined:

bool SSCMA::save_jpeg()
{
char cmd[64] = {0};
snprintf(cmd, sizeof(cmd), CMD_PREFIX "%s=\"save_jpeg()\"" CMD_SUFFIX, CMD_AT_ACTION);
write(cmd, strlen(cmd));
if (wait(CMD_TYPE_RESPONSE, CMD_AT_ACTION) == CMD_OK)
{
return CMD_OK;
}
}

However there are serval action triggers in your AT sets.

I think if we define as the following, could be better:

bool SSCMA::action_fuc(const String& action)
{
    const int MAX_CMD_LENGTH = 64;
    char cmd[MAX_CMD_LENGTH] = {0};
    
    int result = snprintf(cmd, sizeof(cmd), CMD_PREFIX "%s=\"%s\"" CMD_SUFFIX, CMD_AT_ACTION, action.c_str());
    if (result < 0 || result >= MAX_CMD_LENGTH)
    {
        return false;
    }
    if (write(cmd, strlen(cmd)) == -1)
    {
        return false;
    }
    return wait(CMD_TYPE_RESPONSE, CMD_AT_ACTION) == CMD_OK;
}
bool SSCMA::save_jpeg()
{
    return action_fuc("save_jpeg");
}

if so, AI.action_fuc("") can clean the action sets.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant