Page 1 of 1

Call AT command from self-defined AT Command

Posted: Thu Aug 15, 2024 10:56 am
by dmitry.m7
Hi!

How can I call other AT command from self-defined AT command?
For, example

Code: Select all

at_custom_cmd.c

static uint8_t at_test_cmd_test(uint8_t *cmd_name) {                                                                                                                                                                 
  uint8_t buffer[64] = {0};                                                                                                                                     
  snprintf((char *)buffer, 64, "test command: <AT%s=?> is executed\r\n", cmd_name);                                                                             
  esp_at_port_write_data(buffer, strlen((char *)buffer));    
  
  CALL("AT+HTTPCGET=params")    <-- HOW Can I do it?                                                                                                                                                                                                                                                              
  
  return ESP_AT_RESULT_CODE_OK;                                                                                                                             
}                    

Re: Call AT command from self-defined AT Command

Posted: Wed Oct 09, 2024 12:38 pm
by esp-at
Sorry that it's an unsupported usage. because both at_test_cmd_test() and AT+HTTPCGET=params are executed in at_process_task(), however, in the current design, command processing is linear, and you cannot execute another command before one command is completed.

in you case, you can create another task, and in your task, to execute some command like AT+HTTPCGET=<parameters>. and at_test_cmd_test() to get the status of your task.

Re: Call AT command from self-defined AT Command

Posted: Sat Oct 12, 2024 8:51 am
by dmitry.m7
Thanks allot for your answer. Can you help save string data into flash in custom AT command? I couldn't find command for this operation.

Re: Call AT command from self-defined AT Command

Posted: Sat Oct 12, 2024 6:38 pm
by dmitry.m7
I have find way to solve it.

Code: Select all

#include <inttypes.h>
#include "nvs_flash.h"
#include "nvs.h"


void write_to_EEPROM(char *p,char *value, uint32_t size)
{
    char *saveId;
    uint32_t sizeSave = (size);
    saveId = malloc(sizeSave);
    strcpy(saveId,value);
    nvs_handle_t my_handle;
    nvs_open("storage", NVS_READWRITE, &my_handle);
    nvs_set_str(my_handle, p, saveId);
    nvs_commit(my_handle);
    nvs_close(my_handle); 
    free(saveId);  
} 

void read_to_EEPROM(char *k,char *r)
{
    nvs_handle_t my_handle;
    size_t nvs_required_size_id;
    nvs_open("storage", NVS_READWRITE, &my_handle);
    nvs_get_str(my_handle, k, NULL,&nvs_required_size_id);
    char nvs_ret_data_id[10];
    nvs_get_str(my_handle, k, (char *)&nvs_ret_data_id, &nvs_required_size_id);
    nvs_close(my_handle);                                   
    strcpy(r,nvs_ret_data_id);
}


    char buffer1[30];
    write_to_EEPROM("url",buffer1,sizeof(buffer1));
    

Re: Call AT command from self-defined AT Command

Posted: Mon Oct 14, 2024 3:50 am
by esp-at
good to know~