nrf9160dk How to add custom at command

I want to add a custom at command in the SLM example . I follow the https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.6.1/nrf/libraries/modem/at_cmd_custom.html, enable  CONFIG_AT_CMD_CUSTOM in prj.conf, add at_cmd_custom.h to the main.c, and the following code was added

AT_CMD_CUSTOM(my_command_filter, "AT+MYCOMMAND", my_command_callback);

int my_command_callback(char *buf, size_t len, char *at_cmd);
{
    printf("Callback for %s", at_cmd);
    return at_cmd_custom_respond(buf, len, "OK\r\n");
}


I found slm_at_cmdulist in slm_at_commends.c, And try to change my_command_filter to slm_at_cmdulist,It also has no effect
Apart from the at command supported by the SLM example itself, the MYCOMMEND command I added did not take effect. Did I make a mistake in which step? Or which step was missed?

gratitude
Parents Reply
  • Hi Illy,

    llly said:
    One is that in the at client, the end needs to be set to CR and LF to recognize commands properly, but in SLM, keeping the default CR end can recognize commands properly.

    I think this is not an issue. SLM and AT Client use CONFIG_CR_LF_TERMINATION=y and CONFIG_CR_TERMINATION=y by default respectively, you can just change to what you want at building time. The Serial Terminal also has Line Ending option allows you to set up the termination method.

    llly said:
    Another issue is that custom commands in SLM can be case insensitive, and even mixed case is fine. However, in at client, commands can only be executed in all uppercase, otherwise an error will be returned (custom commands in both projects are all uppercase).

    It seems AT Client support case-insensitive for modem AT commands but not custom commands. I think this depends on the at commands processing in MFW. For a custom AT command, it will match exactly what you provide.

    *** Booting nRF Connect SDK v3.5.99-ncs1-1-4-ga681edb8d456 ***
    The AT host sample started
    Ready
    > at+CFUN?
    +CFUN: 0
    OK
    > at+cfun?
    +CFUN: 0
    OK
    > at+mycommand=?
    at+mycommand=?
    > AT+MYCOMMAND=?
    +MYCOMMAND: (0, 1)
    OK

    Best regards,

    Charlie

Children
Related