AnsweredAssumed Answered


Question asked by sachin singh on May 9, 2018
Latest reply on May 21, 2018 by sachin singh

Hello there,
We are using quectel's BG96 module with STM32L432KB over UART, to send some data to a cloud service using MQTT protocol.
For this, We are using HAL_UART Drivers to transmit MQTT AT commands and receive its response.

We need to send CTRL+Z from our controller to BG96 module over UART, so that BG96 can understand 'End of Transmission'.

But some how we are not able to not know that is the data is transmitted or not  and even also not sure that data is receiving.


code which i have written for the this:

uint8_t gsm_connt[45] = "AT+CGDCONT=1,\"IP\",\"bsnllive\"\r";    //  AT command to be send..
uint8_t gsm_activate[15] = "AT+CGACT=1\r";         //   AT command to be send..

uint8_t dummy_mqtt[100]={0};                                                        //   Dummy Variables to store the Rx data..


HAL_UART_Transmit(&huart1,(uint8_t *)gsm_connt,sizeof(gsm_connt),1000);

HAL_UART_Receive(&huart1 , (uint8_t *)&dummy_mqtt, sizeof(dummy_mqtt) , 1000);

Note: Above code is for the reference purpose and above function for transmitting and receiving the data over the UART.


Sending CTRL+Z is really important here.
We know that CTRL+Z = 26(DEc) and 0x1A (HEX).

Suppose we need to send "ABC"(message) + CTRL^Z over UART, we have tried all the below options. But some how we could not receive expected results.

1. char msg[] = "ABC";
   1) char ctrl_z = '0x1A' OR '26'; OR
   2) uint8_t ctrl_z = '0x1A' OR '26'; OR
   3) uint8_t ctrl_z = 0x1A OR 26;


   HAL_UART_Transmit(&huart1,(uint8_t *)msg, sizeof(msg), 1000);
   HAL_UART_Transmit(&huart1, &ctrl_z, sizeof(ctrl_z), 1000);
   HAL_UART_Receive(&huart1, (uint8_t*)&buf, sizeof(buf),1000);

2. uint8_t msg[] = {'0x41','0x42','0x43','0x1A'} OR {'65', '66', '67','26'}
   uint8_t msg[] = {0x41, 0x42, 0x43, 0x1A} OR {65, 66, 67, 26};

   HAL_UART_Transmit(&huart1,(uint8_t *)msg, sizeof(msg), 1000);
   HAL_UART_Receive(&huart1, (uint8_t*)&buf, sizeof(buf),1000);

Problem: We are not able to publish the data to the mqtt server using HAL UART DRIVER ... !!!

Can you share some demo codes for the same. It will be helpful to us.


Thanks & Regards,