Call AT command from self-defined AT Command

dmitry.m7
Posts: 3
Joined: Thu Aug 15, 2024 9:36 am

Call AT command from self-defined AT Command

Postby dmitry.m7 » Thu Aug 15, 2024 10:56 am

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;                                                                                                                             
}                    

esp-at
Posts: 200
Joined: Mon May 09, 2022 3:00 am

Re: Call AT command from self-defined AT Command

Postby esp-at » Wed Oct 09, 2024 12:38 pm

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.

dmitry.m7
Posts: 3
Joined: Thu Aug 15, 2024 9:36 am

Re: Call AT command from self-defined AT Command

Postby dmitry.m7 » Sat Oct 12, 2024 8:51 am

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.

dmitry.m7
Posts: 3
Joined: Thu Aug 15, 2024 9:36 am

Re: Call AT command from self-defined AT Command

Postby dmitry.m7 » Sat Oct 12, 2024 6:38 pm

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));
    

esp-at
Posts: 200
Joined: Mon May 09, 2022 3:00 am

Re: Call AT command from self-defined AT Command

Postby esp-at » Mon Oct 14, 2024 3:50 am

good to know~

Who is online

Users browsing this forum: No registered users and 12 guests