Hey joebambino
Yea this is tricky. I pretty much learned it by looking at Nordic examples.
Here’s an example of how I use it on the test firmware:
/* Send SIM related AT commands */
err = at_cmd_write("AT+CFUN=4", NULL, 0, NULL);
if (err)
{
LOG_INF("Unable to set offline mode.");
const uint8_t resp[] = {2, SimTest, 'f'};
uart_send(resp, sizeof(resp));
goto finish;
}
/* Send SIM related AT commands */
err = at_cmd_write("AT+CFUN=41", NULL, 0, NULL);
if (err)
{
LOG_INF("Unable to power with SIM mode.");
const uint8_t resp[] = {2, SimTest, 'f'};
uart_send(resp, sizeof(resp));
goto finish;
}
k_sleep(K_SECONDS(1));
err = at_cmd_write("AT%XSIM?", buf, sizeof(buf), NULL);
if (err || (strstr(buf, "%XSIM: 1") == NULL))
{
LOG_INF("SIM is not active/present.");
const uint8_t resp[] = {2, SimTest, 'f'};
uart_send(resp, sizeof(resp));
goto finish;
}
In some cases the return value is fine but in other cases you need to parse the output like I did with strstr
.
Here’s the documentation for NCS. It breaks down the API a bit better. I was just using it so it’s fresh in my mind!
I’m sure you know already but here’s a link to all the AT commands.