cancel
Showing results for 
Search instead for 
Did you mean: 

stm32 with simcom A7672S

sreedharan1196
Associate II
#include "main.h"
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#define GETCHAR_PROTOTYPE int __io_getchar(void)
 
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;
 
PUTCHAR_PROTOTYPE
{
    HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
    return ch;
}
 
GETCHAR_PROTOTYPE
{
    uint8_t ch = 0;
    __HAL_UART_CLEAR_OREFLAG(&huart2);
    HAL_UART_Receive(&huart2, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
    return ch;
}
 
int id = 212200;
 
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART2_UART_Init(void);
 
void parseCmd(char* command, int timeout);
 
int main(void)
{
  setvbuf(stdin, NULL, _IONBF, 0);
 
  HAL_Init();
 
  SystemClock_Config();
 
  MX_GPIO_Init();
  MX_USART1_UART_Init();
  MX_USART2_UART_Init();
 
  HAL_GPIO_WritePin(Enable_key_GPIO_Port, Enable_key_Pin, GPIO_PIN_SET);
  HAL_Delay(2000);
  HAL_GPIO_WritePin(Power_key_GPIO_Port, Power_key_Pin, GPIO_PIN_RESET);
  HAL_Delay(2000);
 
  printf("Sending AT commands...\n");
 
  while (1)
  {
  char strAT[50];
  parseCmd("AT\r\n", 1000); //Check AT
  parseCmd("ATE1\r\n", 1000);
  parseCmd("AT+CSQ\r\n", 1000);
  parseCmd("AT+CPIN?\r\n", 1000);
  parseCmd("AT+CREG=1\r\n", 1000);
  parseCmd("AT+CGREG?\r\n", 1000);
  parseCmd("AT+CGATT=1\r\n", 1000);
  parseCmd("AT+QIFGCNT=0\r\n", 1000);
  parseCmd("AT+QICSGP=1,\"WWW\",\"\",\"\"\r\n", 1000);
  parseCmd("AT+QIREGAPP\r\n", 1000);
  parseCmd("AT+QIACT\r\n", 1000);
  HAL_Delay(2000);
  sprintf(strAT, "AT+QHTTPURL=%d,%d", str_len, 180);
  //Serial.println(strAT);
  printf("The string %s",strAT);
  parseCmd(strAT, 1000);
  parseCmd(json_1, 3000);
  parseCmd("AT+QHTTPPOST=60", 3000);
  parseCmd("AT+QHTTPREAD", 3000);
  parseCmd("AT+QIDEACT", 1000);
 
void parseCmd(char* command, int timeout)
{
    HAL_Delay(timeout);
    char rxdata[300];
    memset(rxdata, 0, sizeof(rxdata));
    // Transmit command over UART1
    HAL_UART_Transmit(&huart1, (uint8_t*)command, strlen(command), timeout);
    // Receive response over UART1
    HAL_UART_Receive(&huart1, (uint8_t *)rxdata, sizeof(rxdata), timeout);
    // Transmit response over UART2
    HAL_UART_Transmit(&huart2, (uint8_t *)rxdata, strlen((char *)rxdata), timeout);
}
 
OUTPUT:
10:29:51.329 -> AT
10:29:51.329 -> OK
10:29:53.295 -> ATE1
10:29:53.295 -> OK
10:29:54.323 -> AT
 
i am using the above AT commands in simcom A7672S ,i am unable to get the proper response from the simcom, may, i know what the issues i am facing, Guide me with the issues i am facing her and help me to sort out this issues
21 REPLIES 21

no i dint send the AT+HTTPSEND, is their any command like that, using the AT command data sheet thier is no command like that

Techn
Senior III

Sorry, HTTPSEND was for 7672,  Can you try AT+HTTPREAD and AT+HTTPHEAD  , I am referring to

https://www.ktron.in/wp-content/uploads/2023/03/A76XX-Series_AT_Command_Manual_V1.06-4.pdf

 

but anyway please try to do the reading from UART_RECEIVE_IT, interrupt, so that you will not miss characters

 

If you feel a post has answered your question, please click "Accept as Solution".