2024-05-20 10:03 PM
2024-05-22 08:20 PM
Firstly chek if the module is able to receive call from another mobile. JUST call that number and check ring back tone. Connect the module to computer using a USB to ttl converter and chek if the module behaves properly. ATD your number to initiate a call from mobile. AT+CSQ for signal strength etc..
2024-05-23 12:07 AM
thanks for the response, i clear that issues, now i am facing an issue with response received, i am able to get only the half the response code from the simcom, what tha issues with the above code, help me to short out it
char ATcommand[200];
void parseCmd(char *command, int http_time)
{
char rxdata1[1000];
memset(rxdata1, 0, sizeof(rxdata1));
// printf("The AT : %s\r\n",command);
// Transmit command over UART1
HAL_UART_Transmit(&huart1, (uint8_t*)command, strlen(command),http_time);
// Receive response over UART1
HAL_UART_Receive(&huart1, (uint8_t *)rxdata1, sizeof(rxdata1),http_time);
// Transmit response over UART2
HAL_UART_Transmit(&huart2, (uint8_t *)rxdata1, strlen(rxdata1),100);
}
sprintf(ATcommand,"AT+HTTPPARA=\"URL\",\"http://iot.salieabs.in:5003/api/postDeviceDatadev=2122001&mr=108&warn=Done\"\r\n");
parseCmd(ATcommand,2000);
output:
11:21:33.298 -> ceData?dev=2122001&mr=108&warn=Done"
11:21:33.298 -> OK
2024-05-23 01:08 AM
verify with it, its working properly, for sms, and Call, also for all other AT commands, but the only issues is
sprintf(ATcommand,"AT+HTTPPARA=\"URL\",\"http://iot.salieabs.in:5003/api/postDeviceDatadev=2122001&mr=108&warn=Done\"\r\n");
for the above AT commands i am getting only the below response, the response is ok thats not the issues, issue is for User interface i am not getting the full response
output:
11:21:33.298 -> ceData?dev=2122001&mr=108&warn=Done"
11:21:33.298 -> OK
2024-05-23 01:57 AM
Looks like you have enabled local echo, other wise I guess the response will be "OK", what is the expected output?
2024-05-23 01:59 AM - edited 2024-05-23 02:01 AM
On debugging serial comms:
https://www.avrfreaks.net/s/topic/a5C3l000000UaFXEA0/t153137?comment=P-1212903
Please use this button to properly post source code:
#DebugSerialComms
2024-05-23 02:09 AM
CURRENT OUTPUT :
11:21:33.298 -> ceData?dev=2122001&mr=108&warn=Done"
11:21:33.230 -> OK
EXPECTED OUTPUT :
11:21:33.298 -> http://iot.salieabs.in:5003/api/postDeviceData?dev=2122001&mr=108&warn=Done
11:21:33.230 -> OK
2024-05-23 02:20 AM
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"
/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */
/* USER CODE END PTD */
/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */
const char apn[] = "WWW";
char ATcommand[200];
char Warning_status[] = "Done";
char Count[] = "10";
char devID[] = "2122001";
/* USER CODE END PD */
/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#define GETCHAR_PROTOTYPE int __io_getchar(void)
/* USER CODE END PM */
/* Private variables ---------------------------------------------------------*/
UART_HandleTypeDef huart1;
UART_HandleTypeDef huart2;
/* USER CODE BEGIN PV */
PUTCHAR_PROTOTYPE
{
HAL_UART_Transmit(&huart2, (uint8_t *)&ch, 1, HAL_MAX_DELAY);
return ch;
}
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_USART1_UART_Init(void);
static void MX_USART2_UART_Init(void);
/* USER CODE BEGIN PFP */
/* USER CODE END PFP */
/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
void parseCmd(char *command, int delay)
{
// HAL_UART_Init(&huart1);
char rxdata[100];
memset(rxdata, 0, sizeof(rxdata));
HAL_UART_Transmit(&huart1,(uint8_t*)command,strlen(command),delay);
HAL_UART_Receive(&huart1,rxdata,sizeof(rxdata),delay);
HAL_UART_Transmit(&huart2,rxdata,sizeof(rxdata),1000);
//HAL_UART_DeInit(&huart1);
}
void ExecuteHTTPGetRequest()
{
parseCmd("AT\r\n",2000);
parseCmd("AT+CSQ\r\n",2000);
parseCmd("AT+CREG?\r\n",2000);
parseCmd("AT+CGREG?\r\n",5000);
parseCmd("AT+CEREG=1\r\n",5000);
parseCmd("AT+CPSI?\r\n",2000);
parseCmd("AT+CGACT=1,1\r\n",10000);
parseCmd("AT+CGATT=1\r\n",2000);
parseCmd("AT+CGREG?\r\n",2000);
sprintf(ATcommand,"AT+CGDCONT=1,\"IP\",\"%s\"\r\n",apn);
parseCmd(ATcommand,4000);
parseCmd("AT+HTTPINIT\r\n", 12000);
parseCmd("AT+HTTPPARA=\"URL\",\"http://iot.salieabs.in:5003/api/postDeviceData?dev=2122001&mr=108&warn=Done\"\r\n",12000);
parseCmd("AT+HTTPACTION=1\r\n",10000);
parseCmd("AT+HTTPTERM\r\n",5000);
}
/* USER CODE END 0 */
/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration--------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
/* USER CODE END Init */
/* Configure the system clock */
SystemClock_Config();
/* USER CODE BEGIN SysInit */
/* USER CODE END SysInit */
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_USART1_UART_Init();
MX_USART2_UART_Init();
/* USER CODE BEGIN 2 */
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("Initializing HTTP connection...\n");
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
ExecuteHTTPGetRequest();
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
/**
* @brief System Clock Configuration
* @retval None
*/
void SystemClock_Config(void)
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
RCC_PeriphCLKInitTypeDef PeriphClkInit = {0};
/** Configure the main internal regulator output voltage
*/
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1);
/** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure.
*/
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_MSI;
RCC_OscInitStruct.MSIState = RCC_MSI_ON;
RCC_OscInitStruct.MSICalibrationValue = 0;
RCC_OscInitStruct.MSIClockRange = RCC_MSIRANGE_5;
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
{
Error_Handler();
}
/** Initializes the CPU, AHB and APB buses clocks
*/
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_MSI;
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_0) != HAL_OK)
{
Error_Handler();
}
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1|RCC_PERIPHCLK_USART2;
PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
PeriphClkInit.Usart2ClockSelection = RCC_USART2CLKSOURCE_PCLK1;
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
{
Error_Handler();
}
}
/**
* @brief USART1 Initialization Function
* @PAram None
* @retval None
*/
static void MX_USART1_UART_Init(void)
{
/* USER CODE BEGIN USART1_Init 0 */
/* USER CODE END USART1_Init 0 */
/* USER CODE BEGIN USART1_Init 1 */
/* USER CODE END USART1_Init 1 */
huart1.Instance = USART1;
huart1.Init.BaudRate = 115200;
huart1.Init.WordLength = UART_WORDLENGTH_8B;
huart1.Init.StopBits = UART_STOPBITS_1;
huart1.Init.Parity = UART_PARITY_NONE;
huart1.Init.Mode = UART_MODE_TX_RX;
huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart1.Init.OverSampling = UART_OVERSAMPLING_16;
huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_RXOVERRUNDISABLE_INIT;
huart1.AdvancedInit.OverrunDisable = UART_ADVFEATURE_OVERRUN_DISABLE;
if (HAL_UART_Init(&huart1) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART1_Init 2 */
/* USER CODE END USART1_Init 2 */
}
/**
* @brief USART2 Initialization Function
* @PAram None
* @retval None
*/
static void MX_USART2_UART_Init(void)
{
/* USER CODE BEGIN USART2_Init 0 */
/* USER CODE END USART2_Init 0 */
/* USER CODE BEGIN USART2_Init 1 */
/* USER CODE END USART2_Init 1 */
huart2.Instance = USART2;
huart2.Init.BaudRate = 115200;
huart2.Init.WordLength = UART_WORDLENGTH_8B;
huart2.Init.StopBits = UART_STOPBITS_1;
huart2.Init.Parity = UART_PARITY_NONE;
huart2.Init.Mode = UART_MODE_TX_RX;
huart2.Init.HwFlowCtl = UART_HWCONTROL_NONE;
huart2.Init.OverSampling = UART_OVERSAMPLING_16;
huart2.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;
huart2.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;
if (HAL_UART_Init(&huart2) != HAL_OK)
{
Error_Handler();
}
/* USER CODE BEGIN USART2_Init 2 */
/* USER CODE END USART2_Init 2 */
}
/**
* @brief GPIO Initialization Function
* @PAram None
* @retval None
*/
static void MX_GPIO_Init(void)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOA_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(Enable_key_GPIO_Port, Enable_key_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(Power_key_GPIO_Port, Power_key_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : Enable_key_Pin */
GPIO_InitStruct.Pin = Enable_key_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(Enable_key_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pin : Power_key_Pin */
GPIO_InitStruct.Pin = Power_key_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(Power_key_GPIO_Port, &GPIO_InitStruct);
/* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */
}
/* USER CODE BEGIN 4 */
/* USER CODE END 4 */
/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */
__disable_irq();
while (1)
{
}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @PAram file: pointer to the source file name
* @PAram line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
2024-05-23 02:27 AM
@sreedharan1196 wrote:parseCmd("AT\r\n", 1000); //Check AT
Note that the standard AT command terminator is just CR - not CRLF.
@sreedharan1196 wrote:10:29:53.295 -> ATE110:29:53.295 -> OK
Why are you turning Echo on?
This means that the modem will send back every single character you send to it.
How are you observing this "output" ?
2024-05-23 02:31 AM
@sreedharan1196 wrote:CURRENT OUTPUT :
11:21:33.298 -> ceData?dev=2122001&mr=108&warn=Done"
11:21:33.230 -> OK
EXPECTED OUTPUT :
11:21:33.298 -> http://iot.salieabs.in:5003/api/postDeviceData?dev=2122001&mr=108&warn=Done
11:21:33.230 -> OK
So you're missing the first half (~40 characters) of that string.
Are your buffers big enough?
Again, how are you observing this "output"?