Seeed-Studio / Seeed_Arduino_SSCMA

Arduino library for devices supporting the SSCMA-Micro firmware
MIT License
25 stars 5 forks source link

[Improve request] AT sets Action #10

Closed Love4yzp closed 3 months ago

Love4yzp commented 6 months ago

I've notice that save_jpeg function is defined: https://github.com/Seeed-Studio/Seeed_Arduino_SSCMA/blob/79fa2de0a0ce500cd30cc197c8286cda352b0453/src/Seeed_Arduino_SSCMA.cpp#L845-L855

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.